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
Please add newer entries at the top, list the date and your name with
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>
================================================================================
......
......@@ -7,7 +7,7 @@ INCLUDE_DIRECTORIES(
SET(EESCHEMA_SRCS
affiche.cpp
annotate.cpp
# annotate_dialog.cpp
annotate_dialog.cpp
block.cpp
block_libedit.cpp
busentry.cpp
......
......@@ -2,107 +2,181 @@
/* annotate.cpp: component annotation */
/**************************************/
/* Local Variable */
static bool AnnotProject = true;
static bool SortByPosition = true;
#include "annotate_dialog.cpp"
#include "fctsys.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "netlist.h"
#include "protos.h"
/* Local Functions*/
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 ReAnnotateComponents( 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 );
static int ExistUnit( CmpListStruct* Objet, int Unit,
CmpListStruct* BaseListeCmp, int NbOfCmp );
/**************************************/
void ReAnnotatePowerSymbolsOnly( void )
/**************************************/
/* Used to reannotate the power symbols, before testing erc or computing netlist
* when a true component reannotation is not necessary
/*****************************************************************************
* Used to annotate the power symbols, before testing erc or computing
* netlist when a component reannotation is not necessary
*
* In order to avoid conflicts the ref number starts with a 0:
* PWR with id 12 is named PWR12 in global annotation and PWR012 by the Power annotation
*/
* 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.
****************************************************************************/
void ReAnnotatePowerSymbolsOnly( void )
{
/* Build the screen list (screen, not sheet) */
EDA_SheetList SheetList( NULL );
/* Update the screen number, sheet count and date */
//ScreenList.UpdateScreenNumberAndDate();
DrawSheetList* sheet;
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();
for( ; DrawList != NULL; DrawList = DrawList->Pnext )
{
if( DrawList->Type() != DRAW_LIB_ITEM_STRUCT_TYPE )
continue;
EDA_SchComponentStruct* DrawLibItem = (EDA_SchComponentStruct*) DrawList;
EDA_SchComponentStruct* DrawLibItem =
(EDA_SchComponentStruct*) DrawList;
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) )
continue;
//DrawLibItem->ClearAnnotation(sheet); this clears all annotation :(
wxString refstr = DrawLibItem->m_PrefixString;
//str will be "C?" or so after the ClearAnnotation call.
while(refstr.Last() == '?')
while( refstr.Last() == '?' )
refstr.RemoveLast();
if(!refstr.StartsWith(wxT("#")))
refstr = wxT("#") + refstr;
if( !refstr.StartsWith( wxT( "#" ) ) )
refstr = wxT( "#" ) + refstr;
refstr << wxT( "0" ) << CmpNumber;
DrawLibItem->SetRef(sheet, refstr);
DrawLibItem->SetRef( sheet, refstr );
CmpNumber++;
}
}
}
/***********************************************************************/
CmpListStruct* AllocateCmpListStrct(int numcomponents )
/***********************************************************************/
CmpListStruct* AllocateCmpListStrct( int numcomponents )
{
int ii = numcomponents * sizeof(CmpListStruct);
CmpListStruct* list = (CmpListStruct*) MyZMalloc( ii );
//fill this memory with zeros.
char* cptr = (char*)list;
for(int i=0; i<ii; i++)
char* cptr = (char*) list;
for( int i = 0; i<ii; i++ )
*cptr++ = 0;
return list;
}
/***********************************************************************/
void InstallAnnotateFrame( WinEDA_SchematicFrame* parent, wxPoint& pos )
/***********************************************************************/
/** Function InstallAnnotateFrame
* Install the annotate dialog frame
*/
/* qsort function to annotate items by their position. */
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();
frame->Destroy();
return ii;
}
/******************************************************************/
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.
* All the components or the new ones only will be annotated.
*/
/*****************************************************************************
* AnnotateComponents:
*
* 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;
DrawSheetList* sheet;
......@@ -110,15 +184,10 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
wxBusyCursor dummy;
AnnotProject = (m_AnnotProjetCtrl->GetSelection() == 0) ? true : FALSE;
SortByPosition = (m_AnnotSortCmpCtrl->GetSelection() == 0) ? true : FALSE;
/* If it is an annotation for all the components, reset previous annotation: */
if( m_AnnotNewCmpCtrl->GetSelection() == 0 )
DeleteAnnotation( event );
if( m_Abort )
return;
/* If it is an annotation for all the components, reset previous
annotation: */
if( resetAnnotation )
DeleteAnnotation( parent, annotateSchematic );
/* Build the sheet list */
EDA_SheetList SheetList( g_RootSheet );
......@@ -127,10 +196,13 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
ii = 0;
/* First pass: Component counting */
sheet = m_Parent->GetSheet();
if( AnnotProject == true ){
sheet = parent->GetSheet();
if( annotateSchematic )
{
NbOfCmp = 0;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
NbOfCmp += ListeComposants( NULL, sheet );
}
else
......@@ -139,95 +211,52 @@ void WinEDA_AnnotateFrame::AnnotateComponents( wxCommandEvent& event )
if( NbOfCmp == 0 )
return;
BaseListeCmp = AllocateCmpListStrct(NbOfCmp);
BaseListeCmp = AllocateCmpListStrct( NbOfCmp );
/* Second pass : Int data tables */
if( AnnotProject == true )
if( annotateSchematic )
{
ii = 0;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
ii += ListeComposants( BaseListeCmp + ii, sheet);
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
ii += ListeComposants( BaseListeCmp + ii, sheet );
}
else
ii = ListeComposants( BaseListeCmp, sheet);
ii = ListeComposants( BaseListeCmp, sheet );
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 );
if ( sortByPosition )
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 */
ComputeReferenceNumber( BaseListeCmp, NbOfCmp );
ReAnnotateComponents( BaseListeCmp, NbOfCmp );
MyFree( BaseListeCmp ); BaseListeCmp = NULL;
MyFree( BaseListeCmp );
BaseListeCmp = NULL;
/* Final control */
CheckAnnotate( m_Parent, AnnotProject ? FALSE : true );
m_Parent->DrawPanel->Refresh( true ); /* Refresh screen */
EndModal( 1 );
CheckAnnotate( parent, !annotateSchematic );
parent->DrawPanel->Refresh( true );
}
/********************************************************************/
void WinEDA_AnnotateFrame::DeleteAnnotation( wxCommandEvent& event )
/********************************************************************/
/* 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
/*****************************************************************************
* if BaseListeCmp == NULL : count components
* else update data table BaseListeCmp
*/
*****************************************************************************/
int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet )
{
int NbrCmp = 0;
EDA_BaseStruct* DrawList = sheet->LastDrawList();
......@@ -236,26 +265,19 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet)
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;
Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(), wxEmptyString, FIND_ROOT );
Entry = FindLibPart( DrawLibItem->m_ChipName.GetData(),
wxEmptyString,
FIND_ROOT );
if( Entry == NULL )
break;
continue;
if( BaseListeCmp == NULL ) /* Items counting only */
{
NbrCmp++;
break;
continue;
}
BaseListeCmp[NbrCmp].m_Cmp = DrawLibItem;
......@@ -267,11 +289,11 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet)
BaseListeCmp[NbrCmp].m_Pos = DrawLibItem->m_Pos;
BaseListeCmp[NbrCmp].m_TimeStamp = DrawLibItem->m_TimeStamp;
if( DrawLibItem->GetRef(sheet).IsEmpty() )
if( DrawLibItem->GetRef( sheet ).IsEmpty() )
DrawLibItem->SetRef( sheet, wxT( "DefRef?" ) );
strncpy( BaseListeCmp[NbrCmp].m_TextRef,
CONV_TO_UTF8(DrawLibItem->GetRef(sheet)), 32 );
CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ), 32 );
BaseListeCmp[NbrCmp].m_NumRef = -1;
......@@ -281,19 +303,6 @@ int ListeComposants( CmpListStruct* BaseListeCmp, DrawSheetList* sheet)
strncpy( BaseListeCmp[NbrCmp].m_TextValue,
CONV_TO_UTF8( DrawLibItem->m_Field[VALUE].m_Text ), 32 );
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)
}
/*****************************************************************/
int AnnotTriComposant( const void* o1, const void* o2 )
/****************************************************************/
/* 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;
}
/********************************************************************/
/*****************************************************************************
* Update the reference component for the schematic project (or the current
* sheet)
*****************************************************************************/
static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp )
/********************************************************************/
/* Update the reference component for the schematic project (or the current sheet)
*/
{
int ii;
char* Text;
......@@ -371,22 +331,23 @@ static void ReAnnotateComponents( CmpListStruct* BaseListeCmp, int NbOfCmp )
else
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;
}
}
/**************************************************************/
void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
/**************************************************************/
/** BreakReference
* 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)
/*****************************************************************************
* 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
* to a max value (0x7FFFFFFF).
*
* @param BaseListeCmp = list of component
* @param NbOfCmp = item count in the list
*/
*****************************************************************************/
void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
{
int ii, ll;
char* Text;
......@@ -425,26 +386,26 @@ void BreakReference( CmpListStruct* BaseListeCmp, int NbOfCmp )
break;
}
}
/*printf("BreakReference(): %s number found: %d\n",
wxLogDebug( wxT("BreakReference(): %s number found: %d\n" ),
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
*/
*****************************************************************************/
static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
{
int ii, jj, LastReferenceNumber, NumberOfUnits, Unit;
const char* Text, * RefText, * ValText;
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++ )
{
Text = BaseListeCmp[ii].m_TextRef;
......@@ -466,7 +427,9 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
if( strnicmp( RefText, Text, 32 ) != 0 ) /* Nouveau Identificateur */
{
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)*/
......@@ -483,13 +446,16 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
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;
NumberOfUnits = BaseListeCmp[ii].m_NbParts;
if( BaseListeCmp[ii].m_IsNew )
{
LastReferenceNumber++; BaseListeCmp[ii].m_NumRef = LastReferenceNumber;
LastReferenceNumber++;
BaseListeCmp[ii].m_NumRef = LastReferenceNumber;
if( !BaseListeCmp[ii].m_PartsLocked )
BaseListeCmp[ii].m_Unit = 1;
BaseListeCmp[ii].m_Flag = 1;
......@@ -519,8 +485,10 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
{
continue;
}
/* Component without reference number found, annotate it if possible */
if( !BaseListeCmp[jj].m_PartsLocked || (BaseListeCmp[jj].m_Unit == Unit) )
/* Component without reference number found, annotate it if
possible */
if( !BaseListeCmp[jj].m_PartsLocked ||
(BaseListeCmp[jj].m_Unit == Unit) )
{
BaseListeCmp[jj].m_NumRef = BaseListeCmp[ii].m_NumRef;
BaseListeCmp[jj].m_Unit = Unit;
......@@ -534,18 +502,18 @@ static void ComputeReferenceNumber( CmpListStruct* BaseListeCmp, int NbOfCmp )
}
/*************************************************************************************************/
static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseListeCmp, int NbOfCmp )
/*************************************************************************************************/
/** Function GetLastReferenceNumber
* Search the last (bigger) reference number in the component list
/*****************************************************************************
* Search the last used (greatest) reference number in the component list
* 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 BaseListeCmp = list of items
* @param NbOfCmp = items count in list of items
*/
*****************************************************************************/
int GetLastReferenceNumber( CmpListStruct* Objet,
CmpListStruct* BaseListeCmp,
int NbOfCmp )
{
CmpListStruct* LastObjet = BaseListeCmp + NbOfCmp;
int LastNumber = 0;
......@@ -554,7 +522,8 @@ static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseList
RefText = Objet->m_TextRef;
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;
if( LastNumber < Objet->m_NumRef )
LastNumber = Objet->m_NumRef;
......@@ -564,17 +533,16 @@ static int GetLastReferenceNumber( CmpListStruct* Objet, CmpListStruct* BaseList
}
/*****************************************************************/
static int ExistUnit( CmpListStruct* Objet, int Unit,
CmpListStruct* BaseListeCmp, int NbOfCmp )
/****************************************************************/
/* Recherche dans la liste triee des composants, pour les composants
/*****************************************************************************
* TODO: Translate this to english/
* Recherche dans la liste triee des composants, pour les composants
* multiples s'il existe pour le composant de reference Objet,
* une unite de numero Unit
* Retourne index dans BaseListeCmp si oui
* retourne -1 si non
*/
*****************************************************************************/
static int ExistUnit( CmpListStruct* Objet, int Unit,
CmpListStruct* BaseListeCmp, int NbOfCmp )
{
CmpListStruct* EndList = BaseListeCmp + NbOfCmp;
char* RefText, * ValText;
......@@ -584,7 +552,9 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
RefText = Objet->m_TextRef;
ValText = Objet->m_TextValue;
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 )
continue;
......@@ -592,7 +562,8 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
continue; /* non affecte */
if( ItemToTest->m_NumRef != NumRef )
continue;
if( strnicmp( RefText, ItemToTest->m_TextRef, 32 ) != 0 ) /* Nouveau Identificateur */
/* Nouveau Identificateur */
if( strnicmp( RefText, ItemToTest->m_TextRef, 32 ) != 0 )
continue;
if( ItemToTest->m_Unit == Unit )
{
......@@ -604,15 +575,16 @@ static int ExistUnit( CmpListStruct* Objet, int Unit,
}
/******************************************************************/
int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
/******************************************************************/
/** Function CheckAnnotate
* @return composent count ( which are not annotated or have the same reference (duplicates))
* @param OneSheetOnly : true = search is made only in the current sheet
/*****************************************************************************
*
* Function CheckAnnotate
* @return component count ( which are not annotated or have the same
* reference (duplicates))
* @param oneSheetOnly : true = search is made only in the current sheet
* false = search in whole hierarchy (usual search).
*/
*
*****************************************************************************/
int CheckAnnotate( WinEDA_SchematicFrame* frame, bool oneSheetOnly )
{
int ii, error, NbOfCmp;
DrawSheetList* sheet;
......@@ -627,9 +599,12 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
ii = 0;
/* first pass : count composents */
if( !OneSheetOnly ){
if( !oneSheetOnly )
{
NbOfCmp = 0;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
NbOfCmp += ListeComposants( NULL, sheet );
}
else
......@@ -643,22 +618,26 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
/* Second pass : create the list of components */
ListeCmp = AllocateCmpListStrct(NbOfCmp);
ListeCmp = AllocateCmpListStrct( NbOfCmp );
printf("CheckAnnotate() listing all components:\n");
if( !OneSheetOnly ){
printf( "CheckAnnotate() listing all components:\n" );
if( !oneSheetOnly )
{
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 );
}
else
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 );
/* count not yet annotated items */
......@@ -676,7 +655,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
Buff = wxT( "?" );
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) )
{
......@@ -688,7 +668,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
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 )
Buff << ListeCmp[ii].m_NumRef;
......@@ -696,7 +677,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
Buff = wxT( "?" );
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" ),
ListeCmp[ii].m_Unit, ListeCmp[ii].m_NbParts );
......@@ -716,8 +698,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
msg.Empty();
Buff.Empty();
if( (stricmp( ListeCmp[ii].m_TextRef, ListeCmp[ii + 1].m_TextRef ) != 0)
|| ( ListeCmp[ii].m_NumRef != ListeCmp[ii + 1].m_NumRef ) )
if( (stricmp( ListeCmp[ii].m_TextRef,
ListeCmp[ii + 1].m_TextRef ) != 0)||
( ListeCmp[ii].m_NumRef != ListeCmp[ii + 1].m_NumRef ) )
continue;
/* Same reference found */
......@@ -744,8 +727,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
continue;
}
/* Test error if units are different but number of parts per package too hight
* (ex U3 ( 1 part) and we find U3B the is an error) */
/* Test error if units are different but number of parts per package
* 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_NumRef >= 0 )
......@@ -754,7 +737,8 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
Buff = wxT( "?" );
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) )
{
......@@ -766,8 +750,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
error++;
}
/* Error if values are diff�rent between units, for the same reference */
if( stricmp( ListeCmp[ii].m_TextValue, ListeCmp[ii + 1].m_TextValue ) != 0 )
/* Error if values are different between units, for the same reference */
if( stricmp( ListeCmp[ii].m_TextValue,
ListeCmp[ii + 1].m_TextValue ) != 0 )
{
wxString nextcmpref, cmpvalue, nextcmpvalue;
cmpref = CONV_FROM_UTF8( ListeCmp[ii].m_TextRef );
......@@ -775,7 +760,9 @@ int CheckAnnotate( WinEDA_SchematicFrame* frame, bool OneSheetOnly )
cmpvalue = CONV_FROM_UTF8( ListeCmp[ii].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)" ),
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(),
ListeCmp[ii + 1].m_NumRef,
ListeCmp[ii + 1].m_Unit + 'A' - 1,
......
/////////////////////////////////////////////////////////////////////////////
// Name: annotate_dialog.cpp
// Purpose:
// Author: jean-pierre Charras
// Modified by:
// Modified by: Wayne Stambaugh
//
// Created: 05/02/2006 12:31:28
// Modified 02/21/2008 13:47:10
// RCS-ID:
// Copyright: License GNU
// 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"
#endif
......@@ -26,13 +28,15 @@
#include "wx/wx.h"
#endif
////@begin includes
////@end includes
#include "annotate_dialog.h"
////@begin XPM images
////@end XPM images
extern void DeleteAnnotation( WinEDA_SchematicFrame* parent,
bool annotateSchematic );
extern void AnnotateComponents( WinEDA_SchematicFrame* parent,
bool annotateSchematic,
bool sortByPosition,
bool resetAnnotation );
/*!
* WinEDA_AnnotateFrame type definition
......@@ -45,120 +49,170 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_AnnotateFrame, wxDialog )
*/
BEGIN_EVENT_TABLE( WinEDA_AnnotateFrame, wxDialog )
////@begin WinEDA_AnnotateFrame event table entries
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
EVT_BUTTON( wxID_CLEAR, WinEDA_AnnotateFrame::OnClear )
EVT_BUTTON( wxID_APPLY, WinEDA_AnnotateFrame::OnApply )
END_EVENT_TABLE()
/*!
* 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_Abort = FALSE;
Create(parent, id, caption, pos, size, style);
m_AnnotNewCmpCtrl->SetSelection(1);
Create( parent, id, caption, pos, size, style );
}
/*!
* 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
m_AnnotProjetCtrl = NULL;
m_AnnotNewCmpCtrl = NULL;
m_AnnotSortCmpCtrl = NULL;
////@end WinEDA_AnnotateFrame member initialisation
////@begin WinEDA_AnnotateFrame creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if( GetSizer() )
{
GetSizer()->SetSizeHints(this);
GetSizer()->SetSizeHints( this );
}
Centre();
////@end WinEDA_AnnotateFrame creation
return true;
}
/*!
* Control creation for WinEDA_AnnotateFrame
*/
void WinEDA_AnnotateFrame::CreateControls()
{
SetFont(*g_DialogFont);
////@begin WinEDA_AnnotateFrame content construction
// Generated by DialogBlocks, 07/11/2007 08:19:55 (unregistered)
WinEDA_AnnotateFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
wxArrayString m_AnnotProjetCtrlStrings;
m_AnnotProjetCtrlStrings.Add(_("Hierarchy"));
m_AnnotProjetCtrlStrings.Add(_("Current sheet"));
m_AnnotProjetCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX, _("annotate:"), wxDefaultPosition, wxDefaultSize, m_AnnotProjetCtrlStrings, 1, wxRA_SPECIFY_COLS );
m_AnnotProjetCtrl->SetSelection(0);
itemBoxSizer3->Add(m_AnnotProjetCtrl, 0, wxGROW|wxALL, 5);
wxArrayString m_AnnotNewCmpCtrlStrings;
m_AnnotNewCmpCtrlStrings.Add(_("all components"));
m_AnnotNewCmpCtrlStrings.Add(_("new components only"));
m_AnnotNewCmpCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _("select items:"), wxDefaultPosition, wxDefaultSize, m_AnnotNewCmpCtrlStrings, 1, wxRA_SPECIFY_COLS );
m_AnnotNewCmpCtrl->SetSelection(0);
itemBoxSizer3->Add(m_AnnotNewCmpCtrl, 0, wxGROW|wxALL, 5);
wxArrayString m_AnnotSortCmpCtrlStrings;
m_AnnotSortCmpCtrlStrings.Add(_("by position"));
m_AnnotSortCmpCtrlStrings.Add(_("by value"));
m_AnnotSortCmpCtrl = new wxRadioBox( itemDialog1, ID_RADIOBOX2, _("sorting:"), wxDefaultPosition, wxDefaultSize, m_AnnotSortCmpCtrlStrings, 1, wxRA_SPECIFY_COLS );
m_AnnotSortCmpCtrl->SetSelection(0);
itemBoxSizer3->Add(m_AnnotSortCmpCtrl, 0, wxGROW|wxALL, 5);
wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton8 = new wxButton( itemDialog1, ID_ANNOTATE_CMP, _("&Annotate"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton8->SetDefault();
itemButton8->SetForegroundColour(wxColour(198, 0, 0));
itemBoxSizer7->Add(itemButton8, 0, wxGROW|wxALL, 5);
wxButton* itemButton9 = new wxButton( itemDialog1, ID_DEANNOTATE_CMP, _("&Del Annotate"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton9->SetForegroundColour(wxColour(0, 0, 230));
itemBoxSizer7->Add(itemButton9, 0, wxGROW|wxALL, 5);
wxButton* itemButton10 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton10, 0, wxGROW|wxALL, 5);
////@end WinEDA_AnnotateFrame content construction
m_AnnotSortCmpCtrl->SetSelection(SortByPosition ? 0 : 1);
wxFont fontBold = this->GetFont();
fontBold.SetWeight(wxFONTWEIGHT_BOLD);
wxBoxSizer* sizerTop = new wxBoxSizer( wxVERTICAL );
/* 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
* the common directory so all of the dialogs share the same layout
* spacing */
/* Spacing for grouping labels in a dialog box. */
wxSizerFlags flagsLabelSpacing( 0 );
flagsLabelSpacing.Align( wxALIGN_TOP | wxALIGN_LEFT );
flagsLabelSpacing.Border( wxLEFT | wxTOP, 6 );
/* Spacing for grouping radio buttons inside the grouping sizer. */
wxSizerFlags flagsRadioButtonSpacing( 0 );
flagsRadioButtonSpacing.Align( wxALIGN_LEFT );
flagsRadioButtonSpacing.Border( wxTOP | wxLEFT | wxRIGHT, 6 );
/* Spacing for the radio button sizer inside the group sizer. */
wxSizerFlags flagsRadioButtonSizerSpacing( 0 );
flagsRadioButtonSizerSpacing.Align( wxALIGN_TOP | wxALIGN_LEFT );
flagsRadioButtonSizerSpacing.Border( wxLEFT, 20 );
/* Spacing for the vertical group sizers. */
wxSizerFlags flagsGroupSizerSpacing( 1 );
flagsGroupSizerSpacing.Align( wxALIGN_TOP | wxALIGN_LEFT );
flagsGroupSizerSpacing.Border( wxTOP | wxLEFT | wxRIGHT, 12 );
/* Spacing for dialog button sizer. */
wxSizerFlags flagsDialogButtonSizerSpacing( 0 );
flagsDialogButtonSizerSpacing.Border( wxALL, 12 );
/* Spacing for the dialog buttons. */
wxSizerFlags flagsDialogButtonSpacing( 0 );
flagsDialogButtonSpacing.Border( wxLEFT | wxRIGHT, 3 );
/* Annotate scope sizers, label, and radio buttons. */
wxBoxSizer* sizerAnnotate = new wxBoxSizer( wxVERTICAL );
wxStaticText* labelAnnotate = new wxStaticText( this, -1,
_( "Scope" ) );
labelAnnotate->SetFont( fontBold );
sizerAnnotate->Add( labelAnnotate, flagsLabelSpacing );
wxBoxSizer* sizerAnnotateItems = new wxBoxSizer( wxVERTICAL );
m_rbEntireSchematic =
new wxRadioButton( this, ID_ENTIRE_SCHEMATIC,
_( "Annotate the entire schematic" ),
wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
wxRadioButton* rbCurrentPage =
new wxRadioButton( this, ID_CURRENT_PAGE,
_( "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?
*/
......@@ -168,6 +222,7 @@ bool WinEDA_AnnotateFrame::ShowToolTips()
return true;
}
/*!
* Get bitmap resources
*/
......@@ -175,12 +230,11 @@ bool WinEDA_AnnotateFrame::ShowToolTips()
wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
////@begin WinEDA_AnnotateFrame bitmap retrieval
wxUnusedVar(name);
wxUnusedVar( name );
return wxNullBitmap;
////@end WinEDA_AnnotateFrame bitmap retrieval
}
/*!
* Get icon resources
*/
......@@ -188,34 +242,79 @@ wxBitmap WinEDA_AnnotateFrame::GetBitmapResource( const wxString& name )
wxIcon WinEDA_AnnotateFrame::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin WinEDA_AnnotateFrame icon retrieval
wxUnusedVar(name);
wxUnusedVar( name );
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);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DEANNOTATE_CMP
*/
void WinEDA_AnnotateFrame::OnApply( wxCommandEvent& event )
{
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();
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
bool WinEDA_AnnotateFrame::GetResetItems( void )
{
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
// Purpose:
// Author: jean-pierre Charras
......@@ -9,12 +10,11 @@
// Licence:
/////////////////////////////////////////////////////////////////////////////
// Generated by DialogBlocks (unregistered), 05/02/2006 12:31:28
#ifndef _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"
#endif
......@@ -22,39 +22,28 @@
* Includes
*/
////@begin includes
////@end includes
#include "fctsys.h"
#include "common.h"
#include "program.h"
#include "libcmp.h"
#include "general.h"
/*!
* Forward declarations
*/
////@begin forward declarations
////@end forward declarations
/*!
* Control identifiers
*/
////@begin control identifiers
#define ID_DIALOG 10000
#define ID_RADIOBOX 10001
#define ID_RADIOBOX1 10002
#define ID_RADIOBOX2 10005
#define ID_ANNOTATE_CMP 10003
#define ID_DEANNOTATE_CMP 10004
#define SYMBOL_WINEDA_ANNOTATEFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_ANNOTATEFRAME_TITLE _("EESchema Annotation")
#define SYMBOL_WINEDA_ANNOTATEFRAME_IDNAME ID_DIALOG
#define SYMBOL_WINEDA_ANNOTATEFRAME_SIZE wxSize(400, 300)
#define SYMBOL_WINEDA_ANNOTATEFRAME_POSITION wxDefaultPosition
////@end control identifiers
#define ID_ENTIRE_SCHEMATIC 10001
#define ID_CURRENT_PAGE 10002
#define ID_RESET_ANNOTATION 10003
#define ID_SORT_BY_POSITION 10004
#define ID_SORT_BY_VALUE 10005
#define ANNOTATE_DIALOG_STYLE wxDEFAULT_DIALOG_STYLE | MAYBE_RESIZE_BORDER
#define ANNOTATE_DIALOG_TITLE _( "Annotate" )
/*!
* Compatibility
......@@ -68,60 +57,59 @@
* WinEDA_AnnotateFrame class declaration
*/
class WinEDA_AnnotateFrame: public wxDialog
class WinEDA_AnnotateFrame : public wxDialog
{
DECLARE_DYNAMIC_CLASS( WinEDA_AnnotateFrame )
DECLARE_EVENT_TABLE()
public:
/// Constructors
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_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
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
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
wxBitmap GetBitmapResource( const wxString& name );
/// Retrieves icon resources
wxIcon GetIconResource( const wxString& name );
////@end WinEDA_AnnotateFrame member function declarations
bool GetLevel( void );
bool GetResetItems( void );
bool GetSortOrder( void );
/// Should we show tooltips?
static bool ShowToolTips();
////@begin WinEDA_AnnotateFrame member variables
wxRadioBox* m_AnnotProjetCtrl;
wxRadioBox* m_AnnotNewCmpCtrl;
wxRadioBox* m_AnnotSortCmpCtrl;
////@end WinEDA_AnnotateFrame member variables
WinEDA_SchematicFrame * m_Parent;
bool m_Abort;
WinEDA_SchematicFrame* m_Parent;
private:
void AnnotateComponents(wxCommandEvent& event);
void DeleteAnnotation(wxCommandEvent& event);
void OnClear( wxCommandEvent& event );
void OnApply( wxCommandEvent& event );
wxRadioButton* m_rbEntireSchematic;
wxRadioButton* m_rbSortByPosition;
wxCheckBox* m_cbResetAnnotation;
wxButton* m_btnClear;
DECLARE_EVENT_TABLE()
};
#endif
// _ANNOTATE_DIALOG_H_
// _ANNOTATE_DIALOG_H_
......@@ -2,6 +2,9 @@
/* GENERAL.H : declarations communes */
/***************************************/
#ifndef _GENERAL_H_
#define _GENERAL_H_
#ifndef eda_global
#define eda_global extern
#endif
......@@ -267,3 +270,5 @@ eda_global int g_PlotPSMinimunLineWidth; /* Minimum line (in EESCHEMA units) wid
/* Config keys */
#define MINI_DRAW_LINE_WIDTH_KEY wxT("MinimunDrawLineWidth")
#define MINI_PLOTPS_LINE_WIDTH_KEY wxT("MinimunPlotPSLineWidth")
#endif // _GENERAL_H_
......@@ -300,7 +300,7 @@ void InstallNetlistFrame(WinEDA_SchematicFrame *parent, wxPoint &pos);
/***************/
void ReAnnotatePowerSymbolsOnly();
void InstallAnnotateFrame(WinEDA_SchematicFrame * parent, wxPoint &pos);
void InstallAnnotateFrame(WinEDA_SchematicFrame * parent);
int CheckAnnotate(WinEDA_SchematicFrame * frame, bool OneSheetOnly);
/* Retourne le nombre de composants non annotes ou erron�s
Si OneSheetOnly : recherche sur le schema courant
......
......@@ -15,9 +15,9 @@
#include "protos.h"
/********************************************************************************/
/*****************************************************************************/
void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
/********************************************************************************/
/*****************************************************************************/
/* Traite les selections d'outils et les commandes appelees du menu POPUP
*/
......@@ -116,7 +116,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_CANCEL_CURRENT_COMMAND:
if( GetScreen()->BlockLocate.m_Command != BLOCK_IDLE )
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor = DrawPanel->
DrawPanel->SetCursor( wxCursor( DrawPanel->m_PanelCursor =
DrawPanel->
m_PanelDefaultCursor ) );
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
......@@ -145,7 +146,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
{
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 );
break;
}
......@@ -167,6 +169,7 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_LOAD_ONE_SHEET:
//how is this different from above?
//LoadOneSheet( GetSheet(), wxEmptyString );
break;
......@@ -181,7 +184,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_LOAD_FILE_8:
case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10:
LoadOneEEProject( GetLastProject( id - ID_LOAD_FILE_1 ).GetData(), FALSE );
LoadOneEEProject( GetLastProject( id - ID_LOAD_FILE_1 ).GetData(
), FALSE );
break;
case ID_TO_LIBRARY:
......@@ -191,11 +195,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
}
else
{
m_Parent->m_LibeditFrame = new
WinEDA_LibeditFrame( m_Parent->m_SchematicFrame,
m_Parent->m_LibeditFrame =
new WinEDA_LibeditFrame( m_Parent->m_SchematicFrame,
m_Parent,
wxT( "Library Editor" ),
wxPoint( -1, -1 ), wxSize( 600, 400 ) );
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
ActiveScreen = ScreenLib;
m_Parent->m_LibeditFrame->AdjustScrollBars();
}
......@@ -238,8 +243,9 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
}
else
{
m_Parent->m_ViewlibFrame = new
WinEDA_ViewlibFrame( m_Parent->m_SchematicFrame, m_Parent );
m_Parent->m_ViewlibFrame =
new WinEDA_ViewlibFrame( m_Parent->m_SchematicFrame,
m_Parent );
m_Parent->m_ViewlibFrame->AdjustScrollBars();
}
break;
......@@ -261,10 +267,6 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
HandleBlockBegin( &dc, BLOCK_PASTE, GetScreen()->m_Curseur );
break;
case ID_GET_ANNOTATE:
InstallAnnotateFrame( this, defaultpos );
break;
case ID_GET_ERC:
InstallErcFrame( this, defaultpos );
break;
......@@ -376,12 +378,12 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_EDIT_TEXT:
EditSchematicText((DrawTextStruct*) GetScreen()->GetCurItem(), &dc );
EditSchematicText( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc );
break;
case ID_POPUP_SCH_ROTATE_TEXT:
DrawPanel->MouseToCursorSchema();
ChangeTextOrient((DrawTextStruct*) GetScreen()->GetCurItem(), &dc );
ChangeTextOrient( (DrawTextStruct*) GetScreen()->GetCurItem(), &dc );
break;
case ID_POPUP_SCH_CHANGE_TYPE_TEXT_TO_LABEL:
......@@ -425,7 +427,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DELETE_NODE:
case ID_POPUP_SCH_DELETE_CONNECTION:
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 );
g_ItemToRepeat = NULL;
TestDanglingEnds( GetScreen()->EEDrawList, &dc );
......@@ -447,9 +450,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
if( GetScreen()->GetCurItem() == NULL )
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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
case ID_POPUP_SCH_DELETE:
if( GetScreen()->GetCurItem() == NULL )
......@@ -500,28 +505,39 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_DRAG_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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL )
break;
case ID_POPUP_SCH_MOVE_ITEM_REQUEST:
DrawPanel->MouseToCursorSchema();
if ( id == ID_POPUP_SCH_DRAG_CMP_REQUEST )
{ // The easiest way to handle a drag component is simulate a block drag command
if( id == ID_POPUP_SCH_DRAG_CMP_REQUEST )
{
// The easiest way to handle a drag component is simulate a
// block drag command
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 );
}
}
else Process_Move_Item( GetScreen()->GetCurItem(), &dc );
else
Process_Move_Item( GetScreen()->GetCurItem(), &dc );
break;
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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL )
break;
InstallCmpeditFrame( this, pos,
......@@ -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_COUNTERCLOCKWISE:
case ID_POPUP_SCH_ORIENT_NORMAL_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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL )
break;
{
......@@ -576,9 +593,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL )
break;
EditComponentValue(
......@@ -586,10 +605,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_EDIT_REF_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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL )
break;
EditComponentReference(
......@@ -597,10 +617,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_EDIT_FOOTPRINT_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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL )
break;
EditComponentFootprint(
......@@ -609,10 +630,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_EDIT_CONVERT_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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL )
break;
DrawPanel->MouseToCursorSchema();
......@@ -626,7 +648,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
{
EDA_SchComponentStruct* olditem, * newitem;
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();
if( olditem == NULL )
break;
......@@ -635,7 +658,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
newitem->ClearAnnotation();
newitem->m_Flags = IS_NEW;
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 );
}
break;
......@@ -666,10 +690,11 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_SELECT_UNIT24:
case ID_POPUP_SCH_SELECT_UNIT25:
case ID_POPUP_SCH_SELECT_UNIT26:
// 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 )
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)GetScreen() ) );
GetScreen()->SetCurItem( LocateSmallestComponent( (SCH_SCREEN*)
GetScreen() ) );
if( GetScreen()->GetCurItem() == NULL )
break;
DrawPanel->MouseToCursorSchema();
......@@ -680,19 +705,23 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_SCH_DISPLAYDOC_CMP:
// Ensure the struct is a component (could be a piece of a component, like Field, text..)
// Ensure the struct is a component (could be a piece of a
// component, like Field, text..)
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 )
break;
{
EDA_LibComponentStruct* LibEntry;
LibEntry = FindLibPart( ( (EDA_SchComponentStruct*)
GetScreen()->GetCurItem() )->m_ChipName,
wxEmptyString, FIND_ALIAS );
LibEntry = FindLibPart(
( (EDA_SchComponentStruct*) GetScreen()->GetCurItem() )->m_ChipName,
wxEmptyString,
FIND_ALIAS );
if( LibEntry && LibEntry->m_DocFile != wxEmptyString )
GetAssociatedDocument( this, g_RealLibDirBuffer, LibEntry->m_DocFile );
GetAssociatedDocument( this,
g_RealLibDirBuffer,
LibEntry->m_DocFile );
}
break;
......@@ -764,7 +793,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_SCH_ADD_LABEL:
case ID_POPUP_SCH_ADD_GLABEL:
GetScreen()->SetCurItem( CreateNewText( &dc,
GetScreen()->SetCurItem(
CreateNewText( &dc,
id == ID_POPUP_SCH_ADD_LABEL ?
LAYER_LOCLABEL : LAYER_GLOBLABEL ) );
if( GetScreen()->GetCurItem() )
......@@ -776,17 +806,20 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_SCHEMATIC_UNDO:
if ( GetSchematicFromUndoList() )
if( GetSchematicFromUndoList() )
DrawPanel->Refresh( TRUE );
break;
case ID_SCHEMATIC_REDO:
if ( GetSchematicFromRedoList() )
if( GetSchematicFromRedoList() )
DrawPanel->Refresh( TRUE );
break;
default: // Log error:
DisplayError( this, wxT( "WinEDA_SchematicFrame::Process_Special_Functions error" ) );
DisplayError( this,
wxT( "WinEDA_SchematicFrame::Process_Special_Functions error" ) );
break;
}
......@@ -801,10 +834,8 @@ void WinEDA_SchematicFrame::Process_Special_Functions( wxCommandEvent& event )
}
/********************************************************************************/
void WinEDA_SchematicFrame::Process_Move_Item( EDA_BaseStruct* DrawStruct,
wxDC* DC )
/********************************************************************************/
{
if( DrawStruct == NULL )
return;
......
/******************************************************************/
/* schframe.cpp - fonctions des classes du type WinEDA_DrawFrame */
/******************************************************************/
/******************************************************************/
/* schframe.cpp - fonctions des classes du type WinEDA_DrawFrame */
/******************************************************************/
#ifdef __GNUG__
#pragma implementation
......@@ -17,110 +17,116 @@
#include "protos.h"
#include "id.h"
#include "annotate_dialog.h"
/*******************************/
/* class WinEDA_SchematicFrame */
/*******************************/
/*******************************/
/* class WinEDA_SchematicFrame */
/*******************************/
BEGIN_EVENT_TABLE(WinEDA_SchematicFrame, wxFrame)
COMMON_EVENTS_DRAWFRAME
BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, wxFrame )
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_SOCKET(ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest)
EVT_CLOSE( WinEDA_SchematicFrame::OnCloseWindow )
EVT_SIZE( WinEDA_SchematicFrame::OnSize )
EVT_CLOSE(WinEDA_SchematicFrame::OnCloseWindow)
EVT_SIZE(WinEDA_SchematicFrame::OnSize)
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_MENU_RANGE( ID_LOAD_PROJECT, ID_LOAD_FILE_10,
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_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_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_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter)
EVT_TOOL_RANGE(ID_GET_ANNOTATE,ID_FIND_ITEMS,
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_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_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout)
EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
// 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,
WinEDA_SchematicFrame::Process_Special_Functions)
WinEDA_SchematicFrame::Process_Special_Functions )
EVT_TOOL_RCLICKED(ID_LABEL_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_LABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
EVT_TOOL_RCLICKED( ID_GLABEL_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 )
// Tools et boutons de Schematique, Options toolbar:
EVT_TOOL_RANGE(ID_TB_OPTIONS_START,ID_TB_OPTIONS_END,
WinEDA_SchematicFrame::OnSelectOptionToolbar)
EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
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 )
END_EVENT_TABLE()
/****************/
/* Constructor */
/****************/
/****************/
/* Constructor */
/****************/
WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *parent,
const wxString & title, const wxPoint& pos, const wxSize& size, long style) :
WinEDA_DrawFrame(father, SCHEMATIC_FRAME, parent, title, pos, size, style)
WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
WinEDA_App* parent,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
WinEDA_DrawFrame( father, SCHEMATIC_FRAME, parent, title, pos, size, style )
{
m_FrameName = wxT("SchematicFrame");
m_FrameName = wxT( "SchematicFrame" );
m_AboutTitle = g_EeschemaAboutTitle;
m_Draw_Axis = FALSE; // TRUE to show axis
m_Draw_Grid = g_ShowGrid; // TRUE to show a grid
......@@ -130,21 +136,26 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *pare
CreateScreens();
// Give an icon
#ifdef __WINDOWS__
SetIcon(wxICON(a_icon_eeschema));
#else
SetIcon(wxICON(icon_eeschema));
#endif
#ifdef __WINDOWS__
SetIcon( wxICON( a_icon_eeschema ) );
#else
SetIcon( wxICON( icon_eeschema ) );
#endif
g_ItemToRepeat = NULL;
/* Get config */
GetSettings();
g_DrawMinimunLineWidth = m_Parent->m_EDA_Config->Read(MINI_DRAW_LINE_WIDTH_KEY, (long)0);
g_PlotPSMinimunLineWidth = m_Parent->m_EDA_Config->Read(MINI_PLOTPS_LINE_WIDTH_KEY, (long) 4);
g_DrawMinimunLineWidth = m_Parent->m_EDA_Config->Read(
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);
if ( DrawPanel ) DrawPanel->m_Block_Enable = TRUE;
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if( DrawPanel )
DrawPanel->m_Block_Enable = TRUE;
ReCreateMenuBar();
ReCreateHToolbar();
ReCreateVToolbar();
......@@ -152,9 +163,9 @@ WinEDA_SchematicFrame::WinEDA_SchematicFrame(wxWindow * father, WinEDA_App *pare
}
/***************/
/* Destructor */
/***************/
/***************/
/* Destructor */
/***************/
WinEDA_SchematicFrame::~WinEDA_SchematicFrame()
{
......@@ -163,50 +174,65 @@ WinEDA_SchematicFrame::~WinEDA_SchematicFrame()
SAFE_DELETE( m_CurrentSheet ); //a DrawSheetList, on the heap.
m_CurrentSheet = NULL;
}
/***************/
/* utility functions */
/***************/
/***************/
/* utility functions */
/***************/
DrawSheetList* WinEDA_SchematicFrame::GetSheet()
{
return m_CurrentSheet;
}
BASE_SCREEN* WinEDA_SchematicFrame::GetScreen()
{
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.
//there is ambiguity in this function (there may be several
//instances of a given sheet, but irregardless it is useful
//for printing etc.
DrawSheetList sheetlist;
if(g_RootSheet->LocatePathOfScreen(screen, &sheetlist)){
if( g_RootSheet->LocatePathOfScreen( screen, &sheetlist ) )
{
*m_CurrentSheet = sheetlist;
m_CurrentSheet->UpdateAllScreenReferences();
}
}
wxString WinEDA_SchematicFrame::GetScreenDesc()
{
wxString s = m_CurrentSheet->PathHumanReadable();
return s;
}
/******************************/
void WinEDA_SchematicFrame::CreateScreens()
/******************************/
{
/* creation des ecrans Sch , Lib */
if( g_RootSheet == NULL ){
if( g_RootSheet == NULL )
{
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->m_RefCount++;
}
g_RootSheet->m_s->m_FileName = g_DefaultSchematicFileName;
g_RootSheet->m_s->m_Date = GenDate();
m_CurrentSheet->Clear();
m_CurrentSheet->Push(g_RootSheet);
m_CurrentSheet->Push( g_RootSheet );
if( ScreenLib == NULL )
ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME );
......@@ -214,30 +240,37 @@ void WinEDA_SchematicFrame::CreateScreens()
ScreenLib->m_UndoRedoCountMax = 10;
}
/**************************************************************/
void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event)
void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
/**************************************************************/
{
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 );
for(sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() ){
if(sheet->LastScreen() && sheet->LastScreen()->IsModify()) break;
for( sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() )
{
if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
break;
}
if ( sheet )
if( sheet )
{
unsigned ii;
wxMessageDialog dialog(this, _("Schematic modified, Save before exit ?"),
_("Confirmation"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT);
wxMessageDialog dialog( this,
_( "Schematic modified, Save before exit ?" ),
_( "Confirmation" ), wxYES_NO | wxCANCEL |
wxICON_EXCLAMATION | wxYES_DEFAULT );
ii = dialog.ShowModal();
switch ( ii )
switch( ii )
{
case wxID_CANCEL:
Event.Veto();
......@@ -253,24 +286,28 @@ void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event)
}
}
for(sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() ){
if(sheet->LastScreen()){
for( sheet = sheets.GetFirst(); sheet != NULL; sheet = sheets.GetNext() )
{
if( sheet->LastScreen() )
{
sheet->LastScreen()->ClrModify();
}
}
if ( ! GetScreen()->m_FileName.IsEmpty() && (GetScreen()->EEDrawList != NULL) )
SetLastProject(GetScreen()->m_FileName);
if( !GetScreen()->m_FileName.IsEmpty() && (GetScreen()->EEDrawList != NULL) )
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 */
m_CurrentSheet->Clear();
SaveSettings();
m_Parent->m_EDA_Config->Write(MINI_DRAW_LINE_WIDTH_KEY, (long)g_DrawMinimunLineWidth);
m_Parent->m_EDA_Config->Write(MINI_PLOTPS_LINE_WIDTH_KEY, (long) g_PlotPSMinimunLineWidth);
m_Parent->m_EDA_Config->Write( MINI_DRAW_LINE_WIDTH_KEY,
(long) g_DrawMinimunLineWidth );
m_Parent->m_EDA_Config->Write( MINI_PLOTPS_LINE_WIDTH_KEY,
(long) g_PlotPSMinimunLineWidth );
Destroy();
}
......@@ -279,79 +316,85 @@ void WinEDA_SchematicFrame::OnCloseWindow(wxCloseEvent & Event)
/********************************************/
void WinEDA_SchematicFrame::SetToolbars()
/********************************************/
/* Enable or disable some tools according to current conditions
*/
*/
{
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_COPY,TRUE);
m_HToolBar->EnableTool( wxID_CUT, TRUE );
m_HToolBar->EnableTool( wxID_COPY, TRUE );
}
else
{
m_HToolBar->EnableTool(wxID_CUT,FALSE);
m_HToolBar->EnableTool(wxID_COPY,FALSE);
m_HToolBar->EnableTool( wxID_CUT, FALSE );
m_HToolBar->EnableTool( wxID_COPY, FALSE );
}
if ( g_BlockSaveDataList ) m_HToolBar->EnableTool(wxID_PASTE,TRUE);
else m_HToolBar->EnableTool(wxID_PASTE,FALSE);
if( g_BlockSaveDataList )
m_HToolBar->EnableTool( wxID_PASTE, TRUE );
else
m_HToolBar->EnableTool( wxID_PASTE, FALSE );
wxMenuBar * menuBar = GetMenuBar();
if ( GetScreen() && GetScreen()->m_RedoList )
wxMenuBar* menuBar = GetMenuBar();
if( GetScreen() && GetScreen()->m_RedoList )
{
m_HToolBar->EnableTool(ID_SCHEMATIC_REDO,TRUE);
menuBar->Enable(ID_SCHEMATIC_REDO,TRUE);
m_HToolBar->EnableTool( ID_SCHEMATIC_REDO, TRUE );
menuBar->Enable( ID_SCHEMATIC_REDO, TRUE );
}
else
{
m_HToolBar->EnableTool(ID_SCHEMATIC_REDO,FALSE);
menuBar->Enable(ID_SCHEMATIC_REDO,FALSE);
m_HToolBar->EnableTool( 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);
menuBar->Enable(ID_SCHEMATIC_UNDO,TRUE);
m_HToolBar->EnableTool( ID_SCHEMATIC_UNDO, TRUE );
menuBar->Enable( ID_SCHEMATIC_UNDO, TRUE );
}
else
{
m_HToolBar->EnableTool(ID_SCHEMATIC_UNDO,FALSE);
menuBar->Enable(ID_SCHEMATIC_UNDO,FALSE);
m_HToolBar->EnableTool( 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->SetToolShortHelp(ID_TB_OPTIONS_SHOW_GRID,
m_Draw_Grid ? _("Grid not show") : _("Show Grid"));
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric == MILLIMETRE ? TRUE : FALSE);
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : FALSE);
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SELECT_CURSOR,g_CursorShape);
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_HIDDEN_PINS,g_ShowAllPins);
m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_HIDDEN_PINS,
g_ShowAllPins ? _("No show Hidden Pins") : _("Show Hidden Pins") );
m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_BUS_WIRES_ORIENT, g_HVLines);
m_OptionsToolBar->SetToolShortHelp(ID_TB_OPTIONS_BUS_WIRES_ORIENT,
g_HVLines ? _("Draw lines at any direction") :
_("Draw lines H, V or 45 deg only") );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, m_Draw_Grid );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric == MILLIMETRE ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
g_CursorShape );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_HIDDEN_PINS, g_ShowAllPins );
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS,
g_ShowAllPins ? _( "No show Hidden Pins" ) : _( "Show Hidden Pins" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
g_HVLines );
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();
}
/******************************************/
int WinEDA_SchematicFrame::BestZoom()
/******************************************/
{
int dx, dy, ii,jj ;
int bestzoom;
wxSize size;
int dx, dy, ii, jj;
int bestzoom;
wxSize size;
dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
......@@ -359,12 +402,18 @@ wxSize size;
size = DrawPanel->GetClientSize();
ii = dx / size.x;
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.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:
private:
void Process_Move_Item( EDA_BaseStruct* DrawStruct, wxDC* DC );
void OnAnnotate ( wxCommandEvent& event );
// Bus Entry
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