Commit 1a4d2389 authored by stambaughw's avatar stambaughw

Begin translating comments to English and minor code clean up.

* Translate comments in source files beginning with A-E in eeschema.
* Spell check comments and strings and uncrusified all modified files.
parent d3468dd5
......@@ -13,34 +13,35 @@
#include "general.h"
/* Variables Locales */
/*******************************************************************************************/
bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent(
const wxString& aReference,
const wxString& aFootPrint,
bool aSetVisible )
/********************************************************************************************/
{
/** function FillFootprintFieldForAllInstancesofComponent
* Search for component "aReference", and place a Footprint in Footprint field
* @param aReference = reference of the component to initialise
* @param aReference = reference of the component to initialize
* @param aFootPrint = new value for the filed Fottprint component
* @param aSetVisible = true to have the field visible, false to set the invisible flag
* @param aSetVisible = true to have the field visible, false to set the
* invisible flag
* @return true if the given component is found
* Note:
* the component is searched in the whole schematic, and because some components
* the component is searched in the whole schematic, and because some
* components
* have more than one instance (multiple parts per package components)
* the search is not stopped when a reference is found (all instances must be found).
* the search is not stopped when a reference is found (all instances must be
* found).
*/
{
DrawSheetPath* sheet;
SCH_ITEM* DrawList = NULL;
EDA_SheetList SheetList;
SCH_COMPONENT* Cmp;
bool found = false;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
{
DrawList = (SCH_ITEM*) sheet->LastDrawList();
for( ; (DrawList != NULL); DrawList = DrawList->Next() )
......@@ -51,22 +52,27 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent(
Cmp = (SCH_COMPONENT*) DrawList;
if( aReference.CmpNoCase( Cmp->GetRef( sheet ) ) == 0 )
{
// Found: Init Footprint Field
/* Give a reasonnable value to the fied position and orientation, if
* the text is empty at position 0, because it is probably not yet initialised
*/
if( Cmp->GetField(FOOTPRINT)->m_Text.IsEmpty()
&& ( Cmp->GetField(FOOTPRINT)->m_Pos == wxPoint( 0, 0 ) ) )
// Found: Init Footprint Field
/* Give a reasonable value to the field position and
* orientation, if the text is empty at position 0, because
* it is probably not yet initialized
*/
if( Cmp->GetField( FOOTPRINT )->m_Text.IsEmpty()
&& ( Cmp->GetField( FOOTPRINT )->m_Pos == wxPoint( 0, 0 ) ) )
{
Cmp->GetField(FOOTPRINT)->m_Orient = Cmp->GetField(VALUE)->m_Orient;
Cmp->GetField(FOOTPRINT)->m_Pos = Cmp->GetField(VALUE)->m_Pos;
Cmp->GetField(FOOTPRINT)->m_Pos.y -= 100;
Cmp->GetField( FOOTPRINT )->m_Orient = Cmp->GetField(
VALUE )->m_Orient;
Cmp->GetField( FOOTPRINT )->m_Pos = Cmp->GetField(
VALUE )->m_Pos;
Cmp->GetField( FOOTPRINT )->m_Pos.y -= 100;
}
Cmp->GetField(FOOTPRINT)->m_Text = aFootPrint;
Cmp->GetField( FOOTPRINT )->m_Text = aFootPrint;
if( aSetVisible )
Cmp->GetField(FOOTPRINT)->m_Attributs &= ~TEXT_NO_VISIBLE;
Cmp->GetField( FOOTPRINT )->m_Attributs &=
~TEXT_NO_VISIBLE;
else
Cmp->GetField(FOOTPRINT)->m_Attributs |= TEXT_NO_VISIBLE;
Cmp->GetField( FOOTPRINT )->m_Attributs |= TEXT_NO_VISIBLE;
found = true;
}
}
......@@ -76,11 +82,9 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent(
}
/***************************************************************************/
bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool
aSetFielsAttributeToVisible )
/***************************************************************************/
{
/** Function ProcessStuffFile
* Read a "stuff" file created by cvpcb.
* That file has lines like:
......@@ -91,10 +95,10 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool
* "module =" gives the footprint name
*
* @param aStuffFile = file (*.stf) to Read.
* @param aSetFielsAttributeToVisible = true to set the footprint field flag to visible
* @return true if ok.
* @param aSetFielsAttributeToVisible = true to set the footprint field flag to
* visible
* @return true if OK.
*/
{
int LineNum = 0;
char* cp, Ref[256], FootPrint[256], Line[1024];
......@@ -112,9 +116,10 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool
wxString reference = CONV_FROM_UTF8( Ref );
wxString Footprint = CONV_FROM_UTF8( FootPrint );
FillFootprintFieldForAllInstancesofComponent( reference,
Footprint,
aSetFielsAttributeToVisible );
FillFootprintFieldForAllInstancesofComponent(
reference,
Footprint,
aSetFielsAttributeToVisible );
}
}
......@@ -122,23 +127,20 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool
}
/**************************************************************/
bool WinEDA_SchematicFrame::ReadInputStuffFile()
/**************************************************************/
{
/* Backann footprint info to schematic.
*/
{
wxString Line, filename;
FILE* StuffFile;
wxString msg;
bool SetFieldToVisible = true;
filename = EDA_FileSelector( _( "Load Stuff File" ),
wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */
wxT( ".stf" ), /* extension par defaut */
wxT( "*.stf" ), /* Masque d'affichage */
wxEmptyString,
wxEmptyString,
wxT( ".stf" ),
wxT( "*.stf" ),
this,
wxFD_OPEN,
FALSE
......@@ -156,7 +158,7 @@ bool WinEDA_SchematicFrame::ReadInputStuffFile()
int diag = wxMessageBox(
_( "Set the Footprint Field to Visible ?" ),
_ ("Field Display Option"),
_( "Field Display Option" ),
wxYES_NO | wxICON_QUESTION | wxCANCEL, this );
if( diag == wxCANCEL )
......
/****************************************************/
/* BLOCK.CPP */
/* Gestion des Operations sur Blocks et Effacements */
/****************************************************/
#include "fctsys.h"
......@@ -18,41 +17,35 @@
#include "protos.h"
/* Variables Locales */
// Imported functions:
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList,
wxPoint& Center );
void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList );
void DuplicateItemsInList( SCH_SCREEN* screen,
PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector );
/* Fonctions exportees */
/* Fonctions Locales */
static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxPoint& aPosition,
bool aSearchFirst );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList,
wxPoint& Center );
void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList );
void DuplicateItemsInList( SCH_SCREEN* screen,
PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector );
static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxPoint& aPosition,
bool aSearchFirst );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
/*************************************************************************/
int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
{
/*************************************************************************/
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the key (ALT, SHIFT ALT ..)
*/
{
int cmd;
switch( key )
......@@ -89,11 +82,10 @@ int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
/*************************************************/
void WinEDA_SchematicFrame::InitBlockPasteInfos()
{
/*************************************************/
/* Init the parameters used by the block paste command
*/
{
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
block->m_ItemsSelection.CopyList( g_BlockSaveDataList.m_ItemsSelection );
......@@ -103,14 +95,13 @@ void WinEDA_SchematicFrame::InitBlockPasteInfos()
/******************************************************/
void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
{
/******************************************************/
/* Routine to handle the BLOCK PLACE commande
/* Routine to handle the BLOCK PLACE command
* Last routine for block operation for:
* - block move & drag
* - block copie & paste
* - block copy & paste
*/
{
bool err = FALSE;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
......@@ -124,7 +115,8 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
{
wxString msg;
err = TRUE;
msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd %d, state %d)" ),
msg.Printf( wxT( "HandleBlockPLace() error : no items to place (cmd \
%d, state %d)" ),
block->m_Command, block->m_State );
DisplayError( this, msg );
}
......@@ -142,7 +134,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
SaveCopyInUndoList( block->m_ItemsSelection, UR_MOVED, block->m_MoveVector );
SaveCopyInUndoList( block->m_ItemsSelection,
UR_MOVED,
block->m_MoveVector );
MoveItemsInList( block->m_ItemsSelection, block->m_MoveVector );
block->ClearItemsList();
......@@ -153,15 +147,18 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
DuplicateItemsInList( GetScreen(), block->m_ItemsSelection, block->m_MoveVector );
DuplicateItemsInList(
GetScreen(), block->m_ItemsSelection, block->m_MoveVector );
SaveCopyInUndoList( block->m_ItemsSelection,
(block->m_Command == BLOCK_PRESELECT_MOVE) ? UR_CHANGED : UR_NEW );
SaveCopyInUndoList(
block->m_ItemsSelection,
(block->m_Command ==
BLOCK_PRESELECT_MOVE) ? UR_CHANGED : UR_NEW );
block->ClearItemsList();
break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
case BLOCK_PASTE:
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
PasteListOfItems( DC );
......@@ -184,7 +181,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
/* clear struct.m_Flags */
SCH_ITEM* Struct;
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
for( Struct = GetScreen()->EEDrawList;
Struct != NULL;
Struct = Struct->Next() )
Struct->m_Flags = 0;
DrawPanel->ManageCurseur = NULL;
......@@ -198,27 +197,27 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( block->GetCount() )
{
DisplayError( this, wxT( "HandleBlockPLace() error: some items left in buffer" ) );
DisplayError( this,
wxT( "HandleBlockPLace() error: some items left in buffer" ) );
block->ClearItemsList();
}
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
DrawPanel->Refresh( );
DrawPanel->Refresh();
}
/****************************************************/
int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
{
/****************************************************/
/* Routine de gestion de la commande BLOCK END
* retourne :
* 0 si aucun composant selectionne
* 1 sinon
* -1 si commande terminee et composants trouves (block delete, block save)
/* Manage end block command
* Returns:
* 0 if no features selected
* 1 otherwise
* -1 If control ended and components selection (block delete, block save)
*/
{
int ii = 0;
bool zoom_command = FALSE;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
......@@ -247,6 +246,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
......@@ -288,9 +288,11 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
wxPoint move_vector =
-GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
SaveStructListForPaste( block->m_ItemsSelection );
MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector);
MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection,
move_vector );
ii = -1;
}
block->ClearItemsList();
......@@ -321,7 +323,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
{
/* clear struct.m_Flags */
EDA_BaseStruct* Struct;
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
for( Struct = GetScreen()->EEDrawList;
Struct != NULL;
Struct = Struct->Next() )
Struct->m_Flags = 0;
}
......@@ -333,7 +337,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state,
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
}
if( zoom_command )
......@@ -345,13 +351,12 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
/***********************************************************************/
void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
{
/***********************************************************************/
/* Routine de gestion de la commande BLOCK END by PopUp
* Appelee apres HandleBlockEnd.
* A partir de la commande bloc move, peut executer une commande autre que bloc move.
/* Manage end block command from context menu.
* Called after HandleBlockEnd.
* From the command block move can execute a command other than block move.
*/
{
int ii = 0;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
......@@ -372,8 +377,10 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_DRAG: /* move to Drag */
/* Effacement de la liste des structures de pointage,
* qui est devenue erronnee */
/* *JP translate*
* Effacement de la liste des structures de pointage,
* qui est devenue erronnee
*/
if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
block->ClearItemsList();
......@@ -410,7 +417,8 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() )
{
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
wxPoint move_vector =
-GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
SaveStructListForPaste( block->m_ItemsSelection );
MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector );
ii = -1;
......@@ -435,10 +443,12 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
if( block->GetCount() )
{
ii = -1;
/* Compute the mirror centre and put it on grid */
/* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre();
PutOnGrid( &mirrorPoint );
SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_Y, mirrorPoint );
SaveCopyInUndoList( block->m_ItemsSelection,
UR_MIRRORED_Y,
mirrorPoint );
MirrorListOfItems( block->m_ItemsSelection, mirrorPoint );
GetScreen()->SetModify();
}
......@@ -459,7 +469,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, wxEmptyString );
SetToolID( m_ID_current_state,
DrawPanel->m_PanelDefaultCursor,
wxEmptyString );
}
}
......@@ -467,18 +479,17 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
/************************************************************************/
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase )
{
/************************************************************************/
/* Retrace le contour du block de recherche de structures
* L'ensemble du block suit le curseur
/* Traces the outline of the search block structures
* The entire block follows the cursor
*/
{
BLOCK_SELECTOR* block = &panel->GetScreen()->m_BlockLocate;;
BASE_SCREEN* screen = panel->GetScreen();
SCH_ITEM* schitem;
/* Effacement ancien cadre */
/* Erase old block contents. */
if( erase )
{
block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color );
......@@ -489,8 +500,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
}
}
/* Redessin nouvel affichage */
/* Repaint new view. */
block->m_MoveVector = screen->m_Curseur - block->m_BlockLastCursorPosition;
block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color );
......@@ -505,22 +515,24 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
/*****************************************************************/
void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList )
{
/*****************************************************************/
/* Routine to Save an object from global drawing object list.
* This routine is the same as delete but:
* - the original list is NOT removed.
* - List is saved in g_BlockSaveDataList
*/
{
g_BlockSaveDataList.ClearListAndDeleteItems(); // delete previous saved list, if exists
g_BlockSaveDataList.ClearListAndDeleteItems(); // delete previous
// saved list, if
// exists
/* save the new list: */
ITEM_PICKER item;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{
/* Make a copy of the original picked item. */
SCH_ITEM* DrawStructCopy = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
SCH_ITEM* DrawStructCopy = DuplicateStruct(
(SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
DrawStructCopy->SetParent( NULL );
item.m_PickedItem = DrawStructCopy;
g_BlockSaveDataList.PushItem( item );
......@@ -545,10 +557,12 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
PICKED_ITEMS_LIST picklist;
// Creates data, and push it as new data in undo item list buffer
ITEM_PICKER picker( NULL, UR_NEW );
ITEM_PICKER picker( NULL, UR_NEW );
for( unsigned ii = 0; ii < g_BlockSaveDataList.GetCount(); ii++ )
{
Struct = DuplicateStruct( (SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetPickedItem( ii ) );
Struct = DuplicateStruct(
(SCH_ITEM*) g_BlockSaveDataList.m_ItemsSelection.GetPickedItem(
ii ) );
picker.m_PickedItem = Struct;
picklist.PushItem( picker );
......@@ -569,7 +583,9 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
MoveItemsInList( picklist, GetScreen()->m_BlockLocate.m_MoveVector );
/* clear .m_Flags member for all items */
for( Struct = GetScreen()->EEDrawList; Struct != NULL; Struct = Struct->Next() )
for( Struct = GetScreen()->EEDrawList;
Struct != NULL;
Struct = Struct->Next() )
Struct->m_Flags = 0;
GetScreen()->SetModify();
......@@ -580,13 +596,12 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
/****************************************************/
static void CollectStructsToDrag( SCH_SCREEN* screen )
{
/****************************************************/
/* creates the list of items found when a drag block is initiated.
* items are those selected in window block an some items outside this area but connected
* to a selected item (connected wires to a component or an entry )
* items are those selected in window block an some items outside this area but
* connected to a selected item (connected wires to a component or an entry )
*/
{
SCH_ITEM* Struct;
EDA_DrawLineStruct* SegmStruct;
......@@ -601,14 +616,16 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() )
Struct->m_Flags = 0;
// Sel .m_Flags to selected for a wire or bus in selected area if there is only one item:
// Sel .m_Flags to selected for a wire or bus in selected area if there is
// only one item:
if( pickedlist->GetCount() == 1 )
{
Struct = (SCH_ITEM*) pickedlist->GetPickedItem( 0 );
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
Struct->m_Flags = SELECTED;
}
// Sel .m_Flags to selected for a wire or bus in selected area for a list of items:
// Sel .m_Flags to selected for a wire or bus in selected area for a list
// of items:
else
{
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
......@@ -622,41 +639,40 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
return;
/* Suppression du deplacement des extremites de segments hors cadre
* de selection */
/* Remove the displacement of segment and undo the selection. */
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
Struct = (SCH_ITEM*) (SCH_ITEM*) pickedlist->GetPickedItem( ii );
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{
SegmStruct = (EDA_DrawLineStruct*) Struct;
if( ! screen->m_BlockLocate.Inside(SegmStruct->m_Start) )
if( !screen->m_BlockLocate.Inside( SegmStruct->m_Start ) )
SegmStruct->m_Flags |= STARTPOINT;
if( ! screen->m_BlockLocate.Inside(SegmStruct->m_End) )
if( !screen->m_BlockLocate.Inside( SegmStruct->m_End ) )
SegmStruct->m_Flags |= ENDPOINT;
// Save m_Flags for Undo/redo drag operations:
pickedlist->SetPickerFlags(SegmStruct->m_Flags, ii);
pickedlist->SetPickerFlags( SegmStruct->m_Flags, ii );
}
}
/* Search for other items to drag. They are end wires connected to selected items
/* Search for other items to drag. They are end wires connected to selected
* items
*/
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
{
Struct = (SCH_ITEM*)(SCH_ITEM*) pickedlist->GetPickedItem( ii );
Struct = (SCH_ITEM*) (SCH_ITEM*) pickedlist->GetPickedItem( ii );
if( Struct->Type() == TYPE_SCH_COMPONENT )
{
// Add all pins of the selected component to list
LIB_PIN* pin;
wxPoint pos;
wxPoint pos;
pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, true );
while( pin )
{
if( ! screen->m_BlockLocate.Inside(pos) )
if( !screen->m_BlockLocate.Inside( pos ) )
{
// This pin is outside area,
// but because it it the pin of a selected component
......@@ -693,17 +709,17 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/******************************************************************/
static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{
/******************************************************************/
/** AddPickedItem
* add to the picked list in screen->m_BlockLocate items found at location position
* add to the picked list in screen->m_BlockLocate items found at location
* position
* @param screen = the screen to consider
* @param position = the wxPoint where items must be located to be select
*/
{
SCH_ITEM* Struct;
/* Examen de la liste des elements deja selectionnes */
/* Review the list of already selected elements. */
PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
......@@ -722,7 +738,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
STRUCT->m_Flags &= ~ENDPOINT;
// Save m_Flags for Undo/redo drag operations:
pickedlist->SetPickerFlags(STRUCT->m_Flags, ii);
pickedlist->SetPickerFlags( STRUCT->m_Flags, ii );
break;
default:
......@@ -730,13 +746,13 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
}
}
/* Examen de la liste des elements non selectionnes */
/* Review the list of elements not selected. */
ITEM_PICKER picker;
Struct = screen->EEDrawList;
while( Struct )
{
picker.m_PickedItem = Struct;
picker.m_PickedItem = Struct;
picker.m_PickedItemType = Struct->Type();
switch( Struct->Type() )
{
......@@ -745,14 +761,14 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
case DRAW_POLYLINE_STRUCT_TYPE:
if( Struct->m_Flags & SELECTED )
break; /* Deja en liste */
break;
break;
case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) Struct )
if( Struct->m_Flags & SELECTED )
break; /* Deja en liste */
break;
if( STRUCT->m_Pos != position )
break;
pickedlist->PushItem( picker );
......@@ -762,21 +778,23 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT
#define STRUCT ( (EDA_DrawLineStruct*) Struct )
if( Struct->m_Flags & SELECTED )
break; /* Deja en liste */
break;
if( STRUCT->m_Start == position )
{
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~STARTPOINT;
// Save m_Flags for Undo/redo drag operations:
picker.m_PickerFlags= Struct->m_Flags;
picker.m_PickerFlags = Struct->m_Flags;
pickedlist->PushItem( picker );
}
else if( STRUCT->m_End == position )
{
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~ENDPOINT;
// Save m_Flags for Undo/redo drag operations:
picker.m_PickerFlags= Struct->m_Flags;
picker.m_PickerFlags = Struct->m_Flags;
pickedlist->PushItem( picker );
}
break;
......@@ -791,7 +809,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) Struct )
if( Struct->m_Flags & SELECTED )
break; /* Already in list */
break; /* Already in list */
if( STRUCT->m_Pos != position )
break;
Struct->m_Flags |= SELECTED;
......@@ -803,7 +821,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT
#define STRUCT ( (SCH_LABEL*) Struct )
if( Struct->m_Flags & SELECTED )
break; /* Already in list */
break; /* Already in list */
if( STRUCT->m_Pos != position )
break;
Struct->m_Flags |= SELECTED;
......@@ -819,7 +837,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT
#define STRUCT ( (MARKER_SCH*) Struct )
if( Struct->m_Flags & SELECTED )
break; /* Already in list */
break; /* Already in list */
if( STRUCT->m_Pos != position )
break;
Struct->m_Flags |= SELECTED;
......@@ -830,7 +848,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) Struct )
if( Struct->m_Flags & SELECTED )
break; /* Already in list */
break; /* Already in list */
if( STRUCT->m_Pos != position )
break;
Struct->m_Flags |= SELECTED;
......@@ -845,20 +863,20 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
}
/*********************************************************************************/
/****************************************************************************/
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxPoint& aPosition,
bool aSearchFirst)
/*********************************************************************************/
wxPoint& aPosition,
bool aSearchFirst )
{
/****************************************************************************/
/** GetNextPinPosition()
* calculate position of the "next" pin of the aDrawLibItem component
* @param aDrawLibItem = component to test.
* @param aPosition = the calculated pin position, according to the component orientation and position
* @param aPosition = the calculated pin position, according to the component
* orientation and position
* @param aSearchFirst = if true, search for the first pin
* @return a pointer to the pin
*/
{
static LIB_COMPONENT* Entry;
static int Multi, convert, TransMat[2][2];
static wxPoint CmpPosition;
......@@ -871,8 +889,8 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
if( Entry == NULL )
return NULL;
Pin = Entry->GetNextPin();
Multi = aDrawLibItem->m_Multi;
Pin = Entry->GetNextPin();
Multi = aDrawLibItem->m_Multi;
convert = aDrawLibItem->m_Convert;
CmpPosition = aDrawLibItem->m_Pos;
memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
......@@ -890,9 +908,11 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
if( convert && Pin->m_Convert && ( Pin->m_Convert != convert ) )
continue;
/* Calculate the pin position (according to the component orientation) */
/* Calculate the pin position (according to the component orientation)
**/
aPosition = TransformCoordinate( TransMat, Pin->m_Pos ) + CmpPosition;
return Pin;
}
return NULL;
}
/****************************************************/
/* block_libedit.cpp */
/* Gestion des Operations sur Blocks et Effacements */
/* block_libedit.cpp */
/****************************************************/
#include "fctsys.h"
......@@ -191,10 +190,10 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC )
/*
* Routine to handle the BLOCK PLACE commande
* Routine to handle the BLOCK PLACE command
* Last routine for block operation for:
* - block move & drag
* - block copie & paste
* - block copy & paste
*/
void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
{
......@@ -238,7 +237,7 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
m_component->CopySelectedItems( pt );
break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */
case BLOCK_PASTE: /* Paste (recopy the last block saved) */
GetScreen()->m_BlockLocate.ClearItemsList();
break;
......@@ -276,8 +275,8 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
/*
* Retrace le contour du block de recherche de structures
* L'ensemble du block suit le curseur
* Traces the outline of the search block structures
* The entire block follows the cursor
*/
void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
......@@ -307,7 +306,7 @@ void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
true, true, true );
}
/* Redessin nouvel affichage */
/* Repaint new view */
PtBlock->m_MoveVector.x =
screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x;
PtBlock->m_MoveVector.y =
......
// Name: build_BOM.cpp
/////////////////////////////////////////////////////////////////////////////
// Name: build_BOM.cpp
// Purpose:
// Author: jean-pierre Charras
// Licence: GPL license
// Author: jean-pierre Charras
// License: GPL license
/////////////////////////////////////////////////////////////////////////////
#include <algorithm> // to use sort vector
......@@ -37,8 +38,7 @@ public:
//have to store it here since the object references will be duplicated.
DrawSheetPath m_SheetPath; //composed of UIDs
public:
LABEL_OBJECT()
public: LABEL_OBJECT()
{
m_Label = NULL;
m_LabelType = 0;
......@@ -52,12 +52,17 @@ static const wxString BomFileExtension( wxT( "lst" ) );
/* Local functions */
static void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList );
static void BuildComponentsListFromSchematic(
std::vector <OBJ_CMP_TO_LIST>& aList );
static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList );
static bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 );
static bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 );
static bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 );
static bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 );
static bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1,
const OBJ_CMP_TO_LIST& obj2 );
static bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1,
const OBJ_CMP_TO_LIST& obj2 );
static bool SortLabelsByValue( const LABEL_OBJECT& obj1,
const LABEL_OBJECT& obj2 );
static bool SortLabelsBySheet( const LABEL_OBJECT& obj1,
const LABEL_OBJECT& obj2 );
static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList );
static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList );
......@@ -79,8 +84,8 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( bool aTypeFileIsExport,
bool aIncludeSubComponents,
char aExportSeparatorSymbol,
bool aRunBrowser )
/**************************************************************************/
{
/**************************************************************************/
wxFileName fn;
s_ExportSeparatorSymbol = aExportSeparatorSymbol;
......@@ -120,18 +125,16 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( bool aTypeFileIsExport,
/****************************************************************************/
void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName,
bool aIncludeSubComponents )
{
/****************************************************************************/
/*
* Print a list of components, in a form which can be imported by a spreadsheet
* form is:
* cmp name; cmp val; fields;
*/
{
FILE* f;
wxString msg;
/* Creation de la liste des elements */
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
{
msg = _( "Failed to open file " );
......@@ -157,15 +160,16 @@ void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName,
/****************************************************************************/
void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
bool aIncludeSubComponents )
void DIALOG_BUILD_BOM::GenereListeOfItems(
const wxString& aFullFileName,
bool
aIncludeSubComponents )
{
/****************************************************************************/
/** GenereListeOfItems()
* Main function to create the list of components and/or labels
* (global labels and pin sheets" )
*/
{
FILE* f;
int itemCount;
char Line[1024];
......@@ -217,8 +221,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
if( m_GenListLabelsbySheet->GetValue() )
{
sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsBySheet );
msg.Printf( _(
"\n#Global, Hierarchical Labels and PinSheets ( order = Sheet Number ) count = %d\n" ),
msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \
( order = Sheet Number ) count = %d\n" ),
itemCount );
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
PrintListeGLabel( f, listOfLabels );
......@@ -228,8 +232,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
{
sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsByValue );
msg.Printf( _(
"\n#Global, Hierarchical Labels and PinSheets ( order = Alphab. ) count = %d\n\n" ),
msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \
order = Alphab. ) count = %d\n\n" ),
itemCount );
fprintf( f, "%s", CONV_TO_UTF8( msg ) );
PrintListeGLabel( f, listOfLabels );
......@@ -244,16 +248,15 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
/***************************************************************************/
void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
{
/***************************************************************************/
/* Creates the list of components found in the whole schematic
*
* if List == null, just returns the count. if not, fills the list.
* goes through the sheets, not the screens, so that we account for
* multiple instances of a given screen.
* Also Initialise m_Father as pointerof the SCH_SCREN parent
* Also Initialize m_Father as pointer of the SCH_SCREEN parent
*/
{
EDA_BaseStruct* SchItem;
SCH_COMPONENT* DrawLibItem;
DrawSheetPath* sheet;
......@@ -261,9 +264,12 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
/* Build the sheet (not screen) list */
EDA_SheetList SheetList;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
{
for( SchItem = sheet->LastDrawList(); SchItem; SchItem = SchItem->Next() )
for( SchItem = sheet->LastDrawList(); SchItem;
SchItem = SchItem->Next() )
{
if( SchItem->Type() != TYPE_SCH_COMPONENT )
continue;
......@@ -279,7 +285,7 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ),
sizeof( item.m_Reference ) );
// Ensure always nul terminate m_Ref.
// Ensure always null terminate m_Ref.
item.m_Reference[sizeof( item.m_Reference ) - 1 ] = 0;
aList.push_back( item );
}
......@@ -289,11 +295,10 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
/****************************************************************/
static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
{
/****************************************************************/
/* Fill aList with Glabel info
*/
{
SCH_ITEM* DrawList;
Hierarchical_PIN_Sheet_Struct* PinLabel;
DrawSheetPath* sheet;
......@@ -303,7 +308,9 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
LABEL_OBJECT labet_object;
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
{
DrawList = (SCH_ITEM*) sheet->LastDrawList();
while( DrawList )
......@@ -323,7 +330,8 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
PinLabel = ( (DrawSheetStruct*) DrawList )->m_Label;
while( PinLabel != NULL )
{
labet_object.m_LabelType = DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
labet_object.m_LabelType =
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE;
labet_object.m_SheetPath = *sheet;
labet_object.m_Label = PinLabel;
aList.push_back( labet_object );
......@@ -342,17 +350,17 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
}
/************************************************************************************/
bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 )
/************************************************************************************/
/* Compare fuinction for sort()
/*****************************************************************************/
bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1,
const OBJ_CMP_TO_LIST& obj2 )
{
/*****************************************************************************/
/* Compare function for sort()
* components are sorted
* by value
* if same value: by reference
* if same reference: by unit number
*/
{
int ii;
const wxString* Text1, * Text2;
......@@ -374,17 +382,17 @@ bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST&
}
/***************************************************************************************/
bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 )
/***************************************************************************************/
/*****************************************************************************/
bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1,
const OBJ_CMP_TO_LIST& obj2 )
{
/*****************************************************************************/
/* compare function for sorting
* components are sorted
* by reference
* if same reference: by value
* if same value: by unit number
*/
{
int ii;
const wxString* Text1, * Text2;
......@@ -408,26 +416,25 @@ bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LI
/******************************************************************/
bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
{
/*******************************************************************/
/* compare function for sorting labels
* sort by
* value
* if same value: by sheet
*/
{
int ii;
wxString* Text1, * Text2;
if( obj1.m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
Text1 = &( (Hierarchical_PIN_Sheet_Struct*)(obj1.m_Label) )->m_Text;
Text1 = &( (Hierarchical_PIN_Sheet_Struct*) (obj1.m_Label) )->m_Text;
else
Text1 = &( (SCH_TEXT*)(obj1.m_Label) )->m_Text;
Text1 = &( (SCH_TEXT*) (obj1.m_Label) )->m_Text;
if( obj2.m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE )
Text2 = &( (Hierarchical_PIN_Sheet_Struct*)(obj2.m_Label) )->m_Text;
Text2 = &( (Hierarchical_PIN_Sheet_Struct*) (obj2.m_Label) )->m_Text;
else
Text2 = &( (SCH_TEXT*)(obj2.m_Label) )->m_Text;
Text2 = &( (SCH_TEXT*) (obj2.m_Label) )->m_Text;
ii = Text1->CmpNoCase( *Text2 );
......@@ -440,15 +447,14 @@ bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
}
/*************************************************************************************/
/*****************************************************************************/
bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
/*************************************************************************************/
{
/*****************************************************************************/
/* compare function for sorting labels
* by sheet
* in a sheet, by alphabetic order
*/
{
int ii;
wxString Text1, Text2;
......@@ -476,12 +482,12 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
/**************************************************************/
static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
{
/**************************************************************/
/* Remove sub components from the list, when multiples parts per package are found in this list
/* Remove sub components from the list, when multiples parts per package are
* found in this list
* The component list **MUST** be sorted by reference and by unit number
*/
{
SCH_COMPONENT* libItem;
wxString oldName;
wxString currName;
......@@ -497,7 +503,8 @@ static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
if( !oldName.IsEmpty() )
{
if( oldName == currName ) // currName is a subpart of oldName: remove it
if( oldName == currName ) // currName is a subpart of oldName:
// remove it
{
aList.erase( aList.begin() + ii );
ii--;
......@@ -508,13 +515,14 @@ static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
}
/*******************************************************************************************/
/****************************************************************************/
void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
bool CompactForm )
/*******************************************************************************************/
{
/****************************************************************************/
// @todo make this variable length
const wxCheckBox* FieldListCtrl[] = {
const wxCheckBox* FieldListCtrl[] =
{
m_AddField1,
m_AddField2,
m_AddField3,
......@@ -526,17 +534,18 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
};
int ii;
const wxCheckBox* FieldCtrl = FieldListCtrl[0];
const wxCheckBox* FieldCtrl = FieldListCtrl[0];
if( m_AddFootprintField->IsChecked() )
{
if( CompactForm )
{
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
}
else
fprintf( f, "; %-12s", CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
fprintf( f, "; %-12s",
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
}
for( ii = FIELD1; ii < DrawLibItem->GetFieldCount(); ii++ )
......@@ -557,24 +566,24 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
if( CompactForm )
fprintf( f, "%c%s", s_ExportSeparatorSymbol,
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
else
fprintf( f, "; %-12s", CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
fprintf( f, "; %-12s",
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
}
}
/*********************************************************************************************/
/****************************************************************************/
int DIALOG_BUILD_BOM::PrintComponentsListByRef(
FILE* f,
std::vector <OBJ_CMP_TO_LIST>& aList,
bool CompactForm,
bool aIncludeSubComponents )
/*********************************************************************************************/
{
/****************************************************************************/
/* Print the B.O.M sorted by reference
*/
{
int Multi, Unit;
EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem;
......@@ -585,7 +594,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
if( CompactForm )
{
// @todo make this variable length
const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] = {
const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] =
{
m_AddField1,
m_AddField2,
m_AddField3,
......@@ -618,7 +628,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
continue;
msg = _( "Field" );
fprintf( f, "%c%s%d", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ), ii - FIELD1 + 1 );
fprintf( f, "%c%s%d", s_ExportSeparatorSymbol, CONV_TO_UTF8(
msg ), ii - FIELD1 + 1 );
}
fprintf( f, "\n" );
......@@ -653,15 +664,11 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
Multi = Entry->GetPartCount();
if( ( Multi > 1 ) && aIncludeSubComponents )
#if defined (KICAD_GOST)
#if defined(KICAD_GOST)
Unit = aList[ii].m_Unit + '1' - 1;
#else
Unit = aList[ii].m_Unit + 'A' - 1;
#endif
......@@ -671,10 +678,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
if( CompactForm )
fprintf( f, "%s%c%s", CmpName, s_ExportSeparatorSymbol,
CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) );
CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) );
else
fprintf( f, "| %-10s %-12s", CmpName,
CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) );
CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) );
if( aIncludeSubComponents )
{
......@@ -683,14 +690,17 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
{
fprintf( f, "%c%s", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences(
(BASE_SCREEN*) DrawLibItem->GetParent(), DrawLibItem->m_Pos );
fprintf( f, "%c%s)", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) );
(BASE_SCREEN*) DrawLibItem->GetParent(),
DrawLibItem->m_Pos );
fprintf( f, "%c%s)", s_ExportSeparatorSymbol,
CONV_TO_UTF8( msg ) );
}
else
{
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences(
(BASE_SCREEN*) DrawLibItem->GetParent(), DrawLibItem->m_Pos );
(BASE_SCREEN*) DrawLibItem->GetParent(),
DrawLibItem->m_Pos );
fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) );
}
}
......@@ -709,13 +719,13 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
}
/*********************************************************************************************/
/*****************************************************************************/
int DIALOG_BUILD_BOM::PrintComponentsListByVal(
FILE* f,
std::vector <OBJ_CMP_TO_LIST>& aList,
bool aIncludeSubComponents )
/**********************************************************************************************/
{
/*****************************************************************************/
int Multi;
wxChar Unit;
EDA_BaseStruct* DrawList;
......@@ -764,8 +774,9 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
sprintf( CmpName, "%s%c", aList[ii].m_Reference, Unit );
#endif
fprintf( f, "| %-12s %-10s", CONV_TO_UTF8( DrawLibItem->GetField(
VALUE )->m_Text ), CmpName );
fprintf( f, "| %-12s %-10s",
CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ),
CmpName );
// print the sheet path
if( aIncludeSubComponents )
......@@ -790,8 +801,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
/************************************************************************/
static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
/************************************************************************/
{
/************************************************************************/
SCH_LABEL* DrawTextItem;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
wxString msg, sheetpath;
......@@ -803,7 +814,7 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
{
case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL:
DrawTextItem = (SCH_LABEL*)(aList[ii].m_Label);
DrawTextItem = (SCH_LABEL*) (aList[ii].m_Label);
if( aList[ii].m_LabelType == TYPE_SCH_HIERLABEL )
labeltype = wxT( "Hierarchical" );
......@@ -824,7 +835,8 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
{
DrawSheetLabel = (Hierarchical_PIN_Sheet_Struct*) aList[ii].m_Label;
DrawSheetLabel =
(Hierarchical_PIN_Sheet_Struct*) aList[ii].m_Label;
int jj = DrawSheetLabel->m_Shape;
if( jj < 0 )
jj = NET_TMAX;
......@@ -855,15 +867,14 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
/********************************************/
int RefDesStringCompare( const char* obj1, const char* obj2 )
{
/********************************************/
/* This function will act just like the strcmp function but correctly sort
* the numerical order in the string
* return -1 if first string is less than the second
* return 0 if the strings are equal
* return 1 if the first string is greater than the second
*/
{
/* The strings we are going to compare */
wxString strFWord;
wxString strSWord;
......@@ -877,14 +888,16 @@ int RefDesStringCompare( const char* obj1, const char* obj2 )
int isEqual = 0; /* The numerical results of a string compare */
int iReturn = 0; /* The variable that is being returned */
long lFirstDigit = 0; /* The converted middle section of the first string */
long lSecondDigit = 0; /* The converted middle section of the second string */
long lFirstDigit = 0; /* The converted middle section of the first
*string */
long lSecondDigit = 0; /* The converted middle section of the second
*string */
/* Since m_Ref is a char * it is ASCII */
strFWord = wxString::FromAscii( obj1 );
strSWord = wxString::FromAscii( obj2 );
/* Split the two string into seperate parts */
/* Split the two string into separate parts */
SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
......@@ -920,20 +933,19 @@ int RefDesStringCompare( const char* obj1, const char* obj2 )
}
/**************************************************************************************************/
/****************************************************************************/
int SplitString( wxString strToSplit,
wxString* strBeginning,
wxString* strDigits,
wxString* strEnd )
/**************************************************************************************************/
{
/****************************************************************************/
/* This is the function that breaks a string into three parts.
* The alphabetic preamble
* The numeric part
* Any alphabetic ending
* For example C10A is split to C 10 A
*/
{
/* Clear all the return strings */
strBeginning->Clear();
strDigits->Clear();
......@@ -971,7 +983,8 @@ int SplitString( wxString strToSplit,
if( ii < 0 )
*strDigits = strToSplit.substr( 0, position );
/* We were only looking for the last set of digits everything else is part of the preamble */
/* We were only looking for the last set of digits everything else is
*part of the preamble */
else
{
*strDigits = strToSplit.substr( ii + 1, position - ii - 1 );
......
/*********************************************************/
/* Modules de creations de Traits, Wires, Bus, Junctions */
/*********************************************************/
/***************************************************************/
/* Code for handling creation of buses, wires, and junctions. */
/***************************************************************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -15,31 +15,34 @@
/* Routines Locales */
static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase );
static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC );
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer );
static bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos );
static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_pos );
static void ComputeBreakPoint( EDA_DrawLineStruct* segment,
const wxPoint& new_pos );
SCH_ITEM* s_OldWiresList;
wxPoint s_ConnexionStartPoint;
wxPoint s_ConnexionStartPoint;
/*********************************************************/
SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
{
/*********************************************************/
/* Extract the old wires, junctions and busses, an if CreateCopy replace them by a copy.
* Old ones must be put in undo list, and the new ones can be modified by clean up
* safely.
* If an abord command is made, old wires must be put in EEDrawList, and copies must be deleted
* This is because previously stored undo commands can handle pointers on wires or bus,
* and we do not delete wires or bus, we must put they in undo list.
/* Extract the old wires, junctions and buses, an if CreateCopy replace them
* by a copy. Old ones must be put in undo list, and the new ones can be
* modified by clean up safely.
* If an abort command is made, old wires must be put in EEDrawList, and
* copies must be deleted. This is because previously stored undo commands
* can handle pointers on wires or bus, and we do not delete wires or bus,
* we must put they in undo list.
*
* Because cleanup delete and/or modify bus and wires, the more easy is to put all wires in undo list
* and use a new copy of wires for cleanup
* Because cleanup delete and/or modify bus and wires, the more easy is to put
* all wires in undo list and use a new copy of wires for cleanup.
*/
{
SCH_ITEM* item, * next_item, * new_item, * List = NULL;
for( item = EEDrawList; item != NULL; item = next_item )
......@@ -75,11 +78,10 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
/*************************************************/
static void RestoreOldWires( SCH_SCREEN* screen )
{
/*************************************************/
/* Replace the wires in screen->EEDrawList by s_OldWiresList wires.
*/
{
SCH_ITEM* item;
SCH_ITEM* next_item;
......@@ -105,24 +107,23 @@ static void RestoreOldWires( SCH_SCREEN* screen )
next_item = s_OldWiresList->Next();
s_OldWiresList->SetNext( screen->EEDrawList );
screen->EEDrawList = s_OldWiresList;
s_OldWiresList = next_item;
screen->EEDrawList = s_OldWiresList;
s_OldWiresList = next_item;
}
}
/*************************************************************/
void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
{
/*************************************************************/
/* Creates a new segment ( WIRE, BUS ),
* or terminates the current segment
* If the end of the current segment is on an other segment, place a junction if needed
* and terminates the command
* If the end of the current segment is on an other segment, place a junction
* if needed and terminates the command
* If the end of the current segment is on a pin, terminates the command
* In others cases starts a new segment
*/
{
EDA_DrawLineStruct* oldsegment, * newsegment, * nextsegment;
wxPoint cursorpos = GetScreen()->m_Curseur;
......@@ -145,11 +146,11 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
oldsegment = newsegment =
(EDA_DrawLineStruct*) GetScreen()->GetCurItem();
if( !newsegment ) /* first point : Create first wire ou bus */
if( !newsegment ) /* first point : Create first wire or bus */
{
s_ConnexionStartPoint = cursorpos;
s_OldWiresList = ((SCH_SCREEN*)GetScreen())->ExtractWires( TRUE );
((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL );
s_OldWiresList = ( (SCH_SCREEN*) GetScreen() )->ExtractWires( TRUE );
( (SCH_SCREEN*) GetScreen() )->SchematicCleanUp( NULL );
switch( type )
{
......@@ -160,8 +161,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
case LAYER_WIRE:
newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_WIRE );
/* A junction will be created later, when w'll know the
* segment end position, and if the junction is really needed */
/* A junction will be created later, when we'll know the
* segment end position, and if the junction is really needed */
break;
case LAYER_BUS:
......@@ -170,7 +171,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
}
newsegment->m_Flags = IS_NEW;
if( g_HVLines ) // We need 2 segments to go from a given start pint to an end point
if( g_HVLines ) // We need 2 segments to go from a given start pint to
// an end point
{
nextsegment = newsegment->GenCopy();
nextsegment->m_Flags = IS_NEW;
......@@ -182,17 +184,20 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine;
g_ItemToRepeat = NULL;
}
else /* A segment is in progress: terminates the current segment and add a new segment */
else /* A segment is in progress: terminates the current segment and add
* a new segment */
{
nextsegment = oldsegment->Next();
if( !g_HVLines )
{ /* if only one segment is needed and the current is has len = 0, do not create a new one*/
if( !g_HVLines ) /* if only one segment is needed and the current is
* has len = 0, do not create a new one */
{
if( oldsegment->IsNull() )
return;
}
else
{
/* if we want 2 segment and the last two have len = 0, do not create a new one*/
/* if we want 2 segment and the last two have len = 0, do not
* create a new one */
if( oldsegment->IsNull() && nextsegment && nextsegment->IsNull() )
return;
}
......@@ -200,13 +205,12 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
/* Creates the new segment, or terminates the command
* if the end point is on a pin, jonction or an other wire or bus */
* if the end point is on a pin, junction or an other wire or bus */
if( IsTerminalPoint( GetScreen(), cursorpos, oldsegment->GetLayer() ) )
{
EndSegment( DC ); return;
}
/* Placement en liste generale */
oldsegment->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = oldsegment;
DrawPanel->CursorOff( DC ); // Erase schematic cursor
......@@ -233,11 +237,13 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
newsegment->m_Flags = IS_NEW;
GetScreen()->SetCurItem( newsegment );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
/* This is the first segment: Now we know the start segment position.
* Create a junction if needed. Note: a junction can be needed later,
* if the new segment is merged (after a cleanup) with an older one
* (tested when the connection will be finished)*/
if( oldsegment->m_Start == s_ConnexionStartPoint )
{ /* This is the first segment: Now we know the start segment position.
* Create a junction if needed. Note: a junction can be needed
* later, if the new segment is merged (after a cleanup) with an older one
* (tested when the connection will be finished)*/
{
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
CreateNewJunctionStruct( DC, s_ConnexionStartPoint );
}
......@@ -247,13 +253,13 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
/***********************************************/
void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
{
/***********************************************/
/* Called to terminate a bus, wire, or line creation
*/
{
EDA_DrawLineStruct* firstsegment = (EDA_DrawLineStruct*) GetScreen()->GetCurItem();
EDA_DrawLineStruct* lastsegment = firstsegment;
EDA_DrawLineStruct* firstsegment =
(EDA_DrawLineStruct*) GetScreen()->GetCurItem();
EDA_DrawLineStruct* lastsegment = firstsegment;
EDA_DrawLineStruct* segment;
if( firstsegment == NULL )
......@@ -285,12 +291,11 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
while( segment )
{
lastsegment = segment;
segment = segment->Next();
segment = segment->Next();
lastsegment->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = lastsegment;
}
/* Fin de trace */
DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
......@@ -299,16 +304,16 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
/* A junction can be needed to connect the last segment
* usually to m_End coordinate.
* But if the last segment is removed by a cleanup, because od redundancy,
* a junction can be needed to connect the previous segment m_End coordinate
* with is also the lastsegment->m_Start coordinate */
* But if the last segment is removed by a cleanup, because of redundancy,
* a junction can be needed to connect the previous segment m_End
* coordinate with is also the lastsegment->m_Start coordinate */
if( lastsegment )
{
end_point = lastsegment->m_End;
alt_end_point = lastsegment->m_Start;
}
((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL );
( (SCH_SCREEN*) GetScreen() )->SchematicCleanUp( NULL );
/* clear flags and find last segment entered, for repeat function */
segment = (EDA_DrawLineStruct*) GetScreen()->EEDrawList;
......@@ -333,8 +338,8 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
CreateNewJunctionStruct( DC, alt_end_point );
}
/* Automatic place of a junction on the start point if necessary because the
* Cleanup can suppress intermediate points by merging wire segments*/
/* Automatic place of a junction on the start point if necessary because
* the cleanup can suppress intermediate points by merging wire segments */
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
CreateNewJunctionStruct( DC, s_ConnexionStartPoint );
......@@ -350,7 +355,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
{
case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE:
DrawPanel->PostDirtyRect(item->GetBoundingBox());
DrawPanel->PostDirtyRect( item->GetBoundingBox() );
break;
default:
......@@ -372,12 +377,12 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
/****************************************************************************/
static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
/****************************************************************************/
/* Redraw the segment (g_HVLines == FALSE ) or the two segments (g_HVLines == TRUE )
/* Redraw the segment (g_HVLines == FALSE ) or the two segments (g_HVLines ==
* TRUE )
* from the start point to the cursor, when moving the mouse
*/
{
EDA_DrawLineStruct* CurrentLine =
(EDA_DrawLineStruct*) panel->GetScreen()->GetCurItem();
EDA_DrawLineStruct* segment;
......@@ -393,7 +398,7 @@ static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
segment = CurrentLine;
while( segment )
{
if( !segment->IsNull() ) // Redraw if segment lengtht != 0
if( !segment->IsNull() ) // Redraw if segment length != 0
RedrawOneStruct( panel, DC, segment, g_XorMode, color );
segment = segment->Next();
}
......@@ -410,21 +415,22 @@ static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
segment = CurrentLine;
while( segment )
{
if( !segment->IsNull() ) // Redraw if segment lengtht != 0
if( !segment->IsNull() ) // Redraw if segment length != 0
RedrawOneStruct( panel, DC, segment, g_XorMode, color );
segment = segment->Next();
}
}
/**************************************************************************************/
static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_pos )
/**************************************************************************************/
/* compute the middle coordinate for 2 segments, from the start point to new_pos
/***************************************************************************/
static void ComputeBreakPoint( EDA_DrawLineStruct* segment,
const wxPoint& new_pos )
{
/***************************************************************************/
/* compute the middle coordinate for 2 segments, from the start point to
* new_pos
* with the 2 segments kept H or V only
*/
{
EDA_DrawLineStruct* nextsegment = segment->Next();
wxPoint middle_position = new_pos;
......@@ -439,11 +445,13 @@ static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_p
#else
int iDx = segment->m_End.x - segment->m_Start.x;
int iDy = segment->m_End.y - segment->m_Start.y;
if( iDy != 0 ) // keep the first segment orientation (currently horizontal)
if( iDy != 0 ) // keep the first segment orientation (currently
// horizontal)
{
middle_position.x = segment->m_Start.x;
}
else if( iDx != 0 ) // keep the first segment orientation (currently vertical)
else if( iDx != 0 ) // keep the first segment orientation (currently
// vertical)
{
middle_position.y = segment->m_Start.y;
}
......@@ -465,12 +473,13 @@ static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_p
/*****************************************************************************/
static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel,
wxDC* DC,
bool erase )
{
/*****************************************************************************/
/* Dessin du du Polyline Fantome lors des deplacements du curseur
/* Drawing Polyline phantom at the displacement of the cursor
*/
{
DrawPolylineStruct* NewPoly =
(DrawPolylineStruct*) panel->GetScreen()->GetCurItem();
int color;
......@@ -502,12 +511,11 @@ static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool eras
/**********************************************************/
void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
{
/**********************************************************/
/*
* Routine effacant le dernier trait trace, ou l'element pointe par la souris
* Erase the last trace or the element at the current mouse position.
*/
{
g_ItemToRepeat = NULL;
if( (GetScreen()->GetCurItem() == NULL)
......@@ -516,17 +524,18 @@ void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
return;
}
/* Trace en cours: annulation */
/* Cancel trace in progress */
if( GetScreen()->GetCurItem()->Type() == DRAW_POLYLINE_STRUCT_TYPE )
{
Show_Polyline_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */
Show_Polyline_in_Ghost( DrawPanel, DC, FALSE );
}
else
{
Segment_in_Ghost( DrawPanel, DC, FALSE ); /* Effacement du trace en cours */
Segment_in_Ghost( DrawPanel, DC, FALSE );
}
EraseStruct( (SCH_ITEM*) GetScreen()->GetCurItem(), (SCH_SCREEN*)GetScreen() );
EraseStruct( (SCH_ITEM*) GetScreen()->GetCurItem(),
(SCH_SCREEN*) GetScreen() );
DrawPanel->ManageCurseur = NULL;
GetScreen()->SetCurItem( NULL );
}
......@@ -535,11 +544,10 @@ void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
/***************************************************************************/
DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct(
wxDC* DC, const wxPoint& pos, bool PutInUndoList )
{
/***************************************************************************/
/* Routine to create new connection struct.
*/
{
DrawJunctionStruct* NewJunction;
NewJunction = new DrawJunctionStruct( pos );
......@@ -561,11 +569,9 @@ DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct(
/*******************************************************************************/
DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC )
/*******************************************************************************/
/*Routine to create new NoConnect struct. ( Symbole de Non Connexion)
*/
{
/*******************************************************************************/
/* Routine to create new NoConnect struct. */
DrawNoConnectStruct* NewNoConnect;
NewNoConnect = new DrawNoConnectStruct( GetScreen()->m_Curseur );
......@@ -585,14 +591,13 @@ DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC )
/*****************************************************************/
static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
{
/*****************************************************************/
/* Abort function for wire, bus or line creation
*/
{
SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->GetScreen();
if( Screen->GetCurItem() ) /* trace en cours */
if( Screen->GetCurItem() )
{
Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL;
......@@ -602,9 +607,9 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->Refresh();
}
else
g_ItemToRepeat = NULL; // Fin de commande generale
g_ItemToRepeat = NULL;
/* Clear m_Flags wich is used in edit functions: */
/* Clear m_Flags which is used in edit functions: */
SCH_ITEM* item = Screen->EEDrawList;
while( item )
{
......@@ -616,14 +621,12 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
/***************************************************/
void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
{
/***************************************************/
/* Routine de recopie du dernier element dessine
* Les elements duplicables sont
* fils, bus, traits, textes, labels
* Les labels termines par un nombre seront incrementes
/* Repeat the last item placement.
* Bus lines, text, labels
* Labels that end with a number will be incremented.
*/
{
wxPoint new_pos;
if( g_ItemToRepeat == NULL )
......@@ -653,7 +656,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text );
break;
......@@ -664,7 +666,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text );
break;
......@@ -675,7 +676,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text );
break;
......@@ -685,7 +685,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text );
break;
......@@ -706,21 +705,22 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
new_pos = STRUCT->m_Pos;
break;
case TYPE_SCH_COMPONENT: // In repeat command the new component is put in move mode
case TYPE_SCH_COMPONENT: // In repeat command the new component is put
// in move mode
#undef STRUCT
#define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat )
// Create the duplicate component, position = mouse cursor
g_ItemToRepeat = STRUCT->GenCopy();
new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x;
new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y;
STRUCT->m_Pos = GetScreen()->m_Curseur;
new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x;
new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y;
STRUCT->m_Pos = GetScreen()->m_Curseur;
STRUCT->m_Flags = IS_NEW;
STRUCT->m_TimeStamp = GetTimeStamp();
for( int ii = 0; ii < STRUCT->GetFieldCount(); ii++ )
{
STRUCT->GetField(ii)->m_Pos += new_pos;
STRUCT->GetField( ii )->m_Pos += new_pos;
}
RedrawOneStruct( DrawPanel, DC, STRUCT, g_XorMode );
......@@ -743,20 +743,19 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
SaveCopyInUndoList( g_ItemToRepeat, UR_NEW );
g_ItemToRepeat->m_Flags = 0;
// GetScreen()->Curseur = new_pos;
// DrawPanel->MouseTo( DrawPanel->CursorScreenPosition() );
// GetScreen()->Curseur = new_pos;
// DrawPanel->MouseTo( DrawPanel->CursorScreenPosition() );
}
}
/******************************************/
void IncrementLabelMember( wxString& name )
{
/******************************************/
/* Routine incrementant les labels, c'est a dire pour les textes finissant
* par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre
/* Routine incrementing labels, ie for the text ending with a number, adding
* that a number <RepeatDeltaLabel>
*/
{
int ii, nn;
long number = 0;
......@@ -781,8 +780,8 @@ void IncrementLabelMember( wxString& name )
/***************************************************************************/
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
{
/***************************************************************************/
/* Return TRUE if pos can be a terminal point for a wire or a bus
* i.e. :
* for a WIRE, if at pos is found:
......@@ -793,12 +792,11 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
* - for a BUS, if at pos is found:
* - a BUS
*/
{
EDA_BaseStruct* item;
LIB_PIN* pin;
SCH_COMPONENT* LibItem = NULL;
Hierarchical_PIN_Sheet_Struct* pinsheet;
wxPoint itempos;
Hierarchical_PIN_Sheet_Struct* pinsheet;
wxPoint itempos;
switch( layer )
{
......@@ -829,8 +827,8 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem );
if( pin && LibItem )
{
// calcul de la position exacte du point de connexion de la pin,
// selon orientation du composant:
// Calculate the exact position of the connection point of the pin,
// depending on orientation of the component.
itempos = LibItem->GetScreenCoord( pin->m_Pos );
itempos.x += LibItem->m_Pos.x;
itempos.y += LibItem->m_Pos.y;
......@@ -868,8 +866,8 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
/****************************************************************/
bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos )
{
/****************************************************************/
/* Return True when a wire is located at pos "pos" if
* - there is no junction.
* - The wire has no ends at pos "pos",
......@@ -878,13 +876,14 @@ bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos )
* or
* - a pin is on location pos
*/
{
if( PickStruct( pos, frame->GetScreen(), JUNCTIONITEM ) )
return FALSE;
if( PickStruct( pos, frame->GetScreen(), WIREITEM | EXCLUDE_WIRE_BUS_ENDPOINTS ) )
if( PickStruct( pos, frame->GetScreen(), WIREITEM |
EXCLUDE_WIRE_BUS_ENDPOINTS ) )
{
if( PickStruct( pos, frame->GetScreen(), WIREITEM | WIRE_BUS_ENDPOINTS_ONLY ) )
if( PickStruct( pos, frame->GetScreen(), WIREITEM |
WIRE_BUS_ENDPOINTS_ONLY ) )
return TRUE;
if( frame->LocatePinEnd( frame->GetScreen()->EEDrawList, pos ) )
return TRUE;
......
/*************************************/
/* Modules de creations de Bus Entry */
/*************************************/
/*****************************************************/
/* Code to handle manipulation on bus entry objects. */
/*****************************************************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -13,21 +13,18 @@
#include "general.h"
#include "protos.h"
/* Routines Locales */
/* Variables locales */
static int s_LastShape = '\\';
static wxPoint ItemInitialPosition;
/**************************************************************/
static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
/**************************************************************/
/* Routine de sortie des menus de trace */
{
/**************************************************************/
/* Exit bus entry mode. */
DrawBusEntryStruct* BusEntry =
(DrawBusEntryStruct*) Panel->GetScreen()->GetCurItem();
if( BusEntry ) /* trace en cours */
if( BusEntry )
{
RedrawOneStruct( Panel, DC, BusEntry, g_XorMode );
if( BusEntry->m_Flags & IS_NEW )
......@@ -51,36 +48,36 @@ static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
/************************************************************************/
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/
/* Dessin du Segment "BusEntry" lors des deplacements du curseur
*/
{
/************************************************************************/
/* Drawing of the bus entry segment" while moving the cursor. */
BASE_SCREEN* screen = panel->GetScreen();
DrawBusEntryStruct* BusEntry = (DrawBusEntryStruct*) screen->GetCurItem();
if( BusEntry == NULL )
return;
/* effacement apres deplacement curseur */
/* Erase the last segment position. */
if( erase )
RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
/* Reaffichage au bon endroit */
/* Redraw at the new position. */
BusEntry->m_Pos = screen->m_Curseur;
RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
}
/**********************************************************************************/
DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_type )
DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC,
int entry_type )
{
/**********************************************************************************/
/* Create a new bus entry, and prepare moving function (for later place it)
*/
{
DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct( GetScreen()->m_Curseur,
s_LastShape, entry_type );
DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct(
GetScreen()->m_Curseur,
s_LastShape,
entry_type );
BusEntry->m_Flags = IS_NEW;
......@@ -98,12 +95,13 @@ DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_t
/**************************************************************************/
void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
wxDC* DC )
/**************************************************************************/
{
/**************************************************************************/
if( BusEntry == NULL )
return;
if( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save shape */
if( (BusEntry->m_Flags & IS_NEW) == 0 ) // => not already in edit, save
// shape */
{
delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy();
......@@ -126,13 +124,13 @@ void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
/************************************************************/
void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
DrawBusEntryStruct* BusEntry, int entry_shape )
void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
DrawBusEntryStruct* BusEntry,
int entry_shape )
{
/************************************************************/
/* set the shape of BusEntry (shape = / or \ )
*/
{
if( BusEntry == NULL )
return;
......@@ -169,8 +167,8 @@ void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
/************************************************************************/
int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct* BusEntry )
/************************************************************************/
{
/************************************************************************/
int entry_shape = '\\';
if( BusEntry->m_Size.y < 0 )
......
/////////////////////////////////////////////////////////////////////////////
// Name: class_drawsheet.cpp
// Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h
// Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h
// Author: jean-pierre Charras
// Modified by:
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright:
// Licence: License GNU
// License: License GNU
/////////////////////////////////////////////////////////////////////////////
#include "fctsys.h"
......@@ -26,13 +26,13 @@
/***********************************************************/
DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE )
/***********************************************************/
{
m_Label = NULL;
m_NbLabel = 0;
m_Layer = LAYER_SHEET;
m_Pos = pos;
m_TimeStamp = GetTimeStamp();
/***********************************************************/
m_Label = NULL;
m_NbLabel = 0;
m_Layer = LAYER_SHEET;
m_Pos = pos;
m_TimeStamp = GetTimeStamp();
m_SheetNameSize = m_FileNameSize = 60;
m_AssociatedScreen = NULL;
m_SheetName.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp );
......@@ -42,8 +42,8 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
/**************************************/
DrawSheetStruct::~DrawSheetStruct()
/**************************************/
{
/**************************************/
Hierarchical_PIN_Sheet_Struct* label = m_Label, * next_label;
while( label )
......@@ -67,7 +67,6 @@ DrawSheetStruct::~DrawSheetStruct()
/**********************************************/
bool DrawSheetStruct::Save( FILE* aFile ) const
/***********************************************/
/** Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
......@@ -87,13 +86,13 @@ bool DrawSheetStruct::Save( FILE* aFile ) const
return Success;
}
//save the unique timestamp, like other shematic parts.
//save the unique timestamp, like other schematic parts.
if( fprintf( aFile, "U %8.8lX\n", m_TimeStamp ) == EOF )
{
Success = false; return Success;
}
/* Generation de la liste des 2 textes (sheetname et filename) */
/* Save schematic sheetname and filename. */
if( !m_SheetName.IsEmpty() )
{
if( fprintf( aFile, "F0 \"%s\" %d\n", CONV_TO_UTF8( m_SheetName ),
......@@ -112,7 +111,7 @@ bool DrawSheetStruct::Save( FILE* aFile ) const
}
}
/* Generation de la liste des labels (entrees) de la sous feuille */
/* Create the list of labels in the sheet. */
SheetLabel = m_Label;
int l_id = 2;
while( SheetLabel != NULL )
......@@ -130,12 +129,11 @@ bool DrawSheetStruct::Save( FILE* aFile ) const
/***********************************************/
DrawSheetStruct* DrawSheetStruct::GenCopy()
{
/***********************************************/
/* creates a copy of a sheet
* The linked data itself (EEDrawList) is not duplicated
*/
{
DrawSheetStruct* newitem = new DrawSheetStruct( m_Pos );
......@@ -143,11 +141,14 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
newitem->SetParent( m_Parent );
newitem->m_TimeStamp = GetTimeStamp();
newitem->m_FileName = m_FileName;
newitem->m_FileNameSize = m_FileNameSize;
/* newitem->m_SheetName = m_SheetName; m_SheetName must be unique for all sub sheets in a given sheet
* so we no not duplicate sheet name
*/
newitem->m_FileName = m_FileName;
newitem->m_FileNameSize = m_FileNameSize;
/* newitem->m_SheetName = m_SheetName; m_SheetName must be unique for
* all sub sheets in a given sheet
* so we no not duplicate sheet
* name
*/
newitem->m_SheetNameSize = m_SheetNameSize;
newitem->m_Label = NULL;
......@@ -180,12 +181,11 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
/**********************************************************/
void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem )
{
/**********************************************************/
/* Used if undo / redo command:
* swap data between this and copyitem
*/
{
EXCHG( m_Pos, copyitem->m_Pos );
EXCHG( m_Size, copyitem->m_Size );
EXCHG( m_SheetName, copyitem->m_SheetName );
......@@ -194,7 +194,8 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem )
EXCHG( m_Label, copyitem->m_Label );
EXCHG( m_NbLabel, copyitem->m_NbLabel );
// Ensure sheet labels have their .m_Parent member poiuntin really on their parent, after swapping.
// Ensure sheet labels have their .m_Parent member poiuntin really on their
// parent, after swapping.
Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label )
{
......@@ -213,10 +214,11 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem )
/********************************************************************/
void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/********************************************************************/
{
/* Placement en liste des structures si nouveau composant:*/
/********************************************************************/
/* Place list structures for new sheet. */
bool isnew = (m_Flags & IS_NEW) ? true : false;
if( isnew )
{
if( !frame->EditSheet( this, DC ) )
......@@ -231,7 +233,7 @@ void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
}
SCH_ITEM::Place( frame, DC ); //puts it on the EEDrawList.
if ( isnew )
if( isnew )
{
frame->SetSheetNumberAndCount();
}
......@@ -239,15 +241,15 @@ void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/********************************************************************/
void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw )
void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame,
bool aRedraw )
{
/********************************************************************/
/** Function CleanupSheet
* Delete pinsheets which are not corresponding to a hierarchal label
* Delete pinsheets which are not corresponding to a hierarchical label
* @param aRedraw = true to redraw Sheet
* @param aFrame = the schematic frame
*/
{
Hierarchical_PIN_Sheet_Struct* Pinsheet, * NextPinsheet;
if( !IsOK( aFrame, _( "Ok to cleanup this sheet" ) ) )
......@@ -267,7 +269,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw
HLabel = (SCH_HIERLABEL*) DrawStruct;
if( Pinsheet->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
break; // Found!
break; // Found!
HLabel = NULL;
}
......@@ -289,26 +291,27 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int DrawSheetStruct::GetPenSize( )
int DrawSheetStruct::GetPenSize()
{
return g_DrawDefaultLineThickness;
}
/**************************************************************************************/
/*****************************************************************************/
void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode, int aColor )
/**************************************************************************************/
{
/*****************************************************************************/
/** Function Draw
* Draw the hierarchical sheet shape
* @param aPanel = the current DrawPanel
* @param aDc = the current Device Context
* @param aOffset = draw offset (usually wxPoint(0,0))
* @param aDrawMode = draw mode
* @param aColor = color used to draw sheet. Usually -1 to use the normal color for sheet items
* @param aColor = color used to draw sheet. Usually -1 to use the normal
* color for sheet items
*/
{
Hierarchical_PIN_Sheet_Struct* SheetLabelStruct;
int txtcolor;
wxString Text;
......@@ -332,10 +335,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
txtcolor = ReturnLayerColor( LAYER_SHEETNAME );
Text = wxT( "Sheet: " ) + m_SheetName;
DrawGraphicText( aPanel, aDC,
wxPoint( pos.x, pos.y - 8 ), (EDA_Colors) txtcolor,
Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth, false, false, false );
DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y - 8 ),
(EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ,
wxSize( m_SheetNameSize, m_SheetNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth,
false, false, false );
/* Draw text : FileName */
if( aColor >= 0 )
......@@ -343,11 +347,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
else
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
Text = wxT( "File: " ) + m_FileName;
DrawGraphicText( aPanel, aDC,
wxPoint( pos.x, pos.y + m_Size.y + 4 ),
(EDA_Colors) txtcolor,
Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth, false, false, false );
DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y + m_Size.y + 4 ),
(EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ,
wxSize( m_FileNameSize, m_FileNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth,
false, false, false );
/* Draw text : SheetLabel */
......@@ -363,12 +367,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
/*****************************************/
EDA_Rect DrawSheetStruct::GetBoundingBox()
{
/*****************************************/
/** Function GetBoundingBox
* @return an EDA_Rect giving the bouding box of the sheet
* @return an EDA_Rect giving the bounding box of the sheet
*/
{
int dx, dy;
// Determine length of texts
......@@ -381,32 +384,34 @@ EDA_Rect DrawSheetStruct::GetBoundingBox()
dx = MAX( m_Size.x, textlen1 );
dy = m_Size.y + m_SheetNameSize + m_FileNameSize + 16;
EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y - m_SheetNameSize - 8 ), wxSize( dx, dy ) );
EDA_Rect box( wxPoint( m_Pos.x, m_Pos.y - m_SheetNameSize - 8 ),
wxSize( dx, dy ) );
return box;
}
/************************************************/
bool DrawSheetStruct::HitTest( const wxPoint& aPosRef )
{
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/************************************/
int DrawSheetStruct::ComponentCount()
{
/************************************/
/** Function ComponentCount
* count our own components, without the power components.
* @return the copponent count.
* @return the component count.
*/
{
int n = 0;
if( m_AssociatedScreen )
......@@ -431,17 +436,17 @@ int DrawSheetStruct::ComponentCount()
}
/*******************************************************************************/
bool DrawSheetStruct::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen )
/*******************************************************************************/
/*****************************************************************************/
bool DrawSheetStruct::SearchHierarchy( wxString aFilename,
SCH_SCREEN** aScreen )
{
/*****************************************************************************/
/** Function SearchHierarchy
* search the existing hierarchy for an instance of screen "FileName".
* @param aFilename = the filename to find
* @param aFilename = a location to return a pointer to the screen (if found)
* @return bool if found, and a pointer to the screen
*/
{
if( m_AssociatedScreen )
{
EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList;
......@@ -469,18 +474,18 @@ bool DrawSheetStruct::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen
/*******************************************************************************/
bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen,
DrawSheetPath* aList )
{
/*******************************************************************************/
/** Function LocatePathOfScreen
* search the existing hierarchy for an instance of screen "FileName".
* don't bother looking at the root sheet - it must be unique,
* no other references to its m_AssociatedScreen otherwise there would be loops
* no other references to its m_AssociatedScreen otherwise there would be
* loops
* in the hierarchy.
* @param aScreen = the SCH_SCREEN* screen that we search for
* @param aList = the DrawSheetPath* that must be used
* @return true if found
*/
{
if( m_AssociatedScreen )
{
aList->Push( this );
......@@ -506,8 +511,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen,
/**********************************************************/
bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame )
{
/***********************************************************/
/** Function Load.
* for the sheet: load the file m_FileName
* if a screen already exists, the file is already read.
......@@ -516,7 +521,6 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame )
* @param aFrame = a WinEDA_SchematicFrame pointer to the maim schematic frame
* @return true if OK
*/
{
bool success = true;
if( !m_AssociatedScreen )
......@@ -557,13 +561,13 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame )
/**********************************/
int DrawSheetStruct::CountSheets()
{
/**********************************/
/** Function CountSheets
* calculates the number of sheets found in "this"
* this number includes the full subsheets count
* @return the full count of sheets+subsheets contained by "this"
*/
{
int count = 1; //1 = this!!
if( m_AssociatedScreen )
......@@ -584,8 +588,8 @@ int DrawSheetStruct::CountSheets()
/******************************************/
wxString DrawSheetStruct::GetFileName( void )
/******************************************/
{
/******************************************/
return m_FileName;
}
......@@ -593,16 +597,18 @@ wxString DrawSheetStruct::GetFileName( void )
/************************************************************************/
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
const wxString& aFileName )
{
/************************************************************************/
/** Function ChangeFileName
* Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy.
* - if new filename is not already used: change to the new name (and if an existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the sheet.
* - if new filename is not already used: change to the new name (and if an
* existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the
* sheet.
* @param aFileName = the new filename
* @param aFrame = the schematic frame
*/
{
if( (GetFileName() == aFileName) && m_AssociatedScreen )
return true;
......@@ -611,45 +617,52 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
bool LoadFromFile = false;
if( g_RootSheet->SearchHierarchy( aFileName, &Screen_to_use ) ) //do we reload the data from the existing hierarchy
// do we reload the data from the existing hierarchy
if( g_RootSheet->SearchHierarchy( aFileName, &Screen_to_use ) )
{
if( m_AssociatedScreen ) //upon initial load, this will be null.
if( m_AssociatedScreen ) // upon initial load, this will be null.
{
msg.Printf( _(
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ),
aFileName.GetData() );
msg.Printf( _( "A Sub Hierarchy named %s exists, Use it (The \
data in this sheet will be replaced)?" ),
aFileName.GetData() );
if( !IsOK( NULL, msg ) )
{
DisplayInfoMessage( (wxWindow*)NULL, _( "Sheet Filename Renaming Aborted" ) );
DisplayInfoMessage( (wxWindow*) NULL,
_( "Sheet Filename Renaming Aborted" ) );
return false;
}
}
}
else if( wxFileExists( aFileName ) ) //do we reload the data from an existing file
else if( wxFileExists( aFileName ) ) // do we reload the data from
// an existing file
{
msg.Printf( _(
"A file named %s exists, load it (otherwise keep current sheet data if possible)?" ),
msg.Printf( _( "A file named %s exists, load it (otherwise keep \
current sheet data if possible)?" ),
aFileName.GetData() );
if( IsOK( NULL, msg ) )
{
LoadFromFile = true;
if( m_AssociatedScreen ) // Can be NULL if loading a file when creating a new sheet
// Can be NULL if loading a file when creating a new sheet.
if( m_AssociatedScreen )
{
m_AssociatedScreen->m_RefCount--; //be careful with these
m_AssociatedScreen->m_RefCount--; // be careful with these
if( m_AssociatedScreen->m_RefCount == 0 )
SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; //will be created later
m_AssociatedScreen = NULL; // will be created later
}
}
}
// if an associated screen exists, shared between this sheet and others sheets, what we do ?
// if an associated screen exists, shared between this sheet and others
// sheets, what we do ?
if( m_AssociatedScreen && ( m_AssociatedScreen->m_RefCount > 1 ) )
{
msg = _( "This sheet uses shared data in a complex hierarchy" );
msg << wxT( "\n" );
msg << _(
"Do we convert it in a simple hierarchical sheet (otherwise delete current sheet data)" );
msg << _( "Do we convert it in a simple hierarchical sheet (\
otherwise delete current sheet data)" );
if( IsOK( NULL, msg ) )
{
LoadFromFile = true;
......@@ -665,13 +678,14 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
SetFileName( aFileName );
// if we use new data (from file or from internal hierarchy), delete the current sheet data
// if we use new data (from file or from internal hierarchy), delete the
// current sheet data
if( m_AssociatedScreen && (LoadFromFile || Screen_to_use) )
{
m_AssociatedScreen->m_RefCount--;
if( m_AssociatedScreen->m_RefCount == 0 )
SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; //so that we reload..
m_AssociatedScreen = NULL; // so that we reload..
}
if( LoadFromFile )
......@@ -687,7 +701,7 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
if( !m_AssociatedScreen )
{
m_AssociatedScreen = new SCH_SCREEN();
m_AssociatedScreen->m_RefCount++; //be careful with these
m_AssociatedScreen->m_RefCount++; // be careful with these
}
m_AssociatedScreen->m_FileName = aFileName;
......@@ -708,7 +722,7 @@ void DrawSheetStruct::DisplayInfo( WinEDA_DrawFrame* frame )
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void DrawSheetStruct::Mirror_Y(int aYaxis_position)
void DrawSheetStruct::Mirror_Y( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
......@@ -716,7 +730,7 @@ void DrawSheetStruct::Mirror_Y(int aYaxis_position)
m_Pos.x -= m_Size.x;
Hierarchical_PIN_Sheet_Struct* label = m_Label;
Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label != NULL )
{
label->Mirror_Y( aYaxis_position );
......@@ -732,12 +746,12 @@ void DrawSheetStruct::Show( int nestLevel, std::ostream& os )
wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">"
<< " sheet_name=\"" << CONV_TO_UTF8( m_SheetName ) << '"'
<< ">\n";
<< " sheet_name=\"" << CONV_TO_UTF8( m_SheetName )
<< '"' << ">\n";
// show all the pins, and check the linked list integrity
Hierarchical_PIN_Sheet_Struct* label;
for( label = m_Label; label; label = label->Next() )
for( label = m_Label; label; label = label->Next() )
{
label->Show( nestLevel + 1, os );
}
......
/********************************************/
/* Definitions for the EESchema program: */
/* Definitions for the EESchema program: */
/********************************************/
#ifndef CLASS_DRAWSHEET_H
......@@ -10,8 +10,10 @@
extern DrawSheetStruct* g_RootSheet;
/* class Hierarchical_PIN_Sheet_Struct
* a Hierarchical_PIN_Sheet_Struct is for a hierarchical sheet like a pin for a component
* At root level, a Hierarchical_PIN_Sheet_Struct must be connected to a wire, bus or label
* a Hierarchical_PIN_Sheet_Struct is for a hierarchical sheet like a pin for
* a component
* At root level, a Hierarchical_PIN_Sheet_Struct must be connected to a wire,
* bus or label
* A sheet level it corresponds to a hierarchical label.
*/
class Hierarchical_PIN_Sheet_Struct : public SCH_ITEM,
......@@ -20,13 +22,13 @@ class Hierarchical_PIN_Sheet_Struct : public SCH_ITEM,
public:
int m_Edge, m_Shape;
bool m_IsDangling; // TRUE non connected
int m_Number; // used to numbered labels when writing data on file . m_Number >= 2
int m_Number; // used to numbered labels when writing data on file .
// m_Number >= 2
// value 0 is for sheet name and 1 for sheet filename
public:
Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent,
const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
public: Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent,
const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
~Hierarchical_PIN_Sheet_Struct() { }
......@@ -38,56 +40,67 @@ public:
Hierarchical_PIN_Sheet_Struct* GenCopy();
Hierarchical_PIN_Sheet_Struct* Next() { return (Hierarchical_PIN_Sheet_Struct*) Pnext; }
Hierarchical_PIN_Sheet_Struct* Next()
{
return ( Hierarchical_PIN_Sheet_Struct*) Pnext;
}
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int draw_mode, int Color = -1 );
void Place( WinEDA_SchematicFrame* frame,
wxDC* DC );
void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.sch" format.
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
#if defined (DEBUG)
#if defined(DEBUG)
// comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os );
void Show( int nestLevel, std::ostream& os );
#endif
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
virtual int GetPenSize();
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = list to fill with polygon corners coordinates
* @param Pos = Position of the shape
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos );
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
* @param aMoveVector = the displacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position)
virtual void Mirror_Y( int aYaxis_position )
{
m_Edge = m_Edge ? 0 : 1;
m_Edge = m_Edge ? 0 : 1;
m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
......@@ -96,32 +109,41 @@ public:
/* class DrawSheetStruct
* This class is the sheet symbol placed in a schematic, and is the entry point for a sub schematic
* This class is the sheet symbol placed in a schematic, and is the entry point
* for a sub schematic
*/
class DrawSheetStruct : public SCH_ITEM
{
public:
wxString m_SheetName; /*this is equivalent to C101 for components:
* it is stored in F0 ... of the file. */
wxString m_SheetName; /* this is equivalent to C101 for
* components: it is stored in F0 ...
* of the file. */
private:
wxString m_FileName; /*also in SCH_SCREEN (redundant),
* but need it here for loading after
* reading the sheet description from file. */
* reading the sheet description from
* file. */
public:
int m_SheetNameSize; /* Size (height) of the text, used to draw the sheet name */
int m_FileNameSize; /* Size (height) of the text, used to draw the file name */
int m_SheetNameSize; /* Size (height) of the text, used to
* draw the sheet name */
int m_FileNameSize; /* Size (height) of the text, used to
* draw the file name */
wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */
wxSize m_Size; /* Position and Size of *sheet symbol */
int m_Layer;
Hierarchical_PIN_Sheet_Struct* m_Label; /* Points de connection, linked list.*/
int m_NbLabel; /* Pins sheet (corresponding to hierarchical labels) count */
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which handle the physical data
* In complex hierarchies we can have many DrawSheetStruct using the same data
*/
public:
DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
Hierarchical_PIN_Sheet_Struct* m_Label; /* Points Be connection, linked
* list.*/
int m_NbLabel; /* Pins sheet (corresponding to
* hierarchical labels) count */
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which
* handle the physical data
* In complex hierarchies we
* can have many DrawSheetStruct
* using the same data
*/
public: DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
~DrawSheetStruct();
virtual wxString GetClass() const
{
......@@ -131,7 +153,8 @@ public:
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
......@@ -142,7 +165,7 @@ public:
void DisplayInfo( WinEDA_DrawFrame* frame );
/** Function CleanupSheet
* Delete pinsheets which are not corresponding to a hierarchal label
* Delete pinsheets which are not corresponding to a hierarchical label
* @param aRedraw = true to redraw Sheet
* @param aFrame = the schematic frame
*/
......@@ -151,7 +174,7 @@ public:
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
virtual int GetPenSize( );
virtual int GetPenSize();
/** Function Draw
* Draw the hierarchical sheet shape
......@@ -159,71 +182,80 @@ public:
* @param aDc = the current Device Context
* @param aOffset = draw offset (usually wxPoint(0,0))
* @param aDrawMode = draw mode
* @param aColor = color used to draw sheet. Usually -1 to use the normal color for sheet items
* @param aColor = color used to draw sheet. Usually -1 to use the normal
* color for sheet items
*/
void Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffset,
int aDrawMode, int aColor = -1 );
void Draw( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode,
int aColor = -1 );
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
bool HitTest( const wxPoint& aPosRef );
/** Function GetBoundingBox
* @return an EDA_Rect giving the bouding box of the sheet
* @return an EDA_Rect giving the bounding box of the sheet
*/
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox();
void SwapData( DrawSheetStruct* copyitem );
void SwapData( DrawSheetStruct* copyitem );
/** Function ComponentCount
* count our own components, without the power components.
* @return the component count.
*/
int ComponentCount();
int ComponentCount();
/** Function Load.
* for the sheet: load the file m_FileName
* if a screen already exists, the file is already read.
* m_AssociatedScreen point on the screen, and its m_RefCount is incremented
* m_AssociatedScreen point on the screen, and its m_RefCount is
* incremented
* else creates a new associated screen and load the data file.
* @param aFrame = a WinEDA_SchematicFrame pointer to the maim schematic frame
* @param aFrame = a WinEDA_SchematicFrame pointer to the maim schematic
* frame
* @return true if OK
*/
bool Load( WinEDA_SchematicFrame* aFrame );
bool Load( WinEDA_SchematicFrame* aFrame );
/** Function SearchHierarchy
* search the existing hierarchy for an instance of screen "FileName".
* @param aFilename = the filename to find
* @param aFilename = a location to return a pointer to the screen (if found)
* @param aFilename = a location to return a pointer to the screen (if
* found)
* @return bool if found, and a pointer to the screen
*/
bool SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen );
bool SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen );
/** Function LocatePathOfScreen
* search the existing hierarchy for an instance of screen "FileName".
* don't bother looking at the root sheet - it must be unique,
* no other references to its m_AssociatedScreen otherwise there would be loops
* no other references to its m_AssociatedScreen otherwise there would be
* loops
* in the hierarchy.
* @param aScreen = the SCH_SCREEN* screen that we search for
* @param aList = the DrawSheetPath* that must be used
* @return true if found
*/
bool LocatePathOfScreen( SCH_SCREEN* aScreen, DrawSheetPath* aList );
bool LocatePathOfScreen( SCH_SCREEN* aScreen,
DrawSheetPath* aList );
/** Function CountSheets
* calculates the number of sheets found in "this"
* this number includes the full subsheets count
* @return the full count of sheets+subsheets contained by "this"
*/
int CountSheets();
int CountSheets();
/** Function GetFileName
* return the filename corresponding to this sheet
* @return a wxString containing the filename
*/
wxString GetFileName( void );
wxString GetFileName( void );
// Set a new filename without changing anything else
void SetFileName( const wxString& aFilename )
......@@ -235,26 +267,30 @@ public:
/** Function ChangeFileName
* Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy.
* - if new filename is not already used: change to the new name (and if an existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the sheet.
* - if new filename is not already used: change to the new name (and if an
* existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the
* sheet.
* @param aFileName = the new filename
* @param aFrame = the schematic frame
*/
bool ChangeFileName( WinEDA_SchematicFrame* aFrame, const wxString& aFileName );
bool ChangeFileName( WinEDA_SchematicFrame* aFrame,
const wxString& aFileName );
//void RemoveSheet(DrawSheetStruct* sheet);
//to remove a sheet, just delete it
//-- the destructor should take care of everything else.
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
* @param aMoveVector = the displacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
Hierarchical_PIN_Sheet_Struct* label = m_Label;
Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label != NULL )
{
label->Move( aMoveVector );
......@@ -262,16 +298,17 @@ public:
}
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position);
virtual void Mirror_Y( int aYaxis_position );
#if defined (DEBUG)
#if defined(DEBUG)
// comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os );
void Show( int nestLevel, std::ostream& os );
#endif
};
......
/////////////////////////////////////////////////////////////////////////////
// Name: class_drawsheet.cpp
// Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h
// Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h
// Author: jean-pierre Charras
// Modified by:
// Licence: License GNU
// License: License GNU
/////////////////////////////////////////////////////////////////////////////
#include "fctsys.h"
......@@ -15,7 +16,7 @@
/**********************************************/
/* class to handle a serie of sheets *********/
/* class to handle a series of sheets *********/
/* a 'path' so to speak.. *********************/
/**********************************************/
DrawSheetPath::DrawSheetPath()
......@@ -26,22 +27,26 @@ DrawSheetPath::DrawSheetPath()
m_numSheets = 0;
}
/*********************************************************************************************/
bool DrawSheetPath::BuildSheetPathInfoFromSheetPathValue(const wxString & aPath, bool aFound )
/*********************************************************************************************/
/****************************************************************************/
bool DrawSheetPath::BuildSheetPathInfoFromSheetPathValue(
const wxString& aPath,
bool aFound )
{
/****************************************************************************/
/** Function BuildSheetPathInfoFromSheetPathValue
* Fill this with data to acces to the hierarchical sheet known by its path aPath
* Fill this with data to access to the hierarchical sheet known by its path
* aPath
* @param aPath = path of the sheet to reach (in non human readable format)
* @return true if success else false
*/
{
if ( aFound )
if( aFound )
return true;
if ( GetSheetsCount() == 0 )
if( GetSheetsCount() == 0 )
Push( g_RootSheet );
if ( aPath == Path() )
if( aPath == Path() )
return true;
SCH_ITEM* schitem = LastDrawList();
......@@ -51,25 +56,26 @@ bool DrawSheetPath::BuildSheetPathInfoFromSheetPathValue(const wxString & aPath,
{
DrawSheetStruct* sheet = (DrawSheetStruct*) schitem;
Push( sheet );
if ( aPath == Path() )
if( aPath == Path() )
return true;
if ( BuildSheetPathInfoFromSheetPathValue( aPath ) )
if( BuildSheetPathInfoFromSheetPathValue( aPath ) )
return true;
Pop();
}
schitem = schitem->Next();
}
return false;
}
/*******************************************************************/
int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const
/********************************************************************/
/** Function Cmp
* Compare if this is the same sheet path as aSheetPathToTest
* @param aSheetPathToTest = sheet path to compare
* @return -1 if differents, 0 if same
* @return -1 if different, 0 if same
*/
{
if( m_numSheets > aSheetPathToTest.m_numSheets )
......@@ -80,9 +86,11 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const
//otherwise, same number of sheets.
for( unsigned i = 0; i<m_numSheets; i++ )
{
if( m_sheets[i]->m_TimeStamp > aSheetPathToTest.m_sheets[i]->m_TimeStamp )
if( m_sheets[i]->m_TimeStamp >
aSheetPathToTest.m_sheets[i]->m_TimeStamp )
return 1;
if( m_sheets[i]->m_TimeStamp < aSheetPathToTest.m_sheets[i]->m_TimeStamp )
if( m_sheets[i]->m_TimeStamp <
aSheetPathToTest.m_sheets[i]->m_TimeStamp )
return -1;
}
......@@ -91,8 +99,8 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const
/** Function Last
* returns a pointer to the last sheet of the list
* One can see the others sheet as the "path" to reach this last sheet
* returns a pointer to the last sheet of the list
* One can see the others sheet as the "path" to reach this last sheet
*/
DrawSheetStruct* DrawSheetPath::Last()
{
......@@ -127,15 +135,16 @@ SCH_ITEM* DrawSheetPath::LastDrawList()
/**************************************************/
void DrawSheetPath::Push( DrawSheetStruct* aSheet )
{
/**************************************************/
/** Function Push
* store (push) aSheet in list
* @param aSheet = pointer to the DrawSheetStruct to store in list
*/
{
if( m_numSheets > DSLSZ )
wxMessageBox( wxT( "DrawSheetPath::Push() error: no room in buffer to store sheet" ) );
wxMessageBox( wxT( "DrawSheetPath::Push() error: no room in buffer \
to store sheet" ) );
if( m_numSheets < DSLSZ )
{
m_sheets[m_numSheets] = aSheet;
......@@ -145,12 +154,11 @@ void DrawSheetPath::Push( DrawSheetStruct* aSheet )
DrawSheetStruct* DrawSheetPath::Pop()
{
/** Function Pop
* retrieves (pop) the last entered sheet and remove it from list
* @return a DrawSheetStruct* pointer to the removed sheet in list
*/
{
if( m_numSheets > 0 )
{
m_numSheets--;
......@@ -161,20 +169,20 @@ DrawSheetStruct* DrawSheetPath::Pop()
wxString DrawSheetPath::Path()
{
/** Function Path
* the path uses the time stamps which do not changes even when editing sheet parameters
* the path uses the time stamps which do not changes even when editing sheet
* parameters
* a path is something like / (root) or /34005677 or /34005677/00AE4523
*/
{
wxString s, t;
s = wxT( "/" ); // This is the root path
//start at 1 to avoid the root sheet,
//which does not need to be added to the path
//it's timestamp changes anyway.
for( unsigned i = 1; i< m_numSheets; i++ )
// start at 1 to avoid the root sheet,
// which does not need to be added to the path
// it's timestamp changes anyway.
for( unsigned i = 1; i < m_numSheets; i++ )
{
t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp );
s = s + t;
......@@ -186,19 +194,19 @@ wxString DrawSheetPath::Path()
/******************************************/
wxString DrawSheetPath::PathHumanReadable()
{
/******************************************/
/** Function PathHumanReadable
* Return the sheet path in a readable form, i.e.
* as a path made from sheet names.
* (the "normal" path uses the time stamps which do not changes even when editing sheet parameters)
* (the "normal" path uses the time stamps which do not changes even when
* editing sheet parameters)
*/
{
wxString s, t;
s = wxT( "/" );
//start at 1 to avoid the root sheet, as above.
// start at 1 to avoid the root sheet, as above.
for( unsigned i = 1; i< m_numSheets; i++ )
{
s = s + m_sheets[i]->m_SheetName + wxT( "/" );
......@@ -210,8 +218,8 @@ wxString DrawSheetPath::PathHumanReadable()
/***********************************************/
void DrawSheetPath::UpdateAllScreenReferences()
/***********************************************/
{
/***********************************************/
EDA_BaseStruct* t = LastDrawList();
while( t )
......@@ -231,12 +239,12 @@ bool DrawSheetPath::operator=( const DrawSheetPath& d1 )
{
m_numSheets = d1.m_numSheets;
unsigned i;
for( i = 0; i<m_numSheets; i++ )
for( i = 0; i < m_numSheets; i++ )
{
m_sheets[i] = d1.m_sheets[i];
}
for( ; i<DSLSZ; i++ )
for( ; i < DSLSZ; i++ )
{
m_sheets[i] = 0;
}
......@@ -249,7 +257,7 @@ bool DrawSheetPath::operator==( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
return false;
for( unsigned i = 0; i<m_numSheets; i++ )
for( unsigned i = 0; i < m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
return false;
......@@ -263,7 +271,7 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
{
if( m_numSheets != d1.m_numSheets )
return true;
for( unsigned i = 0; i<m_numSheets; i++ )
for( unsigned i = 0; i < m_numSheets; i++ )
{
if( m_sheets[i] != d1.m_sheets[i] )
return true;
......@@ -280,13 +288,12 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
/*******************************************************/
EDA_SheetList::EDA_SheetList( DrawSheetStruct* aSheet )
{
/*******************************************************/
/* The constructor: build the list of sheets from aSheet.
* If aSheet == NULL (default) build the whole list of sheets in hierarchy
* So usually call it with no param.
*/
{
m_index = 0;
m_count = 0;
m_List = NULL;
......@@ -298,12 +305,11 @@ EDA_SheetList::EDA_SheetList( DrawSheetStruct* aSheet )
/*****************************************/
DrawSheetPath* EDA_SheetList::GetFirst()
{
/*****************************************/
/** Function GetFirst
* @return the first item (sheet) in m_List and prepare calls to GetNext()
*/
{
m_index = 0;
if( GetCount() > 0 )
return &( m_List[0] );
......@@ -313,12 +319,12 @@ DrawSheetPath* EDA_SheetList::GetFirst()
/*****************************************/
DrawSheetPath* EDA_SheetList::GetNext()
{
/*****************************************/
/** Function GetNext
* @return the next item (sheet) in m_List or NULL if no more item in sheet list
* @return the next item (sheet) in m_List or NULL if no more item in sheet
* list
*/
{
if( m_index < GetCount() )
m_index++;
return GetSheet( m_index );
......@@ -327,29 +333,29 @@ DrawSheetPath* EDA_SheetList::GetNext()
/************************************************/
DrawSheetPath* EDA_SheetList::GetSheet( int aIndex )
{
/************************************************/
/** Function GetSheet
* @return the item (sheet) in aIndex position in m_List or NULL if less than index items
* @return the item (sheet) in aIndex position in m_List or NULL if less than
* index items
* @param aIndex = index in sheet list to get the sheet
*/
{
if( aIndex < GetCount() )
return &(m_List[aIndex]);
return &( m_List[aIndex] );
return NULL;
}
/************************************************************************/
void EDA_SheetList::BuildSheetList( DrawSheetStruct* aSheet )
{
/************************************************************************/
/** Function BuildSheetList
* Build the list of sheets and their sheet path from the aSheet sheet
* if aSheet = g_RootSheet, the full sheet path list (and full sheet list) is built
* if aSheet = g_RootSheet, the full sheet path list (and full sheet list) is
* built
* @param aSheet = the starting sheet to build list
*/
{
if( m_List == NULL )
{
int count = aSheet->CountSheets();
......
/********************************************/
/* Definitions for the EESchema program: */
/* Definitions for the EESchema program: */
/********************************************/
#ifndef CLASS_DRAWSHEET_PATH_H
......@@ -8,51 +8,60 @@
#include "base_struct.h"
/** Info about complex hierarchies handling:
* A hierarchical schematic uses sheets (hierachical sheets) included in a given sheet.
* each sheet corresponds to a schematic drawing handled by a SCH_SCREEN structure
* a SCH_SCREEN structure contains drawings, and have a filename to write to its data.
* Also a SCH_SCREEN display a sheet number and the name of the sheet
* In simple (and flat) hierarchies a sheet is linked to a SCH_SCREEN,
* A hierarchical schematic uses sheets (hierarchical sheets) included in a
* given sheet. Rach sheet corresponds to a schematic drawing handled by a
* SCH_SCREEN structure. A SCH_SCREEN structure contains drawings, and have
* a filename to write it's data. Also a SCH_SCREEN display a sheet number
* and the name of the sheet.
*
* In simple (and flat) hierarchies a sheet is linked to a SCH_SCREEN,
* and a SCH_SCREEN is used by only one hierarchical sheet.
*
* In complex hierachies the same SCH_SCREEN (and its data) is shared between more than one sheet.
* Therefore subsheets (like subsheets in a SCH_SCREEN shared by many sheets) can be also shared
* So the same SCH_SCREEN must handle differents components references and parts selection
* depending on which sheet is currently selected, and how a given subsheet is selected.
* 2 sheets share the same SCH_SCREEN (the same drawings) if they have the same filename.
* In complex hierarchies the same SCH_SCREEN (and its data) is shared between
* more than one sheet. Therefore subsheets (like subsheets in a SCH_SCREEN
* shared by many sheets) can be also shared. So the same SCH_SCREEN must
* handle different components references and parts selection depending on
* which sheet is currently selected, and how a given subsheet is selected.
* 2 sheets share the same SCH_SCREEN (the same drawings) if they have the
* same filename.
*
* In kicad each component and sheet receives (when created) an unique identification called Time Stamp.
* So each sheet have 2 id : its time stamp (that cannot change) and its name
* ( that can be edited and therefore is not reliable for strong identification)
* Kicad uses therefore Time Stamp ( an unique 32 bit id), to identify sheets in hierarchies.
* A given sheet in a hierarchy is fully labelled by its path (or sheet path)
* that is the list of timestamp found to access it through the hierarchy
* the root sheet is /
* others have a path like /1234ABCD ou /4567FEDC/AA2233DD/
* of course this path can be displayed as human readable sheet name like :
* / or /sheet1/include_sheet/ or /sheet2/include_sheet/
* In Kicad each component and sheet receives (when created) an unique
* identification called Time Stamp. So each sheet has 2 ids: its time stamp
* (that cannot change) and its name ( that can be edited and therefore is
* not reliable for strong identification). Kicad uses Time Stamp ( a unique
* 32 bit id), to identify sheets in hierarchies.
* A given sheet in a hierarchy is fully labeled by its path (or sheet path)
* that is the list of time stamp found to access it through the hierarchy
* the root sheet is /. All other sheets have a path like /1234ABCD or
* /4567FEDC/AA2233DD/. This path can be displayed as human readable sheet
* name like: / or /sheet1/include_sheet/ or /sheet2/include_sheet/
*
* So to know for a given SCH_SCREEN (a given schematic drawings) we must:
* Handle all references possibilities.
* When acceded by a given selected sheet, display (update) the corresponding references and sheet path
* 1) Handle all references possibilities.
* 2) When acceded by a given selected sheet, display (update) the
* corresponding references and sheet path
*
* the class DrawSheetPath handles paths used to access a sheet
* the class EDA_SheetList allows to handle the full (or partial) list of sheets and their paths in a complex hierarchy.
* the class EDA_ScreenList allow to handle the list of SCH_SCREEN. It is useful to clear or save data,
* but is not suitable to handle the full complex hierarchy possibilities (useable in flat and simple hierarchies).
* The class DrawSheetPath handles paths used to access a sheet. The class
* EDA_SheetList allows to handle the full (or partial) list of sheets and
* their paths in a complex hierarchy. The class EDA_ScreenList allow to
* handle the list of SCH_SCREEN. It is useful to clear or save data,
* but is not suitable to handle the full complex hierarchy possibilities
* (usable in flat and simple hierarchies).
*/
/****************************************/
/* class to handle and acces to a sheet */
/* class to handle and access to a sheet */
/* a 'path' so to speak.. */
/****************************************/
/*
* The member m_sheets stores the list of sheets from the first (usually g_RootSheet)
* to a given sheet in last position.
* The last sheet is usually the sheet we want to select or reach. So Last() return this last sheet
* Others sheets are the "path" from the first to the last sheet
* The member m_sheets stores the list of sheets from the first (usually
* g_RootSheet)
* to a given sheet in last position.
* The last sheet is usually the sheet we want to select or reach. So Last()
* return this last sheet
* Others sheets are the "path" from the first to the last sheet
*/
class DrawSheetPath
{
......@@ -61,94 +70,103 @@ private:
public:
#define DSLSZ 32 // Max number of levels for a sheet path
DrawSheetStruct* m_sheets[DSLSZ];
DrawSheetStruct * m_sheets[DSLSZ];
public:
DrawSheetPath();
public: DrawSheetPath();
~DrawSheetPath() { };
void Clear()
{ m_numSheets = 0;
{
m_numSheets = 0;
}
unsigned GetSheetsCount()
{
return m_numSheets;
}
/** Function Cmp
* Compare if this is the same sheet path as aSheetPathToTest
* @param aSheetPathToTest = sheet path to compare
* @return -1 if differents, 0 if same
* @return -1 if different, 0 if same
*/
int Cmp( const DrawSheetPath& aSheetPathToTest ) const;
int Cmp( const DrawSheetPath& aSheetPathToTest ) const;
/** Function Last
* returns a pointer to the last sheet of the list
* One can see the others sheet as the "path" to reach this last sheet
* returns a pointer to the last sheet of the list
* One can see the others sheet as the "path" to reach this last sheet
*/
DrawSheetStruct* Last();
DrawSheetStruct* Last();
/** Function LastScreen
* @return the SCH_SCREEN relative to the last sheet in list
*/
SCH_SCREEN* LastScreen();
SCH_SCREEN* LastScreen();
/** Function LastScreen
* @return a pointer to the first schematic item handled by the
* SCH_SCREEN relative to the last sheet in list
*/
SCH_ITEM* LastDrawList();
SCH_ITEM* LastDrawList();
/** Function Push
* store (push) aSheet in list
* @param aSheet = pointer to the DrawSheetStruct to store in list
* Push is used when entered a sheet to select or analyse it
* Push is used when entered a sheet to select or analyze it
* This is like cd <directory> in directories navigation
*/
void Push( DrawSheetStruct* aSheet );
void Push( DrawSheetStruct* aSheet );
/** Function Pop
* retrieves (pop) the last entered sheet and remove it from list
* @return a DrawSheetStruct* pointer to the removed sheet in list
* Pop is used when leaving a sheet after a selection or analyse
* Pop is used when leaving a sheet after a selection or analyze
* This is like cd .. in directories navigation
*/
DrawSheetStruct* Pop();
DrawSheetStruct* Pop();
/** Function Path
* the path uses the time stamps which do not changes even when editing sheet parameters
* the path uses the time stamps which do not changes even when editing
* sheet parameters
* a path is something like / (root) or /34005677 or /34005677/00AE4523
*/
wxString Path();
wxString Path();
/** Function PathHumanReadable
* Return the sheet path in a readable form, i.e.
* as a path made from sheet names.
* (the "normal" path uses the time stamps which do not changes even when editing sheet parameters)
* (the "normal" path uses the time stamps which do not changes even when
* editing sheet parameters)
*/
wxString PathHumanReadable();
wxString PathHumanReadable();
/** Function BuildSheetPathInfoFromSheetPathValue
* Fill this with data to acces to the hierarchical sheet known by its path aPath
* Fill this with data to access to the hierarchical sheet known by its
* path aPath
* @param aPath = path of the sheet to reach (in non human readable format)
* @return true if success else false
*/
bool BuildSheetPathInfoFromSheetPathValue(const wxString & aPath, bool aFound = false );
bool BuildSheetPathInfoFromSheetPathValue(
const wxString& aPath,
bool aFound = false );
/**
* Function UpdateAllScreenReferences
* updates the reference and the m_Multi parameter (part selection) for all
* components on a screen depending on the actual sheet path.
* Mandatory in complex hierarchies because sheets use the same screen (basic schematic)
* but with different references and part selections according to the displayed sheet
* Mandatory in complex hierarchies because sheets use the same screen
* (basic schematic)
* but with different references and part selections according to the
* displayed sheet
*/
void UpdateAllScreenReferences();
void UpdateAllScreenReferences();
bool operator =( const DrawSheetPath& d1 );
bool operator =( const DrawSheetPath& d1 );
bool operator ==( const DrawSheetPath& d1 );
bool operator ==( const DrawSheetPath& d1 );
bool operator !=( const DrawSheetPath& d1 );
bool operator !=( const DrawSheetPath& d1 );
};
......@@ -167,16 +185,19 @@ class EDA_SheetList
private:
DrawSheetPath* m_List;
int m_count; /* Number of sheets included in hierarchy,
* starting at the given sheet in constructor . the given sheet is counted
* starting at the given sheet in constructor .
* the given sheet is counted
*/
int m_index; /* internal variable to handle GetNext(): cleared by GetFirst()
* and incremented by GetNext() after returning the next item in m_List
* Also used for internal calculations in BuildSheetList()
int m_index; /* internal variable to handle GetNext():
* cleared by GetFirst()
* and incremented by GetNext() after
* returning the next item in m_List
* Also used for internal calculations in
* BuildSheetList()
*/
DrawSheetPath m_currList;
DrawSheetPath m_currList;
public:
/* The constructor: build the list of sheets from aSheet.
* If aSheet == NULL (default) build the whole list of sheets in hierarchy
* So usually call it with no param.
......@@ -200,18 +221,20 @@ public:
/** Function GetFirst
* @return the first item (sheet) in m_List and prepare calls to GetNext()
*/
DrawSheetPath* GetFirst();
DrawSheetPath* GetFirst();
/** Function GetNext
* @return the next item (sheet) in m_List or NULL if no more item in sheet list
* @return the next item (sheet) in m_List or NULL if no more item in
* sheet list
*/
DrawSheetPath* GetNext();
DrawSheetPath* GetNext();
/** Function GetSheet
* @return the item (sheet) in aIndex position in m_List or NULL if less than index items
* @return the item (sheet) in aIndex position in m_List or NULL if less
* than index items
* @param aIndex = index in sheet list to get the sheet
*/
DrawSheetPath* GetSheet( int aIndex );
DrawSheetPath* GetSheet( int aIndex );
private:
......@@ -220,7 +243,7 @@ private:
* if aSheet = g_RootSheet, the full sheet path and sheet list is built
* @param aSheet = the starting sheet from the built is made
*/
void BuildSheetList( DrawSheetStruct* sheet );
void BuildSheetList( DrawSheetStruct* sheet );
};
#endif /* CLASS_DRAWSHEET_PATH_H */
/////////////////////////////////////////////////////////////////////////////
// Name: class_hierarchical_PIN_sheet.cpp
// Purpose: member functions Hierarchical_PIN_Sheet_Struct
// header = class_drawsheet.h
// Purpose: member functions Hierarchical_PIN_Sheet_Struct
// header = class_drawsheet.h
// Author: jean-pierre Charras
// Modified by:
// Created: 08/02/2006 18:37:02
// RCS-ID:
// Copyright: License GNU
// Licence:
// License:
/////////////////////////////////////////////////////////////////////////////
#include "fctsys.h"
......@@ -23,13 +23,14 @@
/*******************************************************************/
Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent,
const wxPoint& pos,
const wxString& text ) :
Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct(
DrawSheetStruct* parent,
const wxPoint& pos,
const wxString& text ) :
SCH_ITEM( parent, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ),
EDA_TextStruct( text )
/*******************************************************************/
{
/*******************************************************************/
wxASSERT( parent );
wxASSERT( Pnext == NULL );
m_Layer = LAYER_SHEETLABEL;
......@@ -43,10 +44,11 @@ Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* p
/***********************************************************/
Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy()
/***********************************************************/
{
/***********************************************************/
Hierarchical_PIN_Sheet_Struct* newitem =
new Hierarchical_PIN_Sheet_Struct( (DrawSheetStruct*) m_Parent, m_Pos, m_Text );
new Hierarchical_PIN_Sheet_Struct( (DrawSheetStruct*) m_Parent, m_Pos,
m_Text );
newitem->m_Edge = m_Edge;
newitem->m_Shape = m_Shape;
......@@ -59,25 +61,28 @@ Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy()
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int Hierarchical_PIN_Sheet_Struct::GetPenSize( )
int Hierarchical_PIN_Sheet_Struct::GetPenSize()
{
return g_DrawDefaultLineThickness;
}
/********************************************************************************************/
void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
/********************************************************************************************/
/* Routine de dessin des Labels type hierarchie */
/*****************************************************************************/
void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int DrawMode,
int Color )
{
GRTextHorizJustifyType side;
EDA_Colors txtcolor;
/*****************************************************************************/
/* Routine to create hierarchical labels */
GRTextHorizJustifyType side;
EDA_Colors txtcolor;
int posx, tposx, posy;
static std::vector <wxPoint> Poly;
int LineWidth = GetPenSize( );
int LineWidth = GetPenSize();
if( Color >= 0 )
txtcolor = (EDA_Colors) Color;
......@@ -85,8 +90,8 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
txtcolor = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode );
posx = m_Pos.x + offset.x;
posy = m_Pos.y + offset.y;
posx = m_Pos.x + offset.x;
posy = m_Pos.y + offset.y;
wxSize size = m_Size;
if( !m_Text.IsEmpty() )
......@@ -102,15 +107,15 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
side = GR_TEXT_HJUSTIFY_LEFT;
}
DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor,
m_Text, TEXT_ORIENT_HORIZ, size,
side, GR_TEXT_VJUSTIFY_CENTER, LineWidth, false, false );
m_Text, TEXT_ORIENT_HORIZ, size, side,
GR_TEXT_VJUSTIFY_CENTER, LineWidth, false, false );
}
/* Draw the graphic symbol */
CreateGraphicShape( Poly, m_Pos + offset );
int FillShape = false;
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0],
FillShape, LineWidth, txtcolor, txtcolor ); /* Poly Non rempli */
FillShape, LineWidth, txtcolor, txtcolor );
}
......@@ -119,8 +124,9 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
* @param aCorner_list = list to fill with polygon corners coordinates
* @param Pos = Position of the shape
*/
void Hierarchical_PIN_Sheet_Struct::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
void Hierarchical_PIN_Sheet_Struct::CreateGraphicShape(
std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
{
wxSize size = m_Size;
......@@ -206,8 +212,7 @@ bool Hierarchical_PIN_Sheet_Struct::Save( FILE* aFile ) const
}
if( fprintf( aFile, "F%d \"%s\" %c %c %-3d %-3d %-3d\n", m_Number,
CONV_TO_UTF8( m_Text ), type, side,
m_Pos.x, m_Pos.y,
CONV_TO_UTF8( m_Text ), type, side, m_Pos.x, m_Pos.y,
m_Size.x ) == EOF )
{
return false;
......@@ -224,9 +229,8 @@ void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os )
wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">"
<< " pin_name=\"" << CONV_TO_UTF8( m_Text ) << '"'
<< "/>\n"
<< std::flush;
<< " pin_name=\"" << CONV_TO_UTF8( m_Text )
<< '"' << "/>\n" << std::flush;
// NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n";
}
......
......@@ -393,7 +393,6 @@ bool LIB_FIELD::HitTest( wxPoint aPosRef, int aThreshold,
return hit;
}
// Creation et Duplication d'un field
LIB_DRAW_ITEM* LIB_FIELD::DoGenCopy()
{
LIB_FIELD* newfield = new LIB_FIELD( m_FieldId );
......
/**************************************************************/
/* Lib component definitions (libentry) definition of fields */
/* Lib component definitions (libentry) definition of fields */
/**************************************************************/
#ifndef CLASS_LIBENTRY_FIELDS_H
......
......@@ -76,7 +76,7 @@ bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 )
CMP_LIBRARY::CMP_LIBRARY( int type, const wxFileName& fileName )
{
m_Type = type; /* type indicator */
m_IsModified = false; /* flag indicateur d'edition */
m_IsModified = false; /* modified indicator */
m_TimeStamp = 0;
m_Flags = 0;
m_IsCache = false;
......@@ -505,7 +505,7 @@ bool CMP_LIBRARY::Load( wxString& errMsg )
* apparently started with EESchema-LIB. Sometime after 2.0, it
* was changed to EESchema-LIBRARY. Therefore, the test for
* EESchema-LIB will work in both cases. Don't change this unless
* backwards compatability is no longer required.
* backwards compatibility is no longer required.
*/
if( !tkn.HasMoreTokens()
|| !tkn.GetNextToken().Upper().StartsWith(wxT( "EESCHEMA-LIB" ) ) )
......@@ -559,7 +559,7 @@ the current schematic." ),
{
if( !LoadHeader( f, &LineNum ) )
{
errMsg = _( "An error occured attempting to read the header." );
errMsg = _( "An error occurred attempting to read the header." );
return false;
}
......@@ -659,14 +659,14 @@ bool CMP_LIBRARY::LoadDocs( wxString& errMsg )
if( f == NULL )
{
errMsg.Printf( _( "Could not open component document libray file <%s>." ),
errMsg.Printf( _( "Could not open component document library file <%s>." ),
GetChars( fn.GetFullPath() ) );
return false;
}
if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL )
{
errMsg.Printf( _( "Component document libray file <%s> is empty." ),
errMsg.Printf( _( "Component document library file <%s> is empty." ),
GetChars( fn.GetFullPath() ) );
fclose( f );
return false;
......@@ -765,7 +765,6 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName, bool oldDocFormat )
m_IsModified = false;
/* Creation de l'entete de la librairie */
m_TimeStamp = GetTimeStamp();
if( !SaveHeader( libfile ) )
{
......
......@@ -89,8 +89,7 @@ public:
* @param oldDocFormat - Save the document information in a separate
* file if true. The default is to save as the
* current library file format.
*
* @return bool - true if success writing else false.
* @return True if success writing else false.
*/
bool Save( const wxString& aFullFileName, bool oldDocFormat = false );
......@@ -101,8 +100,7 @@ public:
* file *.bck.
*
* @param aFullFileName - The library filename with path.
*
* @return bool - true if success writing else false.
* @return True if success writing else false.
*/
bool SaveDocFile( const wxString& FullFileName );
......@@ -110,8 +108,7 @@ public:
* Load library from file.
*
* @param errMsg - Error message if load fails.
*
* @return bool - True if load was successful otherwise false.
* @return True if load was successful otherwise false.
*/
bool Load( wxString& errMsg );
......@@ -129,7 +126,7 @@ public:
/**
* Get library entry status.
*
* @return true if there are no entries in the library.
* @return True if there are no entries in the library.
*/
bool IsEmpty() const
{
......@@ -151,16 +148,12 @@ public:
return m_IsModified;
}
bool IsCache() const { return m_IsCache; }
void SetModified( void ) { m_IsModified = true; }
void SetCache( void ) { m_IsCache = true; }
/**
* Load a string array with the names of all the entries in this library.
*
......@@ -202,7 +195,6 @@ public:
* Find entry by name.
*
* @param name - Name of entry, case insensitive.
*
* @return Pointer to entry if found. NULL if not found.
*/
CMP_LIB_ENTRY* FindEntry( const wxChar* name );
......@@ -212,7 +204,6 @@ public:
*
* @param name - Name of entry, case insensitive.
* @param type - Type of entry, root or alias.
*
* @return Pointer to entry if found. NULL if not found.
*/
CMP_LIB_ENTRY* FindEntry( const wxChar* name, LibrEntryType type );
......@@ -226,7 +217,6 @@ public:
* @param name - Name of component, case insensitive.
* @param searchAliases - Searches for component by alias name as well as
* component name if true.
*
* @return Pointer to component if found. NULL if not found.
*/
LIB_COMPONENT* FindComponent( const wxChar* name );
......@@ -238,7 +228,6 @@ public:
* a LIB_ALIAS pointer is not required.
*
* @param name - Name of alias, case insensitive.
*
* @return Pointer to alias if found. NULL if not found.
*/
LIB_ALIAS* FindAlias( const wxChar* name )
......@@ -256,9 +245,7 @@ public:
* remove the alias from the library.
*
* @param alias - Alias to add to library.
*
* @return bool - True if alias added to library. False if conflict
* exists.
* @return True if alias added to library. False if conflict exists.
*/
bool AddAlias( LIB_ALIAS* alias );
......@@ -266,7 +253,6 @@ public:
* Add component entry to library.
*
* @param cmp - Component to add.
*
* @return Pointer to added component if successful.
*/
LIB_COMPONENT* AddComponent( LIB_COMPONENT* cmp );
......@@ -311,9 +297,7 @@ public:
* entry in the list is returned.
*
* @param name - Name of current entry.
*
* @return CMP_LIB_ENTRY - Pointer to next entry if entry name is found.
* Otherwise NULL.
* @return Pointer to next entry if entry name is found. Otherwise NULL.
*/
CMP_LIB_ENTRY* GetNextEntry( const wxChar* name );
......@@ -325,23 +309,21 @@ public:
* entry in the list is returned.
*
* @param name - Name of current entry.
*
* @return CMP_LIB_ENTRY - Pointer to previous entry if entry name is found.
* Otherwise NULL.
* @return Previous entry if entry name is found, otherwise NULL.
*/
CMP_LIB_ENTRY* GetPreviousEntry( const wxChar* name );
/**
* Return the file name without path or extension.
*
* @return wxString - Name of library file.
* @return Name of library file.
*/
wxString GetName() const { return m_fileName.GetName(); }
/**
* Return the full file library name with path and extension.
*
* @return wxString - Full library file name with path and extension.
* @return Full library file name with path and extension.
*/
wxString GetFullFileName() { return m_fileName.GetFullPath(); }
......@@ -368,9 +350,8 @@ public:
*
* @param fileName - File name of the component library to load.
* @param errMsg - Error message if the component library failed to load.
*
* @return Pointer to library object if library file loaded successfully.
* Otherwise NULL.
* @return Library object if library file loaded successfully,
* otherwise NULL.
*/
static CMP_LIBRARY* LoadLibrary( const wxFileName& fileName,
wxString& errMsg );
......@@ -380,8 +361,7 @@ public:
*
* @param fileName - File name object of component library.
* @param errMsg - Error message if the component library failed to load.
*
* @return bool - True if library loaded properly otherwise false.
* @return True if library loaded properly otherwise false.
*/
static bool AddLibrary( const wxFileName& fileName, wxString& errMsg );
......@@ -391,8 +371,7 @@ public:
* @param fileName - File name object of component library.
* @param errMsg - Error message if the component library failed to load.
* @param i - Iterator to insert library in front of.
*
* @return bool - True if library loaded properly otherwise false.
* @return True if library loaded properly otherwise false.
*/
static bool AddLibrary( const wxFileName& fileName, wxString& errMsg,
CMP_LIBRARY_LIST::iterator& i );
......@@ -408,9 +387,7 @@ public:
* Find component library by name.
*
* @param name - Library file name without path or extension to find.
*
* @return CMP_LIBRARY* - Pointer to component library if found,
* otherwise NULL.
* @return Pointer to component library if found, otherwise NULL.
*/
static CMP_LIBRARY* FindLibrary( const wxString& name );
......@@ -419,8 +396,7 @@ public:
*
* @param sorted - Sort the list of name if true. Otherwise use the
* library load order.
*
* @return wxArrayString - The list of library names.
* @return The list of library names.
*/
static wxArrayString GetLibraryNames( bool sorted = true );
......@@ -432,8 +408,7 @@ public:
*
* @param name - Name of component to search for.
* @param libNaem - Name of the library to search for component.
*
* @return Pointer to a valid component object if found. Otherwise NULL.
* @return The component object if found, otherwise NULL.
*/
static LIB_COMPONENT* FindLibraryComponent(
const wxString& name, const wxString& libName = wxEmptyString );
......@@ -445,8 +420,7 @@ public:
*
* @param name - Name of component to search for.
* @param libNaem - Name of the library to search for entry.
*
* @return Pointer to a valid entry object if found. Otherwise NULL.
* @return The entry object if found, otherwise NULL.
*/
static CMP_LIB_ENTRY* FindLibraryEntry(
const wxString& name,
......
......@@ -66,9 +66,7 @@ int SCH_CMP_FIELD::GetPenSize()
/**
* Routine de trace des textes type Field du composant.
* entree:
* DrawMode: mode de trace
* Draw schematic component fields.
*/
void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
......@@ -98,7 +96,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
/* Calculate the text orientation, according to the component orientation/mirror */
orient = m_Orient;
if( parentComponent->m_Transform[0][1] ) // Rotation du composant de 90deg
if( parentComponent->m_Transform[0][1] ) // Rotate component 90 degrees.
{
if( orient == TEXT_ORIENT_HORIZ )
orient = TEXT_ORIENT_VERT;
......
/***********************************************************************/
/* Methodes de base de gestion des classes des elements de schematique */
/***********************************************************************/
/*****************************/
/* class_schematic_items.cpp */
/*****************************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -60,7 +60,7 @@ DrawBusEntryStruct* DrawBusEntryStruct::GenCopy()
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
......@@ -162,7 +162,7 @@ DrawJunctionStruct* DrawJunctionStruct::GenCopy()
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
......@@ -202,7 +202,7 @@ bool DrawJunctionStruct::HitTest( const wxPoint& aPosRef )
wxPoint dist = aPosRef - m_Pos;
return sqrt( ( (double) ( dist.x * dist.x ) ) +
( (double) ( dist.y * dist.y ) ) ) < (DRAWJUNCTION_DIAMETER/2);
( (double) ( dist.y * dist.y ) ) ) < (DRAWJUNCTION_DIAMETER/2);
}
......@@ -217,7 +217,7 @@ int DrawJunctionStruct::GetPenSize()
/*****************************************************************************
* Routine to redraw connection struct. *
* Routine to redraw connection struct. *
*****************************************************************************/
void DrawJunctionStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color )
......@@ -231,7 +231,8 @@ void DrawJunctionStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRSetDrawMode( DC, DrawMode );
GRFilledCircle( &panel->m_ClipBox, DC, m_Pos.x + offset.x,
m_Pos.y + offset.y, (DRAWJUNCTION_DIAMETER/2), 0, color, color );
m_Pos.y + offset.y, (DRAWJUNCTION_DIAMETER/2), 0, color,
color );
}
......@@ -274,7 +275,7 @@ EDA_Rect DrawNoConnectStruct::GetBoundingBox()
{
const int DELTA = DRAWNOCONNECT_SIZE / 2;
EDA_Rect box( wxPoint( m_Pos.x - DELTA, m_Pos.y - DELTA ),
wxSize( 2 * DELTA, 2 * DELTA ) );
wxSize( 2 * DELTA, 2 * DELTA ) );
box.Normalize();
return box;
......@@ -301,7 +302,7 @@ bool DrawNoConnectStruct::HitTest( const wxPoint& aPosRef )
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
......@@ -364,7 +365,7 @@ EDA_DrawLineStruct::EDA_DrawLineStruct( const wxPoint& pos, int layer ) :
switch( layer )
{
default:
m_Layer = LAYER_NOTES; /* Mettre ds Notes */
m_Layer = LAYER_NOTES;
break;
case LAYER_WIRE:
......@@ -435,7 +436,7 @@ EDA_Rect EDA_DrawLineStruct::GetBoundingBox()
// return a rectangle which is [pos,dim) in nature. therefore the +1
EDA_Rect ret( wxPoint( xmin, ymin ),
wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
return ret;
}
......@@ -443,7 +444,7 @@ EDA_Rect EDA_DrawLineStruct::GetBoundingBox()
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
......@@ -559,7 +560,7 @@ DrawPolylineStruct* DrawPolylineStruct::GenCopy()
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
......@@ -575,7 +576,7 @@ bool DrawPolylineStruct::Save( FILE* aFile ) const
if( GetLayer() == LAYER_BUS )
layer = "Bus";
if( fprintf( aFile, "Poly %s %s %d\n",
width, layer, GetCornerCount() ) == EOF )
width, layer, GetCornerCount() ) == EOF )
{
return false;
}
......
......@@ -5,17 +5,18 @@
#ifndef CLASS_SCHEMATIC_ITEMS_H
#define CLASS_SCHEMATIC_ITEMS_H
#define DRAWJUNCTION_DIAMETER 32 /* Size (diameter) of junctions between wires */
#define DRAWNOCONNECT_SIZE 48 /* Rayon du symbole No Connexion */
#define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between
* wires */
#define DRAWNOCONNECT_SIZE 48 /* No symbol connection range. */
/* flags pour BUS ENTRY (bus to bus ou wire to bus */
/* Flags for BUS ENTRY (bus to bus or wire to bus */
#define WIRE_TO_BUS 0
#define BUS_TO_BUS 1
/**
* Class EDA_DrawLineStruct
* is a segment decription base class to describe items which have 2 end
* is a segment description base class to describe items which have 2 end
* points (track, wire, draw line ...)
*/
class EDA_DrawLineStruct : public SCH_ITEM
......@@ -26,7 +27,7 @@ public:
wxPoint m_End; // Line end point
bool m_StartIsDangling;
bool m_EndIsDangling; // TRUE si Start ou End not connected (wires, tracks...)
bool m_EndIsDangling; // TRUE if not connected (wires, tracks...)
public:
EDA_DrawLineStruct( const wxPoint& pos, int layer );
......@@ -57,7 +58,7 @@ public:
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd"
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
......@@ -72,7 +73,7 @@ public:
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
* @param aMoveVector = the displacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
......@@ -102,7 +103,7 @@ public:
};
class DrawNoConnectStruct : public SCH_ITEM /* Symboles de non connexion */
class DrawNoConnectStruct : public SCH_ITEM
{
public:
wxPoint m_Pos; /* XY coordinates of NoConnect. */
......@@ -129,7 +130,7 @@ public:
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd"
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
......@@ -146,7 +147,7 @@ public:
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
* @param aMoveVector = the displacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
......@@ -168,7 +169,8 @@ public:
/**
* Class DrawBusEntryStruct
* Struct de descr 1 raccord a 45 degres de BUS ou WIRE
*
* Defines a bus or wire entry.
*/
class DrawBusEntryStruct : public SCH_ITEM
{
......@@ -188,14 +190,14 @@ public:
DrawBusEntryStruct* GenCopy();
wxPoint m_End() const; // retourne la coord de fin du raccord
wxPoint m_End() const;
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode,
int Color = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd"
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
......@@ -212,7 +214,7 @@ public:
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
* @param aMoveVector = the displacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
......@@ -232,10 +234,10 @@ public:
}
};
class DrawPolylineStruct : public SCH_ITEM /* Polyligne (serie de segments) */
class DrawPolylineStruct : public SCH_ITEM
{
public:
int m_Width; /* Tickness */
int m_Width; /* Thickness */
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public:
......@@ -255,7 +257,7 @@ public:
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd"
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
......@@ -284,7 +286,7 @@ public:
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
* @param aMoveVector = the displacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
......@@ -342,7 +344,8 @@ public:
int Color = -1 );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
......@@ -351,7 +354,7 @@ public:
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
* @param aMoveVector = the displacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
{
......
/***********************************************************************/
/* Methodes de base de gestion des classes des elements de schematique */
/***********************************************************************/
/*********************************************/
/* Code for handling schematic sheet labels. */
/*********************************************/
#include "fctsys.h"
#include "gr_basic.h"
......@@ -22,7 +22,7 @@
/* class SCH_HIERLABEL */
/************************/
/* Messages correspondants aux types ou forme des labels */
/* Names of sheet label types. */
const char* SheetLabelType[] =
{
"Input",
......@@ -65,20 +65,25 @@ static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
static int* TemplateShape[5][4] =
{
{ TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM },
{ TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM },
{ TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM },
{ Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM },
{ TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_BOTTOM }
{ TemplateIN_HN, TemplateIN_UP, TemplateIN_HI,
TemplateIN_BOTTOM },
{ TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI,
TemplateOUT_BOTTOM },
{ TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI,
TemplateBIDI_BOTTOM },
{ Template3STATE_HN, Template3STATE_UP, Template3STATE_HI,
Template3STATE_BOTTOM },
{ TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI,
TemplateUNSPC_BOTTOM }
};
/**************************************************************************/
SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text, KICAD_T aType ) :
SCH_ITEM( NULL, aType ),
EDA_TextStruct( text )
/**************************************************************************/
SCH_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text,
KICAD_T aType ) :
SCH_ITEM( NULL, aType ), EDA_TextStruct( text )
{
/**************************************************************************/
m_Layer = LAYER_NOTES;
m_Pos = pos;
m_Shape = 0;
......@@ -100,8 +105,8 @@ bool SCH_TEXT::HitTest( const wxPoint& aPosRef )
/*********************************************/
SCH_TEXT* SCH_TEXT::GenCopy()
/*********************************************/
{
/*********************************************/
SCH_TEXT* newitem;
switch( Type() )
......@@ -124,8 +129,8 @@ SCH_TEXT* SCH_TEXT::GenCopy()
break;
}
newitem->m_Layer = m_Layer;
newitem->m_Shape = m_Shape;
newitem->m_Layer = m_Layer;
newitem->m_Shape = m_Shape;
newitem->m_Orient = m_Orient;
newitem->m_Size = m_Size;
newitem->m_Width = m_Width;
......@@ -141,7 +146,8 @@ SCH_TEXT* SCH_TEXT::GenCopy()
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* @return the offset between the SCH_TEXT position and the text itself
* position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
......@@ -149,7 +155,8 @@ wxPoint SCH_TEXT::GetSchematicTextOffset()
{
wxPoint text_offset;
// add a small offset (TXTMARGE) to x ( or y) position to allow a text to be on a wire or a line and be readable
// add a small offset (TXTMARGE) to x ( or y) position to allow a text to
// be on a wire or a line and be readable
switch( m_SchematicOrientation )
{
default:
......@@ -175,7 +182,8 @@ wxPoint SCH_TEXT::GetSchematicTextOffset()
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* @return the offset between the SCH_TEXT position and the text itself
* position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
......@@ -189,29 +197,33 @@ wxPoint SCH_LABEL::GetSchematicTextOffset()
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void SCH_TEXT::Mirror_Y(int aYaxis_position)
void SCH_TEXT::Mirror_Y( int aYaxis_position )
{
// Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text
// The center position is mirrored and the text is moved for half horizontal len
// The center position is mirrored and the text is moved for half
// horizontal len
int px = m_Pos.x;
int dx;
if( m_Orient == 0 ) /* horizontal text */
if( m_Orient == 0 ) /* horizontal text */
dx = LenSize( m_Text ) / 2;
else if( m_Orient == 2 ) /* invert horizontal text*/
else if( m_Orient == 2 ) /* invert horizontal text*/
dx = -LenSize( m_Text ) / 2;
else
dx = 0;
px += dx;
px -= aYaxis_position;
NEGATE(px);
NEGATE( px );
px += aYaxis_position;
px -= dx;
m_Pos.x = px;
}
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* @return the offset between the SCH_TEXT position and the text itself
* position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
......@@ -245,44 +257,50 @@ wxPoint SCH_HIERLABEL::GetSchematicTextOffset()
return text_offset;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void SCH_HIERLABEL::Mirror_Y(int aYaxis_position)
void SCH_HIERLABEL::Mirror_Y( int aYaxis_position )
{
// Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text
// The center position is mirrored and the text is moved for half horizontal len
if( m_Orient == 0 ) /* horizontal text */
// The center position is mirrored and the text is moved for half
// horizontal len
if( m_Orient == 0 ) /* horizontal text */
m_Orient = 2;
else if( m_Orient == 2 ) /* invert horizontal text*/
else if( m_Orient == 2 ) /* invert horizontal text*/
m_Orient = 0;
m_Pos.x -= aYaxis_position;
NEGATE(m_Pos.x);
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
void SCH_GLOBALLABEL::Mirror_Y(int aYaxis_position)
void SCH_GLOBALLABEL::Mirror_Y( int aYaxis_position )
{
// Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text
// The center position is mirrored and the text is moved for half horizontal len
if( m_Orient == 0 ) /* horizontal text */
// The center position is mirrored and the text is moved for half
// horizontal len
if( m_Orient == 0 ) /* horizontal text */
m_Orient = 2;
else if( m_Orient == 2 ) /* invert horizontal text*/
else if( m_Orient == 2 ) /* invert horizontal text*/
m_Orient = 0;
m_Pos.x -= aYaxis_position;
NEGATE(m_Pos.x);
NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position;
}
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* @return the offset between the SCH_TEXT position and the text itself
* position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
*/
......@@ -314,7 +332,7 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset()
switch( m_SchematicOrientation )
{
case 0: /* Orientation horiz normale */
case 0: /* Orientation horiz normal */
text_offset.x -= offset;
break;
......@@ -337,12 +355,14 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset()
/** function SetTextOrientAndJustifyParmeters (virtual)
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 2 = (horizontal, right justified). This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation )
......@@ -381,12 +401,14 @@ void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation )
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation (for a label)
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation (for a label)
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 2 = (horizontal, right justified). This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation )
......@@ -397,12 +419,14 @@ void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation )
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 2 = (horizontal, right justified). This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
......@@ -441,12 +465,14 @@ void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 2 = (horizontal, right justified). This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
......@@ -485,8 +511,8 @@ void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
/********************************************************/
void SCH_TEXT::SwapData( SCH_TEXT* copyitem )
/********************************************************/
{
/********************************************************/
EXCHG( m_Text, copyitem->m_Text );
EXCHG( m_Pos, copyitem->m_Pos );
EXCHG( m_Size, copyitem->m_Size );
......@@ -504,8 +530,8 @@ void SCH_TEXT::SwapData( SCH_TEXT* copyitem )
/***************************************************************/
void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/***************************************************************/
{
/***************************************************************/
/* save old text in undo list */
if( g_ItemToUndoCopy && ( (m_Flags & IS_NEW) == 0 ) )
{
......@@ -528,9 +554,9 @@ void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int SCH_TEXT::GetPenSize( )
int SCH_TEXT::GetPenSize()
{
int pensize = m_Width;
int pensize = m_Width;
if( pensize == 0 ) // Use default values for pen size
{
......@@ -539,22 +565,24 @@ int SCH_TEXT::GetPenSize( )
else
pensize = g_DrawDefaultLineThickness;
}
// Clip pen size for small texts:
pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold );
return pensize;
}
/*******************************************************************************************/
/****************************************************************************/
void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
int DrawMode, int Color )
/*******************************************************************************************/
/* Texts type Comment (text on layer "NOTE") have 4 directions, and the Text origin is the first letter
*/
{
/****************************************************************************/
/* Text type Comment (text on layer "NOTE") have 4 directions, and the Text
* origin is the first letter
*/
EDA_Colors color;
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
int linewidth =
(m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
......@@ -567,7 +595,8 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
wxPoint text_offset = aOffset + GetSchematicTextOffset();
EXCHG( linewidth, m_Width ); // Set the minimum width
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED,
UNSPECIFIED_COLOR );
EXCHG( linewidth, m_Width ); // set initial value
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
......@@ -601,10 +630,8 @@ bool SCH_TEXT::Save( FILE* aFile ) const
}
if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x,
shape, m_Width,
CONV_TO_UTF8( text ) ) == EOF )
m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x,
shape, m_Width, CONV_TO_UTF8( text ) ) == EOF )
{
success = false;
}
......@@ -635,8 +662,8 @@ void SCH_TEXT::Show( int nestLevel, std::ostream& os )
/****************************************************************************/
SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_LABEL )
/****************************************************************************/
{
/****************************************************************************/
m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
......@@ -659,9 +686,8 @@ bool SCH_LABEL::Save( FILE* aFile ) const
shape = "Italic";
if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x, shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, shape,
m_Width, CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
}
......@@ -670,11 +696,11 @@ bool SCH_LABEL::Save( FILE* aFile ) const
}
/***********************************************************************************/
/*****************************************************************************/
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL )
/***********************************************************************************/
{
/*****************************************************************************/
m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI;
m_IsDangling = TRUE;
......@@ -696,11 +722,9 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
if( m_Italic )
shape = "Italic";
if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape],
shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape], shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
}
......@@ -711,24 +735,23 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
/************************************************/
bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef )
{
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
}
/***********************************************************************************/
/*****************************************************************************/
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL )
/***********************************************************************************/
{
/*****************************************************************************/
m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT;
m_IsDangling = TRUE;
......@@ -750,11 +773,9 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
if( m_Italic )
shape = "Italic";
if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
m_Pos.x, m_Pos.y,
m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape],
shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x,
SheetLabelType[m_Shape], shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
{
success = false;
}
......@@ -765,13 +786,12 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
/************************************************/
bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef )
{
/************************************************/
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
{
EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef );
......@@ -781,23 +801,28 @@ bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef )
/*********************************************************************************************/
void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
/*********************************************************************************************/
{
/*********************************************************************************************/
SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color );
}
/*******************************************************************************************/
void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color )
/******************************************************************************************/
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon
*/
/*****************************************************************************/
void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int DrawMode,
int Color )
{
/*****************************************************************************/
/* Texts type Global Label have 4 directions, and the Text origin is the
* graphic icon
*/
static std::vector <wxPoint> Poly;
EDA_Colors color;
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
int linewidth =
( m_Width == 0 ) ? g_DrawDefaultLineThickness : m_Width;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
if( Color >= 0 )
......@@ -809,11 +834,13 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
EXCHG( linewidth, m_Width ); // Set the minimum width
wxPoint text_offset = offset + GetSchematicTextOffset();
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED,
UNSPECIFIED_COLOR );
EXCHG( linewidth, m_Width ); // set initial value
CreateGraphicShape( Poly, m_Pos + offset );
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth,
color, color );
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
......@@ -825,7 +852,8 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape
*/
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
{
int* Template = TemplateShape[m_Shape][m_SchematicOrientation];
int HalfSize = m_Size.x / 2;
......@@ -849,8 +877,8 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, con
/****************************************/
EDA_Rect SCH_HIERLABEL::GetBoundingBox()
/****************************************/
{
/****************************************/
int x, y, dx, dy, length, height;
x = m_Pos.x;
......@@ -865,7 +893,8 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
switch( m_SchematicOrientation ) // respect orientation
{
case 0: /* Horiz Normal Orientation (left justified) */
case 0: /* Horiz Normal Orientation (left
*justified) */
dx = -length;
dy = height;
x += DANGLING_SYMBOL_SIZE;
......@@ -900,14 +929,17 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
}
/*******************************************************************************************/
void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
int DrawMode, int Color )
/******************************************************************************************/
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon
*/
/*****************************************************************************/
void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& aOffset,
int DrawMode,
int Color )
{
/*****************************************************************************/
/* Texts type Global Label have 4 directions, and the Text origin is the
* graphic icon
*/
static std::vector <wxPoint> Poly;
EDA_Colors color;
wxPoint text_offset = aOffset + GetSchematicTextOffset();
......@@ -923,11 +955,13 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aO
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
EXCHG( linewidth, m_Width ); // Set the minimum width
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED, UNSPECIFIED_COLOR );
EDA_TextStruct::Draw( panel, DC, text_offset, color, DrawMode, FILLED,
UNSPECIFIED_COLOR );
EXCHG( linewidth, m_Width ); // set initial value
CreateGraphicShape( Poly, m_Pos + aOffset );
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth, color, color );
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 0, linewidth,
color, color );
if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
......@@ -939,7 +973,8 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aO
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Position of the shape
*/
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos )
void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
{
int HalfSize = m_Size.y / 2;
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
......@@ -948,17 +983,20 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
aCorner_list.clear();
int symb_len = LenSize( m_Text ) + (TXTMARGE * 2);
int symb_len = LenSize( m_Text ) + ( TXTMARGE * 2 );
// Create outline shape : 6 points
int x = symb_len + linewidth + 3;
int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 ); // 50% more for negation bar
aCorner_list.push_back( wxPoint( 0, 0 ) ); // Starting point (anchor)
aCorner_list.push_back( wxPoint( 0, -y ) ); // Up
aCorner_list.push_back( wxPoint( -x, -y ) ); // left Up
aCorner_list.push_back( wxPoint( -x, 0 ) ); // left
aCorner_list.push_back( wxPoint( -x, y ) ); // left down
aCorner_list.push_back( wxPoint( 0, y ) ); // down
// 50% more for negation bar
int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
// Starting point(anchor)
aCorner_list.push_back( wxPoint( 0, 0 ) );
aCorner_list.push_back( wxPoint( 0, -y ) ); // Up
aCorner_list.push_back( wxPoint( -x, -y ) ); // left
aCorner_list.push_back( wxPoint( -x, 0 ) ); // Up left
aCorner_list.push_back( wxPoint( -x, y ) ); // left down
aCorner_list.push_back( wxPoint( 0, y ) ); // down
int x_offset = 0;
......@@ -989,7 +1027,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
switch( m_SchematicOrientation )
{
case 0: /* Orientation horiz normale */
case 0: /* Orientation horiz normal */
break;
case 1: /* Orientation vert UP */
......@@ -1020,8 +1058,8 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
/******************************************/
EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
/******************************************/
{
/******************************************/
int x, y, dx, dy, length, height;
x = m_Pos.x;
......@@ -1030,14 +1068,12 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
height = ( (m_Size.y * 15) / 10 ) + width + 2 * TXTMARGE;
length =
LenSize( m_Text ) // text X size
+ height // add height for triangular shapes (bidirectional)
+ DANGLING_SYMBOL_SIZE;
// text X size add height for triangular shapes(bidirectional)
length = LenSize( m_Text ) + height + DANGLING_SYMBOL_SIZE;
switch( m_SchematicOrientation ) // respect orientation
{
case 0: /* Horiz Normal Orientation (left justified) */
case 0: /* Horiz Normal Orientation (left justified) */
dx = -length;
dy = height;
x += DANGLING_SYMBOL_SIZE;
......@@ -1074,8 +1110,8 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
/***********************************/
EDA_Rect SCH_TEXT::GetBoundingBox()
/***********************************/
{
/***********************************/
int x, y, dx, dy, length, height;
x = m_Pos.x;
......
/********************************************/
/* Definitions for the EESchema program: */
/* Definitions for the EESchema program: */
/********************************************/
#ifndef CLASS_TEXT_LABEL_H
......@@ -10,7 +10,7 @@
/* Type of SCH_HIERLABEL and SCH_GLOBALLABEL
* mainly used to handle the graphic associated shape
*/
*/
typedef enum {
NET_INPUT,
NET_OUTPUT,
......@@ -29,20 +29,30 @@ class SCH_TEXT : public SCH_ITEM,
public:
int m_Layer;
int m_Shape;
bool m_IsDangling; // true if not connected (used to draw the "not connected" symbol
bool m_IsDangling; // true if not connected (used to draw the "not
// connected" symbol
protected:
int m_SchematicOrientation; /* orientation of texts (comments) and labels in schematic
* 0 = normal (horizontal, left justified).
int m_SchematicOrientation; /* orientation of texts (comments) and
* labels in schematic
* 0 = normal (horizontal, left
* justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 3 = bottom . This can be seen as the mirrored position of up
* this is perhaps a duplicate of m_Orient and m_HJustified or m_VJustified,
* but is more easy to handle that 3 parmeters in editions, Reading and Saving file
* 2 = (horizontal, right justified).
* This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the
* mirrored position of up
* this is perhaps a duplicate of m_Orient
* and m_HJustified or m_VJustified,
* but is more easy to handle that 3
* parameters in editions, Reading and
* Saving file
*/
public:
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString,
SCH_TEXT( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString,
KICAD_T aType = TYPE_SCH_TEXT );
~SCH_TEXT() { }
......@@ -54,69 +64,79 @@ public:
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation (for a text )
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation (for a text )
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 2 = (horizontal, right justified). This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
int GetSchematicTextOrientation() { return m_SchematicOrientation;}
int GetSchematicTextOrientation() { return m_SchematicOrientation; }
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* @return the offset between the SCH_TEXT position and the text itself
* position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
* (room to draw an associated graphic symbol, or put the text above a
* wire)
*/
virtual wxPoint GetSchematicTextOffset( );
virtual wxPoint GetSchematicTextOffset();
SCH_TEXT* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
SCH_TEXT* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
void SwapData( SCH_TEXT* copyitem );
void SwapData( SCH_TEXT* copyitem );
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
void Place( WinEDA_SchematicFrame* frame, wxDC* DC );
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox();
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item
*/
int GetPenSize( );
int GetPenSize();
// Geometric transforms (used in block operations):
/** virtual function Move
* move item to a new position.
* @param aMoveVector = the deplacement vector
* @param aMoveVector = the displacement vector
*/
virtual void Move(const wxPoint& aMoveVector)
virtual void Move( const wxPoint& aMoveVector )
{
m_Pos += aMoveVector;
}
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position);
virtual void Mirror_Y( int aYaxis_position );
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os );
......@@ -128,10 +148,14 @@ public:
class SCH_LABEL : public SCH_TEXT
{
public:
SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
SCH_LABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
~SCH_LABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
virtual wxString GetClass() const
{
......@@ -141,30 +165,35 @@ public:
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation (for a label)
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation (for a label)
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 2 = (horizontal, right justified). This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* @return the offset between the SCH_TEXT position and the text itself
* position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
* (room to draw an associated graphic symbol, or put the text above a
* wire)
*/
virtual wxPoint GetSchematicTextOffset( );
virtual wxPoint GetSchematicTextOffset();
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
};
......@@ -174,8 +203,11 @@ public:
SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
~SCH_GLOBALLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
virtual wxString GetClass() const
{
......@@ -185,51 +217,57 @@ public:
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 2 = (horizontal, right justified). This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* @return the offset between the SCH_TEXT position and the text itself
* position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
* (room to draw an associated graphic symbol, or put the text above a
* wire)
*/
virtual wxPoint GetSchematicTextOffset( );
virtual wxPoint GetSchematicTextOffset();
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox();
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Position of the shape
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos );
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position);
virtual void Mirror_Y( int aYaxis_position );
};
......@@ -239,8 +277,11 @@ public:
SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString );
~SCH_HIERLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode,
int Color = -1 );
virtual void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
virtual wxString GetClass() const
{
......@@ -250,50 +291,57 @@ public:
/** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize
* m_orient,m_HJustified and m_VJustified, according to the value of m_SchematicOrientation
* m_orient,m_HJustified and m_VJustified, according to the value of
* m_SchematicOrientation
* must be called after changing m_SchematicOrientation
* @param aSchematicOrientation =
* 0 = normal (horizontal, left justified).
* 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0
* 2 = (horizontal, right justified). This can be seen as the mirrored
* position of 0
* 3 = bottom . This can be seen as the mirrored position of up
*/
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
virtual void SetSchematicTextOrientation( int aSchematicOrientation );
/** function GetSchematicTextOffset (virtual)
* @return the offset between the SCH_TEXT position and the text itself position
* @return the offset between the SCH_TEXT position and the text itself
* position
* This offset depend on orientation, and the type of text
* (room to draw an associated graphic symbol, or put the text above a wire)
* (room to draw an associated graphic symbol, or put the text above a
* wire)
*/
virtual wxPoint GetSchematicTextOffset( );
virtual wxPoint GetSchematicTextOffset();
/** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape
*/
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list, const wxPoint& Pos );
void CreateGraphicShape( std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos );
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* writes the data structures for this object out to a FILE in "*.sch"
* format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
bool Save( FILE* aFile ) const;
/** Function HitTest
* @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test
*/
bool HitTest( const wxPoint& aPosRef );
bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox();
EDA_Rect GetBoundingBox();
/** virtual function Mirror_Y
* mirror item relative to an Y axis
* @param aYaxis_position = the y axis position
*/
virtual void Mirror_Y(int aYaxis_position);
virtual void Mirror_Y( int aYaxis_position );
};
#endif /* CLASS_TEXT_LABEL_H */
/*********************************/
/* Module de nettoyage du schema */
/*********************************/
/**************************************/
/* Code to handle schematic clean up. */
/**************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -15,21 +15,18 @@
#include "netlist.h"
/* Routines locales */
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm, EDA_DrawLineStruct* TstSegm );
/* Variable locales */
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm,
EDA_DrawLineStruct* TstSegm );
/*******************************************/
bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
{
/*******************************************/
/* Routine de nettoyage:
* - regroupe les segments de fils (ou de bus) alignes en 1 seul segment
* - Detecte les objets identiques superposes
/* Routine cleaning:
* - Includes segments or buses aligned in only 1 segment
* - Detects identical objects superimposed
*/
{
SCH_ITEM* DrawList, * TstDrawList;
int flag;
bool Modify = FALSE;
......@@ -50,9 +47,10 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
{
flag = TstAlignSegment( (EDA_DrawLineStruct*) DrawList,
(EDA_DrawLineStruct*) TstDrawList );
if( flag ) /* Suppression de TstSegm */
if( flag )
{
/* keep the bits set in .m_Flags, because the deleted segment can be flagged */
/* keep the bits set in .m_Flags, because the deleted
* segment can be flagged */
DrawList->m_Flags |= TstDrawList->m_Flags;
EraseStruct( TstDrawList, this );
SetRefreshReq();
......@@ -75,18 +73,16 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
/***********************************************/
void BreakSegmentOnJunction( SCH_SCREEN* Screen )
{
/************************************************/
/* Routine creant des debuts / fin de segment (BUS ou WIRES) sur les jonctions
* et les raccords
/* Routine to start/end segment (BUS or wires) on junctions.
*/
{
SCH_ITEM* DrawList;
if( Screen == NULL )
{
DisplayError( NULL,
wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
return;
}
......@@ -134,24 +130,28 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
* ( excluding ends)
* fill aPicklist with modified items if non null
*/
void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint )
void BreakSegment( SCH_SCREEN* aScreen, wxPoint aBreakpoint )
{
EDA_DrawLineStruct* segment, * NewSegment;
for( SCH_ITEM* DrawList = aScreen->EEDrawList;DrawList; DrawList = DrawList->Next() )
for( SCH_ITEM* DrawList = aScreen->EEDrawList; DrawList;
DrawList = DrawList->Next() )
{
if( DrawList->Type() != DRAW_SEGMENT_STRUCT_TYPE )
continue;
if( DrawList->Type() != DRAW_SEGMENT_STRUCT_TYPE )
continue;
segment = (EDA_DrawLineStruct*) DrawList;
if( !TestSegmentHit( aBreakpoint, segment->m_Start, segment->m_End, 0 ) )
continue;
/* Segment connecte: doit etre coupe en 2 si px,py n'est
/* * JP translate * Segment connecte: doit etre coupe en 2 si px,py
* n'est
* pas une extremite */
if( (segment->m_Start == aBreakpoint) || (segment->m_End == aBreakpoint ) )
if( ( segment->m_Start == aBreakpoint )
|| ( segment->m_End == aBreakpoint ) )
continue;
/* Ici il faut couper le segment en 2 */
/* Here we must cut the segment into 2. */
NewSegment = segment->GenCopy();
NewSegment->m_Start = aBreakpoint;
segment->m_End = NewSegment->m_Start;
......@@ -165,35 +165,36 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint )
/***********************************************************/
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm,
EDA_DrawLineStruct* TstSegm )
{
/***********************************************************/
/* Search if the 2 segments RefSegm and TstSegm are on a line.
* Retourn 0 if no
* Return 0 if no
* 1 if yes, and RefSegm is modified to be the equivalent segment
*/
{
if( RefSegm == TstSegm )
return 0;
if( RefSegm->GetLayer() != TstSegm->GetLayer() )
return 0;
// search for a common end, and modify coordinates to ensure RefSegm->m_End == TstSegm->m_Start
// search for a common end, and modify coordinates to ensure RefSegm->m_End
// == TstSegm->m_Start
if( RefSegm->m_Start == TstSegm->m_Start )
{
if( RefSegm->m_End == TstSegm->m_End ) // trivial case: RefSegm and TstSegm are identical
if( RefSegm->m_End == TstSegm->m_End )
return 1;
EXCHG( RefSegm->m_Start, RefSegm->m_End ); // at this point, RefSegm->m_End == TstSegm->m_Start
EXCHG( RefSegm->m_Start, RefSegm->m_End );
}
else if( RefSegm->m_Start == TstSegm->m_End )
{
EXCHG( RefSegm->m_Start, RefSegm->m_End );
EXCHG( TstSegm->m_Start, TstSegm->m_End ); // at this point, RefSegm->m_End == TstSegm->m_Start
EXCHG( TstSegm->m_Start, TstSegm->m_End );
}
else if( RefSegm->m_End == TstSegm->m_End )
{
EXCHG( TstSegm->m_Start, TstSegm->m_End ); // at this point, RefSegm->m_End == TstSegm->m_Start
EXCHG( TstSegm->m_Start, TstSegm->m_End );
}
else if( RefSegm->m_End != TstSegm->m_Start ) // No common end point, segments cannot be merged
else if( RefSegm->m_End != TstSegm->m_Start )
// No common end point, segments cannot be merged.
return 0;
/* Test alignment: */
......
......@@ -18,12 +18,13 @@
#include "class_marker_sch.h"
/**************************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool IncludePin )
/**************************************************************************************/
/*****************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay(
bool IncludePin )
{
/*****************************************************************************/
/** Function SchematicGeneralLocateAndDisplay
* Overlayed function
* Overlaid function
* Find the schematic item at cursor position
* the priority order is:
* - marker
......@@ -34,11 +35,10 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
* - pin
* - component
* @return an EDA_BaseStruct pointer on the item or NULL if no item found
* @param IncludePin = true to search for pins, fase to ignore them
* @param IncludePin = true to search for pins, false to ignore them
*
* For some items, caracteristics are displayed on the screen.
* For some items, characteristics are displayed on the screen.
*/
{
SCH_ITEM* DrawStruct;
wxString msg;
wxPoint mouse_position = GetScreen()->m_MousePosition;
......@@ -67,7 +67,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur,
&LibItem );
if( Pin )
break; // Priority is probing a pin first
break; // Priority is probing a pin first
LibItem = (SCH_COMPONENT*) DrawStruct;
SendMessageToPCBNEW( DrawStruct, LibItem );
break;
......@@ -92,20 +92,22 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
LibItem->GetField( VALUE )->m_Text, DARKCYAN );
// Cross probing:2 - pin found, and send a locate pin command to
// pcbnew (hightlight net)
// pcbnew (highlight net)
SendMessageToPCBNEW( Pin, LibItem );
}
return DrawStruct;
}
/********************************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint& refpoint,
bool IncludePin )
/********************************************************************************************/
/*****************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay(
const wxPoint& refpoint,
bool
IncludePin )
{
/*****************************************************************************/
/** Function SchematicGeneralLocateAndDisplay
* Overlayed function
* Overlaid function
* Find the schematic item at a given position
* the priority order is:
* - marker
......@@ -116,12 +118,11 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
* - pin
* - component
* @return an EDA_BaseStruct pointer on the item or NULL if no item found
* @param refpoint = the wxPoint loaction where to search
* @param IncludePin = true to search for pins, fase to ignore them
* @param refpoint = the wxPoint location where to search
* @param IncludePin = true to search for pins, false to ignore them
*
* For some items, caracteristics are displayed on the screen.
* For some items, characteristics are displayed on the screen.
*/
{
SCH_ITEM* DrawStruct;
LIB_PIN* Pin;
SCH_COMPONENT* LibItem;
......@@ -148,10 +149,14 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
return DrawStruct;
}
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), WIREITEM | BUSITEM | RACCORDITEM );
if( DrawStruct ) // We have found a wire: Search for a connected pin at the same location
DrawStruct = (SCH_ITEM*) PickStruct( refpoint,
GetScreen(), WIREITEM | BUSITEM |
RACCORDITEM );
if( DrawStruct ) // We have found a wire: Search for a connected pin at
// the same location
{
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
Pin = LocateAnyPin(
(SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, &LibItem );
if( Pin )
{
Pin->DisplayInfo( this );
......@@ -176,7 +181,7 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
/* search for a pin */
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint,
&LibItem );
&LibItem );
if( Pin )
{
Pin->DisplayInfo( this );
......@@ -203,7 +208,6 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
return DrawStruct;
}
// Recherche des autres elements
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), SEARCHALL );
if( DrawStruct )
{
......@@ -215,7 +219,7 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
}
void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
wxPoint MousePositionInPixels )
{
wxRealPoint delta;
......@@ -241,27 +245,27 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
case 0:
break;
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
case WXK_NUMPAD8:
case WXK_UP:
MousePositionInPixels.y -= wxRound(delta.y);
MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
case WXK_NUMPAD2:
case WXK_DOWN:
MousePositionInPixels.y += wxRound(delta.y);
MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
case WXK_NUMPAD4:
case WXK_LEFT:
MousePositionInPixels.x -= wxRound(delta.x);
MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
case WXK_NUMPAD6:
case WXK_RIGHT:
MousePositionInPixels.x += wxRound(delta.x);
MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
break;
......@@ -270,10 +274,10 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
break;
}
/* Recalcul de la position du curseur schema */
/* Update cursor position. */
screen->m_Curseur = curpos;
/* Placement sur la grille generale */
/* Snap cursor to grid. */
PutOnGrid( &(screen->m_Curseur) );
if( screen->IsRefreshReq() )
......@@ -303,12 +307,12 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
OnHotKey( DC, hotkey, NULL );
}
UpdateStatusBar(); /* Display cursor coordintes info */
UpdateStatusBar(); /* Display cursor coordinates info */
SetToolbars();
}
void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
wxPoint MousePositionInPixels )
{
wxRealPoint delta;
......@@ -334,27 +338,27 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
case 0:
break;
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
case WXK_NUMPAD8:
case WXK_UP:
MousePositionInPixels.y -= wxRound(delta.y);
MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
case WXK_NUMPAD2:
case WXK_DOWN:
MousePositionInPixels.y += wxRound(delta.y);
MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
case WXK_NUMPAD4:
case WXK_LEFT:
MousePositionInPixels.x -= wxRound(delta.x);
MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
case WXK_NUMPAD6:
case WXK_RIGHT:
MousePositionInPixels.x += wxRound(delta.x);
MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
break;
......@@ -363,10 +367,10 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
break;
}
/* Recalcul de la position du curseur schema */
/* Update the cursor position. */
screen->m_Curseur = curpos;
/* Placement sur la grille generale */
/* Snap cursor to grid. */
PutOnGrid( &(screen->m_Curseur) );
if( screen->IsRefreshReq() )
......@@ -396,7 +400,7 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
OnHotKey( DC, hotkey, NULL );
}
UpdateStatusBar(); /* Affichage des coord curseur */
UpdateStatusBar();
}
......@@ -426,27 +430,27 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
case 0:
break;
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */
case WXK_NUMPAD8:
case WXK_UP:
MousePositionInPixels.y -= wxRound(delta.y);
MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */
case WXK_NUMPAD2:
case WXK_DOWN:
MousePositionInPixels.y += wxRound(delta.y);
MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */
case WXK_NUMPAD4:
case WXK_LEFT:
MousePositionInPixels.x -= wxRound(delta.x);
MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */
case WXK_NUMPAD6:
case WXK_RIGHT:
MousePositionInPixels.x += wxRound(delta.x);
MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels );
break;
......@@ -455,10 +459,10 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
break;
}
/* Recalcul de la position du curseur schema */
/* Update cursor position. */
screen->m_Curseur = curpos;
/* Placement sur la grille generale */
/* Snap cursor to grid. */
PutOnGrid( &(screen->m_Curseur) );
if( screen->IsRefreshReq() )
......@@ -488,6 +492,6 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
OnHotKey( DC, hotkey, NULL );
}
UpdateStatusBar(); /* Affichage des coord curseur */
UpdateStatusBar();
SetToolbars();
}
......@@ -8,7 +8,7 @@
#include "program.h"
#include "general.h"
#include "netlist.h" /* Definitions generales liees au calcul de netliste */
#include "netlist.h"
#include "protos.h"
#include "class_library.h"
......@@ -34,7 +34,8 @@ public:
int m_Type;
DanglingEndHandle* m_Pnext;
DanglingEndHandle( int type ) {
DanglingEndHandle( int type )
{
m_Item = NULL;
m_Type = type;
m_Pnext = NULL;
......@@ -43,21 +44,21 @@ public:
DanglingEndHandle* ItemList;
static void TestWireForDangling( EDA_DrawLineStruct* DrawRef,
WinEDA_SchematicFrame* frame, wxDC* DC );
void TestLabelForDangling( SCH_TEXT* label,
WinEDA_SchematicFrame* frame, wxDC* DC );
DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList );
static void TestWireForDangling( EDA_DrawLineStruct* DrawRef,
WinEDA_SchematicFrame* frame, wxDC* DC );
void TestLabelForDangling( SCH_TEXT* label,
WinEDA_SchematicFrame* frame,
wxDC* DC );
DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList );
/**********************************************************/
bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2,
int Px1, int Py1 )
{
/**********************************************************/
/* Retourne TRUE si le point P est sur le segment S.
* Le segment est suppose horizontal ou vertical.
/* Returns TRUE if the point P is on the segment S.
* The segment is assumed horizontal or vertical.
*/
{
int Sxmin, Sxmax, Symin, Symax;
if( Sx1 == Sx2 ) /* Line S is vertical. */
......@@ -81,29 +82,26 @@ bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2,
if( Py1 != Sy1 )
return FALSE;
if( Px1 >= Sxmin && Px1 <= Sxmax )
if( Px1 >= Sxmin && Px1 <= Sxmax )
return TRUE;
else
return FALSE;
}
else
return FALSE; // Segments quelconques
return FALSE;
}
/******************************************************************************/
void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
/******************************************************************************/
/* Met a jour les membres m_Dangling des wires, bus, labels
*/
{
if( ItemList )
{
const DanglingEndHandle* DanglingItem;
const DanglingEndHandle* nextitem;
for( DanglingItem = ItemList; DanglingItem != NULL; DanglingItem = nextitem )
for( DanglingItem = ItemList;
DanglingItem != NULL;
DanglingItem = nextitem )
{
nextitem = DanglingItem->m_Pnext;
SAFE_DELETE( DanglingItem );
......@@ -112,8 +110,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
ItemList = RebuildEndList( DrawList );
// Controle des elements
for( SCH_ITEM* item = DrawList; item; item = item->Next() )
for( SCH_ITEM* item = DrawList; item; item = item->Next() )
{
switch( item->Type() )
{
......@@ -135,8 +132,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
break;
if( STRUCT->GetLayer() == LAYER_BUS )
{
STRUCT->m_StartIsDangling =
STRUCT->m_EndIsDangling = FALSE;
STRUCT->m_StartIsDangling = STRUCT->m_EndIsDangling = FALSE;
break;
}
break;
......@@ -148,7 +144,6 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
}
/**
* Test if point pos is on a pin end.
*
......@@ -156,8 +151,8 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
*
* @return LIB_PIN - Pointer to the located pin or NULL if no pin was found.
*/
LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList,
const wxPoint& pos )
LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList,
const wxPoint& pos )
{
SCH_COMPONENT* DrawLibItem;
LIB_PIN* Pin;
......@@ -173,7 +168,7 @@ LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList,
NEGATE( pinpos.y );
else
pinpos = TransformCoordinate( DrawLibItem->m_Transform, pinpos);
pinpos = TransformCoordinate( DrawLibItem->m_Transform, pinpos );
if( pos == pinpos )
return Pin;
......@@ -184,8 +179,8 @@ LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList,
/****************************************************************************/
void TestWireForDangling( EDA_DrawLineStruct* DrawRef,
WinEDA_SchematicFrame* frame, wxDC* DC )
/****************************************************************************/
{
/****************************************************************************/
DanglingEndHandle* terminal_item;
bool Sdangstate = TRUE, Edangstate = TRUE;
......@@ -215,16 +210,17 @@ void TestWireForDangling( EDA_DrawLineStruct* DrawRef,
DrawRef->m_StartIsDangling = Sdangstate;
DrawRef->m_EndIsDangling = Edangstate;
if( DC )
RedrawOneStruct( frame->DrawPanel, DC, DrawRef, GR_DEFAULT_DRAWMODE );
RedrawOneStruct( frame->DrawPanel, DC, DrawRef,
GR_DEFAULT_DRAWMODE );
}
}
/********************************************************/
void TestLabelForDangling( SCH_TEXT* label,
WinEDA_SchematicFrame* frame, wxDC* DC )
/********************************************************/
void TestLabelForDangling( SCH_TEXT* label, WinEDA_SchematicFrame* frame,
wxDC* DC )
{
/********************************************************/
DanglingEndHandle* terminal_item;
bool dangstate = TRUE;
......@@ -239,8 +235,8 @@ void TestLabelForDangling( SCH_TEXT* label,
case PIN_END:
case LABEL_END:
case SHEET_LABEL_END:
if( (label->m_Pos.x == terminal_item->m_Pos.x)
&& (label->m_Pos.y == terminal_item->m_Pos.y) )
if( ( label->m_Pos.x == terminal_item->m_Pos.x )
&& ( label->m_Pos.y == terminal_item->m_Pos.y ) )
dangstate = FALSE;
break;
......@@ -277,9 +273,8 @@ void TestLabelForDangling( SCH_TEXT* label,
}
/* Retourne la position physique de la pin, qui d�pend de l'orientation
* du composant */
/* Returns the physical position of the pin relative to the component
* orientation. */
wxPoint ReturnPinPhysicalPosition( LIB_PIN* Pin, SCH_COMPONENT* DrawLibItem )
{
wxPoint PinPos = Pin->m_Pos;
......@@ -297,8 +292,8 @@ wxPoint ReturnPinPhysicalPosition( LIB_PIN* Pin, SCH_COMPONENT* DrawLibItem )
/***********************************************************/
DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
/***********************************************************/
{
/***********************************************************/
DanglingEndHandle* StartList = NULL, * item, * lastitem = NULL;
EDA_BaseStruct* DrawItem;
......@@ -327,10 +322,12 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
#define STRUCT ( (EDA_DrawLineStruct*) DrawItem )
if( STRUCT->GetLayer() == LAYER_NOTES )
break;
if( (STRUCT->GetLayer() == LAYER_BUS) || (STRUCT->GetLayer() == LAYER_WIRE) )
if( ( STRUCT->GetLayer() == LAYER_BUS )
|| (STRUCT->GetLayer() == LAYER_WIRE ) )
{
item = new DanglingEndHandle( (STRUCT->GetLayer() == LAYER_BUS) ?
BUS_START_END : WIRE_START_END );
item = new DanglingEndHandle(
(STRUCT->GetLayer() == LAYER_BUS) ?
BUS_START_END : WIRE_START_END );
item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_Start;
......@@ -339,11 +336,12 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
else
StartList = item;
lastitem = item;
item = new DanglingEndHandle( (STRUCT->GetLayer() == LAYER_BUS) ?
BUS_END_END : WIRE_END_END );
item =
new DanglingEndHandle( (STRUCT->GetLayer() == LAYER_BUS) ?
BUS_END_END : WIRE_END_END );
item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_End;
item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_End;
lastitem->m_Pnext = item;
lastitem = item;
}
......@@ -375,10 +373,10 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
else
StartList = item;
lastitem = item;
item = new DanglingEndHandle( ENTRY_END );
item = new DanglingEndHandle( ENTRY_END );
item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_End();
item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_End();
lastitem->m_Pnext = item;
lastitem = item;
break;
......@@ -402,7 +400,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
continue;
if( Pin->m_Convert && STRUCT->m_Convert
&& ( STRUCT->m_Convert != Pin->m_Convert ) )
&& ( STRUCT->m_Convert != Pin->m_Convert ) )
continue;
item = new DanglingEndHandle( PIN_END );
......@@ -420,26 +418,29 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
}
case DRAW_SHEET_STRUCT_TYPE:
{
Hierarchical_PIN_Sheet_Struct* pinsheet;
for( pinsheet = ( (DrawSheetStruct*) DrawItem )->m_Label;
pinsheet;
pinsheet = pinsheet->Next() )
{
Hierarchical_PIN_Sheet_Struct* pinsheet;
for( pinsheet = ((DrawSheetStruct*)DrawItem)->m_Label; pinsheet; pinsheet = pinsheet->Next() )
{
wxASSERT( pinsheet->Type() == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
wxASSERT( pinsheet->Type() ==
DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE );
item = new DanglingEndHandle( SHEET_LABEL_END );
item = new DanglingEndHandle( SHEET_LABEL_END );
item->m_Item = pinsheet;
item->m_Pos = pinsheet->m_Pos;
item->m_Item = pinsheet;
item->m_Pos = pinsheet->m_Pos;
if( lastitem )
lastitem->m_Pnext = item;
else
StartList = item;
if( lastitem )
lastitem->m_Pnext = item;
else
StartList = item;
lastitem = item;
}
lastitem = item;
}
break;
}
break;
default:
;
......
......@@ -2,9 +2,6 @@
/* EESchema - database.cpp */
/****************************/
/* Routine de selection d'un composant en librairie
*/
#include "fctsys.h"
#include "gr_basic.h"
#include "common.h"
......@@ -21,16 +18,16 @@
/*
* Routine de selection du nom d'un composant en librairie pour chargement,
* Keys pointe la liste des mots cles de filtrage
* Si Keys = "", recherche des composants qui correspondent
* au masque BufName( avec * et ? )
* Routine name selection of a component library for loading,
* Keys leading the list of the keywords filter
* If Keys = "", research components that correspond
* BufName mask (with * and?)
*
* Retourne
* TRUE si composant selectionne
* FALSE si commande annulee
* place le nom du composant a charger, selectionne a partir d'une liste dans
* BufName
* Returns
* TRUE if the selected component
* FALSE canceled order
* Place the name of the component has loaded, select from a list in
* BufName
*/
wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
wxString& BufName )
......@@ -41,7 +38,7 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
BufName.MakeUpper();
Keys.MakeUpper();
/* Examen de la liste des librairies pour comptage */
/* Review the list of libraries for counting. */
BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{
lib.SearchEntryNames( nameList, BufName, Keys );
......
/************************************/
/* Delete.cpp: routines d'effacement */
/* delete.cpp */
/************************************/
#include "fctsys.h"
......@@ -41,10 +41,10 @@ static int CountConnectedItems( WinEDA_SchematicFrame* frame,
continue;
if( TstJunction && (Struct->Type() == DRAW_JUNCTION_STRUCT_TYPE) )
if( TstJunction && ( Struct->Type() == DRAW_JUNCTION_STRUCT_TYPE ) )
{
#define JUNCTION ( (DrawJunctionStruct*) Struct )
if( (JUNCTION->m_Pos.x == pos.x) && (JUNCTION->m_Pos.y == pos.y) )
if( JUNCTION->m_Pos == pos )
count++;
#undef JUNCTION
}
......@@ -201,7 +201,7 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection )
removed_struct != NULL;
removed_struct = removed_struct->Next() )
{
if( (removed_struct->m_Flags & STRUCT_DELETED) == 0 )
if( ( removed_struct->m_Flags & STRUCT_DELETED ) == 0 )
continue;
if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
......@@ -223,7 +223,7 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection )
removed_struct != NULL;
removed_struct = removed_struct->Next() )
{
if( (removed_struct->m_Flags & STRUCT_DELETED) == 0 )
if( ( removed_struct->m_Flags & STRUCT_DELETED ) == 0 )
continue;
if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
continue;
......@@ -324,12 +324,12 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection )
/*
* Locate and delete the item found under the mouse cousor
* Locate and delete the item found under the mouse cursor
* If more than one item found: the priority order is:
* 1 : MARKER
* 2 : JUNCTION
* 2 : NOCONNECT
* 3 : WIRE ou BUS
* 3 : WIRE or BUS
* 4 : DRAWITEM
* 5 : TEXT
* 6 : COMPOSANT
......@@ -376,16 +376,15 @@ bool LocateAndDeleteItem( WinEDA_SchematicFrame* frame, wxDC* DC )
/*
* Suppression definitive d'une structure dans une liste chainee
* d'elements de dessin
* DrawStruct = pointeur sur la structure
* Screen = pointeur sur l'ecran d'appartenance
* Le chainage de la liste est modifie.
* Remove definition of a structure in a linked list
* Elements of Drawing
* DrawStruct * = pointer to the structure
* Screen = pointer on the screen of belonging
*
* Remarque:
* pour les structures DRAW_SHEET_STRUCT_TYPE, l'ecran et les structures
* correspondantes ne sont pas touches.
* Ils doivent etre traites separement
* Note:
* DRAW_SHEET_STRUCT_TYPE structures for the screen and structures
* Corresponding keys are not.
* They must be treated separately
*/
void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
{
......@@ -424,7 +423,7 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
}
else
{
while( SheetLabel->Next() ) /* Examen de la liste dependante */
while( SheetLabel->Next() )
{
NextLabel =
(Hierarchical_PIN_Sheet_Struct*) SheetLabel->Next();
......@@ -468,9 +467,6 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
}
/*
* Effacement des marqueurs du type "type"
*/
void DeleteAllMarkers( int type )
{
SCH_SCREEN* screen;
......@@ -489,12 +485,11 @@ void DeleteAllMarkers( int type )
if( DrawStruct->Type() != TYPE_MARKER_SCH )
continue;
/* Marqueur trouve */
Marker = (MARKER_SCH*) DrawStruct;
if( Marker->GetMarkerType() != type )
continue;
/* Suppression du marqueur */
/* Remove marker */
EraseStruct( DrawStruct, screen );
}
}
......
/*******************************************************/
/* delsheet.cpp Routine d'effacement d'une hierarchie */
/*******************************************************/
/****************/
/* delsheet.cpp */
/****************/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -38,7 +38,6 @@ void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion )
return;
}
/* effacement du sous schema correspondant */
if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion )
{
msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ),
......@@ -65,7 +64,6 @@ void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion )
}
}
/* Effacement des elements de la feuille courante */
FirstSheet->m_AssociatedScreen->FreeDrawList();
}
}
......
......@@ -5,7 +5,7 @@
// Author: jean-pierre Charras
// Modified by:
// Created: 02/07/2000
// Licence: GPL
// License: GPL
/////////////////////////////////////////////////////////////////////////////
#include "fctsys.h"
#include "common.h"
......@@ -24,13 +24,11 @@
BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
EVT_COMMAND_RANGE( ID_MATRIX_0,
ID_MATRIX_0 + (PIN_NMAX * PIN_NMAX) - 1,
wxEVT_COMMAND_BUTTON_CLICKED,
DIALOG_ERC::ChangeErrorLevel )
EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1,
wxEVT_COMMAND_BUTTON_CLICKED,
DIALOG_ERC::ChangeErrorLevel )
END_EVENT_TABLE()
DIALOG_ERC::DIALOG_ERC( WinEDA_SchematicFrame* parent ) :
DIALOG_ERC_BASE( parent )
{
......@@ -56,7 +54,9 @@ void DIALOG_ERC::Init()
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc );
m_TotalErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc - g_EESchemaVar.NbWarningErc );
num.Printf( wxT(
"%d" ), g_EESchemaVar.NbErrorErc -
g_EESchemaVar.NbWarningErc );
m_LastErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc );
......@@ -71,10 +71,9 @@ void DIALOG_ERC::Init()
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS */
void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
{
/* Delete the old ERC markers, over the whole hierarchy
*/
{
DeleteAllMarkers( MARK_ERC );
m_MarkersList->ClearList();
m_Parent->DrawPanel->Refresh();
......@@ -104,8 +103,8 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
wxSafeYield(); // m_MarkersList must be redraw
wxArrayString messageList;
TestErc( &messageList );
for ( unsigned ii = 0; ii < messageList.GetCount(); ii++ )
m_MessagesList->AppendText(messageList[ii]);
for( unsigned ii = 0; ii < messageList.GetCount(); ii++ )
m_MessagesList->AppendText( messageList[ii] );
}
......@@ -132,9 +131,11 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
NotFound = TRUE;
/* Search for the selected marker */
for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
for( sheet = SheetList.GetFirst();
sheet != NULL;
sheet = SheetList.GetNext() )
{
SCH_ITEM*item = (SCH_ITEM*) sheet->LastDrawList();
SCH_ITEM* item = (SCH_ITEM*) sheet->LastDrawList();
while( item && NotFound )
{
if( item == marker )
......@@ -160,7 +161,7 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
{
sheet->LastScreen()->SetZoom( m_Parent->GetScreen()->GetZoom() );
*m_Parent->m_CurrentSheet = *sheet;
ActiveScreen = m_Parent->m_CurrentSheet->LastScreen();
ActiveScreen = m_Parent->m_CurrentSheet->LastScreen();
m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
}
......@@ -171,11 +172,10 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
/*********************************************/
void DIALOG_ERC::ReBuildMatrixPanel()
{
/*********************************************/
/* Build or rebuild the panel showing the ERC confict matrix
/* Build or rebuild the panel showing the ERC conflict matrix
*/
{
int ii, jj, event_id, text_height;
wxPoint pos, BoxMatrixPosition;
......@@ -191,8 +191,8 @@ void DIALOG_ERC::ReBuildMatrixPanel()
DiagErcTableInit = TRUE;
}
// Get the current text size :
text = new wxStaticText( m_PanelERCOptions, -1, wxT( "W" ), pos ); // this is a dummy text
// Get the current text size: this is a dummy text.
text = new wxStaticText( m_PanelERCOptions, -1, wxT( "W" ), pos );
text_height = text->GetRect().GetHeight();
bitmap_size = MAX( bitmap_size, text_height );
......@@ -218,7 +218,8 @@ void DIALOG_ERC::ReBuildMatrixPanel()
for( ii = 0; ii < PIN_NMAX; ii++ )
{
y = pos.y + (ii * bitmap_size);
text = new wxStaticText( m_PanelERCOptions, -1, CommentERC_H[ii], wxPoint( 5, y ) );
text = new wxStaticText( m_PanelERCOptions, -1, CommentERC_H[ii],
wxPoint( 5, y ) );
x = text->GetRect().GetRight();
pos.x = MAX( pos.x, x );
......@@ -239,37 +240,42 @@ void DIALOG_ERC::ReBuildMatrixPanel()
if( (ii == jj) && !m_Initialized )
{
wxPoint txtpos;
txtpos.x = x + 6; txtpos.y = y - bitmap_size;
text = new wxStaticText( m_PanelERCOptions, -1, CommentERC_V[ii], txtpos );
BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x, text->GetRect().GetRight() );
txtpos.x = x + 6;
txtpos.y = y - bitmap_size;
text = new wxStaticText( m_PanelERCOptions,
-1,
CommentERC_V[ii],
txtpos );
BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x,
text->GetRect().GetRight() );
}
event_id = ID_MATRIX_0 + ii + (jj * PIN_NMAX);
event_id = ID_MATRIX_0 + ii + ( jj * PIN_NMAX );
delete m_ButtonList[ii][jj];
switch( diag )
{
case OK:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id,
wxBitmap( erc_green_xpm ),
wxPoint( x, y ) );
event_id,
wxBitmap( erc_green_xpm ),
wxPoint( x, y ) );
break;
case WAR:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id,
wxBitmap( warning_xpm ),
wxPoint( x, y ) );
event_id,
wxBitmap( warning_xpm ),
wxPoint( x, y ) );
break;
case ERR:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id,
wxBitmap( error_xpm ),
wxPoint( x, y ) );
event_id,
wxBitmap( error_xpm ),
wxPoint( x, y ) );
break;
}
......@@ -296,7 +302,9 @@ void DIALOG_ERC::DisplayERC_MarkersList()
m_MarkersList->ClearList();
for( DrawSheetPath* Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() )
for( DrawSheetPath* Sheet = SheetList.GetFirst();
Sheet != NULL;
Sheet = SheetList.GetNext() )
{
SCH_ITEM* DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
......@@ -304,7 +312,6 @@ void DIALOG_ERC::DisplayERC_MarkersList()
if( DrawStruct->Type() != TYPE_MARKER_SCH )
continue;
/* Marqueur trouve */
MARKER_SCH* Marker = (MARKER_SCH*) DrawStruct;
if( Marker->GetMarkerType() != MARK_ERC )
continue;
......@@ -312,7 +319,8 @@ void DIALOG_ERC::DisplayERC_MarkersList()
/* Display diag */
// wxString msg;
// msg.Printf( _( "<b>sheet %s</b><ul>\n" ), Sheet->PathHumanReadable().GetData() );
// msg.Printf( _( "<b>sheet %s</b><ul>\n" ),
// Sheet->PathHumanReadable().GetData() );
// msg += Marker->GetReporter().ShowHtml();
// m_MarkersList->Append( msg );
m_MarkersList->AppendToList( Marker );
......@@ -323,11 +331,10 @@ void DIALOG_ERC::DisplayERC_MarkersList()
/**************************************************************/
void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
{
/**************************************************************/
/* Remet aux valeurs par defaut la matrice de diagnostic
/* Resets the default values of the ERC matrix.
*/
{
memcpy( DiagErc, DefaultDiagErc, sizeof(DiagErc) );
ReBuildMatrixPanel();
}
......@@ -335,11 +342,10 @@ void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
/************************************************************/
void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
{
/************************************************************/
/* Change the error level for the pressed button, on the matrix table
*/
{
int id, level, ii, x, y;
wxBitmapButton* Butt;
const char** new_bitmap_xpm = NULL;
......
......@@ -14,18 +14,16 @@
#include "class_library.h"
/* Fonctions locales */
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC );
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/************************************************************************************/
/******************************************************************************/
void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
/************************************************************************************/
/* Prepare le deplacement du texte en cours d'edition
*/
{
/******************************************************************************/
/* Prepare the displacement of the text being edited.
*/
LIB_COMPONENT* Entry;
SetCurrentField( aField );
......@@ -38,7 +36,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
return;
}
wxPoint pos, newpos;
wxPoint pos, newpos;
SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent();
SAFE_DELETE( g_ItemToUndoCopy );
......@@ -46,8 +44,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
pos = comp->m_Pos;
/* Les positions sont calculees par la matrice TRANSPOSEE de la matrice
* de rotation-miroir */
/* Positions are computed by the transpose matrix. Rotating mirror. */
newpos = aField->m_Pos - pos;
// Empirically this is necessary. The Y coordinate appears to be inverted
......@@ -55,9 +52,9 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
// combinations of mirroring and rotation. The following clause is true
// when the number of rotations and the number of mirrorings are both odd.
if( comp->m_Transform[1][0] * comp->m_Transform[0][1] < 0 )
NEGATE (newpos.y);
NEGATE( newpos.y );
newpos = TransformCoordinate( comp->m_Transform, newpos) + pos;
newpos = TransformCoordinate( comp->m_Transform, newpos ) + pos;
DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = newpos;
......@@ -84,12 +81,12 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
}
/**********************************************************************************/
/******************************************************************************/
void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
/**********************************************************************************/
/* Edit the field Field (text, size) */
{
int fieldNdx, flag;
/******************************************************************************/
/* Edit the field Field (text, size) */
int fieldNdx, flag;
LIB_COMPONENT* Entry;
if( Field == NULL )
......@@ -107,10 +104,8 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
if( Entry && (Entry->m_Options == ENTRY_POWER) )
{
DisplayInfoMessage( this,
_(
"Part is a POWER, value cannot be modified!\nYou must create a new power" )
);
DisplayInfoMessage( this, _( "Part is a POWER, value cannot be \
modified!\nYou must create a new power" ) );
return;
}
}
......@@ -134,12 +129,12 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
wxString newtext = Field->m_Text;
DrawPanel->m_IgnoreMouseEvents = TRUE;
Get_Message( Field->m_Name, _("Component field text"), newtext, this );
Get_Message( Field->m_Name, _( "Component field text" ), newtext, this );
DrawPanel->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE;
Field->m_AddExtraText = flag;
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
if( !newtext.IsEmpty() )
{
......@@ -149,11 +144,12 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
Field->m_Size.x = Field->m_Size.y = m_TextFieldSize;
}
Field->m_Text = newtext;
if( fieldNdx == REFERENCE ){
Cmp->SetRef(GetSheet(), newtext);
if( fieldNdx == REFERENCE )
{
Cmp->SetRef( GetSheet(), newtext );
}
}
else /* Nouveau texte NULL */
else
{
if( fieldNdx == REFERENCE )
{
......@@ -169,7 +165,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
}
}
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
Cmp->DisplayInfo( this );
GetScreen()->SetModify();
}
......@@ -177,18 +173,16 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
/************************************************************************/
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/
/* Routine de deplacement d'un texte type Field.
* Celle routine est normalement attachee au deplacement du curseur
*/
{
/************************************************************************/
/* Move standard text field. This routine is normally attached to the cursor.
**/
wxPoint pos;
int x1, y1;
int fieldNdx;
int x1, y1;
int fieldNdx;
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->GetParent();
SCH_CMP_FIELD* currentField = frame->GetCurrentField();
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->GetParent();
SCH_CMP_FIELD* currentField = frame->GetCurrentField();
if( currentField == NULL )
return;
......@@ -196,45 +190,44 @@ static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
SCH_COMPONENT* component = (SCH_COMPONENT*) currentField->GetParent();
fieldNdx = currentField->m_FieldId;
// Effacement:
currentField->m_AddExtraText = frame->m_Multiflag;
if( erase )
{
currentField->Draw( panel, DC, wxPoint(0,0), g_XorMode );
currentField->Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode );
}
pos = ( (SCH_COMPONENT*) currentField->GetParent() )->m_Pos;
/* Les positions sont caculees par la matrice TRANSPOSEE de la matrice
* de rotation-miroir
*/
/* Positions are calculated by the transpose matrix, Rotating mirror. */
x1 = panel->GetScreen()->m_Curseur.x - pos.x;
y1 = panel->GetScreen()->m_Curseur.y - pos.y;
currentField->m_Pos.x = pos.x + component->m_Transform[0][0] * x1 + component->m_Transform[1][0] * y1;
currentField->m_Pos.y = pos.y + component->m_Transform[0][1] * x1 + component->m_Transform[1][1] * y1;
currentField->m_Pos.x = pos.x + component->m_Transform[0][0] * x1 +
component->m_Transform[1][0] * y1;
currentField->m_Pos.y = pos.y + component->m_Transform[0][1] * x1 +
component->m_Transform[1][1] * y1;
currentField->Draw( panel, DC, wxPoint(0,0), g_XorMode );
currentField->Draw( panel, DC, wxPoint( 0, 0 ), g_XorMode );
}
/******************************************************************/
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/
{
/******************************************************************/
Panel->ForceCloseManageCurseur = NULL;
Panel->ManageCurseur = NULL;
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) Panel->GetParent();
SCH_CMP_FIELD* currentField = frame->GetCurrentField();
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) Panel->GetParent();
SCH_CMP_FIELD* currentField = frame->GetCurrentField();
if( currentField )
{
currentField->m_AddExtraText = frame->m_Multiflag;
currentField->Draw( Panel, DC, wxPoint(0,0), g_XorMode );
currentField->Draw( Panel, DC, wxPoint( 0, 0 ), g_XorMode );
currentField->m_Flags = 0;
currentField->m_Pos = frame->m_OldPos;
currentField->Draw( Panel, DC, wxPoint(0,0), g_XorMode );
currentField->Draw( Panel, DC, wxPoint( 0, 0 ), g_XorMode );
}
frame->SetCurrentField( NULL );
......@@ -245,9 +238,9 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
/*********************************************************************************/
void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
/*********************************************************************************/
{
int fieldNdx, flag;
/*********************************************************************************/
int fieldNdx, flag;
LIB_COMPONENT* Entry;
if( Field == NULL )
......@@ -258,7 +251,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->GetParent();
fieldNdx = Field->m_FieldId;
flag = 0;
flag = 0;
if( fieldNdx == REFERENCE )
{
Entry = CMP_LIBRARY::FindLibraryComponent(
......@@ -276,25 +269,26 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
SaveCopyInUndoList( Cmp, UR_CHANGED );
Field->m_AddExtraText = flag;
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
if( Field->m_Orient == TEXT_ORIENT_HORIZ )
Field->m_Orient = TEXT_ORIENT_VERT;
else
Field->m_Orient = TEXT_ORIENT_HORIZ;
Field->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
Field->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
GetScreen()->SetModify();
}
/**************************************************************************************************/
void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC )
/**************************************************************************************************/
/* Edit the component text reference*/
/****************************************************************************/
void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp,
wxDC* DC )
{
/****************************************************************************/
/* Edit the component text reference*/
LIB_COMPONENT* Entry;
int flag = 0;
int flag = 0;
if( Cmp == NULL )
return;
......@@ -307,33 +301,37 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
if( Entry->GetPartCount() > 1 )
flag = 1;
wxString ref = Cmp->GetRef(GetSheet());
Get_Message( _( "Reference" ), _("Component reference"), ref, this );
wxString ref = Cmp->GetRef( GetSheet() );
Get_Message( _( "Reference" ), _( "Component reference" ), ref, this );
if( !ref.IsEmpty() ) // New text entered
{
/* save old cmp in undo list if not already in edit, or moving ... */
if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, UR_CHANGED );
Cmp->SetRef(GetSheet(), ref);
Cmp->SetRef( GetSheet(), ref );
Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
Cmp->SetRef(GetSheet(), ref );
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0),
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0,
0 ),
g_XorMode );
Cmp->SetRef( GetSheet(), ref );
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0,
0 ),
Cmp->m_Flags ? g_XorMode :
GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify();
}
Cmp->DisplayInfo( this );
}
/*****************************************************************************************/
/*****************************************************************************/
void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
/*****************************************************************************************/
/* Routine de changement du texte selectionne */
{
wxString message;
/*****************************************************************************/
/* Routine to change the selected text */
wxString message;
LIB_COMPONENT* Entry;
if( Cmp == NULL )
......@@ -347,19 +345,19 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
SCH_CMP_FIELD* TextField = Cmp->GetField( VALUE );
message = TextField->m_Text;
if( Get_Message( _( "Value" ), _("Component value"), message, this ) )
message.Empty(); //allow the user to remove the value.
if( Get_Message( _( "Value" ), _( "Component value" ), message, this ) )
message.Empty(); //allow the user to remove the value.
if( !message.IsEmpty() && !message.IsEmpty())
if( !message.IsEmpty() && !message.IsEmpty() )
{
/* save old cmp in undo list if not already in edit, or moving ... */
if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, UR_CHANGED );
TextField->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
TextField->Draw( DrawPanel, DC, wxPoint( 0, 0 ), g_XorMode );
TextField->m_Text = message;
TextField->Draw( DrawPanel, DC, wxPoint(0,0),
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
TextField->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify();
}
......@@ -367,13 +365,14 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
}
/*****************************************************************************************/
void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC )
/*****************************************************************************************/
/*****************************************************************************/
void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp,
wxDC* DC )
{
wxString message;
/*****************************************************************************/
wxString message;
LIB_COMPONENT* Entry;
bool wasEmpty = false;
bool wasEmpty = false;
if( Cmp == NULL )
return;
......@@ -386,16 +385,18 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
SCH_CMP_FIELD* TextField = Cmp->GetField( FOOTPRINT );
message = TextField->m_Text;
if(message.IsEmpty() )
if( message.IsEmpty() )
wasEmpty = true;
if( Get_Message( _( "Footprint" ), _("Component footprint"), message, this ) )
if( Get_Message( _( "Footprint" ), _( "Component footprint" ), message,
this ) )
message.Empty(); // allow the user to remove the value.
// save old cmp in undo list if not already in edit, or moving ...
if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, UR_CHANGED );
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0,
0 ), g_XorMode );
// move the field if it was new.
if( wasEmpty && !message.IsEmpty() )
......@@ -404,21 +405,24 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
// add offset here - ? suitable heuristic below?
Cmp->GetField( FOOTPRINT )->m_Pos.x +=
(Cmp->GetField( REFERENCE )->m_Pos.x - Cmp->m_Pos.x) > 0 ?
(Cmp->GetField( REFERENCE )->m_Size.x) : (-1*Cmp->GetField( REFERENCE )->m_Size.x);
( Cmp->GetField( REFERENCE )->m_Pos.x - Cmp->m_Pos.x ) > 0 ?
( Cmp->GetField( REFERENCE )->m_Size.x ) :
( -1 * Cmp->GetField( REFERENCE )->m_Size.x );
Cmp->GetField( FOOTPRINT )->m_Pos.y +=
(Cmp->GetField( REFERENCE )->m_Pos.y - Cmp->m_Pos.y) > 0 ?
(Cmp->GetField( REFERENCE )->m_Size.y) : (-1*Cmp->GetField( REFERENCE )->m_Size.y);
( Cmp->GetField( REFERENCE )->m_Pos.y - Cmp->m_Pos.y ) > 0 ?
( Cmp->GetField( REFERENCE )->m_Size.y ) :
( -1 * Cmp->GetField( REFERENCE )->m_Size.y );
Cmp->GetField( FOOTPRINT )->m_Orient = Cmp->GetField( REFERENCE )->m_Orient;
Cmp->GetField( FOOTPRINT )->m_Orient =
Cmp->GetField( REFERENCE )->m_Orient;
}
TextField->m_Text = message;
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0),
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
Cmp->m_Flags ? g_XorMode :
GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify();
Cmp->DisplayInfo( this );
}
/**********************************************/
/* EESchema - symbtext.cpp for Library Editor */
/**********************************************/
/**********************************/
/* edit_graphic_bodyitem_text.cpp */
/**********************************/
/* Menu et routines de creation, modification, suppression de textes
du type symbole
(textes autres que Fields)
*/
/* Code for editing component library text items, not fields. */
#include "fctsys.h"
#include "gr_basic.h"
......@@ -143,8 +140,7 @@ void Dialog_BodyGraphicText_Properties::OnCancelClick( wxCommandEvent& event )
/***************************************************************************/
void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
/***************************************************************************/
/* Met a jour les differents parametres pour le composant en cours d'edition
*/
/* Updates the different parameters for the component being edited */
{
wxString Line;
......@@ -234,7 +230,7 @@ void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem)
|| ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) )
return;
/* Effacement ancien texte */
/* Deleting old text. */
if( DC)
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, DrawMode, NULL,
DefaultTransformMatrix );
......@@ -247,7 +243,7 @@ void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem)
frame->Destroy();
GetScreen()->SetModify();
/* Affichage nouveau texte */
/* Display new text. */
if( DC )
{
if ( ( DrawItem->m_Flags & IS_MOVED ) == 0 )
......
......@@ -17,11 +17,11 @@
#include "dialog_edit_label.h"
/* Fonctions locales */
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC );
/* Variables locales */
static wxPoint ItemInitialPosition;
static int OldOrient;
static wxSize OldSize;
......@@ -31,8 +31,8 @@ static int s_DefaultOrientGLabel = 0;
/****************************************************************************/
void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
/****************************************************************************/
{
/****************************************************************************/
wxString text;
int value;
......@@ -48,7 +48,8 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits );
value = ReturnValueFromString( g_UnitMetric, text,
m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if( m_TextShape )
m_CurrentText->m_Shape = m_TextShape->GetSelection();
......@@ -81,10 +82,10 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
}
/********************************************************************************/
/*****************************************************************************/
void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
/********************************************************************************/
{
/*****************************************************************************/
if( TextStruct == NULL )
return;
......@@ -130,12 +131,11 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
/*************************************************************************/
void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct,
wxDC* DC )
{
/*************************************************************************/
/* Edit the properties of the text (Label, Global label, graphic text).. )
* pointed by "TextStruct"
*/
{
if( TextStruct == NULL )
return;
......@@ -152,10 +152,10 @@ void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct,
}
/***********************************************************************************/
/*****************************************************************************/
void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
/***********************************************************************************/
{
/*****************************************************************************/
if( TextStruct == NULL )
TextStruct = (SCH_TEXT*) PickStruct( GetScreen()->m_Curseur,
GetScreen(), TEXTITEM | LABELITEM );
......@@ -170,7 +170,6 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
DrawPanel->CursorOff( DC );
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
/* Rot text */
int orient;
switch( TextStruct->Type() )
......@@ -189,8 +188,6 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
}
GetScreen()->SetModify();
/* redraw the new tewt */
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
DrawPanel->CursorOn( DC );
}
......@@ -198,11 +195,10 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
/*************************************************************************/
SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
{
/*************************************************************************/
/* Routine to create new text struct (GraphicText, label or Glabel).
*/
{
SCH_TEXT* NewText = NULL;
g_ItemToRepeat = NULL;
......@@ -230,7 +226,8 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
break;
default:
DisplayError( this, wxT( "WinEDA_SchematicFrame::CreateNewText() Internal error" ) );
DisplayError( this,
wxT( "WinEDA_SchematicFrame::CreateNewText() Internal error" ) );
return NULL;
}
......@@ -293,9 +290,9 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*************************************************************/
static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
{
/*************************************************************/
/* Abort function for the command move text */
{
BASE_SCREEN* screen = Panel->GetScreen();
SCH_ITEM* Struct = (SCH_ITEM*) screen->GetCurItem();
......@@ -308,7 +305,8 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
return;
}
/* "Undraw" the text, and delete it if new (i.e. it was beiing just created)*/
/* "Undraw" the text, and delete it if new (i.e. it was being just
* created)*/
RedrawOneStruct( Panel, DC, Struct, g_XorMode );
if( Struct->m_Flags & IS_NEW )
......@@ -316,7 +314,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
SAFE_DELETE( Struct );
screen->SetCurItem( NULL );
}
else /* this was a move command on an "old" text: restore its old settings. */
else /* this was a move command on "old" text: restore its old settings. */
{
switch( Struct->Type() )
{
......@@ -345,13 +343,14 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
/*****************************************************************************/
void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
wxDC* DC, int newtype )
{
/*****************************************************************************/
/* Routine to change a text type to an other one (GraphicText, label or Glabel).
* A new test, label or hierarchical or global label is created from the old text.
/* Routine to change a text type to an other one (GraphicText, label or
* Glabel).
* A new test, label or hierarchical or global label is created from the old
* text.
* the old text is deleted
*/
{
if( Text == NULL )
return;
......@@ -406,17 +405,20 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
}
/* now delete the old text
* If it is a text flagged IS_NEW it will be deleted by ForceCloseManageCurseur()
* If it is a text flagged IS_NEW it will be deleted by
* ForceCloseManageCurseur()
* If not, we must delete it.
*/
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
{
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC );
}
if( (flags & IS_NEW) == 0 ) // Remove old text from current list and save it in undo list
if( (flags & IS_NEW) == 0 ) // Remove old text from current list and
// save it in undo list
{
Text->m_Flags = 0;
DeleteStruct( DrawPanel, DC, Text ); // old text is really saved in undo list
DeleteStruct( DrawPanel, DC, Text ); // old text is really saved in
// undo list
GetScreen()->SetCurItem( NULL );
g_ItemToRepeat = NULL;
}
......@@ -427,9 +429,11 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
DrawPanel->CursorOff( DC ); // Erase schematic cursor
/* Save the new text in undo list if the old text was not itself a "new created text"
/* Save the new text in undo list if the old text was not itself a "new
* created text"
* In this case, the old text is already in undo list as a deleted item
* Of course if the old text was a "new created text" the new text will be put in undo list
* Of course if the old text was a "new created text" the new text will be
* put in undo list
* later, at the end of the current command (if not aborted)
*/
if( (flags & IS_NEW) == 0 )
......
......@@ -41,8 +41,8 @@ END_EVENT_TABLE()
/**************************************************************/
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
const wxPoint& framepos )
/**************************************************************/
{
/**************************************************************/
WinEDA_SetColorsFrame* frame =
new WinEDA_SetColorsFrame( parent, framepos );
......@@ -61,7 +61,7 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame()
// Standard Constructor
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
const wxPoint& framepos )
const wxPoint& framepos )
{
m_Parent = parent;
Init();
......@@ -75,22 +75,27 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
// Destructor
WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame() { }
WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame()
{
}
/**********************************************************/
bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id,
const wxString& caption, const wxPoint& pos,
const wxSize& size, long style )
/**********************************************************/
bool WinEDA_SetColorsFrame::Create( wxWindow* parent,
wxWindowID id,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{
SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
/**********************************************************/
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls();
if (GetSizer())
if( GetSizer() )
{
GetSizer()->SetSizeHints(this);
GetSizer()->SetSizeHints( this );
}
return true;
}
......@@ -98,33 +103,33 @@ bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id,
/**********************************************************/
void WinEDA_SetColorsFrame::Init()
/**********************************************************/
{
OuterBoxSizer = NULL;
MainBoxSizer = NULL;
ColumnBoxSizer = NULL;
RowBoxSizer = NULL;
Label = NULL;
BitmapButton = NULL;
m_ShowGrid = NULL;
m_SelBgColor = NULL;
Line = NULL;
/**********************************************************/
OuterBoxSizer = NULL;
MainBoxSizer = NULL;
ColumnBoxSizer = NULL;
RowBoxSizer = NULL;
Label = NULL;
BitmapButton = NULL;
m_ShowGrid = NULL;
m_SelBgColor = NULL;
Line = NULL;
StdDialogButtonSizer = NULL;
Button = NULL;
Button = NULL;
}
/**********************************************************/
void WinEDA_SetColorsFrame::CreateControls()
/**********************************************************/
{
/**********************************************************/
int lyr, grp, butt_ID, buttcolor;
OuterBoxSizer = new wxBoxSizer(wxVERTICAL);
SetSizer(OuterBoxSizer);
OuterBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( OuterBoxSizer );
MainBoxSizer = new wxBoxSizer(wxHORIZONTAL);
OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxLEFT|wxRIGHT, 5);
MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT, 5 );
// Add various items to the dialog box, as determined by the
// details of each element contained within laytool_list[]
......@@ -143,36 +148,45 @@ void WinEDA_SetColorsFrame::CreateControls()
// associated with the preceeding group.)
if( grp < BUTTON_GROUPS - 1 )
{
ColumnBoxSizer = new wxBoxSizer(wxVERTICAL);
MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_TOP|wxLEFT|wxTOP, 5);
ColumnBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add( ColumnBoxSizer,
1,
wxALIGN_TOP | wxLEFT | wxTOP,
5 );
}
else
{
// Add a spacer to better separate the text string (which is
// about to be added) from the items located above it.
ColumnBoxSizer->AddSpacer(5);
ColumnBoxSizer->AddSpacer( 5 );
}
RowBoxSizer = new wxBoxSizer(wxHORIZONTAL);
ColumnBoxSizer->Add(RowBoxSizer, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
RowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
ColumnBoxSizer->Add( RowBoxSizer,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
// Add a text string to identify the following set of controls
Label = new wxStaticText( this, -1, laytool_index[grp]->m_Name,
wxDefaultPosition, wxDefaultSize, 0 );
// Make this text string bold (so that it stands out better)
Label->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(),
wxNORMAL, wxBOLD, false, wxNORMAL_FONT->GetFaceName() ) );
Label->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(),
wxNORMAL_FONT->GetFamily(),
wxNORMAL, wxBOLD, false,
wxNORMAL_FONT->GetFaceName() ) );
RowBoxSizer->Add(Label, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
RowBoxSizer->Add( Label, 1, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
}
RowBoxSizer = new wxBoxSizer(wxHORIZONTAL);
ColumnBoxSizer->Add(RowBoxSizer, 0, wxGROW|wxALL, 0);
RowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
ColumnBoxSizer->Add( RowBoxSizer, 0, wxGROW | wxALL, 0 );
butt_ID = ID_COLOR_SETUP + lyr;
laytool_list[lyr]->m_Id = butt_ID;
wxMemoryDC iconDC;
wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
iconDC.SelectObject( ButtBitmap );
buttcolor = *laytool_list[lyr]->m_Color;
......@@ -180,112 +194,136 @@ void WinEDA_SetColorsFrame::CreateControls()
wxBrush Brush;
iconDC.SelectObject( ButtBitmap );
iconDC.SetPen( *wxBLACK_PEN );
Brush.SetColour(
ColorRefs[buttcolor].m_Red,
ColorRefs[buttcolor].m_Green,
ColorRefs[buttcolor].m_Blue
);
Brush.SetColour( ColorRefs[buttcolor].m_Red,
ColorRefs[buttcolor].m_Green,
ColorRefs[buttcolor].m_Blue );
Brush.SetStyle( wxSOLID );
iconDC.SetBrush( Brush );
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y );
BitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap, wxDefaultPosition, wxSize(BUTT_SIZE_X, BUTT_SIZE_Y) );
RowBoxSizer->Add(BitmapButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5);
BitmapButton =
new wxBitmapButton( this, butt_ID, ButtBitmap, wxDefaultPosition,
wxSize( BUTT_SIZE_X, BUTT_SIZE_Y ) );
RowBoxSizer->Add( BitmapButton,
0,
wxALIGN_CENTER_VERTICAL | wxRIGHT | wxBOTTOM,
5 );
laytool_list[lyr]->m_Button = BitmapButton;
// Add a text string, unless the current value of lyr is NB_BUTT - 1
if( lyr < NB_BUTT - 1 )
{
Label = new wxStaticText( this, wxID_STATIC, wxGetTranslation( laytool_list[lyr]->m_Name ),
wxDefaultPosition, wxDefaultSize, 0 );
RowBoxSizer->Add(Label, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
Label =
new wxStaticText( this, wxID_STATIC,
wxGetTranslation( laytool_list[lyr]->m_Name ),
wxDefaultPosition, wxDefaultSize, 0 );
RowBoxSizer->Add( Label, 1, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 5 );
}
else
{
// Special case; provide a checkbox instead (rather than a text string).
m_ShowGrid = new wxCheckBox( this, ID_CHECKBOX_SHOW_GRID, _("Grid"), wxDefaultPosition, wxDefaultSize, 0 );
// Special case; provide a checkbox instead (rather than a text
// string).
m_ShowGrid =
new wxCheckBox( this, ID_CHECKBOX_SHOW_GRID, _( "Grid" ),
wxDefaultPosition, wxDefaultSize, 0 );
m_ShowGrid->SetValue( m_Parent->m_Draw_Grid );
RowBoxSizer->Add(m_ShowGrid, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
RowBoxSizer->Add( m_ShowGrid,
1,
wxALIGN_CENTER_VERTICAL | wxBOTTOM,
5 );
}
}
// Add a spacer to improve appearance.
ColumnBoxSizer->AddSpacer(5);
ColumnBoxSizer->AddSpacer( 5 );
wxArrayString m_SelBgColorStrings;
m_SelBgColorStrings.Add(_("White"));
m_SelBgColorStrings.Add(_("Black"));
m_SelBgColor = new wxRadioBox( this, ID_RADIOBOX_BACKGROUND_COLOR, _("Background Color:"),
wxDefaultPosition, wxDefaultSize, m_SelBgColorStrings, 1, wxRA_SPECIFY_COLS );
m_SelBgColorStrings.Add( _( "White" ) );
m_SelBgColorStrings.Add( _( "Black" ) );
m_SelBgColor =
new wxRadioBox( this, ID_RADIOBOX_BACKGROUND_COLOR,
_( "Background Color:" ),
wxDefaultPosition, wxDefaultSize,
m_SelBgColorStrings, 1, wxRA_SPECIFY_COLS );
m_SelBgColor->SetSelection( ( g_DrawBgColor == BLACK ) ? 1 : 0 );
ColumnBoxSizer->Add(m_SelBgColor, 1, wxGROW|wxRIGHT|wxTOP|wxBOTTOM, 5);
ColumnBoxSizer->Add( m_SelBgColor,
1,
wxGROW | wxRIGHT | wxTOP | wxBOTTOM,
5 );
// Provide a line to separate all of the controls added so far from the
// "OK", "Cancel", and "Apply" buttons (which will be added after that line).
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
OuterBoxSizer->Add(Line, 0, wxGROW|wxALL, 5);
// "OK", "Cancel", and "Apply" buttons (which will be added after that
// line).
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize,
wxLI_HORIZONTAL );
OuterBoxSizer->Add( Line, 0, wxGROW | wxALL, 5 );
// Provide a StdDialogButtonSizer to accommodate the OK, Cancel, and Apply
// buttons; using that type of sizer results in those buttons being
// automatically located in positions appropriate for each (OS) version of KiCad.
// automatically located in positions appropriate for each (OS) version of
// KiCad.
StdDialogButtonSizer = new wxStdDialogButtonSizer;
OuterBoxSizer->Add(StdDialogButtonSizer, 0, wxGROW|wxALL, 10);
OuterBoxSizer->Add( StdDialogButtonSizer, 0, wxGROW | wxALL, 10 );
Button = new wxButton( this, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton(Button);
Button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition,
wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton( Button );
Button = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton(Button);
Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ),
wxDefaultPosition, wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton( Button );
Button->SetFocus();
Button = new wxButton( this, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton(Button);
Button = new wxButton( this, wxID_APPLY, _( "Apply" ), wxDefaultPosition,
wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton( Button );
StdDialogButtonSizer->Realize();
// (Dialog now needs to be resized, but the associated command is found elsewhere.)
// (Dialog now needs to be resized, but the associated command is found
// elsewhere.)
}
/**********************************************************/
bool WinEDA_SetColorsFrame::ShowToolTips()
/**********************************************************/
{
/**********************************************************/
return true;
}
/**********************************************************/
wxBitmap WinEDA_SetColorsFrame::GetBitmapResource( const wxString& name )
/**********************************************************/
{
wxUnusedVar(name);
/**********************************************************/
wxUnusedVar( name );
return wxNullBitmap;
}
/**********************************************************/
wxIcon WinEDA_SetColorsFrame::GetIconResource( const wxString& name )
/**********************************************************/
{
wxUnusedVar(name);
/**********************************************************/
wxUnusedVar( name );
return wxNullIcon;
}
/**********************************************************/
void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
/**********************************************************/
{
int id = event.GetId();
int color;
/**********************************************************/
int id = event.GetId();
int color;
wxBitmapButton* Button;
color = DisplayColorFrame( this,
CurrentColor[id - ID_COLOR_SETUP] );
CurrentColor[id - ID_COLOR_SETUP] );
if( color < 0 )
return;
......@@ -294,19 +332,17 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
return;
CurrentColor[id - ID_COLOR_SETUP] = color;
wxMemoryDC iconDC;
wxMemoryDC iconDC;
Button = laytool_list[id - ID_COLOR_SETUP]->m_Button;
wxBitmap ButtBitmap = Button->GetBitmapLabel();
wxBitmap ButtBitmap = Button->GetBitmapLabel();
iconDC.SelectObject( ButtBitmap );
wxBrush Brush;
wxBrush Brush;
iconDC.SetPen( *wxBLACK_PEN );
Brush.SetColour(
ColorRefs[color].m_Red,
ColorRefs[color].m_Green,
ColorRefs[color].m_Blue
);
Brush.SetColour( ColorRefs[color].m_Red,
ColorRefs[color].m_Green,
ColorRefs[color].m_Blue );
Brush.SetStyle( wxSOLID );
iconDC.SetBrush( Brush );
......@@ -320,8 +356,8 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
/******************************************************************/
void WinEDA_SetColorsFrame::UpdateLayerSettings()
/******************************************************************/
{
/******************************************************************/
// Update colors for each layer
for( int lyr = 0; lyr < NB_BUTT; lyr++ )
{
......@@ -347,9 +383,9 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings()
/**********************************************************************/
void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) )
/**********************************************************************/
void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED( event ) )
{
/**********************************************************************/
UpdateLayerSettings();
m_Parent->DrawPanel->Refresh();
EndModal( 1 );
......@@ -357,28 +393,26 @@ void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************/
void WinEDA_SetColorsFrame::OnCancelClick( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************/
void WinEDA_SetColorsFrame::OnCancelClick( wxCommandEvent& WXUNUSED( event ) )
{
/*******************************************************************/
EndModal( -1 );
}
/*******************************************************************/
void WinEDA_SetColorsFrame::OnApplyClick( wxCommandEvent& WXUNUSED (event) )
/*******************************************************************/
void WinEDA_SetColorsFrame::OnApplyClick( wxCommandEvent& WXUNUSED( event ) )
{
/*******************************************************************/
UpdateLayerSettings();
m_Parent->DrawPanel->Refresh();
}
/*************************/
void SeedLayers()
/*************************/
{
/*************************/
LayerStruct* LayerPointer = &g_LayerDescr;
int pt;
......@@ -395,14 +429,14 @@ void SeedLayers()
}
LayerPointer->NumberOfLayers = pt - 1;
/* Couleurs specifiques: Mise a jour par la lecture de la config */
/* Specific colors: update by reading the config. */
}
/***************************************/
EDA_Colors ReturnLayerColor( int Layer )
/****************************************/
{
/****************************************/
if( g_LayerDescr.Flags == 0 )
return (EDA_Colors) g_LayerDescr.LayerColor[Layer];
else
......
......@@ -49,9 +49,9 @@ const int BUTT_SIZE_Y = 20;
#define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer])
/**********************************/
/* Liste des menus de Menu_Layers */
/**********************************/
/********************/
/* Layer menu list. */
/********************/
struct ColorButton
{
......@@ -239,7 +239,7 @@ static ColorButton* laytool_list[NB_BUTT] = {
&Layer_SheetFileName_Item,
&Layer_SheetName_Item,
&Layer_SheetLabel_Item,
&Layer_HierarchicalLabel_Item,
&Layer_HierarchicalLabel_Item,
&Layer_Erc_Warning_Item,
&Layer_Erc_Error_Item,
......@@ -288,9 +288,9 @@ static ButtonIndex* laytool_index[BUTTON_GROUPS] = {
};
/**************************************************************/
/* classe derivee pour la frame de Configuration des couleurs */
/**************************************************************/
/***********************************************/
/* Derived class for the frame color settings. */
/***********************************************/
class WinEDA_SetColorsFrame: public wxDialog
{
......@@ -319,7 +319,7 @@ private:
const wxSize& size = wxDefaultSize,
long style = SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
// Initialises member variables
// Initializes member variables
void Init();
// Creates the controls and sizers
......@@ -342,5 +342,4 @@ public:
~WinEDA_SetColorsFrame();
};
#endif
// _EELAYER_H_
#endif // _EELAYER_H_
......@@ -56,7 +56,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT );
DrawPanel->CursorOff( DC ); // effacement curseur
DrawPanel->CursorOff( DC );
if( DrawPanel->ManageCurseur )
{
......@@ -73,7 +73,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
DrawPanel->CursorOn( DC ); // reaffichage curseur
DrawPanel->CursorOn( DC );
if( DrawPanel->ManageCurseur )
{
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
......@@ -86,7 +86,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
title.Printf( wxT( "%s [%s]" ), msg.GetData(),
GetScreen()->m_FileName.GetData() );
GetScreen()->m_FileName.GetData() );
SetTitle( title );
}
else
......@@ -109,7 +109,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
*/
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref,
int PrintMask, bool aPrintMirrorMode )
int PrintMask, bool aPrintMirrorMode )
{
wxBeginBusyCursor();
......@@ -133,8 +133,10 @@ void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
{
if( !(Structlist->m_Flags & IS_MOVED) )
{
// uncomment line below when there is a virtual EDA_BaseStruct::GetBoundingBox()
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox() ) )
// uncomment line below when there is a virtual
// EDA_BaseStruct::GetBoundingBox()
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox()
// ) )
RedrawOneStruct( panel, DC, Structlist, DrawMode, Color );
}
......@@ -159,13 +161,11 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
}
/* Routine de redessin en mode fantome (Dessin simplifie en g_XorMode et
* g_GhostColor
* de structures.
* Utilisee dans les deplacements de blocs
*/
void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem, const wxPoint & aOffset )
/* Routine for repainting item in ghost mode. Used in the block moves. */
void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
wxDC* aDC,
SCH_ITEM* aItem,
const wxPoint& aOffset )
{
int DrawMode = g_XorMode;
int width = g_DrawDefaultLineThickness;
......@@ -180,8 +180,12 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x,
Struct->m_PolyPoints[0].y + aOffset.y );
for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ )
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_PolyPoints[ii].x + aOffset.x,
Struct->m_PolyPoints[ii].y + aOffset.y, width, g_GhostColor );
GRLineTo( &aPanel->m_ClipBox,
aDC,
Struct->m_PolyPoints[ii].x + aOffset.x,
Struct->m_PolyPoints[ii].y + aOffset.y,
width,
g_GhostColor );
break;
}
......@@ -192,7 +196,8 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
Struct = (EDA_DrawLineStruct*) aItem;
if( (Struct->m_Flags & STARTPOINT) == 0 )
{
GRMoveTo( Struct->m_Start.x + aOffset.x, Struct->m_Start.y + aOffset.y );
GRMoveTo( Struct->m_Start.x + aOffset.x,
Struct->m_Start.y + aOffset.y );
}
else
{
......@@ -214,7 +219,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
case DRAW_BUSENTRY_STRUCT_TYPE:
{
DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) aItem;
wxPoint start = Struct->m_Pos + aOffset;
wxPoint start = Struct->m_Pos + aOffset;
GRMoveTo( start.x, start.y );
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_Size.x + start.x,
Struct->m_Size.y + start.y, width, g_GhostColor );
......@@ -269,9 +274,14 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
case DRAW_SHEET_STRUCT_TYPE:
{
DrawSheetStruct* Struct = (DrawSheetStruct*) aItem;
GRRect( &aPanel->m_ClipBox, aDC, Struct->m_Pos.x + aOffset.x,
Struct->m_Pos.y + aOffset.y, Struct->m_Pos.x + Struct->m_Size.x + aOffset.x,
Struct->m_Pos.y + Struct->m_Size.y + aOffset.y, width, g_GhostColor );
GRRect( &aPanel->m_ClipBox,
aDC,
Struct->m_Pos.x + aOffset.x,
Struct->m_Pos.y + aOffset.y,
Struct->m_Pos.x + Struct->m_Size.x + aOffset.x,
Struct->m_Pos.y + Struct->m_Size.y + aOffset.y,
width,
g_GhostColor );
break;
}
......
......@@ -20,39 +20,38 @@
// Global variables
int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que
* les numeros (netlist PSPICE seulement) */
SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure
* dessinee pouvant etre dupliquee par la commande
* Repeat ( NULL si aucune struct existe ) */
int g_OptNetListUseNames; /* TRUE to use names rather than net
* The numbers (PSPICE netlist only) */
SCH_ITEM* g_ItemToRepeat; /* Pointer to the last structure
* for duplicatation by the repeat command.
* (NULL if no struct exists) */
wxSize g_RepeatStep;
int g_RepeatDeltaLabel;
SCH_ITEM* g_ItemToUndoCopy; /* copy of last modified schematic item
* before it is modified (used for undo managing
* to restore old values ) */
SCH_ITEM* g_ItemToUndoCopy; /* copy of last modified schematic item
* before it is modified (used for undo
* managing to restore old values ) */
bool g_LastSearchIsMarker; /* True if last seach is a marker serach
bool g_LastSearchIsMarker; /* True if last seach is a marker serach
* False for a schematic item search
* Used for hotkey next search */
/* Block operation (copy, paste) */
BLOCK_SELECTOR g_BlockSaveDataList; // List of items to paste (Created by Block Save)
BLOCK_SELECTOR g_BlockSaveDataList; // List of items to paste
// (Created by Block Save)
// Gestion d'options
bool g_HVLines = true; // Bool: force H or V directions (Wires, Bus ..)
bool g_HVLines = true; // Bool: force H or V
// directions (Wires, Bus ..)
struct EESchemaVariables g_EESchemaVar;
/* Variables globales pour Schematic Edit */
int g_DefaultTextLabelSize = DEFAULT_SIZE_TEXT;
int g_DefaultTextLabelSize = DEFAULT_SIZE_TEXT;
HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
//SCH_SCREEN * ScreenSch;
DrawSheetStruct* g_RootSheet = NULL;
DrawSheetStruct* g_RootSheet = NULL;
wxString g_NetCmpExtBuffer( wxT( "cmp" ) );
wxString g_NetCmpExtBuffer( wxT( "cmp" ) );
const wxString SymbolFileExtension( wxT( "sym" ) );
const wxString CompLibFileExtension( wxT( "lib" ) );
......@@ -60,22 +59,30 @@ const wxString CompLibFileExtension( wxT( "lib" ) );
const wxString SymbolFileWildcard( wxT( "Kicad drawing symbol file (*.sym)|*.sym" ) );
const wxString CompLibFileWildcard( wxT( "Kicad component library file (*.lib)|*.lib" ) );
wxString g_SimulatorCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..)
wxString g_NetListerCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..)
// command line to call the simulator (gnucap, spice..)
wxString g_SimulatorCommandLine;
LayerStruct g_LayerDescr; /* couleurs des couches */
// command line to call the simulator net lister (gnucap, spice..)
wxString g_NetListerCommandLine;
bool g_EditPinByPinIsOn = false; /* true to do not synchronize pins edition
* when they are at the same location */
LayerStruct g_LayerDescr; /* layer colors. */
int g_DrawDefaultLineThickness = 6; /* Default line (in EESCHEMA units) thickness
* used to draw/plot items having a default thickness line value (i.e. = 0 ).
* 0 = single pixel line width
*/
bool g_EditPinByPinIsOn = false; /* true to do not synchronize pins
* edition when they are at the
* same location */
int g_DrawDefaultLineThickness = 6; /* Default line thickness in
* EESCHEMA units used to
* draw/plot items having a
* default thickness line value
* (i.e. = 0 ). 0 = single pixel
* line width */
// Color to draw selected items
int g_ItemSelectetColor = BROWN;
// Color to draw items flagged invisible, in libedit (they are insisible in eeschema
// Color to draw items flagged invisible, in libedit (they are insisible
// in eeschema
int g_InvisibleItemColor = DARKGRAY;
int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } };
......@@ -94,7 +101,7 @@ IMPLEMENT_APP( WinEDA_App )
bool WinEDA_App::OnInit()
{
wxFileName fn;
wxFileName fn;
WinEDA_SchematicFrame* frame = NULL;
g_DebugLevel = 0; // Debug level */
......@@ -113,9 +120,10 @@ bool WinEDA_App::OnInit()
/* init EESCHEMA */
SeedLayers();
// read current setup and reopen last directory if no filename to open in command line
// read current setup and reopen last directory if no filename to open in
// command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory);
GetSettings( reopenLastUsedDirectory );
Read_Hotkey_Config( frame, false ); /* Must be called before creating
* the main frame in order to
......
/******************************************************/
/** eeconfig.cpp : routines et menus de configuration */
/*******************************************************/
/******************/
/** eeconfig.cpp **/
/******************/
#include "fctsys.h"
#include "appl_wxstruct.h"
......@@ -19,9 +19,6 @@
#include "hotkeys.h"
/* Variables locales */
#define HOTKEY_FILENAME wxT( "eeschema" )
......@@ -41,13 +38,14 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
DisplayColorSetupFrame( this, pos );
break;
case ID_CONFIG_REQ: // Creation de la fenetre de configuration
case ID_CONFIG_REQ: // Display the configuration window.
InstallConfigFrame( pos );
break;
case ID_OPTIONS_SETUP:
DisplayOptionFrame( this, pos );
DrawPanel->Refresh( TRUE ); // Redraw, because grid settings may have changed.
// Redraw, because grid settings may have changed.
DrawPanel->Refresh( TRUE );
break;
case ID_CONFIG_SAVE:
......@@ -98,7 +96,8 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
HandleHotkeyConfigMenuSelection( this, id );
break;
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display Current hotkey list for eeschema
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
// Display current hotkey list for eeschema.
DisplayHotkeyList( this, s_Schematic_Hokeys_Descr );
break;
......@@ -258,8 +257,9 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
/* User library path takes precedent over default library search paths. */
wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
/* If the list is void, force loadind the library "power.lib" that is the "standard" library for power symbols
*/
/* If the list is void, force loadind the library "power.lib" that is
* the "standard" library for power symbols.
*/
if( m_ComponentLibFiles.GetCount() == 0 )
m_ComponentLibFiles.Add( wxT( "power" ) );
......
/************************************************************/
/** eeconfig.h : configuration: definition des structures **/
/************************************************************/
/*****************/
/** eeconfig.h **/
/*****************/
#include "param_config.h"
......@@ -8,11 +8,11 @@
#define GROUPCOMMON wxT( "/common" )
#define GROUPLIB wxT( "libraries" )
#include "netlist.h" /* Definitions generales liees au calcul de netliste */
#include "netlist.h"
/* variables importees */
extern int g_PenMinWidth;
/* saving parameters option : */
#define INSETUP TRUE // used when the parameter is saved in general config
// if not used, the parameter is saved in the loca config (project config)
#define INSETUP TRUE /* used when the parameter is saved in general config
* if not used, the parameter is saved in the local
* config (project config) */
/**************************************************/
/* Module de tst "ERC" ( Electrical Rules Check ) */
/**************************************************/
/**************************************/
/* erc.cpp - Electrical Rules Check */
/**************************************/
#include "fctsys.h"
#include "common.h"
......@@ -22,11 +22,11 @@
/* ERC tests :
* 1 - conflicts between connected pins ( example: 2 connected outputs )
* 2 - minimal connections requirements ( 1 input *must* be connected to an output, or a passive pin )
* 2 - minimal connections requirements ( 1 input *must* be connected to an
* output, or a passive pin )
*/
/* fonctions locales */
static bool WriteDiagnosticERC( const wxString& FullFileName );
static void Diagnose( WinEDA_DrawPanel* panel,
NETLIST_OBJECT* NetItemRef,
......@@ -35,9 +35,9 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
unsigned NetItemRef,
unsigned NetStart,
int* NetNbItems, int* MinConnexion );
static void TestLabel( WinEDA_DrawPanel* panel,
unsigned NetItemRef,
unsigned StartNet );
static void TestLabel( WinEDA_DrawPanel* panel,
unsigned NetItemRef,
unsigned StartNet );
/* Local variables */
int WriteFichierERC = FALSE;
......@@ -48,17 +48,22 @@ int WriteFichierERC = FALSE;
* PIN_OUTPUT = usual output
* PIN_BIDI = input or output (like port for a microprocessor)
* PIN_TRISTATE = tris state bus pin
* PIN_PASSIVE = pin for passive components: must be connected, and can be connected to any pin
* PIN_UNSPECIFIED = unkown electrical properties: creates alway a warning when connected
* PIN_POWER_IN = power input (GND, VCC for ICs). Must be connected to a power output.
* PIN_POWER_OUT = output of a regulator: intended to be connected to power input pins
* PIN_PASSIVE = pin for passive components: must be connected, and can be
* connected to any pin
* PIN_UNSPECIFIED = unknown electrical properties: creates always a warning
* when connected
* PIN_POWER_IN = power input (GND, VCC for ICs). Must be connected to a power
* output.
* PIN_POWER_OUT = output of a regulator: intended to be connected to power
* input pins
* PIN_OPENCOLLECTOR = pin type open collector
* PIN_OPENEMITTER = pin type open emitter
* PIN_NC = not connected (must be left open)
*
* Minimal requirements:
* All pins *must* be connected (except PIN_NC).
* When a pin is not connected in schematic, the user must place a "non connected" symbol to this pin.
* When a pin is not connected in schematic, the user must place a "non
* connected" symbol to this pin.
* This ensures a forgotten connection will be detected.
*/
......@@ -117,18 +122,18 @@ bool DiagErcTableInit; // go to TRUE after DiagErc init
*/
int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
{
/* I, O, Bi, 3S, Pas, UnS,PwrI,PwrO, OC, OE, NC */
/* I */ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR },
/* O */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, ERR, ERR, WAR },
/* Bi*/ { OK, OK, OK, OK, OK, WAR, OK, WAR, OK, WAR, WAR },
/* 3S*/ { OK, WAR, OK, OK, OK, WAR, WAR, ERR, WAR, WAR, WAR },
/*Pas*/ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR },
/*UnS */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR },
/*PwrI*/ { OK, OK, OK, WAR, OK, WAR, OK, OK, OK, OK, ERR },
/*PwrO*/ { OK, ERR, WAR, ERR, OK, WAR, OK, ERR, ERR, ERR, WAR },
/* OC */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, OK, OK, WAR },
/* OE */ { OK, ERR, WAR, WAR, OK, WAR, OK, ERR, OK, OK, WAR },
/* NC */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR }
/* I, O, Bi, 3S, Pas, UnS, PwrI, PwrO, OC, OE, NC */
/* I */ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR },
/* O */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, ERR, ERR, WAR },
/* Bi*/ { OK, OK, OK, OK, OK, WAR, OK, WAR, OK, WAR, WAR },
/* 3S*/ { OK, WAR, OK, OK, OK, WAR, WAR, ERR, WAR, WAR, WAR },
/*Pas*/ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR },
/*UnS */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR },
/*PwrI*/ { OK, OK, OK, WAR, OK, WAR, OK, OK, OK, OK, ERR },
/*PwrO*/ { OK, ERR, WAR, ERR, OK, WAR, OK, ERR, ERR, ERR, WAR },
/* OC */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, OK, OK, WAR },
/* OE */ { OK, ERR, WAR, WAR, OK, WAR, OK, ERR, OK, OK, WAR },
/* NC */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR }
};
......@@ -136,9 +141,10 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
#define DRV 3 /* Net driven by a signal (a pin output for instance) */
#define NET_NC 2 /* Net "connected" to a "NoConnect symbol" */
#define NOD 1 /* Net not driven ( Such as 2 or more connected inputs )*/
#define NOC 0 /* Pin isolee, non connectee */
#define NOC 0 /* Pin isolated, no connection */
/* Look up table which gives the minimal drive for a pair of connected pins on a net
/* Look up table which gives the minimal drive for a pair of connected pins on
* a net
* Initial state of a net is NOC (No Connection)
* Can be updated to NET_NC, or NOD (Not Driven) or DRV (DRIven)
*
......@@ -149,47 +155,52 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
*/
static int MinimalReq[PIN_NMAX][PIN_NMAX] =
{
/* In, Out, Bi, 3S, Pas, UnS,PwrI,PwrO, OC, OE, NC */
/* In*/ { NOD, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*Out*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NOC },
/* Bi*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/* 3S*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*Pas*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*UnS*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*PwrI*/ { NOD, DRV, NOD, NOD, NOD, NOD, NOD, DRV, NOD, NOD, NOC },
/*PwrO*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NOC },
/* OC*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/* OE*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/* NC*/ { NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC }
/* In Out, Bi, 3S, Pas, UnS, PwrI,PwrO,OC, OE, NC */
/* In*/ { NOD, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*Out*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NOC },
/* Bi*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/* 3S*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*Pas*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*UnS*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*PwrI*/ { NOD, DRV, NOD, NOD, NOD, NOD, NOD, DRV, NOD, NOD, NOC },
/*PwrO*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, NOC },
/* OC*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/* OE*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/* NC*/ { NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC }
};
/** Function TestDuplicateSheetNames( )
* inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
* inside a given sheet, one cannot have sheets with duplicate names (file
* names can be duplicated).
*/
int TestDuplicateSheetNames( )
int TestDuplicateSheetNames()
{
int err_count = 0;
int err_count = 0;
EDA_ScreenList ScreenList; // Created the list of screen
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() )
for( SCH_SCREEN* Screen = ScreenList.GetFirst();
Screen != NULL;
Screen = ScreenList.GetNext() )
{
for( SCH_ITEM* ref_item = Screen->EEDrawList; ref_item != NULL; ref_item = ref_item->Next() )
for( SCH_ITEM* ref_item = Screen->EEDrawList;
ref_item != NULL;
ref_item = ref_item->Next() )
{
// search for a scheet;
// search for a sheet;
if( ref_item->Type() != DRAW_SHEET_STRUCT_TYPE )
continue;
for( SCH_ITEM* item_to_test = ref_item->Next();
item_to_test != NULL;
item_to_test = item_to_test->Next() )
item_to_test != NULL;
item_to_test = item_to_test->Next() )
{
if( item_to_test->Type() != DRAW_SHEET_STRUCT_TYPE )
continue;
// We have found a second sheet: compare names
if( ( (DrawSheetStruct*) ref_item )->m_SheetName.CmpNoCase( ( (DrawSheetStruct*)
item_to_test )->
m_SheetName ) == 0 )
if( ( (DrawSheetStruct*) ref_item )->m_SheetName.CmpNoCase(
( ( DrawSheetStruct* ) item_to_test )-> m_SheetName )
== 0 )
{
/* Create a new marker type ERC error*/
MARKER_SCH* Marker = new MARKER_SCH();
......@@ -211,16 +222,17 @@ int TestDuplicateSheetNames( )
return err_count;
}
/**************************************************/
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
/**************************************************/
{
wxFileName fn;
unsigned NetItemRef;
unsigned OldItem;
unsigned StartNet;
/**************************************************/
wxFileName fn;
unsigned NetItemRef;
unsigned OldItem;
unsigned StartNet;
int NetNbItems, MinConn;
int NetNbItems, MinConn;
if( !DiagErcTableInit )
{
......@@ -251,7 +263,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
/* Cleanup the entire hierarchy */
EDA_ScreenList ScreenList;
for( SCH_SCREEN* Screen = ScreenList.GetFirst(); Screen != NULL; Screen = ScreenList.GetNext() )
for( SCH_SCREEN* Screen = ScreenList.GetFirst();
Screen != NULL;
Screen = ScreenList.GetNext() )
{
bool ModifyWires;
ModifyWires = Screen->SchematicCleanUp( NULL );
......@@ -263,27 +277,29 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
}
/* Test duplicate sheet names
* inside a given sheet, one cannot have sheets with duplicate names (file names can be duplicated).
* inside a given sheet, one cannot have sheets with duplicate names (file
* names can be duplicated).
*/
int errcnt = TestDuplicateSheetNames( );
g_EESchemaVar.NbErrorErc += errcnt;
int errcnt = TestDuplicateSheetNames();
g_EESchemaVar.NbErrorErc += errcnt;
g_EESchemaVar.NbWarningErc += errcnt;
m_Parent->BuildNetListBase();
/* Reset the flag m_FlagOfConnection, that will be used next, in calculations */
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED;
/* Reset the flag m_FlagOfConnection, that will be used next, in
* calculations */
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED;
StartNet = OldItem = 0;
StartNet = OldItem = 0;
NetNbItems = 0;
MinConn = NOC;
for( NetItemRef = 0; NetItemRef < g_NetObjectslist.size(); NetItemRef++ )
{
/* Tst changement de net */
if( g_NetObjectslist[OldItem]->GetNet() != g_NetObjectslist[NetItemRef]->GetNet() )
if( g_NetObjectslist[OldItem]->GetNet() !=
g_NetObjectslist[NetItemRef]->GetNet() )
{
MinConn = NOC;
NetNbItems = 0;
......@@ -310,19 +326,20 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
case NET_SHEETLABEL:
case NET_SHEETBUSLABELMEMBER:
// ERC problems when pin sheets do not match hierachical labels.
// Each pin sheet must match a hierachical label
// Each hierachicallabel must match a pin sheet
// ERC problems when pin sheets do not match hierarchical labels.
// Each pin sheet must match a hierarchical label
// Each hierarchical label must match a pin sheet
TestLabel( m_Parent->DrawPanel, NetItemRef, StartNet );
break;
case NET_NOCONNECT:
// ERC problems when a noconnect symbol is connected to more than one pin.
// ERC problems when a noconnect symbol is connected to more than
// one pin.
MinConn = NET_NC;
if( NetNbItems != 0 )
Diagnose( m_Parent->DrawPanel,
g_NetObjectslist[NetItemRef], NULL, MinConn, UNC );
g_NetObjectslist[NetItemRef], NULL, MinConn, UNC );
break;
case NET_PIN:
......@@ -341,7 +358,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc );
m_TotalErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc - g_EESchemaVar.NbWarningErc );
num.Printf( wxT(
"%d" ), g_EESchemaVar.NbErrorErc -
g_EESchemaVar.NbWarningErc );
m_LastErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc );
......@@ -353,7 +372,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
// Display new markers:
m_Parent->DrawPanel->Refresh();
/* Generation ouverture fichier diag */
if( WriteFichierERC == TRUE )
{
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
......@@ -370,7 +388,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
{
Close( TRUE );
ExecuteFile( this, wxGetApp().GetEditorName(),
QuoteFullPath( fn ) );
QuoteFullPath( fn ) );
}
}
}
......@@ -381,13 +399,12 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
NETLIST_OBJECT* aNetItemRef,
NETLIST_OBJECT* aNetItemTst,
int aMinConn, int aDiag )
{
/********************************************************/
/* Creates an ERC marker to show the ERC problem about aNetItemRef
* or between aNetItemRef and aNetItemTst
* if MinConn < 0: this is an error on labels
*/
{
MARKER_SCH* Marker = NULL;
SCH_SCREEN* screen;
int ii, jj;
......@@ -395,7 +412,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
if( aDiag == OK )
return;
/* Creation du nouveau marqueur type Erreur ERC */
/* Create new marker for ERC error. */
Marker = new MARKER_SCH();
Marker->m_TimeStamp = GetTimeStamp();
......@@ -408,19 +425,22 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
g_EESchemaVar.NbWarningErc++;
wxString msg;
if( aMinConn < 0 ) // Traitement des erreurs sur labels
if( aMinConn < 0 )
{
if( (aNetItemRef->m_Type == NET_HIERLABEL)
|| (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) )
{
msg.Printf( _( "HLabel %s not connected to SheetLabel" ),
aNetItemRef->m_Label->GetData() );
aNetItemRef->m_Label->GetData() );
}
else
msg.Printf( _( "SheetLabel %s not connected to HLabel" ),
aNetItemRef->m_Label->GetData() );
aNetItemRef->m_Label->GetData() );
Marker->SetData( ERCE_HIERACHICAL_LABEL, aNetItemRef->m_Start, msg, aNetItemRef->m_Start );
Marker->SetData( ERCE_HIERACHICAL_LABEL,
aNetItemRef->m_Start,
msg,
aNetItemRef->m_Start );
return;
}
......@@ -433,11 +453,12 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
string_pinnum = CONV_FROM_UTF8( ascii_buf );
cmp_ref = wxT( "?" );
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef( &aNetItemRef->m_SheetList );
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
&aNetItemRef->m_SheetList );
if( aNetItemTst == NULL )
{
if( aMinConn == NOC ) /* 1 seul element dans le net */
if( aMinConn == NOC ) /* Only 1 element in the net. */
{
msg.Printf( _( "Cmp %s, Pin %s (%s) Unconnected" ),
cmp_ref.GetData(), string_pinnum.GetData(),
......@@ -449,15 +470,14 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
return;
}
if( aMinConn == NOD ) /* pas de pilotage du net */
if( aMinConn == NOD ) /* Nothing driving the net. */
{
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
&aNetItemRef->m_SheetList );
msg.Printf(
_( "Cmp %s, Pin %s (%s) not driven (Net %d)" ),
cmp_ref.GetData(), string_pinnum.GetData(),
MsgPinElectricType[ii], aNetItemRef->GetNet() );
msg.Printf( _( "Cmp %s, Pin %s (%s) not driven (Net %d)" ),
cmp_ref.GetData(), string_pinnum.GetData(),
MsgPinElectricType[ii], aNetItemRef->GetNet() );
Marker->SetData( ERCE_PIN_NOT_DRIVEN,
aNetItemRef->m_Start,
msg,
......@@ -477,7 +497,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
}
}
if( aNetItemTst ) /* Erreur entre 2 pins */
if( aNetItemTst ) /* Error between 2 pins */
{
jj = aNetItemTst->m_ElectricalType;
int errortype = ERCE_PIN_TO_PIN_WARNING;
......@@ -493,16 +513,19 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
alt_string_pinnum = CONV_FROM_UTF8( ascii_buf );
alt_cmp = wxT( "?" );
if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link )
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( &aNetItemTst->m_SheetList );
msg.Printf( _("Cmp %s, Pin %s (%s) connected to " ),
cmp_ref.GetData(), string_pinnum.GetData(), MsgPinElectricType[ii] );
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef(
&aNetItemTst->m_SheetList );
msg.Printf( _( "Cmp %s, Pin %s (%s) connected to " ),
cmp_ref.GetData(),
string_pinnum.GetData(), MsgPinElectricType[ii] );
Marker->SetData( errortype,
aNetItemRef->m_Start,
msg,
aNetItemRef->m_Start );
msg.Printf( _("Cmp %s, Pin %s (%s) (net %d)" ),
alt_cmp.GetData(), alt_string_pinnum.GetData(), MsgPinElectricType[jj],
aNetItemRef->GetNet() );
msg.Printf( _( "Cmp %s, Pin %s (%s) (net %d)" ),
alt_cmp.GetData(),
alt_string_pinnum.GetData(), MsgPinElectricType[jj],
aNetItemRef->GetNet() );
Marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
}
}
......@@ -513,68 +536,90 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
unsigned NetItemRef,
unsigned netstart,
int* NetNbItems, int* MinConnexion )
{
/********************************************************************/
/* Routine testant les conflits electriques entre
* NetItemRef
* et les autres items du meme net
/* Routine testing electrical conflicts between NetItemRef and other items
* of the same net
*/
{
unsigned NetItemTst;
int ref_elect_type, jj, erc = OK, local_minconn;
/* Analyse de la table des connexions : */
int ref_elect_type, jj, erc = OK, local_minconn;
/* Analysis of the table of connections. */
ref_elect_type = g_NetObjectslist[NetItemRef]->m_ElectricalType;
NetItemTst = netstart;
local_minconn = NOC;
/* Test pins Pins connected to NetItemRef */
/* Test pins connected to NetItemRef */
for( ; ; NetItemTst++ )
{
if( NetItemRef == NetItemTst )
continue;
/* We examine only a given net. We stop the search if the net changes */
if( (NetItemTst >= g_NetObjectslist.size()) // End of list
|| ( g_NetObjectslist[NetItemRef]->GetNet() != g_NetObjectslist[NetItemTst]->GetNet() ) ) // End of net
/* We examine only a given net. We stop the search if the net changes
**/
if( ( NetItemTst >= g_NetObjectslist.size() ) // End of list
|| ( g_NetObjectslist[NetItemRef]->GetNet() !=
g_NetObjectslist[NetItemTst]->GetNet() ) ) // End of net
{
/* Fin de netcode trouve: Tst connexion minimum */
if( (*MinConnexion < NET_NC ) && (local_minconn < NET_NC ) ) /* Not connected or not driven pin */
/* End net code found: minimum connection test. */
if( (*MinConnexion < NET_NC ) && (local_minconn < NET_NC ) )
{
/* Not connected or not driven pin. */
bool seterr = true;
if( local_minconn == NOC && g_NetObjectslist[NetItemRef]->m_Type == NET_PIN)
if( local_minconn == NOC
&& g_NetObjectslist[NetItemRef]->m_Type == NET_PIN )
{
/* This pin is not connected: for multiple part per package, and duplicated pin,
* search for an other instance of this pin
* this will be flagged only is all instances of this pin are not connected
* TODO test also if instances connected are connected to the same net
*/
for ( unsigned duppin = 0; duppin < g_NetObjectslist.size(); duppin ++ )
/* This pin is not connected: for multiple part per
* package, and duplicated pin,
* search for an other instance of this pin
* this will be flagged only is all instances of this pin
* are not connected
* TODO test also if instances connected are connected to
* the same net
*/
for( unsigned duppin = 0;
duppin < g_NetObjectslist.size();
duppin++ )
{
if ( g_NetObjectslist[duppin]->m_Type != NET_PIN )
if( g_NetObjectslist[duppin]->m_Type != NET_PIN )
continue;
if( duppin == NetItemRef )
continue;
if ( g_NetObjectslist[NetItemRef]->m_PinNum != g_NetObjectslist[duppin]->m_PinNum )
if( g_NetObjectslist[NetItemRef]->m_PinNum !=
g_NetObjectslist[duppin]->m_PinNum )
continue;
if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->m_Link )->GetRef(&g_NetObjectslist[NetItemRef]->m_SheetList) !=
((SCH_COMPONENT*) g_NetObjectslist[duppin]->m_Link )->GetRef(&g_NetObjectslist[duppin]->m_SheetList) )
if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->
m_Link )->GetRef( &g_NetObjectslist[NetItemRef]->
m_SheetList ) !=
( (SCH_COMPONENT*) g_NetObjectslist[duppin]->m_Link )
->GetRef( &g_NetObjectslist[duppin]->m_SheetList ) )
continue;
// Same component and same pin. Do dot create error for this pin
// if the other pin is connected (i.e. if duppin net has an other item)
if ( (duppin > 0) && (g_NetObjectslist[duppin]->GetNet() == g_NetObjectslist[duppin-1]->GetNet()))
// Same component and same pin. Do dot create error for
// this pin
// if the other pin is connected (i.e. if duppin net
// has an other item)
if( (duppin > 0)
&& ( g_NetObjectslist[duppin]->GetNet() ==
g_NetObjectslist[duppin - 1]->GetNet() ) )
seterr = false;
if ( (duppin < g_NetObjectslist.size()-1) && (g_NetObjectslist[duppin]->GetNet() == g_NetObjectslist[duppin+1]->GetNet()) )
if( (duppin < g_NetObjectslist.size() - 1)
&& ( g_NetObjectslist[duppin]->GetNet() ==
g_NetObjectslist[duppin + 1]->GetNet() ) )
seterr = false;
}
}
if ( seterr )
Diagnose( panel, g_NetObjectslist[NetItemRef], NULL, local_minconn, WAR );
*MinConnexion = DRV; // inhibition autres messages de ce type pour ce net
if( seterr )
Diagnose( panel,
g_NetObjectslist[NetItemRef],
NULL,
local_minconn,
WAR );
*MinConnexion = DRV; // inhibiting other messages of this
// type for the net.
}
return;
}
......@@ -608,15 +653,20 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
break;
*NetNbItems += 1;
if( erc == OK ) // 1 marqueur par pin maxi
if( erc == OK )
{
erc = DiagErc[ref_elect_type][jj];
if( erc != OK )
{
if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 )
{
Diagnose( panel, g_NetObjectslist[NetItemRef], g_NetObjectslist[NetItemTst], 0, erc );
g_NetObjectslist[NetItemTst]->m_FlagOfConnection = NOCONNECT_SYMBOL_PRESENT;
Diagnose( panel,
g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemTst],
0,
erc );
g_NetObjectslist[NetItemTst]->m_FlagOfConnection =
NOCONNECT_SYMBOL_PRESENT;
}
}
}
......@@ -628,11 +678,10 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
/********************************************************/
static bool WriteDiagnosticERC( const wxString& FullFileName )
{
/*********************************************************/
/* Create the Diagnostic file (<xxx>.erc file)
*/
{
SCH_ITEM* DrawStruct;
MARKER_SCH* Marker;
char Line[1024];
......@@ -650,7 +699,9 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
EDA_SheetList SheetList;
for( Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() )
for( Sheet = SheetList.GetFirst();
Sheet != NULL;
Sheet = SheetList.GetNext() )
{
if( Sheet->Last() == g_RootSheet )
{
......@@ -691,8 +742,8 @@ static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b )
int at = a->m_Type;
int bt = b->m_Type;
if( (at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER)
&&(bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER) )
if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER )
&& ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) )
{
if( a->m_SheetList == b->m_SheetListInclude )
{
......@@ -704,44 +755,46 @@ static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b )
/***********************************************************************/
void TestLabel( WinEDA_DrawPanel* panel,
unsigned NetItemRef,
unsigned StartNet )
void TestLabel( WinEDA_DrawPanel* panel,
unsigned NetItemRef,
unsigned StartNet )
{
/***********************************************************************/
/* Routine controlant qu'un sheetLabel est bien connecte a un Glabel de la
* sous-feuille correspondante
/* Routine to perform erc on a sheetLabel that is connected to a corresponding
* sub sheet Glabel
*/
{
unsigned NetItemTst;
int erc = 1;
int erc = 1;
NetItemTst = StartNet;
/* Examen de la liste des Labels connectees a NetItemRef */
/* Review the list of labels connected to NetItemRef. */
for( ; ; NetItemTst++ )
{
if( NetItemTst == NetItemRef )
continue;
/* Est - on toujours dans le meme net ? */
/* Is always in the same net? */
if( ( NetItemTst == g_NetObjectslist.size() )
|| ( g_NetObjectslist[NetItemRef]->GetNet() != g_NetObjectslist[NetItemTst]->GetNet() ) )
|| ( g_NetObjectslist[NetItemRef]->GetNet() !=
g_NetObjectslist[NetItemTst]->GetNet() ) )
{
/* Fin de netcode trouve */
/* End Netcode found. */
if( erc )
{
/* GLabel ou SheetLabel orphelin */
/* Glabel or SheetLabel orphaned. */
Diagnose( panel, g_NetObjectslist[NetItemRef], NULL, -1, WAR );
}
return;
}
if( IsLabelsConnected( g_NetObjectslist[NetItemRef], g_NetObjectslist[NetItemTst] ) )
if( IsLabelsConnected( g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemTst] ) )
erc = 0;
//same thing, different order.
if( IsLabelsConnected( g_NetObjectslist[NetItemTst], g_NetObjectslist[NetItemRef] ) )
if( IsLabelsConnected( g_NetObjectslist[NetItemTst],
g_NetObjectslist[NetItemRef] ) )
erc = 0;
}
}
......@@ -38,13 +38,13 @@ enum errortype
/// DRC error codes:
#define ERCE_UNSPECIFIED 0
#define ERCE_DUPLICATE_SHEET_NAME 1 //duplicate sheet names within a given sheet
#define ERCE_PIN_NOT_CONNECTED 2 //pin not connected and not no connect symbol
#define ERCE_PIN_NOT_DRIVEN 3 //pin connected to some others pins but no pin to drive it
#define ERCE_PIN_TO_PIN_WARNING 4 //pin connected to an other pin: warning level
#define ERCE_PIN_TO_PIN_ERROR 5 //pin connected to an other pin: error level
#define ERCE_HIERACHICAL_LABEL 6 //mismatch between hierarchical labels and pins sheets
#define ERCE_NOCONNECT_CONNECTED 7 //a no connect symbol is connected to more than 1 pin
#define ERCE_DUPLICATE_SHEET_NAME 1 // duplicate sheet names within a given sheet
#define ERCE_PIN_NOT_CONNECTED 2 // pin not connected and not no connect symbol
#define ERCE_PIN_NOT_DRIVEN 3 // pin connected to some others pins but no pin to drive it
#define ERCE_PIN_TO_PIN_WARNING 4 // pin connected to an other pin: warning level
#define ERCE_PIN_TO_PIN_ERROR 5 // pin connected to an other pin: error level
#define ERCE_HIERACHICAL_LABEL 6 // mismatch between hierarchical labels and pins sheets
#define ERCE_NOCONNECT_CONNECTED 7 // a no connect symbol is connected to more than 1 pin
#endif // _ERC_H
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