Commit df7e6f37 authored by stambaughw's avatar stambaughw

annotate dialog HIGification, refactor and beautify associated

annotation code
parent d2fe629b
...@@ -5,6 +5,14 @@ Started 2007-June-11 ...@@ -5,6 +5,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2008-Feb-25 UPDATE Wayne Stambaugh <stambaughw{at}verizon{dot}net>
================================================================================
+eeschema
* converted annotate_dialog layout to Gnome HIG per UIPolicy.txt factor
out dialog code from annotate.cpp.
* refactor and uncrustify schframe.cpp and schedit.cpp
* modify eeschema CMakeList.txt to reflect code changes.
2008-Feb-22 UPDATE Dick Hollenbeck <dick@softplc.com> 2008-Feb-22 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
......
...@@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES( ...@@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES(
SET(EESCHEMA_SRCS SET(EESCHEMA_SRCS
affiche.cpp affiche.cpp
annotate.cpp annotate.cpp
# annotate_dialog.cpp annotate_dialog.cpp
block.cpp block.cpp
block_libedit.cpp block_libedit.cpp
busentry.cpp busentry.cpp
......
...@@ -2,107 +2,181 @@ ...@@ -2,107 +2,181 @@
/* annotate.cpp: component annotation */ /* annotate.cpp: component annotation */
/**************************************/ /**************************************/
/* Local Variable */ #include "fctsys.h"
static bool AnnotProject = true; #include "common.h"
static bool SortByPosition = true; #include "program.h"
#include "libcmp.h"
#include "annotate_dialog.cpp"
#include "netlist.h" #include "netlist.h"
#include "protos.h" #include "protos.h"
/* Local Functions*/ /* Local Functions*/
static int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet ); static int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet );
static int AnnotTriComposant( const void* o1, const void* o2 );
static void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ); static void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp );
static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp ); static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp );
static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ); static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp );
static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseListeCmp, int GetLastReferenceNumber( CmpListStruct* Objet,
CmpListStruct* BaseListeCmp,
int NbOfCmp ); int NbOfCmp );
static int ExistUnit( CmpListStruct* Objet, int Unit, static int ExistUnit( CmpListStruct* Objet, int Unit,
CmpListStruct* BaseListeCmp, int NbOfCmp ); CmpListStruct* BaseListeCmp, int NbOfCmp );
/**************************************/ /*****************************************************************************
void ReAnnotatePowerSymbolsOnly( void ) * Used to annotate the power symbols, before testing erc or computing
/**************************************/ * netlist when a component reannotation is not necessary
/* Used to reannotate the power symbols, before testing erc or computing netlist
* when a true component reannotation is not necessary
* *
* In order to avoid conflicts the ref number starts with a 0: * In order to avoid conflicts the reference number starts with a 0. A
* PWR with id 12 is named PWR12 in global annotation and PWR012 by the Power annotation * PWR with id 12 is named PWR12 in global annotation and PWR012 by the
*/ * Power annotation.
****************************************************************************/
void ReAnnotatePowerSymbolsOnly( void )
{ {
/* Build the screen list (screen, not sheet) */ /* Build the screen list (screen, not sheet) */
EDA_SheetList SheetList( NULL ); EDA_SheetList SheetList( NULL );
/* Update the screen number, sheet count and date */ /* Update the screen number, sheet count and date */
//ScreenList.UpdateScreenNumberAndDate(); //ScreenList.UpdateScreenNumberAndDate();
DrawSheetList* sheet; DrawSheetList* sheet;
int CmpNumber = 1; int CmpNumber = 1;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext())
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
{ {
EDA_BaseStruct* DrawList = sheet->LastDrawList(); EDA_BaseStruct* DrawList = sheet->LastDrawList();
for( ; DrawList != NULL; DrawList = DrawList->Pnext ) for( ; DrawList != NULL; DrawList = DrawList->Pnext )
{ {
if( DrawList->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( DrawList->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
continue; continue;
EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*) DrawList; EDA_SchComponentStruct* DrawLibItem =
(EDA_SchComponentStruct*) DrawList;
EDA_LibComponentStruct* Entry = EDA_LibComponentStruct* Entry =
FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); FindLibPart(
DrawLibItem->m_ChipName.GetData(), wxEmptyString,
FIND_ROOT );
if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) ) if( (Entry == NULL) || (Entry->m_Options != ENTRY_POWER) )
continue; continue;
//DrawLibItem->ClearAnnotation(sheet); this clears all annotation :( //DrawLibItem->ClearAnnotation(sheet); this clears all annotation :(
wxString refstr = DrawLibItem->m_PrefixString; wxString refstr = DrawLibItem->m_PrefixString;
//str will be "C?" or so after the ClearAnnotation call. //str will be "C?" or so after the ClearAnnotation call.
while(refstr.Last() == '?') while( refstr.Last() == '?' )
refstr.RemoveLast(); refstr.RemoveLast();
if(!refstr.StartsWith(wxT("#")))
refstr = wxT("#") + refstr; if( !refstr.StartsWith( wxT( "#" ) ) )
refstr = wxT( "#" ) + refstr;
refstr << wxT( "0" ) << CmpNumber; refstr << wxT( "0" ) << CmpNumber;
DrawLibItem->SetRef(sheet, refstr); DrawLibItem->SetRef( sheet, refstr );
CmpNumber++; CmpNumber++;
} }
} }
} }
/***********************************************************************/
CmpListStruct* AllocateCmpListStrct(int numcomponents )
/***********************************************************************/ CmpListStruct* AllocateCmpListStrct( int numcomponents )
{ {
int ii = numcomponents * sizeof(CmpListStruct); int ii = numcomponents * sizeof(CmpListStruct);
CmpListStruct* list = (CmpListStruct*) MyZMalloc( ii ); CmpListStruct* list = (CmpListStruct*) MyZMalloc( ii );
//fill this memory with zeros. //fill this memory with zeros.
char* cptr = (char*)list; char* cptr = (char*) list;
for(int i=0; i<ii; i++)
for( int i = 0; i<ii; i++ )
*cptr++ = 0; *cptr++ = 0;
return list; return list;
} }
/***********************************************************************/
void InstallAnnotateFrame( WinEDA_SchematicFrame* parent, wxPoint& pos )
/***********************************************************************/
/** Function InstallAnnotateFrame /* qsort function to annotate items by their position. */
* Install the annotate dialog frame int AnnotateByPosition( const void* o1, const void* o2 )
*/
{ {
WinEDA_AnnotateFrame* frame = new WinEDA_AnnotateFrame( parent ); CmpListStruct* item1 = (CmpListStruct*) o1;
CmpListStruct* item2 = (CmpListStruct*) o2;
int ii = strnicmp( item1->m_TextRef, item2->m_TextRef, 32 );
if( ii == 0 )
ii = item1->m_SheetList.Cmp( item2->m_SheetList );
if( ii == 0 )
ii = item1->m_Pos.x - item2->m_Pos.x;
if( ii == 0 )
ii = item1->m_Pos.y - item2->m_Pos.y;
if( ii == 0 )
ii = item1->m_TimeStamp - item2->m_TimeStamp;
return ii;
}
/*****************************************************************************
* qsort function to annotate items by value
* Components are sorted
* by reference
* if same reference: by value
* if same value: by unit number
* if same unit number, by sheet
* if same sheet, by time stamp
*****************************************************************************/
int AnnotateByValue( const void* o1, const void* o2 )
{
CmpListStruct* item1 = (CmpListStruct*) o1;
CmpListStruct* item2 = (CmpListStruct*) o2;
int ii = strnicmp( item1->m_TextRef, item2->m_TextRef, 32 );
if( ii == 0 )
ii = strnicmp( item1->m_TextValue, item2->m_TextValue, 32 );
if( ii == 0 )
ii = item1->m_Unit - item2->m_Unit;
if( ii == 0 )
ii = item1->m_SheetList.Cmp( item2->m_SheetList );
if( ii == 0 )
ii = item1->m_Pos.x - item2->m_Pos.x;
if( ii == 0 )
ii = item1->m_Pos.y - item2->m_Pos.y;
if( ii == 0 )
ii = item1->m_TimeStamp - item2->m_TimeStamp;
frame->ShowModal(); return ii;
frame->Destroy();
} }
/******************************************************************/ /*****************************************************************************
void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event ) * DeleteAnnotation:
/******************************************************************/ *
* Clear the current annotation.
****************************************************************************/
void DeleteAnnotation( WinEDA_SchematicFrame* parent, bool annotateSchematic )
{
DrawSheetStruct* sheet;
if( annotateSchematic )
sheet = g_RootSheet;
else
sheet = parent->GetSheet()->Last();
sheet->DeleteAnnotation( annotateSchematic );
g_RootSheet->m_s->SetModify();
parent->DrawPanel->Refresh( true );
}
/** Function WinEDA_AnnotateFrame::AnnotateComponents /*****************************************************************************
* Compute the annotation of the components for the whole project, or the current sheet only. * AnnotateComponents:
* All the components or the new ones only will be annotated. *
*/ * Compute the annotation of the components for the whole project, or the
* current sheet only. All the components or the new ones only will be
* annotated.
*****************************************************************************/
void AnnotateComponents( WinEDA_SchematicFrame* parent,
bool annotateSchematic,
bool sortByPosition,
bool resetAnnotation )
{ {
int ii, NbOfCmp; int ii, NbOfCmp;
DrawSheetList* sheet; DrawSheetList* sheet;
...@@ -110,15 +184,10 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event ) ...@@ -110,15 +184,10 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
wxBusyCursor dummy; wxBusyCursor dummy;
AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? true : FALSE; /* If it is an annotation for all the components, reset previous
SortByPosition = (m_AnnotSortCmpCtrl->GetSelection() == 0) ? true : FALSE; annotation: */
if( resetAnnotation )
/* If it is an annotation for all the components, reset previous annotation: */ DeleteAnnotation( parent, annotateSchematic );
if( m_AnnotNewCmpCtrl->GetSelection() == 0 )
DeleteAnnotation( event );
if( m_Abort )
return;
/* Build the sheet list */ /* Build the sheet list */
EDA_SheetList SheetList( g_RootSheet ); EDA_SheetList SheetList( g_RootSheet );
...@@ -127,10 +196,13 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event ) ...@@ -127,10 +196,13 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
ii = 0; ii = 0;
/* First pass: Component counting */ /* First pass: Component counting */
sheet = m_Parent->GetSheet(); sheet = parent->GetSheet();
if( AnnotProject == true ){ if( annotateSchematic )
{
NbOfCmp = 0; NbOfCmp = 0;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
NbOfCmp += ListeComposants( NULL, sheet ); NbOfCmp += ListeComposants( NULL, sheet );
} }
else else
...@@ -139,95 +211,52 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event ) ...@@ -139,95 +211,52 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
if( NbOfCmp == 0 ) if( NbOfCmp == 0 )
return; return;
BaseListeCmp = AllocateCmpListStrct(NbOfCmp); BaseListeCmp = AllocateCmpListStrct( NbOfCmp );
/* Second pass : Int data tables */ /* Second pass : Int data tables */
if( AnnotProject == true ) if( annotateSchematic )
{ {
ii = 0; ii = 0;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) for( sheet = SheetList.GetFirst();
ii += ListeComposants( BaseListeCmp + ii, sheet); sheet != NULL;
sheet = SheetList.GetNext() )
ii += ListeComposants( BaseListeCmp + ii, sheet );
} }
else else
ii = ListeComposants( BaseListeCmp, sheet); ii = ListeComposants( BaseListeCmp, sheet );
if( ii != NbOfCmp ) if( ii != NbOfCmp )
DisplayError( this, wxT( "Internal error in AnnotateComponents()" ) ); DisplayError( parent, wxT( "Internal error in AnnotateComponents()" ) );
/* Break full components reference in name (prefix) and number: example: IC1 become IC, and 1 */ /* Break full components reference in name (prefix) and number:
example: IC1 become IC, and 1 */
BreakReference( BaseListeCmp, NbOfCmp ); BreakReference( BaseListeCmp, NbOfCmp );
if ( sortByPosition )
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct), qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct),
( int( * ) ( const void*, const void* ) )AnnotTriComposant ); ( int( * ) ( const void*, const void* ) )AnnotateByValue );
else
qsort( BaseListeCmp, NbOfCmp, sizeof(CmpListStruct),
( int( * ) ( const void*, const void* ) )AnnotateByPosition );
/* Recalculate reference numbers */ /* Recalculate reference numbers */
ComputeReferenceNumber( BaseListeCmp, NbOfCmp ); ComputeReferenceNumber( BaseListeCmp, NbOfCmp );
ReAnnotateComponents( BaseListeCmp, NbOfCmp ); ReAnnotateComponents( BaseListeCmp, NbOfCmp );
MyFree( BaseListeCmp ); BaseListeCmp = NULL; MyFree( BaseListeCmp );
BaseListeCmp = NULL;
/* Final control */ /* Final control */
CheckAnnotate( m_Parent, AnnotProject ? FALSE : true ); CheckAnnotate( parent, !annotateSchematic );
parent->DrawPanel->Refresh( true );
m_Parent->DrawPanel->Refresh( true ); /* Refresh screen */
EndModal( 1 );
} }
/********************************************************************/ /*****************************************************************************
void WinEDA_AnnotateFrame::DeleteAnnotation( wxCommandEvent& event ) * if BaseListeCmp == NULL : count components
/********************************************************************/
/* Clear the current annotation for the whole project or only for the current sheet
* Update sheet number and number of sheets
*/
{
DrawSheetStruct* sheet;
//EDA_SchComponentStruct* DrawLibItem;
if( !IsOK( this, _( "Previous Annotation will be deleted. Continue ?" ) ) ){
m_Abort = true;
return;
}
AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? true : FALSE;
m_Abort = FALSE;
if( AnnotProject == true )
sheet = g_RootSheet;
else
sheet = m_Parent->GetSheet()->Last();
sheet->DeleteAnnotation( AnnotProject );
/*
for( ; screen != NULL; screen = ScreenList.GetNext() )
{
EDA_BaseStruct* DrawList = screen->EEDrawList;
for( ; DrawList != NULL; DrawList = DrawList->Pnext )
{
if( DrawList->Type() == DRAW_LIB_ITEM_STRUCT_TYPE )
{
DrawLibItem = (EDA_SchComponentStruct*) DrawList;
DrawLibItem->ClearAnnotation();
}
}
if( !AnnotProject )
break;
}
*/
g_RootSheet->m_s->SetModify();
m_Parent->DrawPanel->Refresh( true );
//EndModal( 0 );
}
/************************************************************************************/
int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet)
/***********************************************************************************/
/* if BaseListeCmp == NULL : count components
* else update data table BaseListeCmp * else update data table BaseListeCmp
*/ *****************************************************************************/
int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet )
{ {
int NbrCmp = 0; int NbrCmp = 0;
EDA_BaseStruct* DrawList = sheet->LastDrawList(); EDA_BaseStruct* DrawList = sheet->LastDrawList();
...@@ -236,26 +265,19 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet) ...@@ -236,26 +265,19 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet)
for( ; DrawList; DrawList = DrawList->Pnext ) for( ; DrawList; DrawList = DrawList->Pnext )
{ {
switch( DrawList->Type() ) if( DrawList->Type() == DRAW_LIB_ITEM_STRUCT_TYPE )
{ {
case DRAW_SEGMENT_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_HIER_LABEL_STRUCT_TYPE:
break;
case DRAW_LIB_ITEM_STRUCT_TYPE:
DrawLibItem = (EDA_SchComponentStruct*) DrawList; DrawLibItem = (EDA_SchComponentStruct*) DrawList;
Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT ); Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(),
wxEmptyString,
FIND_ROOT );
if( Entry == NULL ) if( Entry == NULL )
break; continue;
if( BaseListeCmp == NULL ) /* Items counting only */ if( BaseListeCmp == NULL ) /* Items counting only */
{ {
NbrCmp++; NbrCmp++;
break; continue;
} }
BaseListeCmp[NbrCmp].m_Cmp = DrawLibItem; BaseListeCmp[NbrCmp].m_Cmp = DrawLibItem;
...@@ -267,11 +289,11 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet) ...@@ -267,11 +289,11 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet)
BaseListeCmp[NbrCmp].m_Pos = DrawLibItem->m_Pos; BaseListeCmp[NbrCmp].m_Pos = DrawLibItem->m_Pos;
BaseListeCmp[NbrCmp].m_TimeStamp = DrawLibItem->m_TimeStamp; BaseListeCmp[NbrCmp].m_TimeStamp = DrawLibItem->m_TimeStamp;
if( DrawLibItem->GetRef(sheet).IsEmpty() ) if( DrawLibItem->GetRef( sheet ).IsEmpty() )
DrawLibItem->SetRef( sheet, wxT( "DefRef?" ) ); DrawLibItem->SetRef( sheet, wxT( "DefRef?" ) );
strncpy( BaseListeCmp[NbrCmp].m_TextRef, strncpy( BaseListeCmp[NbrCmp].m_TextRef,
CONV_TO_UTF8(DrawLibItem->GetRef(sheet)), 32 ); CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ), 32 );
BaseListeCmp[NbrCmp].m_NumRef = -1; BaseListeCmp[NbrCmp].m_NumRef = -1;
...@@ -281,19 +303,6 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet) ...@@ -281,19 +303,6 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet)
strncpy( BaseListeCmp[NbrCmp].m_TextValue, strncpy( BaseListeCmp[NbrCmp].m_TextValue,
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ), 32 ); CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ), 32 );
NbrCmp++; NbrCmp++;
break;
case DRAW_PICK_ITEM_STRUCT_TYPE:
case DRAW_POLYLINE_STRUCT_TYPE:
case DRAW_BUSENTRY_STRUCT_TYPE:
case DRAW_SHEET_STRUCT_TYPE:
case DRAW_SHEETLABEL_STRUCT_TYPE:
case DRAW_MARKER_STRUCT_TYPE:
case DRAW_NOCONNECT_STRUCT_TYPE:
break;
default:
break;
} }
} }
...@@ -301,60 +310,11 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet) ...@@ -301,60 +310,11 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet)
} }
/*****************************************************************/ /*****************************************************************************
int AnnotTriComposant( const void* o1, const void* o2 ) * Update the reference component for the schematic project (or the current
/****************************************************************/ * sheet)
*****************************************************************************/
/* function used par qsort() for sorting the list
* Composants are sorted
* by reference
* if same reference: by value
* if same value: by unit number
* if same unit number, by sheet
* if same sheet, by time stamp
**/
{
CmpListStruct* Objet1 = (CmpListStruct*) o1;
CmpListStruct* Objet2 = (CmpListStruct*) o2;
int ii = strnicmp( Objet1->m_TextRef, Objet2->m_TextRef, 32 );
if( SortByPosition == true )
{
if( ii == 0 )
ii = Objet1->m_SheetList.Cmp(Objet2->m_SheetList);
if( ii == 0 )
ii = Objet1->m_Pos.x - Objet2->m_Pos.x;
if( ii == 0 )
ii = Objet1->m_Pos.y - Objet2->m_Pos.y;
}
else // Sort by value
{
if( ii == 0 )
ii = strnicmp( Objet1->m_TextValue, Objet2->m_TextValue, 32 );
if( ii == 0 )
ii = Objet1->m_Unit - Objet2->m_Unit;
if( ii == 0 )
ii = Objet1->m_SheetList.Cmp(Objet2->m_SheetList);
if( ii == 0 )
ii = Objet1->m_Pos.x - Objet2->m_Pos.x;
if( ii == 0 )
ii = Objet1->m_Pos.y - Objet2->m_Pos.y;
}
if( ii == 0 )
ii = Objet1->m_TimeStamp - Objet2->m_TimeStamp;
return ii;
}
/********************************************************************/
static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp ) static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp )
/********************************************************************/
/* Update the reference component for the schematic project (or the current sheet)
*/
{ {
int ii; int ii;
char* Text; char* Text;
...@@ -371,22 +331,23 @@ static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp ) ...@@ -371,22 +331,23 @@ static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp )
else else
sprintf( Text + strlen( Text ), "%d", BaseListeCmp[ii].m_NumRef ); sprintf( Text + strlen( Text ), "%d", BaseListeCmp[ii].m_NumRef );
DrawLibItem->SetRef(&(BaseListeCmp[ii].m_SheetList), CONV_FROM_UTF8( Text ) ); DrawLibItem->SetRef( &(BaseListeCmp[ii].m_SheetList),
CONV_FROM_UTF8( Text ) );
DrawLibItem->m_Multi = BaseListeCmp[ii].m_Unit; DrawLibItem->m_Multi = BaseListeCmp[ii].m_Unit;
} }
} }
/**************************************************************/ /*****************************************************************************
void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ) * Split component reference designators into a name (prefix) and number.
/**************************************************************/ * Example: IC1 becomes IC and 1 in the .m_NumRef member.
* For multi part per package components not already annotated, set .m_Unit
/** BreakReference * to a max value (0x7FFFFFFF).
* Break full components reference in name (prefix) and number: example: IC1 become IC, and 1 in .m_NumRef *
* For multi part per package components not already annotated, set .m_Unit to a max value (0x7FFFFFFF)
* @param BaseListeCmp = list of component * @param BaseListeCmp = list of component
* @param NbOfCmp = item count in the list * @param NbOfCmp = item count in the list
*/ *****************************************************************************/
void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
{ {
int ii, ll; int ii, ll;
char* Text; char* Text;
...@@ -425,26 +386,26 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp ) ...@@ -425,26 +386,26 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
break; break;
} }
} }
/*printf("BreakReference(): %s number found: %d\n",
wxLogDebug( wxT("BreakReference(): %s number found: %d\n" ),
BaseListeCmp[ii].m_TextRef, BaseListeCmp[ii].m_TextRef,
BaseListeCmp[ii].m_NumRef); */ BaseListeCmp[ii].m_NumRef );
} }
} }
/*****************************************************************************/ /*****************************************************************************
static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ) * Compute the reference number for components without reference number
/*****************************************************************************/
/* Compute the reference number for components without reference number
* Compute .m_NumRef member * Compute .m_NumRef member
*/ *****************************************************************************/
static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
{ {
int ii, jj, LastReferenceNumber, NumberOfUnits, Unit; int ii, jj, LastReferenceNumber, NumberOfUnits, Unit;
const char* Text, * RefText, * ValText; const char* Text, * RefText, * ValText;
CmpListStruct* ObjRef, * ObjToTest; CmpListStruct* ObjRef, * ObjToTest;
/* Components with an invisible reference (power...) always are re-annotated */ /* Components with an invisible reference (power...) always are
* re-annotated */
for( ii = 0; ii < NbOfCmp; ii++ ) for( ii = 0; ii < NbOfCmp; ii++ )
{ {
Text = BaseListeCmp[ii].m_TextRef; Text = BaseListeCmp[ii].m_TextRef;
...@@ -466,7 +427,9 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ) ...@@ -466,7 +427,9 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
if( strnicmp( RefText, Text, 32 ) != 0 ) /* Nouveau Identificateur */ if( strnicmp( RefText, Text, 32 ) != 0 ) /* Nouveau Identificateur */
{ {
RefText = BaseListeCmp[ii].m_TextRef; RefText = BaseListeCmp[ii].m_TextRef;
LastReferenceNumber = GetLastReferenceNumber( BaseListeCmp + ii, BaseListeCmp, NbOfCmp ); LastReferenceNumber = GetLastReferenceNumber( BaseListeCmp + ii,
BaseListeCmp,
NbOfCmp );
} }
/* Annotation of one part per package components (trivial case)*/ /* Annotation of one part per package components (trivial case)*/
...@@ -483,13 +446,16 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ) ...@@ -483,13 +446,16 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
continue; continue;
} }
/* Annotation of multi-part components ( n parts per package ) (complex case) */ /* Annotation of multi-part components ( n parts per package )
(complex case) */
ValText = BaseListeCmp[ii].m_TextValue; ValText = BaseListeCmp[ii].m_TextValue;
NumberOfUnits = BaseListeCmp[ii].m_NbParts; NumberOfUnits = BaseListeCmp[ii].m_NbParts;
if( BaseListeCmp[ii].m_IsNew ) if( BaseListeCmp[ii].m_IsNew )
{ {
LastReferenceNumber++; BaseListeCmp[ii].m_NumRef = LastReferenceNumber; LastReferenceNumber++;
BaseListeCmp[ii].m_NumRef = LastReferenceNumber;
if( !BaseListeCmp[ii].m_PartsLocked ) if( !BaseListeCmp[ii].m_PartsLocked )
BaseListeCmp[ii].m_Unit = 1; BaseListeCmp[ii].m_Unit = 1;
BaseListeCmp[ii].m_Flag = 1; BaseListeCmp[ii].m_Flag = 1;
...@@ -519,8 +485,10 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ) ...@@ -519,8 +485,10 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
{ {
continue; continue;
} }
/* Component without reference number found, annotate it if possible */ /* Component without reference number found, annotate it if
if( !BaseListeCmp[jj].m_PartsLocked || (BaseListeCmp[jj].m_Unit == Unit) ) possible */
if( !BaseListeCmp[jj].m_PartsLocked ||
(BaseListeCmp[jj].m_Unit == Unit) )
{ {
BaseListeCmp[jj].m_NumRef = BaseListeCmp[ii].m_NumRef; BaseListeCmp[jj].m_NumRef = BaseListeCmp[ii].m_NumRef;
BaseListeCmp[jj].m_Unit = Unit; BaseListeCmp[jj].m_Unit = Unit;
...@@ -534,18 +502,18 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp ) ...@@ -534,18 +502,18 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
} }
/*************************************************************************************************/ /*****************************************************************************
static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseListeCmp, int NbOfCmp ) * Search the last used (greatest) reference number in the component list
/*************************************************************************************************/
/** Function GetLastReferenceNumber
* Search the last (bigger) reference number in the component list
* for the prefix reference given by Objet * for the prefix reference given by Objet
* The component list must be sorted * The component list must be sorted.
*
* @param Objet = reference item ( Objet->m_TextRef is the search pattern) * @param Objet = reference item ( Objet->m_TextRef is the search pattern)
* @param BaseListeCmp = list of items * @param BaseListeCmp = list of items
* @param NbOfCmp = items count in list of items * @param NbOfCmp = items count in list of items
*/ *****************************************************************************/
int GetLastReferenceNumber( CmpListStruct* Objet,
CmpListStruct* BaseListeCmp,
int NbOfCmp )
{ {
CmpListStruct* LastObjet = BaseListeCmp + NbOfCmp; CmpListStruct* LastObjet = BaseListeCmp + NbOfCmp;
int LastNumber = 0; int LastNumber = 0;
...@@ -554,7 +522,8 @@ static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseList ...@@ -554,7 +522,8 @@ static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseList
RefText = Objet->m_TextRef; RefText = Objet->m_TextRef;
for( ; Objet < LastObjet; Objet++ ) for( ; Objet < LastObjet; Objet++ )
{ {
if( strnicmp( RefText, Objet->m_TextRef, 32 ) != 0 ) /* Nouveau Identificateur */ /* Nouveau Identificateur */
if( strnicmp( RefText, Objet->m_TextRef, 32 ) != 0 )
break; break;
if( LastNumber < Objet->m_NumRef ) if( LastNumber < Objet->m_NumRef )
LastNumber = Objet->m_NumRef; LastNumber = Objet->m_NumRef;
...@@ -564,17 +533,16 @@ static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseList ...@@ -564,17 +533,16 @@ static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseList
} }
/*****************************************************************/ /*****************************************************************************
static int ExistUnit( CmpListStruct* Objet, int Unit, * TODO: Translate this to english/
CmpListStruct* BaseListeCmp, int NbOfCmp ) * Recherche dans la liste triee des composants, pour les composants
/****************************************************************/
/* Recherche dans la liste triee des composants, pour les composants
* multiples s'il existe pour le composant de reference Objet, * multiples s'il existe pour le composant de reference Objet,
* une unite de numero Unit * une unite de numero Unit
* Retourne index dans BaseListeCmp si oui * Retourne index dans BaseListeCmp si oui
* retourne -1 si non * retourne -1 si non
*/ *****************************************************************************/
static int ExistUnit( CmpListStruct* Objet, int Unit,
CmpListStruct* BaseListeCmp, int NbOfCmp )
{ {
CmpListStruct* EndList = BaseListeCmp + NbOfCmp; CmpListStruct* EndList = BaseListeCmp + NbOfCmp;
char* RefText, * ValText; char* RefText, * ValText;
...@@ -584,7 +552,9 @@ static int ExistUnit( CmpListStruct* Objet, int Unit, ...@@ -584,7 +552,9 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
RefText = Objet->m_TextRef; RefText = Objet->m_TextRef;
ValText = Objet->m_TextValue; ValText = Objet->m_TextValue;
NumRef = Objet->m_NumRef; NumRef = Objet->m_NumRef;
for( ItemToTest = BaseListeCmp, ii = 0; ItemToTest < EndList; ItemToTest++, ii++ ) for( ItemToTest = BaseListeCmp, ii = 0;
ItemToTest < EndList;
ItemToTest++, ii++ )
{ {
if( Objet == ItemToTest ) if( Objet == ItemToTest )
continue; continue;
...@@ -592,7 +562,8 @@ static int ExistUnit( CmpListStruct* Objet, int Unit, ...@@ -592,7 +562,8 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
continue; /* non affecte */ continue; /* non affecte */
if( ItemToTest->m_NumRef != NumRef ) if( ItemToTest->m_NumRef != NumRef )
continue; continue;
if( strnicmp( RefText, ItemToTest->m_TextRef, 32 ) != 0 ) /* Nouveau Identificateur */ /* Nouveau Identificateur */
if( strnicmp( RefText, ItemToTest->m_TextRef, 32 ) != 0 )
continue; continue;
if( ItemToTest->m_Unit == Unit ) if( ItemToTest->m_Unit == Unit )
{ {
...@@ -604,15 +575,16 @@ static int ExistUnit( CmpListStruct* Objet, int Unit, ...@@ -604,15 +575,16 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
} }
/******************************************************************/ /*****************************************************************************
int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) *
/******************************************************************/ * Function CheckAnnotate
* @return component count ( which are not annotated or have the same
/** Function CheckAnnotate * reference (duplicates))
* @return composent count ( which are not annotated or have the same reference (duplicates)) * @param oneSheetOnly : true = search is made only in the current sheet
* @param OneSheetOnly : true = search is made only in the current sheet
* false = search in whole hierarchy (usual search). * false = search in whole hierarchy (usual search).
*/ *
*****************************************************************************/
int CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly )
{ {
int ii, error, NbOfCmp; int ii, error, NbOfCmp;
DrawSheetList* sheet; DrawSheetList* sheet;
...@@ -627,9 +599,12 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -627,9 +599,12 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
ii = 0; ii = 0;
/* first pass : count composents */ /* first pass : count composents */
if( !OneSheetOnly ){ if( !oneSheetOnly )
{
NbOfCmp = 0; NbOfCmp = 0;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
NbOfCmp += ListeComposants( NULL, sheet ); NbOfCmp += ListeComposants( NULL, sheet );
} }
else else
...@@ -643,22 +618,26 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -643,22 +618,26 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
/* Second pass : create the list of components */ /* Second pass : create the list of components */
ListeCmp = AllocateCmpListStrct(NbOfCmp); ListeCmp = AllocateCmpListStrct( NbOfCmp );
printf("CheckAnnotate() listing all components:\n"); printf( "CheckAnnotate() listing all components:\n" );
if( !OneSheetOnly ){ if( !oneSheetOnly )
{
ii = 0; ii = 0;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
ii += ListeComposants( ListeCmp + ii, sheet ); ii += ListeComposants( ListeCmp + ii, sheet );
} }
else else
ListeComposants( ListeCmp, frame->GetSheet() ); ListeComposants( ListeCmp, frame->GetSheet() );
printf("CheckAnnotate() done:\n"); printf( "CheckAnnotate() done:\n" );
qsort( ListeCmp, NbOfCmp, sizeof(CmpListStruct), AnnotTriComposant ); qsort( ListeCmp, NbOfCmp, sizeof(CmpListStruct), AnnotateByValue );
/* Break full components reference in name (prefix) and number: example: IC1 become IC, and 1 */ /* Break full components reference in name (prefix) and number: example:
IC1 become IC, and 1 */
BreakReference( ListeCmp, NbOfCmp ); BreakReference( ListeCmp, NbOfCmp );
/* count not yet annotated items */ /* count not yet annotated items */
...@@ -676,7 +655,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -676,7 +655,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
Buff = wxT( "?" ); Buff = wxT( "?" );
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef );
msg.Printf( _( "item not annotated: %s%s" ), cmpref.GetData(), Buff.GetData() ); msg.Printf( _( "item not annotated: %s%s" ),
cmpref.GetData(), Buff.GetData() );
if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) ) if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) )
{ {
...@@ -688,7 +668,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -688,7 +668,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
break; break;
} }
if( MAX( ListeCmp[ii].m_NbParts, 1 ) < ListeCmp[ii].m_Unit ) // Annotate error // Annotate error
if( MAX( ListeCmp[ii].m_NbParts, 1 ) < ListeCmp[ii].m_Unit )
{ {
if( ListeCmp[ii].m_NumRef >= 0 ) if( ListeCmp[ii].m_NumRef >= 0 )
Buff << ListeCmp[ii].m_NumRef; Buff << ListeCmp[ii].m_NumRef;
...@@ -696,7 +677,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -696,7 +677,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
Buff = wxT( "?" ); Buff = wxT( "?" );
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef );
msg.Printf( _( "Error item %s%s" ), cmpref.GetData(), Buff.GetData() ); msg.Printf( _( "Error item %s%s" ), cmpref.GetData(),
Buff.GetData() );
Buff.Printf( _( " unit %d and no more than %d parts" ), Buff.Printf( _( " unit %d and no more than %d parts" ),
ListeCmp[ii].m_Unit, ListeCmp[ii].m_NbParts ); ListeCmp[ii].m_Unit, ListeCmp[ii].m_NbParts );
...@@ -716,8 +698,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -716,8 +698,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
msg.Empty(); msg.Empty();
Buff.Empty(); Buff.Empty();
if( (stricmp( ListeCmp[ii].m_TextRef, ListeCmp[ii + 1].m_TextRef ) != 0) if( (stricmp( ListeCmp[ii].m_TextRef,
|| ( ListeCmp[ii].m_NumRef != ListeCmp[ii + 1].m_NumRef ) ) ListeCmp[ii + 1].m_TextRef ) != 0)||
( ListeCmp[ii].m_NumRef != ListeCmp[ii + 1].m_NumRef ) )
continue; continue;
/* Same reference found */ /* Same reference found */
...@@ -744,8 +727,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -744,8 +727,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
continue; continue;
} }
/* Test error if units are different but number of parts per package too hight /* Test error if units are different but number of parts per package
* (ex U3 ( 1 part) and we find U3B the is an error) */ * too hight (ex U3 ( 1 part) and we find U3B the is an error) */
if( ListeCmp[ii].m_NbParts != ListeCmp[ii + 1].m_NbParts ) if( ListeCmp[ii].m_NbParts != ListeCmp[ii + 1].m_NbParts )
{ {
if( ListeCmp[ii].m_NumRef >= 0 ) if( ListeCmp[ii].m_NumRef >= 0 )
...@@ -754,7 +737,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -754,7 +737,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
Buff = wxT( "?" ); Buff = wxT( "?" );
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef );
msg.Printf( _( "Multiple item %s%s" ), cmpref.GetData(), Buff.GetData() ); msg.Printf( _( "Multiple item %s%s" ),
cmpref.GetData(), Buff.GetData() );
if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) ) if( (ListeCmp[ii].m_Unit > 0) && (ListeCmp[ii].m_Unit < 0x7FFFFFFF) )
{ {
...@@ -766,8 +750,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -766,8 +750,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
error++; error++;
} }
/* Error if values are diff�rent between units, for the same reference */ /* Error if values are different between units, for the same reference */
if( stricmp( ListeCmp[ii].m_TextValue, ListeCmp[ii + 1].m_TextValue ) != 0 ) if( stricmp( ListeCmp[ii].m_TextValue,
ListeCmp[ii + 1].m_TextValue ) != 0 )
{ {
wxString nextcmpref, cmpvalue, nextcmpvalue; wxString nextcmpref, cmpvalue, nextcmpvalue;
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef ); cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef );
...@@ -775,7 +760,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly ) ...@@ -775,7 +760,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
cmpvalue = CONV_FROM_UTF8( ListeCmp[ii].m_TextValue ); cmpvalue = CONV_FROM_UTF8( ListeCmp[ii].m_TextValue );
nextcmpvalue = CONV_FROM_UTF8( ListeCmp[ii + 1].m_TextValue ); nextcmpvalue = CONV_FROM_UTF8( ListeCmp[ii + 1].m_TextValue );
msg.Printf( _( "Diff values for %s%d%c (%s) and %s%d%c (%s)" ), msg.Printf( _( "Diff values for %s%d%c (%s) and %s%d%c (%s)" ),
cmpref.GetData(), ListeCmp[ii].m_NumRef, ListeCmp[ii].m_Unit + 'A' - 1, cmpref.GetData(),
ListeCmp[ii].m_NumRef,
ListeCmp[ii].m_Unit + 'A' - 1,
cmpvalue.GetData(), nextcmpref.GetData(), cmpvalue.GetData(), nextcmpref.GetData(),
ListeCmp[ii + 1].m_NumRef, ListeCmp[ii + 1].m_NumRef,
ListeCmp[ii + 1].m_Unit + 'A' - 1, ListeCmp[ii + 1].m_Unit + 'A' - 1,
......
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: annotate_dialog.cpp // Name: annotate_dialog.cpp
// Purpose: // Purpose:
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by: Wayne Stambaugh
//
// Created: 05/02/2006 12:31:28 // Created: 05/02/2006 12:31:28
// Modified 02/21/2008 13:47:10
// RCS-ID: // RCS-ID:
// Copyright: License GNU // Copyright: License GNU
// Licence: // Licence:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 05/02/2006 12:31:28
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #if defined (__GNUG__) && !defined (NO_GCC_PRAGMA)
#pragma implementation "annotate_dialog.h" #pragma implementation "annotate_dialog.h"
#endif #endif
...@@ -26,13 +28,15 @@ ...@@ -26,13 +28,15 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
////@begin includes
////@end includes
#include "annotate_dialog.h" #include "annotate_dialog.h"
////@begin XPM images extern void DeleteAnnotation( WinEDA_SchematicFrame* parent,
////@end XPM images bool annotateSchematic );
extern void AnnotateComponents( WinEDA_SchematicFrame* parent,
bool annotateSchematic,
bool sortByPosition,
bool resetAnnotation );
/*! /*!
* WinEDA_AnnotateFrame type definition * WinEDA_AnnotateFrame type definition
...@@ -45,120 +49,170 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_AnnotateFrame, wxDialog ) ...@@ -45,120 +49,170 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_AnnotateFrame, wxDialog )
*/ */
BEGIN_EVENT_TABLE( WinEDA_AnnotateFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_AnnotateFrame, wxDialog )
EVT_BUTTON( wxID_CLEAR, WinEDA_AnnotateFrame::OnClear )
////@begin WinEDA_AnnotateFrame event table entries EVT_BUTTON( wxID_APPLY, WinEDA_AnnotateFrame::OnApply )
EVT_BUTTON( ID_ANNOTATE_CMP, WinEDA_AnnotateFrame::OnAnnotateCmpClick )
EVT_BUTTON( ID_DEANNOTATE_CMP, WinEDA_AnnotateFrame::OnDeannotateCmpClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_AnnotateFrame::OnCancelClick )
////@end WinEDA_AnnotateFrame event table entries
END_EVENT_TABLE() END_EVENT_TABLE()
/*! /*!
* WinEDA_AnnotateFrame constructors * WinEDA_AnnotateFrame constructors
*/ */
WinEDA_AnnotateFrame::WinEDA_AnnotateFrame( ) WinEDA_AnnotateFrame::WinEDA_AnnotateFrame()
{ {
m_rbEntireSchematic = NULL;
m_cbResetAnnotation = NULL;
m_rbSortByPosition = NULL;
m_btnClear = NULL;
} }
WinEDA_AnnotateFrame::WinEDA_AnnotateFrame( WinEDA_SchematicFrame* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
WinEDA_AnnotateFrame::WinEDA_AnnotateFrame( WinEDA_SchematicFrame* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{ {
m_Parent = parent; m_Parent = parent;
m_Abort = FALSE; Create( parent, id, caption, pos, size, style );
Create(parent, id, caption, pos, size, style);
m_AnnotNewCmpCtrl->SetSelection(1);
} }
/*! /*!
* WinEDA_AnnotateFrame creator * WinEDA_AnnotateFrame creator
*/ */
bool WinEDA_AnnotateFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) bool WinEDA_AnnotateFrame::Create( wxWindow* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{ {
////@begin WinEDA_AnnotateFrame member initialisation SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
m_AnnotProjetCtrl = NULL;
m_AnnotNewCmpCtrl = NULL;
m_AnnotSortCmpCtrl = NULL;
////@end WinEDA_AnnotateFrame member initialisation
////@begin WinEDA_AnnotateFrame creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, id, caption, pos, size, style ); wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls(); CreateControls();
if( GetSizer() ) if( GetSizer() )
{ {
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
} }
Centre(); Centre();
////@end WinEDA_AnnotateFrame creation
return true; return true;
} }
/*! /*!
* Control creation for WinEDA_AnnotateFrame * Control creation for WinEDA_AnnotateFrame
*/ */
void WinEDA_AnnotateFrame::CreateControls() void WinEDA_AnnotateFrame::CreateControls()
{ {
SetFont(*g_DialogFont); wxFont fontBold = this->GetFont();
fontBold.SetWeight(wxFONTWEIGHT_BOLD);
////@begin WinEDA_AnnotateFrame content construction
// Generated by DialogBlocks, 07/11/2007 08:19:55 (unregistered) wxBoxSizer* sizerTop = new wxBoxSizer( wxVERTICAL );
WinEDA_AnnotateFrame* itemDialog1 = this; /* Sizer flags for setting up the spacing of the controls in the dialog
* box. These eventually should be moved to a file with a header in
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL); * the common directory so all of the dialogs share the same layout
itemDialog1->SetSizer(itemBoxSizer2); * spacing */
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL); /* Spacing for grouping labels in a dialog box. */
itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5); wxSizerFlags flagsLabelSpacing( 0 );
flagsLabelSpacing.Align( wxALIGN_TOP | wxALIGN_LEFT );
wxArrayString m_AnnotProjetCtrlStrings; flagsLabelSpacing.Border( wxLEFT | wxTOP, 6 );
m_AnnotProjetCtrlStrings.Add(_("Hierarchy"));
m_AnnotProjetCtrlStrings.Add(_("Current sheet")); /* Spacing for grouping radio buttons inside the grouping sizer. */
m_AnnotProjetCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("annotate:"), wxDefaultPosition, wxDefaultSize, m_AnnotProjetCtrlStrings, 1, wxRA_SPECIFY_COLS ); wxSizerFlags flagsRadioButtonSpacing( 0 );
m_AnnotProjetCtrl->SetSelection(0); flagsRadioButtonSpacing.Align( wxALIGN_LEFT );
itemBoxSizer3->Add(m_AnnotProjetCtrl, 0, wxGROW|wxALL, 5); flagsRadioButtonSpacing.Border( wxTOP | wxLEFT | wxRIGHT, 6 );
wxArrayString m_AnnotNewCmpCtrlStrings; /* Spacing for the radio button sizer inside the group sizer. */
m_AnnotNewCmpCtrlStrings.Add(_("all components")); wxSizerFlags flagsRadioButtonSizerSpacing( 0 );
m_AnnotNewCmpCtrlStrings.Add(_("new components only")); flagsRadioButtonSizerSpacing.Align( wxALIGN_TOP | wxALIGN_LEFT );
m_AnnotNewCmpCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("select items:"), wxDefaultPosition, wxDefaultSize, m_AnnotNewCmpCtrlStrings, 1, wxRA_SPECIFY_COLS ); flagsRadioButtonSizerSpacing.Border( wxLEFT, 20 );
m_AnnotNewCmpCtrl->SetSelection(0);
itemBoxSizer3->Add(m_AnnotNewCmpCtrl, 0, wxGROW|wxALL, 5); /* Spacing for the vertical group sizers. */
wxSizerFlags flagsGroupSizerSpacing( 1 );
wxArrayString m_AnnotSortCmpCtrlStrings; flagsGroupSizerSpacing.Align( wxALIGN_TOP | wxALIGN_LEFT );
m_AnnotSortCmpCtrlStrings.Add(_("by position")); flagsGroupSizerSpacing.Border( wxTOP | wxLEFT | wxRIGHT, 12 );
m_AnnotSortCmpCtrlStrings.Add(_("by value"));
m_AnnotSortCmpCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("sorting:"), wxDefaultPosition, wxDefaultSize, m_AnnotSortCmpCtrlStrings, 1, wxRA_SPECIFY_COLS ); /* Spacing for dialog button sizer. */
m_AnnotSortCmpCtrl->SetSelection(0); wxSizerFlags flagsDialogButtonSizerSpacing( 0 );
itemBoxSizer3->Add(m_AnnotSortCmpCtrl, 0, wxGROW|wxALL, 5); flagsDialogButtonSizerSpacing.Border( wxALL, 12 );
wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL); /* Spacing for the dialog buttons. */
itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); wxSizerFlags flagsDialogButtonSpacing( 0 );
flagsDialogButtonSpacing.Border( wxLEFT | wxRIGHT, 3 );
wxButton* itemButton8 = new wxButton( itemDialog1, ID_ANNOTATE_CMP, _("&Annotate"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton8->SetDefault(); /* Annotate scope sizers, label, and radio buttons. */
itemButton8->SetForegroundColour(wxColour(198, 0, 0)); wxBoxSizer* sizerAnnotate = new wxBoxSizer( wxVERTICAL );
itemBoxSizer7->Add(itemButton8, 0, wxGROW|wxALL, 5); wxStaticText* labelAnnotate = new wxStaticText( this, -1,
_( "Scope" ) );
wxButton* itemButton9 = new wxButton( itemDialog1, ID_DEANNOTATE_CMP, _("&Del Annotate"), wxDefaultPosition, wxDefaultSize, 0 ); labelAnnotate->SetFont( fontBold );
itemButton9->SetForegroundColour(wxColour(0, 0, 230)); sizerAnnotate->Add( labelAnnotate, flagsLabelSpacing );
itemBoxSizer7->Add(itemButton9, 0, wxGROW|wxALL, 5); wxBoxSizer* sizerAnnotateItems = new wxBoxSizer( wxVERTICAL );
m_rbEntireSchematic =
wxButton* itemButton10 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); new wxRadioButton( this, ID_ENTIRE_SCHEMATIC,
itemBoxSizer7->Add(itemButton10, 0, wxGROW|wxALL, 5); _( "Annotate the entire schematic" ),
wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
////@end WinEDA_AnnotateFrame content construction wxRadioButton* rbCurrentPage =
new wxRadioButton( this, ID_CURRENT_PAGE,
m_AnnotSortCmpCtrl->SetSelection(SortByPosition ? 0 : 1); _( "Annotate the current page only" ) );
m_rbEntireSchematic->SetValue( true );
m_cbResetAnnotation = new wxCheckBox( this, ID_RESET_ANNOTATION,
_( "Reset existing annotation" ) );
sizerAnnotateItems->Add( m_rbEntireSchematic, flagsRadioButtonSpacing );
sizerAnnotateItems->Add( rbCurrentPage, flagsRadioButtonSpacing );
sizerAnnotateItems->Add( m_cbResetAnnotation, flagsRadioButtonSpacing );
sizerAnnotate->Add( sizerAnnotateItems, flagsRadioButtonSizerSpacing );
sizerTop->Add( sizerAnnotate, flagsGroupSizerSpacing );
/* Annotation sort order sizers, label, and radio buttons. */
wxBoxSizer* sizerSort = new wxBoxSizer( wxVERTICAL );
wxStaticText* labelSort = new wxStaticText( this, wxID_ANY,
_( "Order" ) );
labelSort->SetFont( fontBold );
sizerSort->Add( labelSort, flagsLabelSpacing );
wxBoxSizer* sizerSortItems = new wxBoxSizer( wxVERTICAL );
m_rbSortByPosition = new wxRadioButton( this,
ID_SORT_BY_POSITION,
_( "Sort components by position" ),
wxDefaultPosition,
wxDefaultSize,
wxRB_GROUP );
wxRadioButton* rbSortByValue =
new wxRadioButton( this, ID_SORT_BY_VALUE,
_( "Sort components by value" ) );
sizerSortItems->Add( m_rbSortByPosition, flagsRadioButtonSpacing );
sizerSortItems->Add( rbSortByValue, flagsRadioButtonSpacing );
sizerSort->Add( sizerSortItems, flagsRadioButtonSizerSpacing );
sizerTop->Add( sizerSort, flagsGroupSizerSpacing );
/* Standard dialog buttons and sizer. */
wxBoxSizer* sizerDialogButtons = new wxBoxSizer( wxHORIZONTAL );
wxButton* btnClose = new wxButton( this, wxID_CANCEL, _( "Close" ) );
/* TODO: Check if there is any existing annotation and enable/disable
* the clear button accordingly. Probably should also enable/
* disable new components radio button if all of the components
* are already annotated. Some low level work on the DrawSheetList
* class will need to be done to accomadate this.
*/
m_btnClear = new wxButton( this, wxID_CLEAR );
wxButton* btnApply = new wxButton( this, wxID_APPLY );
sizerDialogButtons->Add( btnClose, flagsDialogButtonSpacing );
sizerDialogButtons->Add( new wxBoxSizer( wxHORIZONTAL ),
wxSizerFlags( 1 ).Expand( ) );
sizerDialogButtons->Add( m_btnClear, flagsDialogButtonSpacing );
sizerDialogButtons->Add( btnApply, flagsDialogButtonSpacing );
sizerTop->Add( sizerDialogButtons, flagsDialogButtonSizerSpacing );
SetSizer( sizerTop );
} }
/*! /*!
* Should we show tooltips? * Should we show tooltips?
*/ */
...@@ -168,6 +222,7 @@ bool WinEDA_AnnotateFrame::ShowToolTips() ...@@ -168,6 +222,7 @@ bool WinEDA_AnnotateFrame::ShowToolTips()
return true; return true;
} }
/*! /*!
* Get bitmap resources * Get bitmap resources
*/ */
...@@ -175,12 +230,11 @@ bool WinEDA_AnnotateFrame::ShowToolTips() ...@@ -175,12 +230,11 @@ bool WinEDA_AnnotateFrame::ShowToolTips()
wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name ) wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin WinEDA_AnnotateFrame bitmap retrieval wxUnusedVar( name );
wxUnusedVar(name);
return wxNullBitmap; return wxNullBitmap;
////@end WinEDA_AnnotateFrame bitmap retrieval
} }
/*! /*!
* Get icon resources * Get icon resources
*/ */
...@@ -188,34 +242,79 @@ wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name ) ...@@ -188,34 +242,79 @@ wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name )
wxIcon WinEDA_AnnotateFrame::GetIconResource( const wxString& name ) wxIcon WinEDA_AnnotateFrame::GetIconResource( const wxString& name )
{ {
// Icon retrieval // Icon retrieval
////@begin WinEDA_AnnotateFrame icon retrieval wxUnusedVar( name );
wxUnusedVar(name);
return wxNullIcon; return wxNullIcon;
////@end WinEDA_AnnotateFrame icon retrieval
} }
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ANNOTATE_CMP
*/
void WinEDA_AnnotateFrame::OnAnnotateCmpClick( wxCommandEvent& event ) void WinEDA_AnnotateFrame::OnClear( wxCommandEvent& event )
{ {
AnnotateComponents(event); int response;
wxString message = _( "Clear the existing annotation for " );
if( GetLevel() )
message += _( "the entire schematic?" );
else
message += _( "the current sheet?" );
message += _( "\n\nThis operation will clear the existing annotation " \
"and cannot be undone." );
response = wxMessageBox( message, _( "" ),
wxICON_EXCLAMATION | wxOK | wxCANCEL );
if (response == wxCANCEL)
return;
DeleteAnnotation( m_Parent, GetLevel() );
m_btnClear->Enable(false);
} }
/*! void WinEDA_AnnotateFrame::OnApply( wxCommandEvent& event )
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DEANNOTATE_CMP {
*/ int response;
wxButton* btn;
wxString message;
if( GetResetItems() )
message = _( "Clear and annotate all of the components " );
else
message = _( "Annotate only the unannotated components " );
if( GetLevel() )
message += _( "on the entire schematic?" );
else
message += _( "on the current sheet?" );
message += _( "\n\nThis operation will change the current annotation and " \
"cannot be undone." );
response = wxMessageBox( message, _( "" ),
wxICON_EXCLAMATION | wxOK | wxCANCEL );
if (response == wxCANCEL)
return;
AnnotateComponents( m_Parent, GetLevel(), GetSortOrder(),
GetResetItems() );
m_btnClear->Enable();
}
void WinEDA_AnnotateFrame::OnDeannotateCmpClick( wxCommandEvent& event ) bool WinEDA_AnnotateFrame::GetLevel( void )
{ {
DeleteAnnotation(event); wxASSERT_MSG( ((m_rbEntireSchematic != NULL) &&
m_rbEntireSchematic->IsKindOf( CLASSINFO( wxRadioButton ) )),
wxT( "m_rbEntireSchematic pointer was NULL." ) );
return m_rbEntireSchematic->GetValue();
} }
/*! bool WinEDA_AnnotateFrame::GetResetItems( void )
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL {
*/ wxASSERT_MSG( (m_cbResetAnnotation != NULL) &&
m_cbResetAnnotation->IsKindOf( CLASSINFO( wxCheckBox ) ),
wxT( "m_cbResetAnnotation pointer was NULL." ) );
void WinEDA_AnnotateFrame::OnCancelClick( wxCommandEvent& event ) return m_cbResetAnnotation->IsChecked();
}
bool WinEDA_AnnotateFrame::GetSortOrder( void )
{ {
EndModal( -1 ); wxASSERT_MSG( (m_rbSortByPosition != NULL) &&
m_rbSortByPosition->IsKindOf( CLASSINFO( wxRadioButton ) ),
wxT( "m_rbSortByPosition pointer was NULL." ) );
return m_rbSortByPosition->GetValue();
} }
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: annotate_dialog.h // Name: annotate_dialog.h
// Purpose: // Purpose:
// Author: jean-pierre Charras // Author: jean-pierre Charras
...@@ -9,12 +10,11 @@ ...@@ -9,12 +10,11 @@
// Licence: // Licence:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 05/02/2006 12:31:28
#ifndef _ANNOTATE_DIALOG_H_ #ifndef _ANNOTATE_DIALOG_H_
#define _ANNOTATE_DIALOG_H_ #define _ANNOTATE_DIALOG_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #if defined (__GNUG__) && !defined (NO_GCC_PRAGMA)
#pragma interface "annotate_dialog.h" #pragma interface "annotate_dialog.h"
#endif #endif
...@@ -22,39 +22,28 @@ ...@@ -22,39 +22,28 @@
* Includes * Includes
*/ */
////@begin includes
////@end includes
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include "program.h" #include "program.h"
#include "libcmp.h" #include "libcmp.h"
#include "general.h" #include "general.h"
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*! /*!
* Control identifiers * Control identifiers
*/ */
////@begin control identifiers
#define ID_DIALOG 10000 #define ID_DIALOG 10000
#define ID_RADIOBOX 10001 #define ID_ENTIRE_SCHEMATIC 10001
#define ID_RADIOBOX1 10002 #define ID_CURRENT_PAGE 10002
#define ID_RADIOBOX2 10005 #define ID_RESET_ANNOTATION 10003
#define ID_ANNOTATE_CMP 10003 #define ID_SORT_BY_POSITION 10004
#define ID_DEANNOTATE_CMP 10004 #define ID_SORT_BY_VALUE 10005
#define SYMBOL_WINEDA_ANNOTATEFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_ANNOTATEFRAME_TITLE _("EESchema Annotation") #define ANNOTATE_DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_ANNOTATEFRAME_IDNAME ID_DIALOG #define ANNOTATE_DIALOG_TITLE _( "Annotate" )
#define SYMBOL_WINEDA_ANNOTATEFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_ANNOTATEFRAME_POSITION wxDefaultPosition
////@end control identifiers
/*! /*!
* Compatibility * Compatibility
...@@ -68,60 +57,59 @@ ...@@ -68,60 +57,59 @@
* WinEDA_AnnotateFrame class declaration * WinEDA_AnnotateFrame class declaration
*/ */
class WinEDA_AnnotateFrame: public wxDialog class WinEDA_AnnotateFrame : public wxDialog
{ {
DECLARE_DYNAMIC_CLASS( WinEDA_AnnotateFrame ) DECLARE_DYNAMIC_CLASS( WinEDA_AnnotateFrame )
DECLARE_EVENT_TABLE()
public: public:
/// Constructors /// Constructors
WinEDA_AnnotateFrame( ); WinEDA_AnnotateFrame();
WinEDA_AnnotateFrame( WinEDA_SchematicFrame* parent, wxWindowID id = SYMBOL_WINEDA_ANNOTATEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ANNOTATEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ANNOTATEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ANNOTATEFRAME_SIZE, long style = SYMBOL_WINEDA_ANNOTATEFRAME_STYLE ); WinEDA_AnnotateFrame( WinEDA_SchematicFrame* parent,
wxWindowID id = wxID_ANY,
const wxString& caption = ANNOTATE_DIALOG_TITLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = ANNOTATE_DIALOG_STYLE );
/// Creation /// Creation
bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WINEDA_ANNOTATEFRAME_IDNAME, const wxString& caption = SYMBOL_WINEDA_ANNOTATEFRAME_TITLE, const wxPoint& pos = SYMBOL_WINEDA_ANNOTATEFRAME_POSITION, const wxSize& size = SYMBOL_WINEDA_ANNOTATEFRAME_SIZE, long style = SYMBOL_WINEDA_ANNOTATEFRAME_STYLE ); bool Create( wxWindow* parent,
wxWindowID id = wxID_ANY,
const wxString& caption = ANNOTATE_DIALOG_TITLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = ANNOTATE_DIALOG_STYLE );
/// Creates the controls and sizers /// Creates the controls and sizers
void CreateControls(); void CreateControls();
////@begin WinEDA_AnnotateFrame event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ANNOTATE_CMP
void OnAnnotateCmpClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DEANNOTATE_CMP
void OnDeannotateCmpClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
void OnCancelClick( wxCommandEvent& event );
////@end WinEDA_AnnotateFrame event handler declarations
////@begin WinEDA_AnnotateFrame member function declarations
/// Retrieves bitmap resources /// Retrieves bitmap resources
wxBitmap GetBitmapResource( const wxString& name ); wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources /// Retrieves icon resources
wxIcon GetIconResource( const wxString& name ); wxIcon GetIconResource( const wxString& name );
////@end WinEDA_AnnotateFrame member function declarations
bool GetLevel( void );
bool GetResetItems( void );
bool GetSortOrder( void );
/// Should we show tooltips? /// Should we show tooltips?
static bool ShowToolTips(); static bool ShowToolTips();
////@begin WinEDA_AnnotateFrame member variables WinEDA_SchematicFrame* m_Parent;
wxRadioBox* m_AnnotProjetCtrl;
wxRadioBox* m_AnnotNewCmpCtrl;
wxRadioBox* m_AnnotSortCmpCtrl;
////@end WinEDA_AnnotateFrame member variables
WinEDA_SchematicFrame * m_Parent;
bool m_Abort;
private: private:
void AnnotateComponents(wxCommandEvent& event); void OnClear( wxCommandEvent& event );
void DeleteAnnotation(wxCommandEvent& event); void OnApply( wxCommandEvent& event );
wxRadioButton* m_rbEntireSchematic;
wxRadioButton* m_rbSortByPosition;
wxCheckBox* m_cbResetAnnotation;
wxButton* m_btnClear;
DECLARE_EVENT_TABLE()
}; };
#endif #endif
// _ANNOTATE_DIALOG_H_
// _ANNOTATE_DIALOG_H_
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
/* GENERAL.H : declarations communes */ /* GENERAL.H : declarations communes */
/***************************************/ /***************************************/
#ifndef _GENERAL_H_
#define _GENERAL_H_
#ifndef eda_global #ifndef eda_global
#define eda_global extern #define eda_global extern
#endif #endif
...@@ -267,3 +270,5 @@ eda_global int g_PlotPSMinimunLineWidth; /* Minimum line (in EESCHEMA units) wid ...@@ -267,3 +270,5 @@ eda_global int g_PlotPSMinimunLineWidth; /* Minimum line (in EESCHEMA units) wid
/* Config keys */ /* Config keys */
#define MINI_DRAW_LINE_WIDTH_KEY wxT("MinimunDrawLineWidth") #define MINI_DRAW_LINE_WIDTH_KEY wxT("MinimunDrawLineWidth")
#define MINI_PLOTPS_LINE_WIDTH_KEY wxT("MinimunPlotPSLineWidth") #define MINI_PLOTPS_LINE_WIDTH_KEY wxT("MinimunPlotPSLineWidth")
#endif // _GENERAL_H_
...@@ -300,7 +300,7 @@ void InstallNetlistFrame(WinEDA_SchematicFrame *parent, wxPoint &pos); ...@@ -300,7 +300,7 @@ void InstallNetlistFrame(WinEDA_SchematicFrame *parent, wxPoint &pos);
/***************/ /***************/
void ReAnnotatePowerSymbolsOnly(); void ReAnnotatePowerSymbolsOnly();
void InstallAnnotateFrame(WinEDA_SchematicFrame * parent, wxPoint &pos); void InstallAnnotateFrame(WinEDA_SchematicFrame * parent);
int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly); int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly);
/* Retourne le nombre de composants non annotes ou erron�s /* Retourne le nombre de composants non annotes ou erron�s
Si OneSheetOnly : recherche sur le schema courant Si OneSheetOnly : recherche sur le schema courant
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
#include "protos.h" #include "protos.h"
/********************************************************************************/ /*****************************************************************************/
void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
/********************************************************************************/ /*****************************************************************************/
/* Traite les selections d'outils et les commandes appelees du menu POPUP /* Traite les selections d'outils et les commandes appelees du menu POPUP
*/ */
...@@ -116,7 +116,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -116,7 +116,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_CANCEL_CURRENT_COMMAND: case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE ) if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE )
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor = DrawPanel-> DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
DrawPanel->
m_PanelDefaultCursor ) ); m_PanelDefaultCursor ) );
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
...@@ -145,7 +146,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -145,7 +146,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc ); DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
} }
DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor = wxCURSOR_ARROW; DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor =
wxCURSOR_ARROW;
SetToolID( 0, DrawPanel->m_PanelCursor, wxEmptyString ); SetToolID( 0, DrawPanel->m_PanelCursor, wxEmptyString );
break; break;
} }
...@@ -167,6 +169,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -167,6 +169,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_LOAD_ONE_SHEET: case ID_LOAD_ONE_SHEET:
//how is this different from above? //how is this different from above?
//LoadOneSheet( GetSheet(), wxEmptyString ); //LoadOneSheet( GetSheet(), wxEmptyString );
break; break;
...@@ -181,7 +184,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -181,7 +184,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_LOAD_FILE_8: case ID_LOAD_FILE_8:
case ID_LOAD_FILE_9: case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10: case ID_LOAD_FILE_10:
LoadOneEEProject( GetLastProject( id - ID_LOAD_FILE_1 ).GetData(), FALSE ); LoadOneEEProject( GetLastProject( id - ID_LOAD_FILE_1 ).GetData(
), FALSE );
break; break;
case ID_TO_LIBRARY: case ID_TO_LIBRARY:
...@@ -191,11 +195,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -191,11 +195,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
} }
else else
{ {
m_Parent->m_LibeditFrame = new m_Parent->m_LibeditFrame =
WinEDA_LibeditFrame( m_Parent->m_SchematicFrame, new WinEDA_LibeditFrame( m_Parent->m_SchematicFrame,
m_Parent, m_Parent,
wxT( "Library Editor" ), wxT( "Library Editor" ),
wxPoint( -1, -1 ), wxSize( 600, 400 ) ); wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
ActiveScreen = ScreenLib; ActiveScreen = ScreenLib;
m_Parent->m_LibeditFrame->AdjustScrollBars(); m_Parent->m_LibeditFrame->AdjustScrollBars();
} }
...@@ -238,8 +243,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -238,8 +243,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
} }
else else
{ {
m_Parent->m_ViewlibFrame = new m_Parent->m_ViewlibFrame =
WinEDA_ViewlibFrame( m_Parent->m_SchematicFrame, m_Parent ); new WinEDA_ViewlibFrame( m_Parent->m_SchematicFrame,
m_Parent );
m_Parent->m_ViewlibFrame->AdjustScrollBars(); m_Parent->m_ViewlibFrame->AdjustScrollBars();
} }
break; break;
...@@ -261,10 +267,6 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -261,10 +267,6 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
HandleBlockBegin( &dc, BLOCK_PASTE, GetScreen()->m_Curseur ); HandleBlockBegin( &dc, BLOCK_PASTE, GetScreen()->m_Curseur );
break; break;
case ID_GET_ANNOTATE:
InstallAnnotateFrame( this, defaultpos );
break;
case ID_GET_ERC: case ID_GET_ERC:
InstallErcFrame( this, defaultpos ); InstallErcFrame( this, defaultpos );
break; break;
...@@ -376,12 +378,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -376,12 +378,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_SCH_EDIT_TEXT: case ID_POPUP_SCH_EDIT_TEXT:
EditSchematicText((DrawTextStruct*) GetScreen()->GetCurItem(), &dc ); EditSchematicText( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc );
break; break;
case ID_POPUP_SCH_ROTATE_TEXT: case ID_POPUP_SCH_ROTATE_TEXT:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
ChangeTextOrient((DrawTextStruct*) GetScreen()->GetCurItem(), &dc ); ChangeTextOrient( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc );
break; break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL: case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
...@@ -425,7 +427,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -425,7 +427,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DELETE_NODE: case ID_POPUP_SCH_DELETE_NODE:
case ID_POPUP_SCH_DELETE_CONNECTION: case ID_POPUP_SCH_DELETE_CONNECTION:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
DeleteConnection( &dc, id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE ); DeleteConnection( &dc,
id == ID_POPUP_SCH_DELETE_CONNECTION ? TRUE : FALSE );
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
TestDanglingEnds( GetScreen()->EEDrawList, &dc ); TestDanglingEnds( GetScreen()->EEDrawList, &dc );
...@@ -447,9 +450,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -447,9 +450,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
// Ensure the struct is a component (could be a struct of a component, like Field, text..) // Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
case ID_POPUP_SCH_DELETE: case ID_POPUP_SCH_DELETE:
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
...@@ -500,28 +505,39 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -500,28 +505,39 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DRAG_CMP_REQUEST: case ID_POPUP_SCH_DRAG_CMP_REQUEST:
case ID_POPUP_SCH_MOVE_CMP_REQUEST: case ID_POPUP_SCH_MOVE_CMP_REQUEST:
// Ensure the struct is a component (could be a struct of a component, like Field, text..)
// Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
case ID_POPUP_SCH_MOVE_ITEM_REQUEST: case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
if ( id == ID_POPUP_SCH_DRAG_CMP_REQUEST ) if( id == ID_POPUP_SCH_DRAG_CMP_REQUEST )
{ // The easiest way to handle a drag component is simulate a block drag command {
// The easiest way to handle a drag component is simulate a
// block drag command
if( GetScreen()->BlockLocate.m_State == STATE_NO_BLOCK ) if( GetScreen()->BlockLocate.m_State == STATE_NO_BLOCK )
{ {
if( !HandleBlockBegin( &dc, BLOCK_DRAG, GetScreen()->m_Curseur ) ) break; if( !HandleBlockBegin( &dc, BLOCK_DRAG,
GetScreen()->m_Curseur ) )
break;
HandleBlockEnd( &dc ); HandleBlockEnd( &dc );
} }
} }
else Process_Move_Item( GetScreen()->GetCurItem(), &dc ); else
Process_Move_Item( GetScreen()->GetCurItem(), &dc );
break; break;
case ID_POPUP_SCH_EDIT_CMP: case ID_POPUP_SCH_EDIT_CMP:
// Ensure the struct is a component (could be a struct of a component, like Field, text..) // Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
InstallCmpeditFrame( this, pos, InstallCmpeditFrame( this, pos,
...@@ -533,10 +549,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -533,10 +549,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE: case ID_POPUP_SCH_ROTATE_CMP_CLOCKWISE:
case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE: case ID_POPUP_SCH_ROTATE_CMP_COUNTERCLOCKWISE:
case ID_POPUP_SCH_ORIENT_NORMAL_CMP: case ID_POPUP_SCH_ORIENT_NORMAL_CMP:
// Ensure the struct is a component (could be a struct of a
// Ensure the struct is a component (could be a struct of a component, like Field, text..) // component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
{ {
...@@ -576,9 +593,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -576,9 +593,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_EDIT_VALUE_CMP: case ID_POPUP_SCH_EDIT_VALUE_CMP:
// Ensure the struct is a component (could be a struct of a component, like Field, text..) // Ensure the struct is a component (could be a struct of a
// component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
EditComponentValue( EditComponentValue(
...@@ -586,10 +605,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -586,10 +605,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_SCH_EDIT_REF_CMP: case ID_POPUP_SCH_EDIT_REF_CMP:
// Ensure the struct is a component (could be a struct of a
// Ensure the struct is a component (could be a struct of a component, like Field, text..) // component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
EditComponentReference( EditComponentReference(
...@@ -597,10 +617,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -597,10 +617,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP: case ID_POPUP_SCH_EDIT_FOOTPRINT_CMP:
// Ensure the struct is a component (could be a struct of a
// Ensure the struct is a component (could be a struct of a component, like Field, text..) // component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
EditComponentFootprint( EditComponentFootprint(
...@@ -609,10 +630,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -609,10 +630,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_EDIT_CONVERT_CMP: case ID_POPUP_SCH_EDIT_CONVERT_CMP:
// Ensure the struct is a component (could be a struct of a
// Ensure the struct is a component (could be a struct of a component, like Field, text..) // component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
...@@ -626,7 +648,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -626,7 +648,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
EDA_SchComponentStruct* olditem, * newitem; EDA_SchComponentStruct* olditem, * newitem;
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
olditem = (EDA_SchComponentStruct*) GetScreen()->GetCurItem(); olditem = (EDA_SchComponentStruct*) GetScreen()->GetCurItem();
if( olditem == NULL ) if( olditem == NULL )
break; break;
...@@ -635,7 +658,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -635,7 +658,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
newitem->ClearAnnotation(); newitem->ClearAnnotation();
newitem->m_Flags = IS_NEW; newitem->m_Flags = IS_NEW;
StartMovePart( newitem, &dc ); StartMovePart( newitem, &dc );
/* Redraw the original part, because StartMovePart() has erase it from screen */ /* Redraw the original part, because StartMovePart() has erase
* it from screen */
RedrawOneStruct( DrawPanel, &dc, olditem, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( DrawPanel, &dc, olditem, GR_DEFAULT_DRAWMODE );
} }
break; break;
...@@ -666,10 +690,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -666,10 +690,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_SELECT_UNIT24: case ID_POPUP_SCH_SELECT_UNIT24:
case ID_POPUP_SCH_SELECT_UNIT25: case ID_POPUP_SCH_SELECT_UNIT25:
case ID_POPUP_SCH_SELECT_UNIT26: case ID_POPUP_SCH_SELECT_UNIT26:
// Ensure the struct is a component (could be a struct of a
// Ensure the struct is a component (could be a struct of a component, like Field, text..) // component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
DrawPanel->MouseToCursorSchema(); DrawPanel->MouseToCursorSchema();
...@@ -680,19 +705,23 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -680,19 +705,23 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_POPUP_SCH_DISPLAYDOC_CMP: case ID_POPUP_SCH_DISPLAYDOC_CMP:
// Ensure the struct is a component (could be a piece of a
// Ensure the struct is a component (could be a piece of a component, like Field, text..) // component, like Field, text..)
if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE ) if( GetScreen()->GetCurItem()->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) ); GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL ) if( GetScreen()->GetCurItem() == NULL )
break; break;
{ {
EDA_LibComponentStruct* LibEntry; EDA_LibComponentStruct* LibEntry;
LibEntry = FindLibPart( ( (EDA_SchComponentStruct*) LibEntry = FindLibPart(
GetScreen()->GetCurItem() )->m_ChipName, ( (EDA_SchComponentStruct*) GetScreen()->GetCurItem() )->m_ChipName,
wxEmptyString, FIND_ALIAS ); wxEmptyString,
FIND_ALIAS );
if( LibEntry && LibEntry->m_DocFile != wxEmptyString ) if( LibEntry && LibEntry->m_DocFile != wxEmptyString )
GetAssociatedDocument( this, g_RealLibDirBuffer, LibEntry->m_DocFile ); GetAssociatedDocument( this,
g_RealLibDirBuffer,
LibEntry->m_DocFile );
} }
break; break;
...@@ -764,7 +793,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -764,7 +793,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_ADD_LABEL: case ID_POPUP_SCH_ADD_LABEL:
case ID_POPUP_SCH_ADD_GLABEL: case ID_POPUP_SCH_ADD_GLABEL:
GetScreen()->SetCurItem( CreateNewText( &dc, GetScreen()->SetCurItem(
CreateNewText( &dc,
id == ID_POPUP_SCH_ADD_LABEL ? id == ID_POPUP_SCH_ADD_LABEL ?
LAYER_LOCLABEL : LAYER_GLOBLABEL ) ); LAYER_LOCLABEL : LAYER_GLOBLABEL ) );
if( GetScreen()->GetCurItem() ) if( GetScreen()->GetCurItem() )
...@@ -776,17 +806,20 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -776,17 +806,20 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_SCHEMATIC_UNDO: case ID_SCHEMATIC_UNDO:
if ( GetSchematicFromUndoList() ) if( GetSchematicFromUndoList() )
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
case ID_SCHEMATIC_REDO: case ID_SCHEMATIC_REDO:
if ( GetSchematicFromRedoList() ) if( GetSchematicFromRedoList() )
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( TRUE );
break; break;
default: // Log error: default: // Log error:
DisplayError( this, wxT( "WinEDA_SchematicFrame::Process_Special_Functions error" ) ); DisplayError( this,
wxT( "WinEDA_SchematicFrame::Process_Special_Functions error" ) );
break; break;
} }
...@@ -801,10 +834,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -801,10 +834,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
} }
/********************************************************************************/
void WinEDA_SchematicFrame::Process_Move_Item( EDA_BaseStruct* DrawStruct, void WinEDA_SchematicFrame::Process_Move_Item( EDA_BaseStruct* DrawStruct,
wxDC* DC ) wxDC* DC )
/********************************************************************************/
{ {
if( DrawStruct == NULL ) if( DrawStruct == NULL )
return; return;
......
/******************************************************************/ /******************************************************************/
/* schframe.cpp - fonctions des classes du type WinEDA_DrawFrame */ /* schframe.cpp - fonctions des classes du type WinEDA_DrawFrame */
/******************************************************************/ /******************************************************************/
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
...@@ -17,110 +17,116 @@ ...@@ -17,110 +17,116 @@
#include "protos.h" #include "protos.h"
#include "id.h" #include "id.h"
#include "annotate_dialog.h"
/*******************************/ /*******************************/
/* class WinEDA_SchematicFrame */ /* class WinEDA_SchematicFrame */
/*******************************/ /*******************************/
BEGIN_EVENT_TABLE(WinEDA_SchematicFrame, wxFrame) BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, wxFrame )
COMMON_EVENTS_DRAWFRAME COMMON_EVENTS_DRAWFRAME EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV,
WinEDA_DrawFrame::OnSockRequestServer )
EVT_SOCKET( ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest )
EVT_SOCKET(ID_EDA_SOCKET_EVENT_SERV, WinEDA_DrawFrame::OnSockRequestServer) EVT_CLOSE( WinEDA_SchematicFrame::OnCloseWindow )
EVT_SOCKET(ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest) EVT_SIZE( WinEDA_SchematicFrame::OnSize )
EVT_CLOSE(WinEDA_SchematicFrame::OnCloseWindow) EVT_MENU_RANGE( ID_LOAD_PROJECT, ID_LOAD_FILE_10,
EVT_SIZE(WinEDA_SchematicFrame::OnSize) WinEDA_SchematicFrame::Process_Special_Functions )
EVT_MENU_RANGE(ID_LOAD_PROJECT,ID_LOAD_FILE_10,
WinEDA_SchematicFrame::Process_Special_Functions)
EVT_TOOL(ID_NEW_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions)
EVT_TOOL(ID_LOAD_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions)
EVT_TOOL_RANGE(ID_SCHEMATIC_MAIN_TOOLBAR_START, ID_SCHEMATIC_MAIN_TOOLBAR_END,
WinEDA_SchematicFrame::Process_Special_Functions)
EVT_MENU_RANGE(ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
WinEDA_DrawFrame::ProcessFontPreferences)
EVT_MENU(ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File)
EVT_MENU(ID_SAVE_ONE_SHEET, WinEDA_SchematicFrame::Save_File)
EVT_MENU(ID_SAVE_ONE_SHEET_AS, WinEDA_SchematicFrame::Save_File)
EVT_TOOL(ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File)
EVT_MENU(ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter)
EVT_MENU(ID_GEN_PLOT_PS, WinEDA_SchematicFrame::ToPlot_PS)
EVT_MENU(ID_GEN_PLOT_HPGL, WinEDA_SchematicFrame::ToPlot_HPGL)
EVT_MENU(ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print)
EVT_MENU(ID_GEN_COPY_SHEET_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard)
EVT_MENU(ID_GEN_COPY_BLOCK_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard)
EVT_MENU(ID_EXIT, WinEDA_SchematicFrame::Process_Special_Functions)
EVT_MENU_RANGE(ID_CONFIG_AND_PREFERENCES_START, ID_CONFIG_AND_PREFERENCES_END, WinEDA_SchematicFrame::Process_Config)
EVT_TOOL(ID_COLORS_SETUP, WinEDA_SchematicFrame::Process_Config)
EVT_TOOL(ID_OPTIONS_SETUP, WinEDA_SchematicFrame::Process_Config)
EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
WinEDA_DrawFrame::SetLanguage)
EVT_TOOL_RANGE(ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
WinEDA_SchematicFrame::Process_Zoom)
EVT_TOOL(ID_NEW_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions)
EVT_TOOL(ID_LOAD_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions)
EVT_TOOL(ID_TO_LIBRARY, WinEDA_SchematicFrame::Process_Special_Functions)
EVT_TOOL(ID_TO_LIBVIEW, WinEDA_SchematicFrame::Process_Special_Functions)
EVT_TOOL(ID_TO_PCB, WinEDA_SchematicFrame::Process_Special_Functions) EVT_TOOL( ID_NEW_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL(ID_TO_CVPCB, WinEDA_SchematicFrame::Process_Special_Functions) EVT_TOOL( ID_LOAD_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL_RANGE( ID_SCHEMATIC_MAIN_TOOLBAR_START,
ID_SCHEMATIC_MAIN_TOOLBAR_END,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL(ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings) EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
EVT_TOOL(ID_HIERARCHY, WinEDA_SchematicFrame::Process_Special_Functions) WinEDA_DrawFrame::ProcessFontPreferences )
EVT_TOOL(wxID_CUT, WinEDA_SchematicFrame::Process_Special_Functions)
EVT_TOOL(wxID_COPY, WinEDA_SchematicFrame::Process_Special_Functions) EVT_MENU( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File )
EVT_TOOL(wxID_PASTE, WinEDA_SchematicFrame::Process_Special_Functions) EVT_MENU( ID_SAVE_ONE_SHEET, WinEDA_SchematicFrame::Save_File )
EVT_TOOL(ID_UNDO_BUTT, WinEDA_SchematicFrame::Process_Special_Functions) EVT_MENU( ID_SAVE_ONE_SHEET_AS, WinEDA_SchematicFrame::Save_File )
EVT_TOOL(ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter) EVT_TOOL( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File )
EVT_TOOL_RANGE(ID_GET_ANNOTATE,ID_FIND_ITEMS, EVT_MENU( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
WinEDA_SchematicFrame::Process_Special_Functions) EVT_MENU( ID_GEN_PLOT_PS, WinEDA_SchematicFrame::ToPlot_PS )
EVT_MENU( ID_GEN_PLOT_HPGL, WinEDA_SchematicFrame::ToPlot_HPGL )
EVT_MENU( ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print )
EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
EVT_MENU( ID_GEN_COPY_BLOCK_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
EVT_MENU( ID_EXIT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_MENU_RANGE( ID_CONFIG_AND_PREFERENCES_START,
ID_CONFIG_AND_PREFERENCES_END,
WinEDA_SchematicFrame::Process_Config )
EVT_TOOL( ID_COLORS_SETUP, WinEDA_SchematicFrame::Process_Config )
EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_SchematicFrame::Process_Config )
EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
WinEDA_DrawFrame::SetLanguage )
EVT_TOOL_RANGE( ID_ZOOM_IN_BUTT, ID_ZOOM_PAGE_BUTT,
WinEDA_SchematicFrame::Process_Zoom )
EVT_TOOL( ID_NEW_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_LOAD_PROJECT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_TO_LIBRARY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_TO_LIBVIEW, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_TO_PCB, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_TO_CVPCB, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings )
EVT_TOOL( ID_HIERARCHY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_CUT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_COPY, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( wxID_PASTE, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_UNDO_BUTT, WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL( ID_GET_ANNOTATE, WinEDA_SchematicFrame::OnAnnotate )
EVT_TOOL( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
EVT_TOOL_RANGE( ID_GET_ERC, ID_FIND_ITEMS,
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_MENU(ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp) EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU(ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout) EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
// Tools et boutons de Schematique, Vertical toolbar: // Tools et boutons de Schematique, Vertical toolbar:
EVT_TOOL_RANGE(ID_SCHEMATIC_VERTICAL_TOOLBAR_START, EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
ID_SCHEMATIC_VERTICAL_TOOLBAR_END, ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
WinEDA_SchematicFrame::Process_Special_Functions) WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL_RCLICKED(ID_LABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick) EVT_TOOL_RCLICKED( ID_LABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
EVT_TOOL_RCLICKED(ID_GLABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick) EVT_TOOL_RCLICKED( ID_GLABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
EVT_TOOL_RCLICKED(ID_HIERLABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick) EVT_TOOL_RCLICKED( ID_HIERLABEL_BUTT,
WinEDA_SchematicFrame::ToolOnRightClick )
EVT_MENU_RANGE(ID_POPUP_START_RANGE, ID_POPUP_END_RANGE, EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
WinEDA_SchematicFrame::Process_Special_Functions ) WinEDA_SchematicFrame::Process_Special_Functions )
// Tools et boutons de Schematique, Options toolbar: // Tools et boutons de Schematique, Options toolbar:
EVT_TOOL_RANGE(ID_TB_OPTIONS_START,ID_TB_OPTIONS_END, EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
WinEDA_SchematicFrame::OnSelectOptionToolbar) WinEDA_SchematicFrame::OnSelectOptionToolbar )
EVT_MENU_RANGE(ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE, EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_SchematicFrame::Process_Special_Functions ) WinEDA_SchematicFrame::Process_Special_Functions )
END_EVENT_TABLE() END_EVENT_TABLE()
/****************/
/* Constructor */
/****************/
WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
/****************/ WinEDA_App* parent,
/* Constructor */ const wxString& title,
/****************/ const wxPoint& pos,
const wxSize& size,
WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *parent, long style ) :
const wxString & title, const wxPoint& pos, const wxSize& size, long style) : WinEDA_DrawFrame( father, SCHEMATIC_FRAME, parent, title, pos, size, style )
WinEDA_DrawFrame(father, SCHEMATIC_FRAME, parent, title, pos, size, style)
{ {
m_FrameName = wxT("SchematicFrame"); m_FrameName = wxT( "SchematicFrame" );
m_AboutTitle = g_EeschemaAboutTitle; m_AboutTitle = g_EeschemaAboutTitle;
m_Draw_Axis = FALSE; // TRUE to show axis m_Draw_Axis = FALSE; // TRUE to show axis
m_Draw_Grid = g_ShowGrid; // TRUE to show a grid m_Draw_Grid = g_ShowGrid; // TRUE to show a grid
...@@ -130,21 +136,26 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *pare ...@@ -130,21 +136,26 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *pare
CreateScreens(); CreateScreens();
// Give an icon // Give an icon
#ifdef __WINDOWS__ #ifdef __WINDOWS__
SetIcon(wxICON(a_icon_eeschema)); SetIcon( wxICON( a_icon_eeschema ) );
#else #else
SetIcon(wxICON(icon_eeschema)); SetIcon( wxICON( icon_eeschema ) );
#endif #endif
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
/* Get config */ /* Get config */
GetSettings(); GetSettings();
g_DrawMinimunLineWidth = m_Parent->m_EDA_Config->Read(MINI_DRAW_LINE_WIDTH_KEY, (long)0); g_DrawMinimunLineWidth = m_Parent->m_EDA_Config->Read(
g_PlotPSMinimunLineWidth = m_Parent->m_EDA_Config->Read(MINI_PLOTPS_LINE_WIDTH_KEY, (long) 4); MINI_DRAW_LINE_WIDTH_KEY,
(long) 0 );
g_PlotPSMinimunLineWidth = m_Parent->m_EDA_Config->Read(
MINI_PLOTPS_LINE_WIDTH_KEY,
(long) 4 );
/****/ /****/
SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE; if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE;
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
...@@ -152,9 +163,9 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *pare ...@@ -152,9 +163,9 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *pare
} }
/***************/ /***************/
/* Destructor */ /* Destructor */
/***************/ /***************/
WinEDA_SchematicFrame::~WinEDA_SchematicFrame() WinEDA_SchematicFrame::~WinEDA_SchematicFrame()
{ {
...@@ -163,50 +174,65 @@ WinEDA_SchematicFrame::~WinEDA_SchematicFrame() ...@@ -163,50 +174,65 @@ WinEDA_SchematicFrame::~WinEDA_SchematicFrame()
SAFE_DELETE( m_CurrentSheet ); //a DrawSheetList, on the heap. SAFE_DELETE( m_CurrentSheet ); //a DrawSheetList, on the heap.
m_CurrentSheet = NULL; m_CurrentSheet = NULL;
} }
/***************/
/* utility functions */
/***************/ /***************/
/* utility functions */
/***************/
DrawSheetList* WinEDA_SchematicFrame::GetSheet() DrawSheetList* WinEDA_SchematicFrame::GetSheet()
{ {
return m_CurrentSheet; return m_CurrentSheet;
} }
BASE_SCREEN* WinEDA_SchematicFrame::GetScreen() BASE_SCREEN* WinEDA_SchematicFrame::GetScreen()
{ {
return m_CurrentSheet->LastScreen(); return m_CurrentSheet->LastScreen();
} }
void WinEDA_SchematicFrame::SetScreen(SCH_SCREEN* screen)
void WinEDA_SchematicFrame::SetScreen( SCH_SCREEN* screen )
{ {
//find it in the hierarchy, and set it. //find it in the hierarchy, and set it.
//there is ambiguity in this function (there may be several //there is ambiguity in this function (there may be several
//instances of a given sheet, but irregardless it is useful //instances of a given sheet, but irregardless it is useful
//for printing etc. //for printing etc.
DrawSheetList sheetlist; DrawSheetList sheetlist;
if(g_RootSheet->LocatePathOfScreen(screen, &sheetlist)){
if( g_RootSheet->LocatePathOfScreen( screen, &sheetlist ) )
{
*m_CurrentSheet = sheetlist; *m_CurrentSheet = sheetlist;
m_CurrentSheet->UpdateAllScreenReferences(); m_CurrentSheet->UpdateAllScreenReferences();
} }
} }
wxString WinEDA_SchematicFrame::GetScreenDesc() wxString WinEDA_SchematicFrame::GetScreenDesc()
{ {
wxString s = m_CurrentSheet->PathHumanReadable(); wxString s = m_CurrentSheet->PathHumanReadable();
return s; return s;
} }
/******************************/ /******************************/
void WinEDA_SchematicFrame::CreateScreens() void WinEDA_SchematicFrame::CreateScreens()
/******************************/ /******************************/
{ {
/* creation des ecrans Sch , Lib */ /* creation des ecrans Sch , Lib */
if( g_RootSheet == NULL ){ if( g_RootSheet == NULL )
{
g_RootSheet = new DrawSheetStruct(); g_RootSheet = new DrawSheetStruct();
} }
if( g_RootSheet->m_s == NULL ){ if( g_RootSheet->m_s == NULL )
{
g_RootSheet->m_s = new SCH_SCREEN( SCHEMATIC_FRAME ); g_RootSheet->m_s = new SCH_SCREEN( SCHEMATIC_FRAME );
g_RootSheet->m_s->m_RefCount++; g_RootSheet->m_s->m_RefCount++;
} }
g_RootSheet->m_s->m_FileName = g_DefaultSchematicFileName; g_RootSheet->m_s->m_FileName = g_DefaultSchematicFileName;
g_RootSheet->m_s->m_Date = GenDate(); g_RootSheet->m_s->m_Date = GenDate();
m_CurrentSheet->Clear(); m_CurrentSheet->Clear();
m_CurrentSheet->Push(g_RootSheet); m_CurrentSheet->Push( g_RootSheet );
if( ScreenLib == NULL ) if( ScreenLib == NULL )
ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME ); ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME );
...@@ -214,30 +240,37 @@ void WinEDA_SchematicFrame::CreateScreens() ...@@ -214,30 +240,37 @@ void WinEDA_SchematicFrame::CreateScreens()
ScreenLib->m_UndoRedoCountMax = 10; ScreenLib->m_UndoRedoCountMax = 10;
} }
/**************************************************************/ /**************************************************************/
void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event) void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
/**************************************************************/ /**************************************************************/
{ {
DrawSheetList* sheet; DrawSheetList* sheet;
if ( m_Parent->m_LibeditFrame ) // Can close component editor ? if( m_Parent->m_LibeditFrame ) // Can close component editor ?
{ {
if ( ! m_Parent->m_LibeditFrame->Close() ) return; if( !m_Parent->m_LibeditFrame->Close() )
return;
} }
EDA_SheetList sheets( g_RootSheet ); EDA_SheetList sheets( g_RootSheet );
for(sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() ){ for( sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() )
if(sheet->LastScreen() && sheet->LastScreen()->IsModify()) break; {
if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
break;
} }
if ( sheet ) if( sheet )
{ {
unsigned ii; unsigned ii;
wxMessageDialog dialog(this, _("Schematic modified, Save before exit ?"), wxMessageDialog dialog( this,
_("Confirmation"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT); _( "Schematic modified, Save before exit ?" ),
_( "Confirmation" ), wxYES_NO | wxCANCEL |
wxICON_EXCLAMATION | wxYES_DEFAULT );
ii = dialog.ShowModal(); ii = dialog.ShowModal();
switch ( ii )
switch( ii )
{ {
case wxID_CANCEL: case wxID_CANCEL:
Event.Veto(); Event.Veto();
...@@ -253,24 +286,28 @@ void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event) ...@@ -253,24 +286,28 @@ void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event)
} }
} }
for(sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() ){ for( sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() )
if(sheet->LastScreen()){ {
if( sheet->LastScreen() )
{
sheet->LastScreen()->ClrModify(); sheet->LastScreen()->ClrModify();
} }
} }
if ( ! GetScreen()->m_FileName.IsEmpty() && (GetScreen()->EEDrawList != NULL) ) if( !GetScreen()->m_FileName.IsEmpty() && (GetScreen()->EEDrawList != NULL) )
SetLastProject(GetScreen()->m_FileName); SetLastProject( GetScreen()->m_FileName );
ClearProjectDrawList(g_RootSheet->m_s, TRUE); ClearProjectDrawList( g_RootSheet->m_s, TRUE );
/* allof sub sheets are deleted, only the main sheet is useable */ /* allof sub sheets are deleted, only the main sheet is useable */
m_CurrentSheet->Clear(); m_CurrentSheet->Clear();
SaveSettings(); SaveSettings();
m_Parent->m_EDA_Config->Write(MINI_DRAW_LINE_WIDTH_KEY, (long)g_DrawMinimunLineWidth); m_Parent->m_EDA_Config->Write( MINI_DRAW_LINE_WIDTH_KEY,
m_Parent->m_EDA_Config->Write(MINI_PLOTPS_LINE_WIDTH_KEY, (long) g_PlotPSMinimunLineWidth); (long) g_DrawMinimunLineWidth );
m_Parent->m_EDA_Config->Write( MINI_PLOTPS_LINE_WIDTH_KEY,
(long) g_PlotPSMinimunLineWidth );
Destroy(); Destroy();
} }
...@@ -279,79 +316,85 @@ void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event) ...@@ -279,79 +316,85 @@ void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event)
/********************************************/ /********************************************/
void WinEDA_SchematicFrame::SetToolbars() void WinEDA_SchematicFrame::SetToolbars()
/********************************************/ /********************************************/
/* Enable or disable some tools according to current conditions /* Enable or disable some tools according to current conditions
*/ */
{ {
if( m_HToolBar ) if( m_HToolBar )
{ {
if ( GetScreen() && GetScreen()->BlockLocate.m_Command == BLOCK_MOVE ) if( GetScreen() && GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
{ {
m_HToolBar->EnableTool(wxID_CUT,TRUE); m_HToolBar->EnableTool( wxID_CUT, TRUE );
m_HToolBar->EnableTool(wxID_COPY,TRUE); m_HToolBar->EnableTool( wxID_COPY, TRUE );
} }
else else
{ {
m_HToolBar->EnableTool(wxID_CUT,FALSE); m_HToolBar->EnableTool( wxID_CUT, FALSE );
m_HToolBar->EnableTool(wxID_COPY,FALSE); m_HToolBar->EnableTool( wxID_COPY, FALSE );
} }
if ( g_BlockSaveDataList ) m_HToolBar->EnableTool(wxID_PASTE,TRUE); if( g_BlockSaveDataList )
else m_HToolBar->EnableTool(wxID_PASTE,FALSE); m_HToolBar->EnableTool( wxID_PASTE, TRUE );
else
m_HToolBar->EnableTool( wxID_PASTE, FALSE );
wxMenuBar * menuBar = GetMenuBar(); wxMenuBar* menuBar = GetMenuBar();
if ( GetScreen() && GetScreen()->m_RedoList ) if( GetScreen() && GetScreen()->m_RedoList )
{ {
m_HToolBar->EnableTool(ID_SCHEMATIC_REDO,TRUE); m_HToolBar->EnableTool( ID_SCHEMATIC_REDO, TRUE );
menuBar->Enable(ID_SCHEMATIC_REDO,TRUE); menuBar->Enable( ID_SCHEMATIC_REDO, TRUE );
} }
else else
{ {
m_HToolBar->EnableTool(ID_SCHEMATIC_REDO,FALSE); m_HToolBar->EnableTool( ID_SCHEMATIC_REDO, FALSE );
menuBar->Enable(ID_SCHEMATIC_REDO,FALSE); menuBar->Enable( ID_SCHEMATIC_REDO, FALSE );
} }
if ( GetScreen() && GetScreen()->m_UndoList ) if( GetScreen() && GetScreen()->m_UndoList )
{ {
m_HToolBar->EnableTool(ID_SCHEMATIC_UNDO,TRUE); m_HToolBar->EnableTool( ID_SCHEMATIC_UNDO, TRUE );
menuBar->Enable(ID_SCHEMATIC_UNDO,TRUE); menuBar->Enable( ID_SCHEMATIC_UNDO, TRUE );
} }
else else
{ {
m_HToolBar->EnableTool(ID_SCHEMATIC_UNDO,FALSE); m_HToolBar->EnableTool( ID_SCHEMATIC_UNDO, FALSE );
menuBar->Enable(ID_SCHEMATIC_UNDO,FALSE); menuBar->Enable( ID_SCHEMATIC_UNDO, FALSE );
} }
} }
if ( m_OptionsToolBar ) if( m_OptionsToolBar )
{ {
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_GRID,m_Draw_Grid); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, m_Draw_Grid );
m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_SHOW_GRID, m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
m_Draw_Grid ? _("Grid not show") : _("Show Grid")); m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) );
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric == MILLIMETRE ? TRUE : FALSE); g_UnitMetric == MILLIMETRE ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : FALSE); g_UnitMetric == INCHES ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR,g_CursorShape); m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_HIDDEN_PINS,g_ShowAllPins); g_CursorShape );
m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_HIDDEN_PINS, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_HIDDEN_PINS, g_ShowAllPins );
g_ShowAllPins ? _("No show Hidden Pins") : _("Show Hidden Pins") ); m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS,
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_BUS_WIRES_ORIENT, g_HVLines); g_ShowAllPins ? _( "No show Hidden Pins" ) : _( "Show Hidden Pins" ) );
m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_BUS_WIRES_ORIENT, m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
g_HVLines ? _("Draw lines at any direction") : g_HVLines );
_("Draw lines H, V or 45 deg only") ); m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
g_HVLines ? _( "Draw lines at any direction" ) :
_( "Draw lines H, V or 45 deg only" ) );
} }
DisplayUnitsMsg(); DisplayUnitsMsg();
} }
/******************************************/ /******************************************/
int WinEDA_SchematicFrame::BestZoom() int WinEDA_SchematicFrame::BestZoom()
/******************************************/ /******************************************/
{ {
int dx, dy, ii,jj ; int dx, dy, ii, jj;
int bestzoom; int bestzoom;
wxSize size; wxSize size;
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x; dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y; dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
...@@ -359,12 +402,18 @@ wxSize size; ...@@ -359,12 +402,18 @@ wxSize size;
size = DrawPanel->GetClientSize(); size = DrawPanel->GetClientSize();
ii = dx / size.x; ii = dx / size.x;
jj = dy / size.y; jj = dy / size.y;
bestzoom = MAX(ii, jj) + 1; bestzoom = MAX( ii, jj ) + 1;
GetScreen()->SetZoom(ii); GetScreen()->SetZoom( ii );
GetScreen()->m_Curseur.x = dx / 2; GetScreen()->m_Curseur.x = dx / 2;
GetScreen()->m_Curseur.y = dy / 2; GetScreen()->m_Curseur.y = dy / 2;
return(bestzoom); return bestzoom;
} }
void WinEDA_SchematicFrame::OnAnnotate( wxCommandEvent& event )
{
WinEDA_AnnotateFrame* dlg = new WinEDA_AnnotateFrame( this );
dlg->ShowModal();
dlg->Destroy();
}
...@@ -438,6 +438,7 @@ public: ...@@ -438,6 +438,7 @@ public:
private: private:
void Process_Move_Item( EDA_BaseStruct* DrawStruct, wxDC* DC ); void Process_Move_Item( EDA_BaseStruct* DrawStruct, wxDC* DC );
void OnAnnotate ( wxCommandEvent& event );
// Bus Entry // Bus Entry
DrawBusEntryStruct* CreateBusEntry( wxDC* DC, int entry_type ); DrawBusEntryStruct* CreateBusEntry( wxDC* DC, int entry_type );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment