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 @@ ...@@ -13,34 +13,35 @@
#include "general.h" #include "general.h"
/* Variables Locales */
/*******************************************************************************************/
bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent( bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent(
const wxString& aReference, const wxString& aReference,
const wxString& aFootPrint, const wxString& aFootPrint,
bool aSetVisible ) bool aSetVisible )
/********************************************************************************************/ {
/** function FillFootprintFieldForAllInstancesofComponent /** function FillFootprintFieldForAllInstancesofComponent
* Search for component "aReference", and place a Footprint in Footprint field * 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 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 * @return true if the given component is found
* Note: * 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) * 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; DrawSheetPath* sheet;
SCH_ITEM* DrawList = NULL; SCH_ITEM* DrawList = NULL;
EDA_SheetList SheetList; EDA_SheetList SheetList;
SCH_COMPONENT* Cmp; SCH_COMPONENT* Cmp;
bool found = false; 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(); DrawList = (SCH_ITEM*) sheet->LastDrawList();
for( ; (DrawList != NULL); DrawList = DrawList->Next() ) for( ; (DrawList != NULL); DrawList = DrawList->Next() )
...@@ -51,22 +52,27 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent( ...@@ -51,22 +52,27 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent(
Cmp = (SCH_COMPONENT*) DrawList; Cmp = (SCH_COMPONENT*) DrawList;
if( aReference.CmpNoCase( Cmp->GetRef( sheet ) ) == 0 ) if( aReference.CmpNoCase( Cmp->GetRef( sheet ) ) == 0 )
{ {
// Found: Init Footprint Field // 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 /* Give a reasonable value to the field position and
*/ * orientation, if the text is empty at position 0, because
if( Cmp->GetField(FOOTPRINT)->m_Text.IsEmpty() * it is probably not yet initialized
&& ( Cmp->GetField(FOOTPRINT)->m_Pos == wxPoint( 0, 0 ) ) ) */
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_Orient = Cmp->GetField(
Cmp->GetField(FOOTPRINT)->m_Pos = Cmp->GetField(VALUE)->m_Pos; VALUE )->m_Orient;
Cmp->GetField(FOOTPRINT)->m_Pos.y -= 100; 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 ) if( aSetVisible )
Cmp->GetField(FOOTPRINT)->m_Attributs &= ~TEXT_NO_VISIBLE; Cmp->GetField( FOOTPRINT )->m_Attributs &=
~TEXT_NO_VISIBLE;
else else
Cmp->GetField(FOOTPRINT)->m_Attributs |= TEXT_NO_VISIBLE; Cmp->GetField( FOOTPRINT )->m_Attributs |= TEXT_NO_VISIBLE;
found = true; found = true;
} }
} }
...@@ -76,11 +82,9 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent( ...@@ -76,11 +82,9 @@ bool WinEDA_SchematicFrame::FillFootprintFieldForAllInstancesofComponent(
} }
/***************************************************************************/
bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool
aSetFielsAttributeToVisible ) aSetFielsAttributeToVisible )
/***************************************************************************/ {
/** Function ProcessStuffFile /** Function ProcessStuffFile
* Read a "stuff" file created by cvpcb. * Read a "stuff" file created by cvpcb.
* That file has lines like: * That file has lines like:
...@@ -91,10 +95,10 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool ...@@ -91,10 +95,10 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool
* "module =" gives the footprint name * "module =" gives the footprint name
* *
* @param aStuffFile = file (*.stf) to Read. * @param aStuffFile = file (*.stf) to Read.
* @param aSetFielsAttributeToVisible = true to set the footprint field flag to visible * @param aSetFielsAttributeToVisible = true to set the footprint field flag to
* @return true if ok. * visible
* @return true if OK.
*/ */
{
int LineNum = 0; int LineNum = 0;
char* cp, Ref[256], FootPrint[256], Line[1024]; char* cp, Ref[256], FootPrint[256], Line[1024];
...@@ -112,9 +116,10 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool ...@@ -112,9 +116,10 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool
wxString reference = CONV_FROM_UTF8( Ref ); wxString reference = CONV_FROM_UTF8( Ref );
wxString Footprint = CONV_FROM_UTF8( FootPrint ); wxString Footprint = CONV_FROM_UTF8( FootPrint );
FillFootprintFieldForAllInstancesofComponent( reference, FillFootprintFieldForAllInstancesofComponent(
Footprint, reference,
aSetFielsAttributeToVisible ); Footprint,
aSetFielsAttributeToVisible );
} }
} }
...@@ -122,23 +127,20 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool ...@@ -122,23 +127,20 @@ bool WinEDA_SchematicFrame::ProcessStuffFile( FILE* aStuffFile, bool
} }
/**************************************************************/
bool WinEDA_SchematicFrame::ReadInputStuffFile() bool WinEDA_SchematicFrame::ReadInputStuffFile()
/**************************************************************/ {
/* Backann footprint info to schematic. /* Backann footprint info to schematic.
*/ */
{
wxString Line, filename; wxString Line, filename;
FILE* StuffFile; FILE* StuffFile;
wxString msg; wxString msg;
bool SetFieldToVisible = true; bool SetFieldToVisible = true;
filename = EDA_FileSelector( _( "Load Stuff File" ), filename = EDA_FileSelector( _( "Load Stuff File" ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString,
wxEmptyString, /* nom fichier par defaut */ wxEmptyString,
wxT( ".stf" ), /* extension par defaut */ wxT( ".stf" ),
wxT( "*.stf" ), /* Masque d'affichage */ wxT( "*.stf" ),
this, this,
wxFD_OPEN, wxFD_OPEN,
FALSE FALSE
...@@ -156,7 +158,7 @@ bool WinEDA_SchematicFrame::ReadInputStuffFile() ...@@ -156,7 +158,7 @@ bool WinEDA_SchematicFrame::ReadInputStuffFile()
int diag = wxMessageBox( int diag = wxMessageBox(
_( "Set the Footprint Field to Visible ?" ), _( "Set the Footprint Field to Visible ?" ),
_ ("Field Display Option"), _( "Field Display Option" ),
wxYES_NO | wxICON_QUESTION | wxCANCEL, this ); wxYES_NO | wxICON_QUESTION | wxCANCEL, this );
if( diag == wxCANCEL ) if( diag == wxCANCEL )
......
/****************************************************/ /****************************************************/
/* BLOCK.CPP */ /* BLOCK.CPP */
/* Gestion des Operations sur Blocks et Effacements */
/****************************************************/ /****************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -18,41 +17,35 @@ ...@@ -18,41 +17,35 @@
#include "protos.h" #include "protos.h"
/* Variables Locales */
// Imported functions: // Imported functions:
void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList, void MoveItemsInList( PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector ); const wxPoint aMoveVector );
void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList, void MirrorListOfItems( PICKED_ITEMS_LIST& aItemsList,
wxPoint& Center ); wxPoint& Center );
void DeleteItemsInList( WinEDA_DrawPanel* panel, void DeleteItemsInList( WinEDA_DrawPanel* panel,
PICKED_ITEMS_LIST& aItemsList ); PICKED_ITEMS_LIST& aItemsList );
void DuplicateItemsInList( SCH_SCREEN* screen, void DuplicateItemsInList( SCH_SCREEN* screen,
PICKED_ITEMS_LIST& aItemsList, PICKED_ITEMS_LIST& aItemsList,
const wxPoint aMoveVector ); const wxPoint aMoveVector );
/* Fonctions exportees */ static void CollectStructsToDrag( SCH_SCREEN* screen );
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition );
/* Fonctions Locales */ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
static void CollectStructsToDrag( SCH_SCREEN* screen ); wxPoint& aPosition,
static void AddPickedItem( SCH_SCREEN* screen, wxPoint aPosition ); bool aSearchFirst );
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel,
wxPoint& aPosition, wxDC* DC,
bool aSearchFirst ); bool erase );
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
wxDC* DC,
bool erase );
static void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList );
/*************************************************************************/ /*************************************************************************/
int WinEDA_SchematicFrame::ReturnBlockCommand( int key ) int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
{
/*************************************************************************/ /*************************************************************************/
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to /* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the key (ALT, SHIFT ALT ..) * the key (ALT, SHIFT ALT ..)
*/ */
{
int cmd; int cmd;
switch( key ) switch( key )
...@@ -89,11 +82,10 @@ int WinEDA_SchematicFrame::ReturnBlockCommand( int key ) ...@@ -89,11 +82,10 @@ int WinEDA_SchematicFrame::ReturnBlockCommand( int key )
/*************************************************/ /*************************************************/
void WinEDA_SchematicFrame::InitBlockPasteInfos() void WinEDA_SchematicFrame::InitBlockPasteInfos()
{
/*************************************************/ /*************************************************/
/* Init the parameters used by the block paste command /* Init the parameters used by the block paste command
*/ */
{
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
block->m_ItemsSelection.CopyList( g_BlockSaveDataList.m_ItemsSelection ); block->m_ItemsSelection.CopyList( g_BlockSaveDataList.m_ItemsSelection );
...@@ -103,14 +95,13 @@ void WinEDA_SchematicFrame::InitBlockPasteInfos() ...@@ -103,14 +95,13 @@ void WinEDA_SchematicFrame::InitBlockPasteInfos()
/******************************************************/ /******************************************************/
void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
{
/******************************************************/ /******************************************************/
/* Routine to handle the BLOCK PLACE command
/* Routine to handle the BLOCK PLACE commande
* Last routine for block operation for: * Last routine for block operation for:
* - block move & drag * - block move & drag
* - block copie & paste * - block copy & paste
*/ */
{
bool err = FALSE; bool err = FALSE;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
...@@ -124,7 +115,8 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -124,7 +115,8 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
{ {
wxString msg; wxString msg;
err = TRUE; 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 ); block->m_Command, block->m_State );
DisplayError( this, msg ); DisplayError( this, msg );
} }
...@@ -142,7 +134,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -142,7 +134,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); 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 ); MoveItemsInList( block->m_ItemsSelection, block->m_MoveVector );
block->ClearItemsList(); block->ClearItemsList();
...@@ -153,15 +147,18 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -153,15 +147,18 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); 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, SaveCopyInUndoList(
(block->m_Command == BLOCK_PRESELECT_MOVE) ? UR_CHANGED : UR_NEW ); block->m_ItemsSelection,
(block->m_Command ==
BLOCK_PRESELECT_MOVE) ? UR_CHANGED : UR_NEW );
block->ClearItemsList(); block->ClearItemsList();
break; break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ case BLOCK_PASTE:
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
PasteListOfItems( DC ); PasteListOfItems( DC );
...@@ -184,7 +181,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -184,7 +181,9 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
/* clear struct.m_Flags */ /* clear struct.m_Flags */
SCH_ITEM* Struct; 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; Struct->m_Flags = 0;
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
...@@ -198,27 +197,27 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC ) ...@@ -198,27 +197,27 @@ void WinEDA_SchematicFrame::HandleBlockPlace( wxDC* DC )
if( block->GetCount() ) 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(); block->ClearItemsList();
} }
SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor, SetToolID( m_ID_current_state, DrawPanel->m_PanelDefaultCursor,
wxEmptyString ); wxEmptyString );
DrawPanel->Refresh( ); DrawPanel->Refresh();
} }
/****************************************************/ /****************************************************/
int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
{
/****************************************************/ /****************************************************/
/* Manage end block command
/* Routine de gestion de la commande BLOCK END * Returns:
* retourne : * 0 if no features selected
* 0 si aucun composant selectionne * 1 otherwise
* 1 sinon * -1 If control ended and components selection (block delete, block save)
* -1 si commande terminee et composants trouves (block delete, block save)
*/ */
{
int ii = 0; int ii = 0;
bool zoom_command = FALSE; bool zoom_command = FALSE;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
...@@ -247,6 +246,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -247,6 +246,7 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */ case BLOCK_DRAG: /* Drag */
BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() ); BreakSegmentOnJunction( (SCH_SCREEN*) GetScreen() );
case BLOCK_MOVE: /* Move */ case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */ case BLOCK_COPY: /* Copy */
PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() ); PickItemsInBlock( GetScreen()->m_BlockLocate, GetScreen() );
...@@ -288,9 +288,11 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -288,9 +288,11 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE ); DrawAndSizingBlockOutlines( DrawPanel, DC, FALSE );
if( block->GetCount() ) if( block->GetCount() )
{ {
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition; wxPoint move_vector =
-GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
SaveStructListForPaste( block->m_ItemsSelection ); SaveStructListForPaste( block->m_ItemsSelection );
MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector); MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection,
move_vector );
ii = -1; ii = -1;
} }
block->ClearItemsList(); block->ClearItemsList();
...@@ -321,7 +323,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -321,7 +323,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
{ {
/* clear struct.m_Flags */ /* clear struct.m_Flags */
EDA_BaseStruct* Struct; 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; Struct->m_Flags = 0;
} }
...@@ -333,7 +337,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -333,7 +337,9 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( 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 ) if( zoom_command )
...@@ -345,13 +351,12 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC ) ...@@ -345,13 +351,12 @@ int WinEDA_SchematicFrame::HandleBlockEnd( wxDC* DC )
/***********************************************************************/ /***********************************************************************/
void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
{
/***********************************************************************/ /***********************************************************************/
/* Manage end block command from context menu.
/* Routine de gestion de la commande BLOCK END by PopUp * Called after HandleBlockEnd.
* Appelee apres HandleBlockEnd. * From the command block move can execute a command other than block move.
* A partir de la commande bloc move, peut executer une commande autre que bloc move.
*/ */
{
int ii = 0; int ii = 0;
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
...@@ -372,8 +377,10 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -372,8 +377,10 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
case BLOCK_DRAG: /* move to Drag */ case BLOCK_DRAG: /* move to Drag */
/* Effacement de la liste des structures de pointage, /* *JP translate*
* qui est devenue erronnee */ * Effacement de la liste des structures de pointage,
* qui est devenue erronnee
*/
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
block->ClearItemsList(); block->ClearItemsList();
...@@ -410,7 +417,8 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -410,7 +417,8 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
if( block->GetCount() ) if( block->GetCount() )
{ {
wxPoint move_vector = -GetScreen()->m_BlockLocate.m_BlockLastCursorPosition; wxPoint move_vector =
-GetScreen()->m_BlockLocate.m_BlockLastCursorPosition;
SaveStructListForPaste( block->m_ItemsSelection ); SaveStructListForPaste( block->m_ItemsSelection );
MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector ); MoveItemsInList( g_BlockSaveDataList.m_ItemsSelection, move_vector );
ii = -1; ii = -1;
...@@ -435,10 +443,12 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -435,10 +443,12 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
if( block->GetCount() ) if( block->GetCount() )
{ {
ii = -1; ii = -1;
/* Compute the mirror centre and put it on grid */ /* Compute the mirror center and put it on grid */
wxPoint mirrorPoint = block->Centre(); wxPoint mirrorPoint = block->Centre();
PutOnGrid( &mirrorPoint ); PutOnGrid( &mirrorPoint );
SaveCopyInUndoList( block->m_ItemsSelection, UR_MIRRORED_Y, mirrorPoint ); SaveCopyInUndoList( block->m_ItemsSelection,
UR_MIRRORED_Y,
mirrorPoint );
MirrorListOfItems( block->m_ItemsSelection, mirrorPoint ); MirrorListOfItems( block->m_ItemsSelection, mirrorPoint );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
...@@ -459,7 +469,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC ) ...@@ -459,7 +469,9 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( 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 ) ...@@ -467,18 +479,17 @@ void WinEDA_SchematicFrame::HandleBlockEndByPopUp( int Command, wxDC* DC )
/************************************************************************/ /************************************************************************/
static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
bool erase ) bool erase )
{
/************************************************************************/ /************************************************************************/
/* Traces the outline of the search block structures
/* Retrace le contour du block de recherche de structures * The entire block follows the cursor
* L'ensemble du block suit le curseur
*/ */
{
BLOCK_SELECTOR* block = &panel->GetScreen()->m_BlockLocate;; BLOCK_SELECTOR* block = &panel->GetScreen()->m_BlockLocate;;
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
SCH_ITEM* schitem; SCH_ITEM* schitem;
/* Effacement ancien cadre */ /* Erase old block contents. */
if( erase ) if( erase )
{ {
block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color ); block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color );
...@@ -489,8 +500,7 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -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->m_MoveVector = screen->m_Curseur - block->m_BlockLastCursorPosition;
block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color ); block->Draw( panel, DC, block->m_MoveVector, g_XorMode, block->m_Color );
...@@ -505,22 +515,24 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -505,22 +515,24 @@ static void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC,
/*****************************************************************/ /*****************************************************************/
void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList ) void SaveStructListForPaste( PICKED_ITEMS_LIST& aItemsList )
{
/*****************************************************************/ /*****************************************************************/
/* Routine to Save an object from global drawing object list. /* Routine to Save an object from global drawing object list.
* This routine is the same as delete but: * This routine is the same as delete but:
* - the original list is NOT removed. * - the original list is NOT removed.
* - List is saved in g_BlockSaveDataList * - List is saved in g_BlockSaveDataList
*/ */
{ g_BlockSaveDataList.ClearListAndDeleteItems(); // delete previous
g_BlockSaveDataList.ClearListAndDeleteItems(); // delete previous saved list, if exists // saved list, if
// exists
/* save the new list: */ /* save the new list: */
ITEM_PICKER item; ITEM_PICKER item;
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
/* Make a copy of the original picked item. */ /* 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 ); DrawStructCopy->SetParent( NULL );
item.m_PickedItem = DrawStructCopy; item.m_PickedItem = DrawStructCopy;
g_BlockSaveDataList.PushItem( item ); g_BlockSaveDataList.PushItem( item );
...@@ -545,10 +557,12 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) ...@@ -545,10 +557,12 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
PICKED_ITEMS_LIST picklist; PICKED_ITEMS_LIST picklist;
// Creates data, and push it as new data in undo item list buffer // 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++ ) 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; picker.m_PickedItem = Struct;
picklist.PushItem( picker ); picklist.PushItem( picker );
...@@ -569,7 +583,9 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) ...@@ -569,7 +583,9 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
MoveItemsInList( picklist, GetScreen()->m_BlockLocate.m_MoveVector ); MoveItemsInList( picklist, GetScreen()->m_BlockLocate.m_MoveVector );
/* clear .m_Flags member for all items */ /* 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; Struct->m_Flags = 0;
GetScreen()->SetModify(); GetScreen()->SetModify();
...@@ -580,13 +596,12 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC ) ...@@ -580,13 +596,12 @@ void WinEDA_SchematicFrame::PasteListOfItems( wxDC* DC )
/****************************************************/ /****************************************************/
static void CollectStructsToDrag( SCH_SCREEN* screen ) static void CollectStructsToDrag( SCH_SCREEN* screen )
{
/****************************************************/ /****************************************************/
/* creates the list of items found when a drag block is initiated. /* 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 * items are those selected in window block an some items outside this area but
* to a selected item (connected wires to a component or an entry ) * connected to a selected item (connected wires to a component or an entry )
*/ */
{
SCH_ITEM* Struct; SCH_ITEM* Struct;
EDA_DrawLineStruct* SegmStruct; EDA_DrawLineStruct* SegmStruct;
...@@ -601,14 +616,16 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -601,14 +616,16 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() ) for( Struct = screen->EEDrawList; Struct != NULL; Struct = Struct->Next() )
Struct->m_Flags = 0; 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 ) if( pickedlist->GetCount() == 1 )
{ {
Struct = (SCH_ITEM*) pickedlist->GetPickedItem( 0 ); Struct = (SCH_ITEM*) pickedlist->GetPickedItem( 0 );
if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE ) if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
Struct->m_Flags = SELECTED; 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 else
{ {
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
...@@ -622,41 +639,40 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -622,41 +639,40 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
return; return;
/* Suppression du deplacement des extremites de segments hors cadre /* Remove the displacement of segment and undo the selection. */
* de selection */
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) 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 ) if( Struct->Type() == DRAW_SEGMENT_STRUCT_TYPE )
{ {
SegmStruct = (EDA_DrawLineStruct*) Struct; SegmStruct = (EDA_DrawLineStruct*) Struct;
if( ! screen->m_BlockLocate.Inside(SegmStruct->m_Start) ) if( !screen->m_BlockLocate.Inside( SegmStruct->m_Start ) )
SegmStruct->m_Flags |= STARTPOINT; SegmStruct->m_Flags |= STARTPOINT;
if( ! screen->m_BlockLocate.Inside(SegmStruct->m_End) ) if( !screen->m_BlockLocate.Inside( SegmStruct->m_End ) )
SegmStruct->m_Flags |= ENDPOINT; SegmStruct->m_Flags |= ENDPOINT;
// Save m_Flags for Undo/redo drag operations: // 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++ ) 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 ) if( Struct->Type() == TYPE_SCH_COMPONENT )
{ {
// Add all pins of the selected component to list // Add all pins of the selected component to list
LIB_PIN* pin; LIB_PIN* pin;
wxPoint pos; wxPoint pos;
pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, true ); pin = GetNextPinPosition( (SCH_COMPONENT*) Struct, pos, true );
while( pin ) while( pin )
{ {
if( ! screen->m_BlockLocate.Inside(pos) ) if( !screen->m_BlockLocate.Inside( pos ) )
{ {
// This pin is outside area, // This pin is outside area,
// but because it it the pin of a selected component // but because it it the pin of a selected component
...@@ -693,17 +709,17 @@ static void CollectStructsToDrag( SCH_SCREEN* screen ) ...@@ -693,17 +709,17 @@ static void CollectStructsToDrag( SCH_SCREEN* screen )
/******************************************************************/ /******************************************************************/
static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
{
/******************************************************************/ /******************************************************************/
/** AddPickedItem /** 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 screen = the screen to consider
* @param position = the wxPoint where items must be located to be select * @param position = the wxPoint where items must be located to be select
*/ */
{
SCH_ITEM* Struct; 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; PICKED_ITEMS_LIST* pickedlist = &screen->m_BlockLocate.m_ItemsSelection;
for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ ) for( unsigned ii = 0; ii < pickedlist->GetCount(); ii++ )
...@@ -722,7 +738,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -722,7 +738,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
STRUCT->m_Flags &= ~ENDPOINT; STRUCT->m_Flags &= ~ENDPOINT;
// Save m_Flags for Undo/redo drag operations: // Save m_Flags for Undo/redo drag operations:
pickedlist->SetPickerFlags(STRUCT->m_Flags, ii); pickedlist->SetPickerFlags( STRUCT->m_Flags, ii );
break; break;
default: default:
...@@ -730,13 +746,13 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -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; ITEM_PICKER picker;
Struct = screen->EEDrawList; Struct = screen->EEDrawList;
while( Struct ) while( Struct )
{ {
picker.m_PickedItem = Struct; picker.m_PickedItem = Struct;
picker.m_PickedItemType = Struct->Type(); picker.m_PickedItemType = Struct->Type();
switch( Struct->Type() ) switch( Struct->Type() )
{ {
...@@ -745,14 +761,14 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -745,14 +761,14 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
case DRAW_POLYLINE_STRUCT_TYPE: case DRAW_POLYLINE_STRUCT_TYPE:
if( Struct->m_Flags & SELECTED ) if( Struct->m_Flags & SELECTED )
break; /* Deja en liste */ break;
break; break;
case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_JUNCTION_STRUCT_TYPE:
#undef STRUCT #undef STRUCT
#define STRUCT ( (DrawJunctionStruct*) Struct ) #define STRUCT ( (DrawJunctionStruct*) Struct )
if( Struct->m_Flags & SELECTED ) if( Struct->m_Flags & SELECTED )
break; /* Deja en liste */ break;
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
pickedlist->PushItem( picker ); pickedlist->PushItem( picker );
...@@ -762,21 +778,23 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -762,21 +778,23 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT #undef STRUCT
#define STRUCT ( (EDA_DrawLineStruct*) Struct ) #define STRUCT ( (EDA_DrawLineStruct*) Struct )
if( Struct->m_Flags & SELECTED ) if( Struct->m_Flags & SELECTED )
break; /* Deja en liste */ break;
if( STRUCT->m_Start == position ) if( STRUCT->m_Start == position )
{ {
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~STARTPOINT; Struct->m_Flags &= ~STARTPOINT;
// Save m_Flags for Undo/redo drag operations: // Save m_Flags for Undo/redo drag operations:
picker.m_PickerFlags= Struct->m_Flags; picker.m_PickerFlags = Struct->m_Flags;
pickedlist->PushItem( picker ); pickedlist->PushItem( picker );
} }
else if( STRUCT->m_End == position ) else if( STRUCT->m_End == position )
{ {
Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT; Struct->m_Flags = SELECTED | ENDPOINT | STARTPOINT;
Struct->m_Flags &= ~ENDPOINT; Struct->m_Flags &= ~ENDPOINT;
// Save m_Flags for Undo/redo drag operations: // Save m_Flags for Undo/redo drag operations:
picker.m_PickerFlags= Struct->m_Flags; picker.m_PickerFlags = Struct->m_Flags;
pickedlist->PushItem( picker ); pickedlist->PushItem( picker );
} }
break; break;
...@@ -791,7 +809,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -791,7 +809,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_LABEL*) Struct ) #define STRUCT ( (SCH_LABEL*) Struct )
if( Struct->m_Flags & SELECTED ) if( Struct->m_Flags & SELECTED )
break; /* Already in list */ break; /* Already in list */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
Struct->m_Flags |= SELECTED; Struct->m_Flags |= SELECTED;
...@@ -803,7 +821,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -803,7 +821,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT #undef STRUCT
#define STRUCT ( (SCH_LABEL*) Struct ) #define STRUCT ( (SCH_LABEL*) Struct )
if( Struct->m_Flags & SELECTED ) if( Struct->m_Flags & SELECTED )
break; /* Already in list */ break; /* Already in list */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
Struct->m_Flags |= SELECTED; Struct->m_Flags |= SELECTED;
...@@ -819,7 +837,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -819,7 +837,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT #undef STRUCT
#define STRUCT ( (MARKER_SCH*) Struct ) #define STRUCT ( (MARKER_SCH*) Struct )
if( Struct->m_Flags & SELECTED ) if( Struct->m_Flags & SELECTED )
break; /* Already in list */ break; /* Already in list */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
Struct->m_Flags |= SELECTED; Struct->m_Flags |= SELECTED;
...@@ -830,7 +848,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -830,7 +848,7 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
#undef STRUCT #undef STRUCT
#define STRUCT ( (DrawNoConnectStruct*) Struct ) #define STRUCT ( (DrawNoConnectStruct*) Struct )
if( Struct->m_Flags & SELECTED ) if( Struct->m_Flags & SELECTED )
break; /* Already in list */ break; /* Already in list */
if( STRUCT->m_Pos != position ) if( STRUCT->m_Pos != position )
break; break;
Struct->m_Flags |= SELECTED; Struct->m_Flags |= SELECTED;
...@@ -845,20 +863,20 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position ) ...@@ -845,20 +863,20 @@ static void AddPickedItem( SCH_SCREEN* screen, wxPoint position )
} }
/*********************************************************************************/ /****************************************************************************/
static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
wxPoint& aPosition, wxPoint& aPosition,
bool aSearchFirst) bool aSearchFirst )
/*********************************************************************************/ {
/****************************************************************************/
/** GetNextPinPosition() /** GetNextPinPosition()
* calculate position of the "next" pin of the aDrawLibItem component * calculate position of the "next" pin of the aDrawLibItem component
* @param aDrawLibItem = component to test. * @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 * @param aSearchFirst = if true, search for the first pin
* @return a pointer to the pin * @return a pointer to the pin
*/ */
{
static LIB_COMPONENT* Entry; static LIB_COMPONENT* Entry;
static int Multi, convert, TransMat[2][2]; static int Multi, convert, TransMat[2][2];
static wxPoint CmpPosition; static wxPoint CmpPosition;
...@@ -871,8 +889,8 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -871,8 +889,8 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
if( Entry == NULL ) if( Entry == NULL )
return NULL; return NULL;
Pin = Entry->GetNextPin(); Pin = Entry->GetNextPin();
Multi = aDrawLibItem->m_Multi; Multi = aDrawLibItem->m_Multi;
convert = aDrawLibItem->m_Convert; convert = aDrawLibItem->m_Convert;
CmpPosition = aDrawLibItem->m_Pos; CmpPosition = aDrawLibItem->m_Pos;
memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) ); memcpy( TransMat, aDrawLibItem->m_Transform, sizeof(TransMat) );
...@@ -890,9 +908,11 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem, ...@@ -890,9 +908,11 @@ static LIB_PIN* GetNextPinPosition( SCH_COMPONENT* aDrawLibItem,
if( convert && Pin->m_Convert && ( Pin->m_Convert != convert ) ) if( convert && Pin->m_Convert && ( Pin->m_Convert != convert ) )
continue; 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; aPosition = TransformCoordinate( TransMat, Pin->m_Pos ) + CmpPosition;
return Pin; return Pin;
} }
return NULL; return NULL;
} }
/****************************************************/ /****************************************************/
/* block_libedit.cpp */ /* block_libedit.cpp */
/* Gestion des Operations sur Blocks et Effacements */
/****************************************************/ /****************************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -191,10 +190,10 @@ int WinEDA_LibeditFrame::HandleBlockEnd( wxDC* DC ) ...@@ -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: * Last routine for block operation for:
* - block move & drag * - block move & drag
* - block copie & paste * - block copy & paste
*/ */
void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
{ {
...@@ -238,7 +237,7 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -238,7 +237,7 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
m_component->CopySelectedItems( pt ); m_component->CopySelectedItems( pt );
break; break;
case BLOCK_PASTE: /* Paste (recopie du dernier bloc sauve */ case BLOCK_PASTE: /* Paste (recopy the last block saved) */
GetScreen()->m_BlockLocate.ClearItemsList(); GetScreen()->m_BlockLocate.ClearItemsList();
break; break;
...@@ -276,8 +275,8 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC ) ...@@ -276,8 +275,8 @@ void WinEDA_LibeditFrame::HandleBlockPlace( wxDC* DC )
/* /*
* Retrace le contour du block de recherche de structures * Traces the outline of the search block structures
* L'ensemble du block suit le curseur * The entire block follows the cursor
*/ */
void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) void DrawMovingBlockOutlines( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{ {
...@@ -307,7 +306,7 @@ 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 ); true, true, true );
} }
/* Redessin nouvel affichage */ /* Repaint new view */
PtBlock->m_MoveVector.x = PtBlock->m_MoveVector.x =
screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x; screen->m_Curseur.x - PtBlock->m_BlockLastCursorPosition.x;
PtBlock->m_MoveVector.y = PtBlock->m_MoveVector.y =
......
// Name: build_BOM.cpp /////////////////////////////////////////////////////////////////////////////
// Name: build_BOM.cpp
// Purpose: // Purpose:
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Licence: GPL license // License: GPL license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include <algorithm> // to use sort vector #include <algorithm> // to use sort vector
...@@ -37,8 +38,7 @@ public: ...@@ -37,8 +38,7 @@ public:
//have to store it here since the object references will be duplicated. //have to store it here since the object references will be duplicated.
DrawSheetPath m_SheetPath; //composed of UIDs DrawSheetPath m_SheetPath; //composed of UIDs
public: public: LABEL_OBJECT()
LABEL_OBJECT()
{ {
m_Label = NULL; m_Label = NULL;
m_LabelType = 0; m_LabelType = 0;
...@@ -52,12 +52,17 @@ static const wxString BomFileExtension( wxT( "lst" ) ); ...@@ -52,12 +52,17 @@ static const wxString BomFileExtension( wxT( "lst" ) );
/* Local functions */ /* 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 void GenListeGLabels( std::vector <LABEL_OBJECT>& aList );
static bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ); static bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1,
static bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& obj2 ); const OBJ_CMP_TO_LIST& obj2 );
static bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ); static bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1,
static bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ); 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 void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList );
static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ); static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList );
...@@ -79,8 +84,8 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( bool aTypeFileIsExport, ...@@ -79,8 +84,8 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( bool aTypeFileIsExport,
bool aIncludeSubComponents, bool aIncludeSubComponents,
char aExportSeparatorSymbol, char aExportSeparatorSymbol,
bool aRunBrowser ) bool aRunBrowser )
/**************************************************************************/
{ {
/**************************************************************************/
wxFileName fn; wxFileName fn;
s_ExportSeparatorSymbol = aExportSeparatorSymbol; s_ExportSeparatorSymbol = aExportSeparatorSymbol;
...@@ -120,18 +125,16 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( bool aTypeFileIsExport, ...@@ -120,18 +125,16 @@ void DIALOG_BUILD_BOM::Create_BOM_Lists( bool aTypeFileIsExport,
/****************************************************************************/ /****************************************************************************/
void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName, void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName,
bool aIncludeSubComponents ) bool aIncludeSubComponents )
{
/****************************************************************************/ /****************************************************************************/
/* /*
* Print a list of components, in a form which can be imported by a spreadsheet * Print a list of components, in a form which can be imported by a spreadsheet
* form is: * form is:
* cmp name; cmp val; fields; * cmp name; cmp val; fields;
*/ */
{
FILE* f; FILE* f;
wxString msg; wxString msg;
/* Creation de la liste des elements */
if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL ) if( ( f = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL )
{ {
msg = _( "Failed to open file " ); msg = _( "Failed to open file " );
...@@ -157,15 +160,16 @@ void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName, ...@@ -157,15 +160,16 @@ void DIALOG_BUILD_BOM::CreateExportList( const wxString& aFullFileName,
/****************************************************************************/ /****************************************************************************/
void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, void DIALOG_BUILD_BOM::GenereListeOfItems(
bool aIncludeSubComponents ) const wxString& aFullFileName,
bool
aIncludeSubComponents )
{
/****************************************************************************/ /****************************************************************************/
/** GenereListeOfItems() /** GenereListeOfItems()
* Main function to create the list of components and/or labels * Main function to create the list of components and/or labels
* (global labels and pin sheets" ) * (global labels and pin sheets" )
*/ */
{
FILE* f; FILE* f;
int itemCount; int itemCount;
char Line[1024]; char Line[1024];
...@@ -217,8 +221,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, ...@@ -217,8 +221,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
if( m_GenListLabelsbySheet->GetValue() ) if( m_GenListLabelsbySheet->GetValue() )
{ {
sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsBySheet ); sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsBySheet );
msg.Printf( _( msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets \
"\n#Global, Hierarchical Labels and PinSheets ( order = Sheet Number ) count = %d\n" ), ( order = Sheet Number ) count = %d\n" ),
itemCount ); itemCount );
fprintf( f, "%s", CONV_TO_UTF8( msg ) ); fprintf( f, "%s", CONV_TO_UTF8( msg ) );
PrintListeGLabel( f, listOfLabels ); PrintListeGLabel( f, listOfLabels );
...@@ -228,8 +232,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, ...@@ -228,8 +232,8 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
{ {
sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsByValue ); sort( listOfLabels.begin(), listOfLabels.end(), SortLabelsByValue );
msg.Printf( _( msg.Printf( _( "\n#Global, Hierarchical Labels and PinSheets ( \
"\n#Global, Hierarchical Labels and PinSheets ( order = Alphab. ) count = %d\n\n" ), order = Alphab. ) count = %d\n\n" ),
itemCount ); itemCount );
fprintf( f, "%s", CONV_TO_UTF8( msg ) ); fprintf( f, "%s", CONV_TO_UTF8( msg ) );
PrintListeGLabel( f, listOfLabels ); PrintListeGLabel( f, listOfLabels );
...@@ -244,16 +248,15 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName, ...@@ -244,16 +248,15 @@ void DIALOG_BUILD_BOM::GenereListeOfItems( const wxString& aFullFileName,
/***************************************************************************/ /***************************************************************************/
void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ) void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
{
/***************************************************************************/ /***************************************************************************/
/* Creates the list of components found in the whole schematic /* Creates the list of components found in the whole schematic
* *
* if List == null, just returns the count. if not, fills the list. * if List == null, just returns the count. if not, fills the list.
* goes through the sheets, not the screens, so that we account for * goes through the sheets, not the screens, so that we account for
* multiple instances of a given screen. * 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; EDA_BaseStruct* SchItem;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
DrawSheetPath* sheet; DrawSheetPath* sheet;
...@@ -261,9 +264,12 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ) ...@@ -261,9 +264,12 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
/* Build the sheet (not screen) list */ /* Build the sheet (not screen) list */
EDA_SheetList SheetList; 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 ) if( SchItem->Type() != TYPE_SCH_COMPONENT )
continue; continue;
...@@ -279,7 +285,7 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ) ...@@ -279,7 +285,7 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ), CONV_TO_UTF8( DrawLibItem->GetRef( sheet ) ),
sizeof( item.m_Reference ) ); 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; item.m_Reference[sizeof( item.m_Reference ) - 1 ] = 0;
aList.push_back( item ); aList.push_back( item );
} }
...@@ -289,11 +295,10 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList ) ...@@ -289,11 +295,10 @@ void BuildComponentsListFromSchematic( std::vector <OBJ_CMP_TO_LIST>& aList )
/****************************************************************/ /****************************************************************/
static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
{
/****************************************************************/ /****************************************************************/
/* Fill aList with Glabel info /* Fill aList with Glabel info
*/ */
{
SCH_ITEM* DrawList; SCH_ITEM* DrawList;
Hierarchical_PIN_Sheet_Struct* PinLabel; Hierarchical_PIN_Sheet_Struct* PinLabel;
DrawSheetPath* sheet; DrawSheetPath* sheet;
...@@ -303,7 +308,9 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) ...@@ -303,7 +308,9 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
LABEL_OBJECT labet_object; 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(); DrawList = (SCH_ITEM*) sheet->LastDrawList();
while( DrawList ) while( DrawList )
...@@ -323,7 +330,8 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) ...@@ -323,7 +330,8 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList )
PinLabel = ( (DrawSheetStruct*) DrawList )->m_Label; PinLabel = ( (DrawSheetStruct*) DrawList )->m_Label;
while( PinLabel != NULL ) 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_SheetPath = *sheet;
labet_object.m_Label = PinLabel; labet_object.m_Label = PinLabel;
aList.push_back( labet_object ); aList.push_back( labet_object );
...@@ -342,17 +350,17 @@ static void GenListeGLabels( std::vector <LABEL_OBJECT>& aList ) ...@@ -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 ) bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1,
/************************************************************************************/ const OBJ_CMP_TO_LIST& obj2 )
{
/* Compare fuinction for sort() /*****************************************************************************/
/* Compare function for sort()
* components are sorted * components are sorted
* by value * by value
* if same value: by reference * if same value: by reference
* if same reference: by unit number * if same reference: by unit number
*/ */
{
int ii; int ii;
const wxString* Text1, * Text2; const wxString* Text1, * Text2;
...@@ -374,17 +382,17 @@ bool SortComponentsByValue( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LIST& ...@@ -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 /* compare function for sorting
* components are sorted * components are sorted
* by reference * by reference
* if same reference: by value * if same reference: by value
* if same value: by unit number * if same value: by unit number
*/ */
{
int ii; int ii;
const wxString* Text1, * Text2; const wxString* Text1, * Text2;
...@@ -408,26 +416,25 @@ bool SortComponentsByReference( const OBJ_CMP_TO_LIST& obj1, const OBJ_CMP_TO_LI ...@@ -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 ) bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
{
/*******************************************************************/ /*******************************************************************/
/* compare function for sorting labels /* compare function for sorting labels
* sort by * sort by
* value * value
* if same value: by sheet * if same value: by sheet
*/ */
{
int ii; int ii;
wxString* Text1, * Text2; wxString* Text1, * Text2;
if( obj1.m_LabelType == DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ) 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 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 ) 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 else
Text2 = &( (SCH_TEXT*)(obj2.m_Label) )->m_Text; Text2 = &( (SCH_TEXT*) (obj2.m_Label) )->m_Text;
ii = Text1->CmpNoCase( *Text2 ); ii = Text1->CmpNoCase( *Text2 );
...@@ -440,15 +447,14 @@ bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ) ...@@ -440,15 +447,14 @@ bool SortLabelsByValue( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
} }
/*************************************************************************************/ /*****************************************************************************/
bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ) bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
/*************************************************************************************/ {
/*****************************************************************************/
/* compare function for sorting labels /* compare function for sorting labels
* by sheet * by sheet
* in a sheet, by alphabetic order * in a sheet, by alphabetic order
*/ */
{
int ii; int ii;
wxString Text1, Text2; wxString Text1, Text2;
...@@ -476,12 +482,12 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 ) ...@@ -476,12 +482,12 @@ bool SortLabelsBySheet( const LABEL_OBJECT& obj1, const LABEL_OBJECT& obj2 )
/**************************************************************/ /**************************************************************/
static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ) static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
{
/**************************************************************/ /**************************************************************/
/* Remove sub components from the list, when multiples parts per package are
/* Remove sub components from the list, when multiples parts per package are found in this list * found in this list
* The component list **MUST** be sorted by reference and by unit number * The component list **MUST** be sorted by reference and by unit number
*/ */
{
SCH_COMPONENT* libItem; SCH_COMPONENT* libItem;
wxString oldName; wxString oldName;
wxString currName; wxString currName;
...@@ -497,7 +503,8 @@ static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ) ...@@ -497,7 +503,8 @@ static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
if( !oldName.IsEmpty() ) 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 ); aList.erase( aList.begin() + ii );
ii--; ii--;
...@@ -508,13 +515,14 @@ static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList ) ...@@ -508,13 +515,14 @@ static void DeleteSubCmp( std::vector <OBJ_CMP_TO_LIST>& aList )
} }
/*******************************************************************************************/ /****************************************************************************/
void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem, void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
bool CompactForm ) bool CompactForm )
/*******************************************************************************************/
{ {
/****************************************************************************/
// @todo make this variable length // @todo make this variable length
const wxCheckBox* FieldListCtrl[] = { const wxCheckBox* FieldListCtrl[] =
{
m_AddField1, m_AddField1,
m_AddField2, m_AddField2,
m_AddField3, m_AddField3,
...@@ -526,17 +534,18 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem, ...@@ -526,17 +534,18 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
}; };
int ii; int ii;
const wxCheckBox* FieldCtrl = FieldListCtrl[0]; const wxCheckBox* FieldCtrl = FieldListCtrl[0];
if( m_AddFootprintField->IsChecked() ) if( m_AddFootprintField->IsChecked() )
{ {
if( CompactForm ) if( CompactForm )
{ {
fprintf( f, "%c%s", s_ExportSeparatorSymbol, fprintf( f, "%c%s", s_ExportSeparatorSymbol,
CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField( FOOTPRINT )->m_Text ) );
} }
else 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++ ) for( ii = FIELD1; ii < DrawLibItem->GetFieldCount(); ii++ )
...@@ -557,24 +566,24 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem, ...@@ -557,24 +566,24 @@ void DIALOG_BUILD_BOM::PrintFieldData( FILE* f, SCH_COMPONENT* DrawLibItem,
if( CompactForm ) if( CompactForm )
fprintf( f, "%c%s", s_ExportSeparatorSymbol, fprintf( f, "%c%s", s_ExportSeparatorSymbol,
CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField( ii )->m_Text ) );
else 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( int DIALOG_BUILD_BOM::PrintComponentsListByRef(
FILE* f, FILE* f,
std::vector <OBJ_CMP_TO_LIST>& aList, std::vector <OBJ_CMP_TO_LIST>& aList,
bool CompactForm, bool CompactForm,
bool aIncludeSubComponents ) bool aIncludeSubComponents )
/*********************************************************************************************/ {
/****************************************************************************/
/* Print the B.O.M sorted by reference /* Print the B.O.M sorted by reference
*/ */
{
int Multi, Unit; int Multi, Unit;
EDA_BaseStruct* DrawList; EDA_BaseStruct* DrawList;
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
...@@ -585,7 +594,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -585,7 +594,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
if( CompactForm ) if( CompactForm )
{ {
// @todo make this variable length // @todo make this variable length
const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] = { const wxCheckBox* FieldListCtrl[FIELD8 - FIELD1 + 1] =
{
m_AddField1, m_AddField1,
m_AddField2, m_AddField2,
m_AddField3, m_AddField3,
...@@ -618,7 +628,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -618,7 +628,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
continue; continue;
msg = _( "Field" ); 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" ); fprintf( f, "\n" );
...@@ -653,15 +664,11 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -653,15 +664,11 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
Multi = Entry->GetPartCount(); Multi = Entry->GetPartCount();
if( ( Multi > 1 ) && aIncludeSubComponents ) if( ( Multi > 1 ) && aIncludeSubComponents )
#if defined (KICAD_GOST) #if defined(KICAD_GOST)
Unit = aList[ii].m_Unit + '1' - 1; Unit = aList[ii].m_Unit + '1' - 1;
#else #else
Unit = aList[ii].m_Unit + 'A' - 1; Unit = aList[ii].m_Unit + 'A' - 1;
#endif #endif
...@@ -671,10 +678,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -671,10 +678,10 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
if( CompactForm ) if( CompactForm )
fprintf( f, "%s%c%s", CmpName, s_ExportSeparatorSymbol, 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 else
fprintf( f, "| %-10s %-12s", CmpName, fprintf( f, "| %-10s %-12s", CmpName,
CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) ); CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ) );
if( aIncludeSubComponents ) if( aIncludeSubComponents )
{ {
...@@ -683,14 +690,17 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -683,14 +690,17 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
{ {
fprintf( f, "%c%s", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) ); fprintf( f, "%c%s", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences( msg = m_Parent->GetXYSheetReferences(
(BASE_SCREEN*) DrawLibItem->GetParent(), DrawLibItem->m_Pos ); (BASE_SCREEN*) DrawLibItem->GetParent(),
fprintf( f, "%c%s)", s_ExportSeparatorSymbol, CONV_TO_UTF8( msg ) ); DrawLibItem->m_Pos );
fprintf( f, "%c%s)", s_ExportSeparatorSymbol,
CONV_TO_UTF8( msg ) );
} }
else else
{ {
fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) ); fprintf( f, " (Sheet %s)", CONV_TO_UTF8( msg ) );
msg = m_Parent->GetXYSheetReferences( 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 ) ); fprintf( f, " (loc %s)", CONV_TO_UTF8( msg ) );
} }
} }
...@@ -709,13 +719,13 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef( ...@@ -709,13 +719,13 @@ int DIALOG_BUILD_BOM::PrintComponentsListByRef(
} }
/*********************************************************************************************/ /*****************************************************************************/
int DIALOG_BUILD_BOM::PrintComponentsListByVal( int DIALOG_BUILD_BOM::PrintComponentsListByVal(
FILE* f, FILE* f,
std::vector <OBJ_CMP_TO_LIST>& aList, std::vector <OBJ_CMP_TO_LIST>& aList,
bool aIncludeSubComponents ) bool aIncludeSubComponents )
/**********************************************************************************************/
{ {
/*****************************************************************************/
int Multi; int Multi;
wxChar Unit; wxChar Unit;
EDA_BaseStruct* DrawList; EDA_BaseStruct* DrawList;
...@@ -764,8 +774,9 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( ...@@ -764,8 +774,9 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
sprintf( CmpName, "%s%c", aList[ii].m_Reference, Unit ); sprintf( CmpName, "%s%c", aList[ii].m_Reference, Unit );
#endif #endif
fprintf( f, "| %-12s %-10s", CONV_TO_UTF8( DrawLibItem->GetField( fprintf( f, "| %-12s %-10s",
VALUE )->m_Text ), CmpName ); CONV_TO_UTF8( DrawLibItem->GetField( VALUE )->m_Text ),
CmpName );
// print the sheet path // print the sheet path
if( aIncludeSubComponents ) if( aIncludeSubComponents )
...@@ -790,8 +801,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal( ...@@ -790,8 +801,8 @@ int DIALOG_BUILD_BOM::PrintComponentsListByVal(
/************************************************************************/ /************************************************************************/
static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ) static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
/************************************************************************/
{ {
/************************************************************************/
SCH_LABEL* DrawTextItem; SCH_LABEL* DrawTextItem;
Hierarchical_PIN_Sheet_Struct* DrawSheetLabel; Hierarchical_PIN_Sheet_Struct* DrawSheetLabel;
wxString msg, sheetpath; wxString msg, sheetpath;
...@@ -803,7 +814,7 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ) ...@@ -803,7 +814,7 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
{ {
case TYPE_SCH_HIERLABEL: case TYPE_SCH_HIERLABEL:
case TYPE_SCH_GLOBALLABEL: 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 ) if( aList[ii].m_LabelType == TYPE_SCH_HIERLABEL )
labeltype = wxT( "Hierarchical" ); labeltype = wxT( "Hierarchical" );
...@@ -824,7 +835,8 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ) ...@@ -824,7 +835,8 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE: 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; int jj = DrawSheetLabel->m_Shape;
if( jj < 0 ) if( jj < 0 )
jj = NET_TMAX; jj = NET_TMAX;
...@@ -855,15 +867,14 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList ) ...@@ -855,15 +867,14 @@ static int PrintListeGLabel( FILE* f, std::vector <LABEL_OBJECT>& aList )
/********************************************/ /********************************************/
int RefDesStringCompare( const char* obj1, const char* obj2 ) int RefDesStringCompare( const char* obj1, const char* obj2 )
{
/********************************************/ /********************************************/
/* This function will act just like the strcmp function but correctly sort /* This function will act just like the strcmp function but correctly sort
* the numerical order in the string * the numerical order in the string
* return -1 if first string is less than the second * return -1 if first string is less than the second
* return 0 if the strings are equal * return 0 if the strings are equal
* return 1 if the first string is greater than the second * return 1 if the first string is greater than the second
*/ */
{
/* The strings we are going to compare */ /* The strings we are going to compare */
wxString strFWord; wxString strFWord;
wxString strSWord; wxString strSWord;
...@@ -877,14 +888,16 @@ int RefDesStringCompare( const char* obj1, const char* obj2 ) ...@@ -877,14 +888,16 @@ int RefDesStringCompare( const char* obj1, const char* obj2 )
int isEqual = 0; /* The numerical results of a string compare */ int isEqual = 0; /* The numerical results of a string compare */
int iReturn = 0; /* The variable that is being returned */ int iReturn = 0; /* The variable that is being returned */
long lFirstDigit = 0; /* The converted middle section of the first string */ long lFirstDigit = 0; /* The converted middle section of the first
long lSecondDigit = 0; /* The converted middle section of the second string */ *string */
long lSecondDigit = 0; /* The converted middle section of the second
*string */
/* Since m_Ref is a char * it is ASCII */ /* Since m_Ref is a char * it is ASCII */
strFWord = wxString::FromAscii( obj1 ); strFWord = wxString::FromAscii( obj1 );
strSWord = wxString::FromAscii( obj2 ); strSWord = wxString::FromAscii( obj2 );
/* Split the two string into seperate parts */ /* Split the two string into separate parts */
SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd ); SplitString( strFWord, &strFWordBeg, &strFWordMid, &strFWordEnd );
SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd ); SplitString( strSWord, &strSWordBeg, &strSWordMid, &strSWordEnd );
...@@ -920,20 +933,19 @@ int RefDesStringCompare( const char* obj1, const char* obj2 ) ...@@ -920,20 +933,19 @@ int RefDesStringCompare( const char* obj1, const char* obj2 )
} }
/**************************************************************************************************/ /****************************************************************************/
int SplitString( wxString strToSplit, int SplitString( wxString strToSplit,
wxString* strBeginning, wxString* strBeginning,
wxString* strDigits, wxString* strDigits,
wxString* strEnd ) wxString* strEnd )
/**************************************************************************************************/ {
/****************************************************************************/
/* This is the function that breaks a string into three parts. /* This is the function that breaks a string into three parts.
* The alphabetic preamble * The alphabetic preamble
* The numeric part * The numeric part
* Any alphabetic ending * Any alphabetic ending
* For example C10A is split to C 10 A * For example C10A is split to C 10 A
*/ */
{
/* Clear all the return strings */ /* Clear all the return strings */
strBeginning->Clear(); strBeginning->Clear();
strDigits->Clear(); strDigits->Clear();
...@@ -971,7 +983,8 @@ int SplitString( wxString strToSplit, ...@@ -971,7 +983,8 @@ int SplitString( wxString strToSplit,
if( ii < 0 ) if( ii < 0 )
*strDigits = strToSplit.substr( 0, position ); *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 else
{ {
*strDigits = strToSplit.substr( ii + 1, position - ii - 1 ); *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 "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -15,31 +15,34 @@ ...@@ -15,31 +15,34 @@
/* Routines Locales */ /* 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 Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ); static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC );
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ); static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer );
static bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos ); 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; SCH_ITEM* s_OldWiresList;
wxPoint s_ConnexionStartPoint; wxPoint s_ConnexionStartPoint;
/*********************************************************/ /*********************************************************/
SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy ) SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
{
/*********************************************************/ /*********************************************************/
/* Extract the old wires, junctions and buses, an if CreateCopy replace them
/* Extract the old wires, junctions and busses, an if CreateCopy replace them by a copy. * by a copy. Old ones must be put in undo list, and the new ones can be
* Old ones must be put in undo list, and the new ones can be modified by clean up * modified by clean up safely.
* safely. * If an abort command is made, old wires must be put in EEDrawList, and
* If an abord command is made, old wires must be put in EEDrawList, and copies must be deleted * copies must be deleted. This is because previously stored undo commands
* This is because previously stored undo commands can handle pointers on wires or bus, * can handle pointers on wires or bus, and we do not delete wires or bus,
* and we do not delete wires or bus, we must put they in undo list. * 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 * Because cleanup delete and/or modify bus and wires, the more easy is to put
* and use a new copy of wires for cleanup * all wires in undo list and use a new copy of wires for cleanup.
*/ */
{
SCH_ITEM* item, * next_item, * new_item, * List = NULL; SCH_ITEM* item, * next_item, * new_item, * List = NULL;
for( item = EEDrawList; item != NULL; item = next_item ) for( item = EEDrawList; item != NULL; item = next_item )
...@@ -75,11 +78,10 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy ) ...@@ -75,11 +78,10 @@ SCH_ITEM* SCH_SCREEN::ExtractWires( bool CreateCopy )
/*************************************************/ /*************************************************/
static void RestoreOldWires( SCH_SCREEN* screen ) static void RestoreOldWires( SCH_SCREEN* screen )
{
/*************************************************/ /*************************************************/
/* Replace the wires in screen->EEDrawList by s_OldWiresList wires. /* Replace the wires in screen->EEDrawList by s_OldWiresList wires.
*/ */
{
SCH_ITEM* item; SCH_ITEM* item;
SCH_ITEM* next_item; SCH_ITEM* next_item;
...@@ -105,24 +107,23 @@ static void RestoreOldWires( SCH_SCREEN* screen ) ...@@ -105,24 +107,23 @@ static void RestoreOldWires( SCH_SCREEN* screen )
next_item = s_OldWiresList->Next(); next_item = s_OldWiresList->Next();
s_OldWiresList->SetNext( screen->EEDrawList ); s_OldWiresList->SetNext( screen->EEDrawList );
screen->EEDrawList = s_OldWiresList; screen->EEDrawList = s_OldWiresList;
s_OldWiresList = next_item; s_OldWiresList = next_item;
} }
} }
/*************************************************************/ /*************************************************************/
void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
{
/*************************************************************/ /*************************************************************/
/* Creates a new segment ( WIRE, BUS ), /* Creates a new segment ( WIRE, BUS ),
* or terminates the current segment * or terminates the current segment
* If the end of the current segment is on an other segment, place a junction if needed * If the end of the current segment is on an other segment, place a junction
* and terminates the command * if needed and terminates the command
* If the end of the current segment is on a pin, terminates the command * If the end of the current segment is on a pin, terminates the command
* In others cases starts a new segment * In others cases starts a new segment
*/ */
{
EDA_DrawLineStruct* oldsegment, * newsegment, * nextsegment; EDA_DrawLineStruct* oldsegment, * newsegment, * nextsegment;
wxPoint cursorpos = GetScreen()->m_Curseur; wxPoint cursorpos = GetScreen()->m_Curseur;
...@@ -145,11 +146,11 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -145,11 +146,11 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
oldsegment = newsegment = oldsegment = newsegment =
(EDA_DrawLineStruct*) GetScreen()->GetCurItem(); (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_ConnexionStartPoint = cursorpos;
s_OldWiresList = ((SCH_SCREEN*)GetScreen())->ExtractWires( TRUE ); s_OldWiresList = ( (SCH_SCREEN*) GetScreen() )->ExtractWires( TRUE );
((SCH_SCREEN*)GetScreen())->SchematicCleanUp( NULL ); ( (SCH_SCREEN*) GetScreen() )->SchematicCleanUp( NULL );
switch( type ) switch( type )
{ {
...@@ -160,8 +161,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -160,8 +161,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
case LAYER_WIRE: case LAYER_WIRE:
newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_WIRE ); newsegment = new EDA_DrawLineStruct( cursorpos, LAYER_WIRE );
/* A junction will be created later, when w'll know the /* A junction will be created later, when we'll know the
* segment end position, and if the junction is really needed */ * segment end position, and if the junction is really needed */
break; break;
case LAYER_BUS: case LAYER_BUS:
...@@ -170,7 +171,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -170,7 +171,8 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
} }
newsegment->m_Flags = IS_NEW; 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 = newsegment->GenCopy();
nextsegment->m_Flags = IS_NEW; nextsegment->m_Flags = IS_NEW;
...@@ -182,17 +184,20 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -182,17 +184,20 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine; DrawPanel->ForceCloseManageCurseur = AbortCreateNewLine;
g_ItemToRepeat = NULL; 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(); nextsegment = oldsegment->Next();
if( !g_HVLines ) if( !g_HVLines ) /* if only one segment is needed and the current is
{ /* if only one segment is needed and the current is has len = 0, do not create a new one*/ * has len = 0, do not create a new one */
{
if( oldsegment->IsNull() ) if( oldsegment->IsNull() )
return; return;
} }
else 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() ) if( oldsegment->IsNull() && nextsegment && nextsegment->IsNull() )
return; return;
} }
...@@ -200,13 +205,12 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -200,13 +205,12 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
/* Creates the new segment, or terminates the command /* 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() ) ) if( IsTerminalPoint( GetScreen(), cursorpos, oldsegment->GetLayer() ) )
{ {
EndSegment( DC ); return; EndSegment( DC ); return;
} }
/* Placement en liste generale */
oldsegment->SetNext( GetScreen()->EEDrawList ); oldsegment->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = oldsegment; GetScreen()->EEDrawList = oldsegment;
DrawPanel->CursorOff( DC ); // Erase schematic cursor DrawPanel->CursorOff( DC ); // Erase schematic cursor
...@@ -233,11 +237,13 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -233,11 +237,13 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
newsegment->m_Flags = IS_NEW; newsegment->m_Flags = IS_NEW;
GetScreen()->SetCurItem( newsegment ); GetScreen()->SetCurItem( newsegment );
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); 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 ) 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 ) ) if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
CreateNewJunctionStruct( DC, s_ConnexionStartPoint ); CreateNewJunctionStruct( DC, s_ConnexionStartPoint );
} }
...@@ -247,13 +253,13 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type ) ...@@ -247,13 +253,13 @@ void WinEDA_SchematicFrame::BeginSegment( wxDC* DC, int type )
/***********************************************/ /***********************************************/
void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
{
/***********************************************/ /***********************************************/
/* Called to terminate a bus, wire, or line creation /* Called to terminate a bus, wire, or line creation
*/ */
{ EDA_DrawLineStruct* firstsegment =
EDA_DrawLineStruct* firstsegment = (EDA_DrawLineStruct*) GetScreen()->GetCurItem(); (EDA_DrawLineStruct*) GetScreen()->GetCurItem();
EDA_DrawLineStruct* lastsegment = firstsegment; EDA_DrawLineStruct* lastsegment = firstsegment;
EDA_DrawLineStruct* segment; EDA_DrawLineStruct* segment;
if( firstsegment == NULL ) if( firstsegment == NULL )
...@@ -285,12 +291,11 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) ...@@ -285,12 +291,11 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
while( segment ) while( segment )
{ {
lastsegment = segment; lastsegment = segment;
segment = segment->Next(); segment = segment->Next();
lastsegment->SetNext( GetScreen()->EEDrawList ); lastsegment->SetNext( GetScreen()->EEDrawList );
GetScreen()->EEDrawList = lastsegment; GetScreen()->EEDrawList = lastsegment;
} }
/* Fin de trace */
DrawPanel->ManageCurseur = NULL; DrawPanel->ManageCurseur = NULL;
DrawPanel->ForceCloseManageCurseur = NULL; DrawPanel->ForceCloseManageCurseur = NULL;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
...@@ -299,16 +304,16 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) ...@@ -299,16 +304,16 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
/* A junction can be needed to connect the last segment /* A junction can be needed to connect the last segment
* usually to m_End coordinate. * usually to m_End coordinate.
* But if the last segment is removed by a cleanup, because od redundancy, * 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 * a junction can be needed to connect the previous segment m_End
* with is also the lastsegment->m_Start coordinate */ * coordinate with is also the lastsegment->m_Start coordinate */
if( lastsegment ) if( lastsegment )
{ {
end_point = lastsegment->m_End; end_point = lastsegment->m_End;
alt_end_point = lastsegment->m_Start; 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 */ /* clear flags and find last segment entered, for repeat function */
segment = (EDA_DrawLineStruct*) GetScreen()->EEDrawList; segment = (EDA_DrawLineStruct*) GetScreen()->EEDrawList;
...@@ -333,8 +338,8 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) ...@@ -333,8 +338,8 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
CreateNewJunctionStruct( DC, alt_end_point ); CreateNewJunctionStruct( DC, alt_end_point );
} }
/* Automatic place of a junction on the start point if necessary because the /* Automatic place of a junction on the start point if necessary because
* Cleanup can suppress intermediate points by merging wire segments*/ * the cleanup can suppress intermediate points by merging wire segments */
if( IsJunctionNeeded( this, s_ConnexionStartPoint ) ) if( IsJunctionNeeded( this, s_ConnexionStartPoint ) )
CreateNewJunctionStruct( DC, s_ConnexionStartPoint ); CreateNewJunctionStruct( DC, s_ConnexionStartPoint );
...@@ -350,7 +355,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) ...@@ -350,7 +355,7 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
{ {
case DRAW_JUNCTION_STRUCT_TYPE: case DRAW_JUNCTION_STRUCT_TYPE:
case DRAW_SEGMENT_STRUCT_TYPE: case DRAW_SEGMENT_STRUCT_TYPE:
DrawPanel->PostDirtyRect(item->GetBoundingBox()); DrawPanel->PostDirtyRect( item->GetBoundingBox() );
break; break;
default: default:
...@@ -372,12 +377,12 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC ) ...@@ -372,12 +377,12 @@ void WinEDA_SchematicFrame::EndSegment( wxDC* DC )
/****************************************************************************/ /****************************************************************************/
static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
{
/****************************************************************************/ /****************************************************************************/
/* Redraw the segment (g_HVLines == FALSE ) or the two segments (g_HVLines ==
/* Redraw the segment (g_HVLines == FALSE ) or the two segments (g_HVLines == TRUE ) * TRUE )
* from the start point to the cursor, when moving the mouse * from the start point to the cursor, when moving the mouse
*/ */
{
EDA_DrawLineStruct* CurrentLine = EDA_DrawLineStruct* CurrentLine =
(EDA_DrawLineStruct*) panel->GetScreen()->GetCurItem(); (EDA_DrawLineStruct*) panel->GetScreen()->GetCurItem();
EDA_DrawLineStruct* segment; EDA_DrawLineStruct* segment;
...@@ -393,7 +398,7 @@ static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -393,7 +398,7 @@ static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
segment = CurrentLine; segment = CurrentLine;
while( segment ) 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 ); RedrawOneStruct( panel, DC, segment, g_XorMode, color );
segment = segment->Next(); segment = segment->Next();
} }
...@@ -410,21 +415,22 @@ static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -410,21 +415,22 @@ static void Segment_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
segment = CurrentLine; segment = CurrentLine;
while( segment ) 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 ); RedrawOneStruct( panel, DC, segment, g_XorMode, color );
segment = segment->Next(); segment = segment->Next();
} }
} }
/**************************************************************************************/ /***************************************************************************/
static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& 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 /***************************************************************************/
/* compute the middle coordinate for 2 segments, from the start point to
* new_pos
* with the 2 segments kept H or V only * with the 2 segments kept H or V only
*/ */
{
EDA_DrawLineStruct* nextsegment = segment->Next(); EDA_DrawLineStruct* nextsegment = segment->Next();
wxPoint middle_position = new_pos; wxPoint middle_position = new_pos;
...@@ -439,11 +445,13 @@ static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_p ...@@ -439,11 +445,13 @@ static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_p
#else #else
int iDx = segment->m_End.x - segment->m_Start.x; int iDx = segment->m_End.x - segment->m_Start.x;
int iDy = segment->m_End.y - segment->m_Start.y; 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; 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; middle_position.y = segment->m_Start.y;
} }
...@@ -465,12 +473,13 @@ static void ComputeBreakPoint( EDA_DrawLineStruct* segment, const wxPoint& new_p ...@@ -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 )
{
/*****************************************************************************/ /*****************************************************************************/
/* Drawing Polyline phantom at the displacement of the cursor
/* Dessin du du Polyline Fantome lors des deplacements du curseur
*/ */
{
DrawPolylineStruct* NewPoly = DrawPolylineStruct* NewPoly =
(DrawPolylineStruct*) panel->GetScreen()->GetCurItem(); (DrawPolylineStruct*) panel->GetScreen()->GetCurItem();
int color; int color;
...@@ -502,12 +511,11 @@ static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool eras ...@@ -502,12 +511,11 @@ static void Show_Polyline_in_Ghost( WinEDA_DrawPanel* panel, wxDC* DC, bool eras
/**********************************************************/ /**********************************************************/
void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC ) void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
{
/**********************************************************/ /**********************************************************/
/* /*
* Routine effacant le dernier trait trace, ou l'element pointe par la souris * Erase the last trace or the element at the current mouse position.
*/ */
{
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
if( (GetScreen()->GetCurItem() == NULL) if( (GetScreen()->GetCurItem() == NULL)
...@@ -516,17 +524,18 @@ void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC ) ...@@ -516,17 +524,18 @@ void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
return; return;
} }
/* Trace en cours: annulation */ /* Cancel trace in progress */
if( GetScreen()->GetCurItem()->Type() == DRAW_POLYLINE_STRUCT_TYPE ) 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 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; DrawPanel->ManageCurseur = NULL;
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
} }
...@@ -535,11 +544,10 @@ void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC ) ...@@ -535,11 +544,10 @@ void WinEDA_SchematicFrame::DeleteCurrentSegment( wxDC* DC )
/***************************************************************************/ /***************************************************************************/
DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct( DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct(
wxDC* DC, const wxPoint& pos, bool PutInUndoList ) wxDC* DC, const wxPoint& pos, bool PutInUndoList )
{
/***************************************************************************/ /***************************************************************************/
/* Routine to create new connection struct. /* Routine to create new connection struct.
*/ */
{
DrawJunctionStruct* NewJunction; DrawJunctionStruct* NewJunction;
NewJunction = new DrawJunctionStruct( pos ); NewJunction = new DrawJunctionStruct( pos );
...@@ -561,11 +569,9 @@ DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct( ...@@ -561,11 +569,9 @@ DrawJunctionStruct* WinEDA_SchematicFrame::CreateNewJunctionStruct(
/*******************************************************************************/ /*******************************************************************************/
DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC ) DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC )
/*******************************************************************************/
/*Routine to create new NoConnect struct. ( Symbole de Non Connexion)
*/
{ {
/*******************************************************************************/
/* Routine to create new NoConnect struct. */
DrawNoConnectStruct* NewNoConnect; DrawNoConnectStruct* NewNoConnect;
NewNoConnect = new DrawNoConnectStruct( GetScreen()->m_Curseur ); NewNoConnect = new DrawNoConnectStruct( GetScreen()->m_Curseur );
...@@ -585,14 +591,13 @@ DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC ) ...@@ -585,14 +591,13 @@ DrawNoConnectStruct* WinEDA_SchematicFrame::CreateNewNoConnectStruct( wxDC* DC )
/*****************************************************************/ /*****************************************************************/
static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ) static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
{
/*****************************************************************/ /*****************************************************************/
/* Abort function for wire, bus or line creation /* Abort function for wire, bus or line creation
*/ */
{
SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->GetScreen(); SCH_SCREEN* Screen = (SCH_SCREEN*) Panel->GetScreen();
if( Screen->GetCurItem() ) /* trace en cours */ if( Screen->GetCurItem() )
{ {
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
...@@ -602,9 +607,9 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -602,9 +607,9 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
Panel->Refresh(); Panel->Refresh();
} }
else 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; SCH_ITEM* item = Screen->EEDrawList;
while( item ) while( item )
{ {
...@@ -616,14 +621,12 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -616,14 +621,12 @@ static void AbortCreateNewLine( WinEDA_DrawPanel* Panel, wxDC* DC )
/***************************************************/ /***************************************************/
void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
{
/***************************************************/ /***************************************************/
/* Repeat the last item placement.
/* Routine de recopie du dernier element dessine * Bus lines, text, labels
* Les elements duplicables sont * Labels that end with a number will be incremented.
* fils, bus, traits, textes, labels
* Les labels termines par un nombre seront incrementes
*/ */
{
wxPoint new_pos; wxPoint new_pos;
if( g_ItemToRepeat == NULL ) if( g_ItemToRepeat == NULL )
...@@ -653,7 +656,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -653,7 +656,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text ); IncrementLabelMember( STRUCT->m_Text );
break; break;
...@@ -664,7 +666,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -664,7 +666,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text ); IncrementLabelMember( STRUCT->m_Text );
break; break;
...@@ -675,7 +676,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -675,7 +676,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text ); IncrementLabelMember( STRUCT->m_Text );
break; break;
...@@ -685,7 +685,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -685,7 +685,6 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
STRUCT->m_Pos += g_RepeatStep; STRUCT->m_Pos += g_RepeatStep;
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
/*** Increment du numero de label ***/
IncrementLabelMember( STRUCT->m_Text ); IncrementLabelMember( STRUCT->m_Text );
break; break;
...@@ -706,21 +705,22 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -706,21 +705,22 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
new_pos = STRUCT->m_Pos; new_pos = STRUCT->m_Pos;
break; 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 #undef STRUCT
#define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat ) #define STRUCT ( (SCH_COMPONENT*) g_ItemToRepeat )
// Create the duplicate component, position = mouse cursor // Create the duplicate component, position = mouse cursor
g_ItemToRepeat = STRUCT->GenCopy(); g_ItemToRepeat = STRUCT->GenCopy();
new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x; new_pos.x = GetScreen()->m_Curseur.x - STRUCT->m_Pos.x;
new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y; new_pos.y = GetScreen()->m_Curseur.y - STRUCT->m_Pos.y;
STRUCT->m_Pos = GetScreen()->m_Curseur; STRUCT->m_Pos = GetScreen()->m_Curseur;
STRUCT->m_Flags = IS_NEW; STRUCT->m_Flags = IS_NEW;
STRUCT->m_TimeStamp = GetTimeStamp(); STRUCT->m_TimeStamp = GetTimeStamp();
for( int ii = 0; ii < STRUCT->GetFieldCount(); ii++ ) 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 ); RedrawOneStruct( DrawPanel, DC, STRUCT, g_XorMode );
...@@ -743,20 +743,19 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC ) ...@@ -743,20 +743,19 @@ void WinEDA_SchematicFrame::RepeatDrawItem( wxDC* DC )
SaveCopyInUndoList( g_ItemToRepeat, UR_NEW ); SaveCopyInUndoList( g_ItemToRepeat, UR_NEW );
g_ItemToRepeat->m_Flags = 0; g_ItemToRepeat->m_Flags = 0;
// GetScreen()->Curseur = new_pos; // GetScreen()->Curseur = new_pos;
// DrawPanel->MouseTo( DrawPanel->CursorScreenPosition() ); // DrawPanel->MouseTo( DrawPanel->CursorScreenPosition() );
} }
} }
/******************************************/ /******************************************/
void IncrementLabelMember( wxString& name ) void IncrementLabelMember( wxString& name )
{
/******************************************/ /******************************************/
/* Routine incrementing labels, ie for the text ending with a number, adding
/* Routine incrementant les labels, c'est a dire pour les textes finissant * that a number <RepeatDeltaLabel>
* par un nombre, ajoutant <RepeatDeltaLabel> a ce nombre
*/ */
{
int ii, nn; int ii, nn;
long number = 0; long number = 0;
...@@ -781,8 +780,8 @@ void IncrementLabelMember( wxString& name ) ...@@ -781,8 +780,8 @@ void IncrementLabelMember( wxString& name )
/***************************************************************************/ /***************************************************************************/
static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) 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 /* Return TRUE if pos can be a terminal point for a wire or a bus
* i.e. : * i.e. :
* for a WIRE, if at pos is found: * for a WIRE, if at pos is found:
...@@ -793,12 +792,11 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) ...@@ -793,12 +792,11 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
* - for a BUS, if at pos is found: * - for a BUS, if at pos is found:
* - a BUS * - a BUS
*/ */
{
EDA_BaseStruct* item; EDA_BaseStruct* item;
LIB_PIN* pin; LIB_PIN* pin;
SCH_COMPONENT* LibItem = NULL; SCH_COMPONENT* LibItem = NULL;
Hierarchical_PIN_Sheet_Struct* pinsheet; Hierarchical_PIN_Sheet_Struct* pinsheet;
wxPoint itempos; wxPoint itempos;
switch( layer ) switch( layer )
{ {
...@@ -829,8 +827,8 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) ...@@ -829,8 +827,8 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem ); pin = LocateAnyPin( screen->EEDrawList, pos, &LibItem );
if( pin && LibItem ) if( pin && LibItem )
{ {
// calcul de la position exacte du point de connexion de la pin, // Calculate the exact position of the connection point of the pin,
// selon orientation du composant: // depending on orientation of the component.
itempos = LibItem->GetScreenCoord( pin->m_Pos ); itempos = LibItem->GetScreenCoord( pin->m_Pos );
itempos.x += LibItem->m_Pos.x; itempos.x += LibItem->m_Pos.x;
itempos.y += LibItem->m_Pos.y; itempos.y += LibItem->m_Pos.y;
...@@ -868,8 +866,8 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer ) ...@@ -868,8 +866,8 @@ static bool IsTerminalPoint( SCH_SCREEN* screen, const wxPoint& pos, int layer )
/****************************************************************/ /****************************************************************/
bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos ) bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos )
{
/****************************************************************/ /****************************************************************/
/* Return True when a wire is located at pos "pos" if /* Return True when a wire is located at pos "pos" if
* - there is no junction. * - there is no junction.
* - The wire has no ends at pos "pos", * - The wire has no ends at pos "pos",
...@@ -878,13 +876,14 @@ bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos ) ...@@ -878,13 +876,14 @@ bool IsJunctionNeeded( WinEDA_SchematicFrame* frame, wxPoint& pos )
* or * or
* - a pin is on location pos * - a pin is on location pos
*/ */
{
if( PickStruct( pos, frame->GetScreen(), JUNCTIONITEM ) ) if( PickStruct( pos, frame->GetScreen(), JUNCTIONITEM ) )
return FALSE; 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; return TRUE;
if( frame->LocatePinEnd( frame->GetScreen()->EEDrawList, pos ) ) if( frame->LocatePinEnd( frame->GetScreen()->EEDrawList, pos ) )
return TRUE; return TRUE;
......
/*************************************/ /*****************************************************/
/* Modules de creations de Bus Entry */ /* Code to handle manipulation on bus entry objects. */
/*************************************/ /*****************************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -13,21 +13,18 @@ ...@@ -13,21 +13,18 @@
#include "general.h" #include "general.h"
#include "protos.h" #include "protos.h"
/* Routines Locales */
/* Variables locales */
static int s_LastShape = '\\'; static int s_LastShape = '\\';
static wxPoint ItemInitialPosition; static wxPoint ItemInitialPosition;
/**************************************************************/ /**************************************************************/
static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC ) static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
/**************************************************************/
/* Routine de sortie des menus de trace */
{ {
/**************************************************************/
/* Exit bus entry mode. */
DrawBusEntryStruct* BusEntry = DrawBusEntryStruct* BusEntry =
(DrawBusEntryStruct*) Panel->GetScreen()->GetCurItem(); (DrawBusEntryStruct*) Panel->GetScreen()->GetCurItem();
if( BusEntry ) /* trace en cours */ if( BusEntry )
{ {
RedrawOneStruct( Panel, DC, BusEntry, g_XorMode ); RedrawOneStruct( Panel, DC, BusEntry, g_XorMode );
if( BusEntry->m_Flags & IS_NEW ) if( BusEntry->m_Flags & IS_NEW )
...@@ -51,36 +48,36 @@ static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -51,36 +48,36 @@ static void ExitBusEntry( WinEDA_DrawPanel* Panel, wxDC* DC )
/************************************************************************/ /************************************************************************/
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/************************************************************************/
/* Dessin du Segment "BusEntry" lors des deplacements du curseur
*/
{ {
/************************************************************************/
/* Drawing of the bus entry segment" while moving the cursor. */
BASE_SCREEN* screen = panel->GetScreen(); BASE_SCREEN* screen = panel->GetScreen();
DrawBusEntryStruct* BusEntry = (DrawBusEntryStruct*) screen->GetCurItem(); DrawBusEntryStruct* BusEntry = (DrawBusEntryStruct*) screen->GetCurItem();
if( BusEntry == NULL ) if( BusEntry == NULL )
return; return;
/* effacement apres deplacement curseur */ /* Erase the last segment position. */
if( erase ) if( erase )
RedrawOneStruct( panel, DC, BusEntry, g_XorMode ); RedrawOneStruct( panel, DC, BusEntry, g_XorMode );
/* Reaffichage au bon endroit */ /* Redraw at the new position. */
BusEntry->m_Pos = screen->m_Curseur; BusEntry->m_Pos = screen->m_Curseur;
RedrawOneStruct( panel, DC, BusEntry, g_XorMode ); 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) /* Create a new bus entry, and prepare moving function (for later place it)
*/ */
{ DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct(
DrawBusEntryStruct* BusEntry = new DrawBusEntryStruct( GetScreen()->m_Curseur, GetScreen()->m_Curseur,
s_LastShape, entry_type ); s_LastShape,
entry_type );
BusEntry->m_Flags = IS_NEW; BusEntry->m_Flags = IS_NEW;
...@@ -98,12 +95,13 @@ DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_t ...@@ -98,12 +95,13 @@ DrawBusEntryStruct* WinEDA_SchematicFrame::CreateBusEntry( wxDC* DC, int entry_t
/**************************************************************************/ /**************************************************************************/
void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry, void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
wxDC* DC ) wxDC* DC )
/**************************************************************************/
{ {
/**************************************************************************/
if( BusEntry == NULL ) if( BusEntry == NULL )
return; 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; delete g_ItemToUndoCopy;
g_ItemToUndoCopy = BusEntry->GenCopy(); g_ItemToUndoCopy = BusEntry->GenCopy();
...@@ -126,13 +124,13 @@ void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry, ...@@ -126,13 +124,13 @@ void WinEDA_SchematicFrame::StartMoveBusEntry( DrawBusEntryStruct* BusEntry,
/************************************************************/ /************************************************************/
void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC, void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
DrawBusEntryStruct* BusEntry, int entry_shape ) DrawBusEntryStruct* BusEntry,
int entry_shape )
{
/************************************************************/ /************************************************************/
/* set the shape of BusEntry (shape = / or \ ) /* set the shape of BusEntry (shape = / or \ )
*/ */
{
if( BusEntry == NULL ) if( BusEntry == NULL )
return; return;
...@@ -169,8 +167,8 @@ void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC, ...@@ -169,8 +167,8 @@ void WinEDA_SchematicFrame::SetBusEntryShape( wxDC* DC,
/************************************************************************/ /************************************************************************/
int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct* BusEntry ) int WinEDA_SchematicFrame::GetBusEntryShape( DrawBusEntryStruct* BusEntry )
/************************************************************************/
{ {
/************************************************************************/
int entry_shape = '\\'; int entry_shape = '\\';
if( BusEntry->m_Size.y < 0 ) if( BusEntry->m_Size.y < 0 )
......
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: class_drawsheet.cpp // Name: class_drawsheet.cpp
// Purpose: member functions for DrawSheetStruct // Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h // header = class_drawsheet.h
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Created: 08/02/2006 18:37:02 // Created: 08/02/2006 18:37:02
// RCS-ID: // RCS-ID:
// Copyright: // Copyright:
// Licence: License GNU // License: License GNU
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "fctsys.h" #include "fctsys.h"
...@@ -26,13 +26,13 @@ ...@@ -26,13 +26,13 @@
/***********************************************************/ /***********************************************************/
DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) : DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE ) SCH_ITEM( NULL, DRAW_SHEET_STRUCT_TYPE )
/***********************************************************/
{ {
m_Label = NULL; /***********************************************************/
m_NbLabel = 0; m_Label = NULL;
m_Layer = LAYER_SHEET; m_NbLabel = 0;
m_Pos = pos; m_Layer = LAYER_SHEET;
m_TimeStamp = GetTimeStamp(); m_Pos = pos;
m_TimeStamp = GetTimeStamp();
m_SheetNameSize = m_FileNameSize = 60; m_SheetNameSize = m_FileNameSize = 60;
m_AssociatedScreen = NULL; m_AssociatedScreen = NULL;
m_SheetName.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp ); m_SheetName.Printf( wxT( "Sheet%8.8lX" ), m_TimeStamp );
...@@ -42,8 +42,8 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) : ...@@ -42,8 +42,8 @@ DrawSheetStruct::DrawSheetStruct( const wxPoint& pos ) :
/**************************************/ /**************************************/
DrawSheetStruct::~DrawSheetStruct() DrawSheetStruct::~DrawSheetStruct()
/**************************************/
{ {
/**************************************/
Hierarchical_PIN_Sheet_Struct* label = m_Label, * next_label; Hierarchical_PIN_Sheet_Struct* label = m_Label, * next_label;
while( label ) while( label )
...@@ -67,7 +67,6 @@ DrawSheetStruct::~DrawSheetStruct() ...@@ -67,7 +67,6 @@ DrawSheetStruct::~DrawSheetStruct()
/**********************************************/ /**********************************************/
bool DrawSheetStruct::Save( FILE* aFile ) const bool DrawSheetStruct::Save( FILE* aFile ) const
/***********************************************/ /***********************************************/
/** Function Save /** 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 "*.brd" format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
...@@ -87,13 +86,13 @@ bool DrawSheetStruct::Save( FILE* aFile ) const ...@@ -87,13 +86,13 @@ bool DrawSheetStruct::Save( FILE* aFile ) const
return Success; 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 ) if( fprintf( aFile, "U %8.8lX\n", m_TimeStamp ) == EOF )
{ {
Success = false; return Success; Success = false; return Success;
} }
/* Generation de la liste des 2 textes (sheetname et filename) */ /* Save schematic sheetname and filename. */
if( !m_SheetName.IsEmpty() ) if( !m_SheetName.IsEmpty() )
{ {
if( fprintf( aFile, "F0 \"%s\" %d\n", CONV_TO_UTF8( m_SheetName ), if( fprintf( aFile, "F0 \"%s\" %d\n", CONV_TO_UTF8( m_SheetName ),
...@@ -112,7 +111,7 @@ bool DrawSheetStruct::Save( FILE* aFile ) const ...@@ -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; SheetLabel = m_Label;
int l_id = 2; int l_id = 2;
while( SheetLabel != NULL ) while( SheetLabel != NULL )
...@@ -130,12 +129,11 @@ bool DrawSheetStruct::Save( FILE* aFile ) const ...@@ -130,12 +129,11 @@ bool DrawSheetStruct::Save( FILE* aFile ) const
/***********************************************/ /***********************************************/
DrawSheetStruct* DrawSheetStruct::GenCopy() DrawSheetStruct* DrawSheetStruct::GenCopy()
{
/***********************************************/ /***********************************************/
/* creates a copy of a sheet /* creates a copy of a sheet
* The linked data itself (EEDrawList) is not duplicated * The linked data itself (EEDrawList) is not duplicated
*/ */
{
DrawSheetStruct* newitem = new DrawSheetStruct( m_Pos ); DrawSheetStruct* newitem = new DrawSheetStruct( m_Pos );
...@@ -143,11 +141,14 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() ...@@ -143,11 +141,14 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
newitem->SetParent( m_Parent ); newitem->SetParent( m_Parent );
newitem->m_TimeStamp = GetTimeStamp(); newitem->m_TimeStamp = GetTimeStamp();
newitem->m_FileName = m_FileName; newitem->m_FileName = m_FileName;
newitem->m_FileNameSize = m_FileNameSize; 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_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_SheetNameSize = m_SheetNameSize;
newitem->m_Label = NULL; newitem->m_Label = NULL;
...@@ -180,12 +181,11 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() ...@@ -180,12 +181,11 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
/**********************************************************/ /**********************************************************/
void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem )
{
/**********************************************************/ /**********************************************************/
/* Used if undo / redo command: /* Used if undo / redo command:
* swap data between this and copyitem * swap data between this and copyitem
*/ */
{
EXCHG( m_Pos, copyitem->m_Pos ); EXCHG( m_Pos, copyitem->m_Pos );
EXCHG( m_Size, copyitem->m_Size ); EXCHG( m_Size, copyitem->m_Size );
EXCHG( m_SheetName, copyitem->m_SheetName ); EXCHG( m_SheetName, copyitem->m_SheetName );
...@@ -194,7 +194,8 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) ...@@ -194,7 +194,8 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem )
EXCHG( m_Label, copyitem->m_Label ); EXCHG( m_Label, copyitem->m_Label );
EXCHG( m_NbLabel, copyitem->m_NbLabel ); 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; Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label ) while( label )
{ {
...@@ -213,10 +214,11 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem ) ...@@ -213,10 +214,11 @@ void DrawSheetStruct::SwapData( DrawSheetStruct* copyitem )
/********************************************************************/ /********************************************************************/
void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) 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; bool isnew = (m_Flags & IS_NEW) ? true : false;
if( isnew ) if( isnew )
{ {
if( !frame->EditSheet( this, DC ) ) if( !frame->EditSheet( this, DC ) )
...@@ -231,7 +233,7 @@ void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -231,7 +233,7 @@ void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
} }
SCH_ITEM::Place( frame, DC ); //puts it on the EEDrawList. SCH_ITEM::Place( frame, DC ); //puts it on the EEDrawList.
if ( isnew ) if( isnew )
{ {
frame->SetSheetNumberAndCount(); frame->SetSheetNumberAndCount();
} }
...@@ -239,15 +241,15 @@ void DrawSheetStruct::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -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 /** 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 aRedraw = true to redraw Sheet
* @param aFrame = the schematic frame * @param aFrame = the schematic frame
*/ */
{
Hierarchical_PIN_Sheet_Struct* Pinsheet, * NextPinsheet; Hierarchical_PIN_Sheet_Struct* Pinsheet, * NextPinsheet;
if( !IsOK( aFrame, _( "Ok to cleanup this sheet" ) ) ) if( !IsOK( aFrame, _( "Ok to cleanup this sheet" ) ) )
...@@ -267,7 +269,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw ...@@ -267,7 +269,7 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw
HLabel = (SCH_HIERLABEL*) DrawStruct; HLabel = (SCH_HIERLABEL*) DrawStruct;
if( Pinsheet->m_Text.CmpNoCase( HLabel->m_Text ) == 0 ) if( Pinsheet->m_Text.CmpNoCase( HLabel->m_Text ) == 0 )
break; // Found! break; // Found!
HLabel = NULL; HLabel = NULL;
} }
...@@ -289,26 +291,27 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw ...@@ -289,26 +291,27 @@ void DrawSheetStruct::CleanupSheet( WinEDA_SchematicFrame* aFrame, bool aRedraw
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
int DrawSheetStruct::GetPenSize( ) int DrawSheetStruct::GetPenSize()
{ {
return g_DrawDefaultLineThickness; return g_DrawDefaultLineThickness;
} }
/**************************************************************************************/
/*****************************************************************************/
void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
const wxPoint& aOffset, const wxPoint& aOffset,
int aDrawMode, int aColor ) int aDrawMode, int aColor )
/**************************************************************************************/ {
/*****************************************************************************/
/** Function Draw /** Function Draw
* Draw the hierarchical sheet shape * Draw the hierarchical sheet shape
* @param aPanel = the current DrawPanel * @param aPanel = the current DrawPanel
* @param aDc = the current Device Context * @param aDc = the current Device Context
* @param aOffset = draw offset (usually wxPoint(0,0)) * @param aOffset = draw offset (usually wxPoint(0,0))
* @param aDrawMode = draw mode * @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; Hierarchical_PIN_Sheet_Struct* SheetLabelStruct;
int txtcolor; int txtcolor;
wxString Text; wxString Text;
...@@ -332,10 +335,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -332,10 +335,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
txtcolor = ReturnLayerColor( LAYER_SHEETNAME ); txtcolor = ReturnLayerColor( LAYER_SHEETNAME );
Text = wxT( "Sheet: " ) + m_SheetName; Text = wxT( "Sheet: " ) + m_SheetName;
DrawGraphicText( aPanel, aDC, DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y - 8 ),
wxPoint( pos.x, pos.y - 8 ), (EDA_Colors) txtcolor, (EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ,
Text, TEXT_ORIENT_HORIZ, wxSize( m_SheetNameSize, m_SheetNameSize ), wxSize( m_SheetNameSize, m_SheetNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth, false, false, false ); GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth,
false, false, false );
/* Draw text : FileName */ /* Draw text : FileName */
if( aColor >= 0 ) if( aColor >= 0 )
...@@ -343,11 +347,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -343,11 +347,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
else else
txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME ); txtcolor = ReturnLayerColor( LAYER_SHEETFILENAME );
Text = wxT( "File: " ) + m_FileName; Text = wxT( "File: " ) + m_FileName;
DrawGraphicText( aPanel, aDC, DrawGraphicText( aPanel, aDC, wxPoint( pos.x, pos.y + m_Size.y + 4 ),
wxPoint( pos.x, pos.y + m_Size.y + 4 ), (EDA_Colors) txtcolor, Text, TEXT_ORIENT_HORIZ,
(EDA_Colors) txtcolor, wxSize( m_FileNameSize, m_FileNameSize ),
Text, TEXT_ORIENT_HORIZ, wxSize( m_FileNameSize, m_FileNameSize ), GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth,
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth, false, false, false ); false, false, false );
/* Draw text : SheetLabel */ /* Draw text : SheetLabel */
...@@ -363,12 +367,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, ...@@ -363,12 +367,11 @@ void DrawSheetStruct::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC,
/*****************************************/ /*****************************************/
EDA_Rect DrawSheetStruct::GetBoundingBox() EDA_Rect DrawSheetStruct::GetBoundingBox()
{
/*****************************************/ /*****************************************/
/** Function 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; int dx, dy;
// Determine length of texts // Determine length of texts
...@@ -381,32 +384,34 @@ EDA_Rect DrawSheetStruct::GetBoundingBox() ...@@ -381,32 +384,34 @@ EDA_Rect DrawSheetStruct::GetBoundingBox()
dx = MAX( m_Size.x, textlen1 ); dx = MAX( m_Size.x, textlen1 );
dy = m_Size.y + m_SheetNameSize + m_FileNameSize + 16; 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; return box;
} }
/************************************************/ /************************************************/
bool DrawSheetStruct::HitTest( const wxPoint& aPosRef ) bool DrawSheetStruct::HitTest( const wxPoint& aPosRef )
{
/************************************************/ /************************************************/
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
{
EDA_Rect rect = GetBoundingBox(); EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef ); return rect.Inside( aPosRef );
} }
/************************************/ /************************************/
int DrawSheetStruct::ComponentCount() int DrawSheetStruct::ComponentCount()
{
/************************************/ /************************************/
/** Function ComponentCount /** Function ComponentCount
* count our own components, without the power components. * count our own components, without the power components.
* @return the copponent count. * @return the component count.
*/ */
{
int n = 0; int n = 0;
if( m_AssociatedScreen ) if( m_AssociatedScreen )
...@@ -431,17 +436,17 @@ int DrawSheetStruct::ComponentCount() ...@@ -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 /** Function SearchHierarchy
* search the existing hierarchy for an instance of screen "FileName". * search the existing hierarchy for an instance of screen "FileName".
* @param aFilename = the filename to find * @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 * @return bool if found, and a pointer to the screen
*/ */
{
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList; EDA_BaseStruct* strct = m_AssociatedScreen->EEDrawList;
...@@ -469,18 +474,18 @@ bool DrawSheetStruct::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen ...@@ -469,18 +474,18 @@ bool DrawSheetStruct::SearchHierarchy( wxString aFilename, SCH_SCREEN** aScreen
/*******************************************************************************/ /*******************************************************************************/
bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen, bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen,
DrawSheetPath* aList ) DrawSheetPath* aList )
{
/*******************************************************************************/ /*******************************************************************************/
/** Function LocatePathOfScreen /** Function LocatePathOfScreen
* search the existing hierarchy for an instance of screen "FileName". * search the existing hierarchy for an instance of screen "FileName".
* don't bother looking at the root sheet - it must be unique, * 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. * in the hierarchy.
* @param aScreen = the SCH_SCREEN* screen that we search for * @param aScreen = the SCH_SCREEN* screen that we search for
* @param aList = the DrawSheetPath* that must be used * @param aList = the DrawSheetPath* that must be used
* @return true if found * @return true if found
*/ */
{
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
aList->Push( this ); aList->Push( this );
...@@ -506,8 +511,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen, ...@@ -506,8 +511,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* aScreen,
/**********************************************************/ /**********************************************************/
bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame ) bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame )
{
/***********************************************************/ /***********************************************************/
/** Function Load. /** Function Load.
* for the sheet: load the file m_FileName * for the sheet: load the file m_FileName
* if a screen already exists, the file is already read. * if a screen already exists, the file is already read.
...@@ -516,7 +521,6 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame ) ...@@ -516,7 +521,6 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame )
* @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 * @return true if OK
*/ */
{
bool success = true; bool success = true;
if( !m_AssociatedScreen ) if( !m_AssociatedScreen )
...@@ -557,13 +561,13 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame ) ...@@ -557,13 +561,13 @@ bool DrawSheetStruct::Load( WinEDA_SchematicFrame* aFrame )
/**********************************/ /**********************************/
int DrawSheetStruct::CountSheets() int DrawSheetStruct::CountSheets()
{
/**********************************/ /**********************************/
/** Function CountSheets /** Function CountSheets
* calculates the number of sheets found in "this" * calculates the number of sheets found in "this"
* this number includes the full subsheets count * this number includes the full subsheets count
* @return the full count of sheets+subsheets contained by "this" * @return the full count of sheets+subsheets contained by "this"
*/ */
{
int count = 1; //1 = this!! int count = 1; //1 = this!!
if( m_AssociatedScreen ) if( m_AssociatedScreen )
...@@ -584,8 +588,8 @@ int DrawSheetStruct::CountSheets() ...@@ -584,8 +588,8 @@ int DrawSheetStruct::CountSheets()
/******************************************/ /******************************************/
wxString DrawSheetStruct::GetFileName( void ) wxString DrawSheetStruct::GetFileName( void )
/******************************************/
{ {
/******************************************/
return m_FileName; return m_FileName;
} }
...@@ -593,16 +597,18 @@ wxString DrawSheetStruct::GetFileName( void ) ...@@ -593,16 +597,18 @@ wxString DrawSheetStruct::GetFileName( void )
/************************************************************************/ /************************************************************************/
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
const wxString& aFileName ) const wxString& aFileName )
{
/************************************************************************/ /************************************************************************/
/** Function ChangeFileName /** Function ChangeFileName
* Set a new filename and manage data and associated screen * Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy. * 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 not already used: change to the new name (and if an
* - if new filename is already used (a complex hierarchy) : reference the sheet. * 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 aFileName = the new filename
* @param aFrame = the schematic frame * @param aFrame = the schematic frame
*/ */
{
if( (GetFileName() == aFileName) && m_AssociatedScreen ) if( (GetFileName() == aFileName) && m_AssociatedScreen )
return true; return true;
...@@ -611,45 +617,52 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, ...@@ -611,45 +617,52 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
bool LoadFromFile = false; 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( _( msg.Printf( _( "A Sub Hierarchy named %s exists, Use it (The \
"A Sub Hierarchy named %s exists, Use it (The data in this sheet will be replaced)?" ), data in this sheet will be replaced)?" ),
aFileName.GetData() ); aFileName.GetData() );
if( !IsOK( NULL, msg ) ) if( !IsOK( NULL, msg ) )
{ {
DisplayInfoMessage( (wxWindow*)NULL, _( "Sheet Filename Renaming Aborted" ) ); DisplayInfoMessage( (wxWindow*) NULL,
_( "Sheet Filename Renaming Aborted" ) );
return false; 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( _( msg.Printf( _( "A file named %s exists, load it (otherwise keep \
"A file named %s exists, load it (otherwise keep current sheet data if possible)?" ), current sheet data if possible)?" ),
aFileName.GetData() ); aFileName.GetData() );
if( IsOK( NULL, msg ) ) if( IsOK( NULL, msg ) )
{ {
LoadFromFile = true; 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 ) if( m_AssociatedScreen->m_RefCount == 0 )
SAFE_DELETE( m_AssociatedScreen ); 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 ) ) if( m_AssociatedScreen && ( m_AssociatedScreen->m_RefCount > 1 ) )
{ {
msg = _( "This sheet uses shared data in a complex hierarchy" ); msg = _( "This sheet uses shared data in a complex hierarchy" );
msg << wxT( "\n" ); msg << wxT( "\n" );
msg << _( msg << _( "Do we convert it in a simple hierarchical sheet (\
"Do we convert it in a simple hierarchical sheet (otherwise delete current sheet data)" ); otherwise delete current sheet data)" );
if( IsOK( NULL, msg ) ) if( IsOK( NULL, msg ) )
{ {
LoadFromFile = true; LoadFromFile = true;
...@@ -665,13 +678,14 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, ...@@ -665,13 +678,14 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
SetFileName( aFileName ); 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) ) if( m_AssociatedScreen && (LoadFromFile || Screen_to_use) )
{ {
m_AssociatedScreen->m_RefCount--; m_AssociatedScreen->m_RefCount--;
if( m_AssociatedScreen->m_RefCount == 0 ) if( m_AssociatedScreen->m_RefCount == 0 )
SAFE_DELETE( m_AssociatedScreen ); SAFE_DELETE( m_AssociatedScreen );
m_AssociatedScreen = NULL; //so that we reload.. m_AssociatedScreen = NULL; // so that we reload..
} }
if( LoadFromFile ) if( LoadFromFile )
...@@ -687,7 +701,7 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame, ...@@ -687,7 +701,7 @@ bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame* aFrame,
if( !m_AssociatedScreen ) if( !m_AssociatedScreen )
{ {
m_AssociatedScreen = new SCH_SCREEN(); 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; m_AssociatedScreen->m_FileName = aFileName;
...@@ -708,7 +722,7 @@ void DrawSheetStruct::DisplayInfo( WinEDA_DrawFrame* frame ) ...@@ -708,7 +722,7 @@ void DrawSheetStruct::DisplayInfo( WinEDA_DrawFrame* frame )
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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; m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x ); NEGATE( m_Pos.x );
...@@ -716,7 +730,7 @@ void DrawSheetStruct::Mirror_Y(int aYaxis_position) ...@@ -716,7 +730,7 @@ void DrawSheetStruct::Mirror_Y(int aYaxis_position)
m_Pos.x -= m_Size.x; m_Pos.x -= m_Size.x;
Hierarchical_PIN_Sheet_Struct* label = m_Label; Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label != NULL ) while( label != NULL )
{ {
label->Mirror_Y( aYaxis_position ); label->Mirror_Y( aYaxis_position );
...@@ -732,12 +746,12 @@ void DrawSheetStruct::Show( int nestLevel, std::ostream& os ) ...@@ -732,12 +746,12 @@ void DrawSheetStruct::Show( int nestLevel, std::ostream& os )
wxString s = GetClass(); wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">"
<< " sheet_name=\"" << CONV_TO_UTF8( m_SheetName ) << '"' << " sheet_name=\"" << CONV_TO_UTF8( m_SheetName )
<< ">\n"; << '"' << ">\n";
// show all the pins, and check the linked list integrity // show all the pins, and check the linked list integrity
Hierarchical_PIN_Sheet_Struct* label; 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 ); label->Show( nestLevel + 1, os );
} }
......
/********************************************/ /********************************************/
/* Definitions for the EESchema program: */ /* Definitions for the EESchema program: */
/********************************************/ /********************************************/
#ifndef CLASS_DRAWSHEET_H #ifndef CLASS_DRAWSHEET_H
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
extern DrawSheetStruct* g_RootSheet; extern DrawSheetStruct* g_RootSheet;
/* class Hierarchical_PIN_Sheet_Struct /* class Hierarchical_PIN_Sheet_Struct
* a Hierarchical_PIN_Sheet_Struct is for a hierarchical sheet like a pin for a component * a Hierarchical_PIN_Sheet_Struct is for a hierarchical sheet like a pin for
* At root level, a Hierarchical_PIN_Sheet_Struct must be connected to a wire, bus or label * 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. * A sheet level it corresponds to a hierarchical label.
*/ */
class Hierarchical_PIN_Sheet_Struct : public SCH_ITEM, class Hierarchical_PIN_Sheet_Struct : public SCH_ITEM,
...@@ -20,13 +22,13 @@ class Hierarchical_PIN_Sheet_Struct : public SCH_ITEM, ...@@ -20,13 +22,13 @@ class Hierarchical_PIN_Sheet_Struct : public SCH_ITEM,
public: public:
int m_Edge, m_Shape; int m_Edge, m_Shape;
bool m_IsDangling; // TRUE non connected 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 // value 0 is for sheet name and 1 for sheet filename
public: public: Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent,
Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent, const wxPoint& pos = wxPoint( 0, 0 ),
const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString );
const wxString& text = wxEmptyString );
~Hierarchical_PIN_Sheet_Struct() { } ~Hierarchical_PIN_Sheet_Struct() { }
...@@ -38,56 +40,67 @@ public: ...@@ -38,56 +40,67 @@ public:
Hierarchical_PIN_Sheet_Struct* GenCopy(); 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 Place( WinEDA_SchematicFrame* frame,
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, wxDC* DC );
int draw_mode, int Color = -1 ); void Draw( WinEDA_DrawPanel* panel,
wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @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 // comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
virtual int GetPenSize( ); virtual int GetPenSize();
/** function CreateGraphicShape /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = list to fill with polygon corners coordinates * @param aCorner_list = list to fill with polygon corners coordinates
* @param Pos = Position of the shape * @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): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * 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; m_Pos += aMoveVector;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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; m_Pos.x -= aYaxis_position;
NEGATE( m_Pos.x ); NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position; m_Pos.x += aYaxis_position;
...@@ -96,32 +109,41 @@ public: ...@@ -96,32 +109,41 @@ public:
/* class DrawSheetStruct /* 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 class DrawSheetStruct : public SCH_ITEM
{ {
public: public:
wxString m_SheetName; /*this is equivalent to C101 for components: wxString m_SheetName; /* this is equivalent to C101 for
* it is stored in F0 ... of the file. */ * components: it is stored in F0 ...
* of the file. */
private: private:
wxString m_FileName; /*also in SCH_SCREEN (redundant), wxString m_FileName; /*also in SCH_SCREEN (redundant),
* but need it here for loading after * but need it here for loading after
* reading the sheet description from file. */ * reading the sheet description from
* file. */
public: public:
int m_SheetNameSize; /* Size (height) of the text, used to draw the sheet name */ int m_SheetNameSize; /* Size (height) of the text, used to
int m_FileNameSize; /* Size (height) of the text, used to draw the file name */ * draw the sheet name */
int m_FileNameSize; /* Size (height) of the text, used to
* draw the file name */
wxPoint m_Pos; wxPoint m_Pos;
wxSize m_Size; /* Position and Size of sheet symbol */ wxSize m_Size; /* Position and Size of *sheet symbol */
int m_Layer; int m_Layer;
Hierarchical_PIN_Sheet_Struct* m_Label; /* Points de connection, linked list.*/ Hierarchical_PIN_Sheet_Struct* m_Label; /* Points Be connection, linked
int m_NbLabel; /* Pins sheet (corresponding to hierarchical labels) count */ * list.*/
SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which handle the physical data int m_NbLabel; /* Pins sheet (corresponding to
* In complex hierarchies we can have many DrawSheetStruct using the same data * hierarchical labels) count */
*/ SCH_SCREEN* m_AssociatedScreen; /* Associated Screen which
* handle the physical data
public: * In complex hierarchies we
DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) ); * can have many DrawSheetStruct
* using the same data
*/
public: DrawSheetStruct( const wxPoint& pos = wxPoint( 0, 0 ) );
~DrawSheetStruct(); ~DrawSheetStruct();
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -131,7 +153,8 @@ public: ...@@ -131,7 +153,8 @@ public:
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
...@@ -142,7 +165,7 @@ public: ...@@ -142,7 +165,7 @@ public:
void DisplayInfo( WinEDA_DrawFrame* frame ); void DisplayInfo( WinEDA_DrawFrame* frame );
/** Function CleanupSheet /** 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 aRedraw = true to redraw Sheet
* @param aFrame = the schematic frame * @param aFrame = the schematic frame
*/ */
...@@ -151,7 +174,7 @@ public: ...@@ -151,7 +174,7 @@ public:
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @return the size of the "pen" that be used to draw or plot this item
*/ */
virtual int GetPenSize( ); virtual int GetPenSize();
/** Function Draw /** Function Draw
* Draw the hierarchical sheet shape * Draw the hierarchical sheet shape
...@@ -159,71 +182,80 @@ public: ...@@ -159,71 +182,80 @@ public:
* @param aDc = the current Device Context * @param aDc = the current Device Context
* @param aOffset = draw offset (usually wxPoint(0,0)) * @param aOffset = draw offset (usually wxPoint(0,0))
* @param aDrawMode = draw mode * @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, void Draw( WinEDA_DrawPanel* aPanel,
int aDrawMode, int aColor = -1 ); wxDC* aDC,
const wxPoint& aOffset,
int aDrawMode,
int aColor = -1 );
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
bool HitTest( const wxPoint& aPosRef ); bool HitTest( const wxPoint& aPosRef );
/** Function 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
*/ */
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
void SwapData( DrawSheetStruct* copyitem ); void SwapData( DrawSheetStruct* copyitem );
/** Function ComponentCount /** Function ComponentCount
* count our own components, without the power components. * count our own components, without the power components.
* @return the component count. * @return the component count.
*/ */
int ComponentCount(); int ComponentCount();
/** Function Load. /** Function Load.
* for the sheet: load the file m_FileName * for the sheet: load the file m_FileName
* if a screen already exists, the file is already read. * 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. * 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 * @return true if OK
*/ */
bool Load( WinEDA_SchematicFrame* aFrame ); bool Load( WinEDA_SchematicFrame* aFrame );
/** Function SearchHierarchy /** Function SearchHierarchy
* search the existing hierarchy for an instance of screen "FileName". * search the existing hierarchy for an instance of screen "FileName".
* @param aFilename = the filename to find * @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 * @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 /** Function LocatePathOfScreen
* search the existing hierarchy for an instance of screen "FileName". * search the existing hierarchy for an instance of screen "FileName".
* don't bother looking at the root sheet - it must be unique, * 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. * in the hierarchy.
* @param aScreen = the SCH_SCREEN* screen that we search for * @param aScreen = the SCH_SCREEN* screen that we search for
* @param aList = the DrawSheetPath* that must be used * @param aList = the DrawSheetPath* that must be used
* @return true if found * @return true if found
*/ */
bool LocatePathOfScreen( SCH_SCREEN* aScreen, DrawSheetPath* aList ); bool LocatePathOfScreen( SCH_SCREEN* aScreen,
DrawSheetPath* aList );
/** Function CountSheets /** Function CountSheets
* calculates the number of sheets found in "this" * calculates the number of sheets found in "this"
* this number includes the full subsheets count * this number includes the full subsheets count
* @return the full count of sheets+subsheets contained by "this" * @return the full count of sheets+subsheets contained by "this"
*/ */
int CountSheets(); int CountSheets();
/** Function GetFileName /** Function GetFileName
* return the filename corresponding to this sheet * return the filename corresponding to this sheet
* @return a wxString containing the filename * @return a wxString containing the filename
*/ */
wxString GetFileName( void ); wxString GetFileName( void );
// Set a new filename without changing anything else // Set a new filename without changing anything else
void SetFileName( const wxString& aFilename ) void SetFileName( const wxString& aFilename )
...@@ -235,26 +267,30 @@ public: ...@@ -235,26 +267,30 @@ public:
/** Function ChangeFileName /** Function ChangeFileName
* Set a new filename and manage data and associated screen * Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy. * 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 not already used: change to the new name (and if an
* - if new filename is already used (a complex hierarchy) : reference the sheet. * 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 aFileName = the new filename
* @param aFrame = the schematic frame * @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); //void RemoveSheet(DrawSheetStruct* sheet);
//to remove a sheet, just delete it //to remove a sheet, just delete it
//-- the destructor should take care of everything else. //-- the destructor should take care of everything else.
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * 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; m_Pos += aMoveVector;
Hierarchical_PIN_Sheet_Struct* label = m_Label; Hierarchical_PIN_Sheet_Struct* label = m_Label;
while( label != NULL ) while( label != NULL )
{ {
label->Move( aMoveVector ); label->Move( aMoveVector );
...@@ -262,16 +298,17 @@ public: ...@@ -262,16 +298,17 @@ public:
} }
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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 // comment inherited by Doxygen from Base_Struct
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
#endif #endif
}; };
......
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: class_drawsheet.cpp // Name: class_drawsheet.cpp
// Purpose: member functions for DrawSheetStruct // Purpose: member functions for DrawSheetStruct
// header = class_drawsheet.h // header = class_drawsheet.h
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Licence: License GNU // License: License GNU
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "fctsys.h" #include "fctsys.h"
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
/**********************************************/ /**********************************************/
/* class to handle a serie of sheets *********/ /* class to handle a series of sheets *********/
/* a 'path' so to speak.. *********************/ /* a 'path' so to speak.. *********************/
/**********************************************/ /**********************************************/
DrawSheetPath::DrawSheetPath() DrawSheetPath::DrawSheetPath()
...@@ -26,22 +27,26 @@ DrawSheetPath::DrawSheetPath() ...@@ -26,22 +27,26 @@ DrawSheetPath::DrawSheetPath()
m_numSheets = 0; m_numSheets = 0;
} }
/*********************************************************************************************/
bool DrawSheetPath::BuildSheetPathInfoFromSheetPathValue(const wxString & aPath, bool aFound ) /****************************************************************************/
/*********************************************************************************************/ bool DrawSheetPath::BuildSheetPathInfoFromSheetPathValue(
const wxString& aPath,
bool aFound )
{
/****************************************************************************/
/** Function BuildSheetPathInfoFromSheetPathValue /** 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) * @param aPath = path of the sheet to reach (in non human readable format)
* @return true if success else false * @return true if success else false
*/ */
{ if( aFound )
if ( aFound )
return true; return true;
if ( GetSheetsCount() == 0 ) if( GetSheetsCount() == 0 )
Push( g_RootSheet ); Push( g_RootSheet );
if ( aPath == Path() ) if( aPath == Path() )
return true; return true;
SCH_ITEM* schitem = LastDrawList(); SCH_ITEM* schitem = LastDrawList();
...@@ -51,25 +56,26 @@ bool DrawSheetPath::BuildSheetPathInfoFromSheetPathValue(const wxString & aPath, ...@@ -51,25 +56,26 @@ bool DrawSheetPath::BuildSheetPathInfoFromSheetPathValue(const wxString & aPath,
{ {
DrawSheetStruct* sheet = (DrawSheetStruct*) schitem; DrawSheetStruct* sheet = (DrawSheetStruct*) schitem;
Push( sheet ); Push( sheet );
if ( aPath == Path() ) if( aPath == Path() )
return true; return true;
if ( BuildSheetPathInfoFromSheetPathValue( aPath ) ) if( BuildSheetPathInfoFromSheetPathValue( aPath ) )
return true; return true;
Pop(); Pop();
} }
schitem = schitem->Next(); schitem = schitem->Next();
} }
return false; return false;
} }
/*******************************************************************/ /*******************************************************************/
int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const
/********************************************************************/ /********************************************************************/
/** Function Cmp /** Function Cmp
* Compare if this is the same sheet path as aSheetPathToTest * Compare if this is the same sheet path as aSheetPathToTest
* @param aSheetPathToTest = sheet path to compare * @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 ) if( m_numSheets > aSheetPathToTest.m_numSheets )
...@@ -80,9 +86,11 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const ...@@ -80,9 +86,11 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const
//otherwise, same number of sheets. //otherwise, same number of sheets.
for( unsigned i = 0; i<m_numSheets; i++ ) 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; 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; return -1;
} }
...@@ -91,8 +99,8 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const ...@@ -91,8 +99,8 @@ int DrawSheetPath::Cmp( const DrawSheetPath& aSheetPathToTest ) const
/** Function Last /** Function Last
* returns a pointer to the last sheet of the list * returns a pointer to the last sheet of the list
* One can see the others sheet as the "path" to reach this last sheet * One can see the others sheet as the "path" to reach this last sheet
*/ */
DrawSheetStruct* DrawSheetPath::Last() DrawSheetStruct* DrawSheetPath::Last()
{ {
...@@ -127,15 +135,16 @@ SCH_ITEM* DrawSheetPath::LastDrawList() ...@@ -127,15 +135,16 @@ SCH_ITEM* DrawSheetPath::LastDrawList()
/**************************************************/ /**************************************************/
void DrawSheetPath::Push( DrawSheetStruct* aSheet ) void DrawSheetPath::Push( DrawSheetStruct* aSheet )
{
/**************************************************/ /**************************************************/
/** Function Push /** Function Push
* store (push) aSheet in list * store (push) aSheet in list
* @param aSheet = pointer to the DrawSheetStruct to store in list * @param aSheet = pointer to the DrawSheetStruct to store in list
*/ */
{
if( m_numSheets > DSLSZ ) 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 ) if( m_numSheets < DSLSZ )
{ {
m_sheets[m_numSheets] = aSheet; m_sheets[m_numSheets] = aSheet;
...@@ -145,12 +154,11 @@ void DrawSheetPath::Push( DrawSheetStruct* aSheet ) ...@@ -145,12 +154,11 @@ void DrawSheetPath::Push( DrawSheetStruct* aSheet )
DrawSheetStruct* DrawSheetPath::Pop() DrawSheetStruct* DrawSheetPath::Pop()
{
/** Function Pop /** Function Pop
* retrieves (pop) the last entered sheet and remove it from list * retrieves (pop) the last entered sheet and remove it from list
* @return a DrawSheetStruct* pointer to the removed sheet in list * @return a DrawSheetStruct* pointer to the removed sheet in list
*/ */
{
if( m_numSheets > 0 ) if( m_numSheets > 0 )
{ {
m_numSheets--; m_numSheets--;
...@@ -161,20 +169,20 @@ DrawSheetStruct* DrawSheetPath::Pop() ...@@ -161,20 +169,20 @@ DrawSheetStruct* DrawSheetPath::Pop()
wxString DrawSheetPath::Path() wxString DrawSheetPath::Path()
{
/** Function 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 * a path is something like / (root) or /34005677 or /34005677/00AE4523
*/ */
{
wxString s, t; wxString s, t;
s = wxT( "/" ); // This is the root path s = wxT( "/" ); // This is the root path
//start at 1 to avoid the root sheet, // start at 1 to avoid the root sheet,
//which does not need to be added to the path // which does not need to be added to the path
//it's timestamp changes anyway. // it's timestamp changes anyway.
for( unsigned i = 1; i< m_numSheets; i++ ) for( unsigned i = 1; i < m_numSheets; i++ )
{ {
t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp ); t.Printf( _( "%8.8lX/" ), m_sheets[i]->m_TimeStamp );
s = s + t; s = s + t;
...@@ -186,19 +194,19 @@ wxString DrawSheetPath::Path() ...@@ -186,19 +194,19 @@ wxString DrawSheetPath::Path()
/******************************************/ /******************************************/
wxString DrawSheetPath::PathHumanReadable() wxString DrawSheetPath::PathHumanReadable()
{
/******************************************/ /******************************************/
/** Function PathHumanReadable /** Function PathHumanReadable
* Return the sheet path in a readable form, i.e. * Return the sheet path in a readable form, i.e.
* as a path made from sheet names. * 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; wxString s, t;
s = wxT( "/" ); 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++ ) for( unsigned i = 1; i< m_numSheets; i++ )
{ {
s = s + m_sheets[i]->m_SheetName + wxT( "/" ); s = s + m_sheets[i]->m_SheetName + wxT( "/" );
...@@ -210,8 +218,8 @@ wxString DrawSheetPath::PathHumanReadable() ...@@ -210,8 +218,8 @@ wxString DrawSheetPath::PathHumanReadable()
/***********************************************/ /***********************************************/
void DrawSheetPath::UpdateAllScreenReferences() void DrawSheetPath::UpdateAllScreenReferences()
/***********************************************/
{ {
/***********************************************/
EDA_BaseStruct* t = LastDrawList(); EDA_BaseStruct* t = LastDrawList();
while( t ) while( t )
...@@ -231,12 +239,12 @@ bool DrawSheetPath::operator=( const DrawSheetPath& d1 ) ...@@ -231,12 +239,12 @@ bool DrawSheetPath::operator=( const DrawSheetPath& d1 )
{ {
m_numSheets = d1.m_numSheets; m_numSheets = d1.m_numSheets;
unsigned i; unsigned i;
for( i = 0; i<m_numSheets; i++ ) for( i = 0; i < m_numSheets; i++ )
{ {
m_sheets[i] = d1.m_sheets[i]; m_sheets[i] = d1.m_sheets[i];
} }
for( ; i<DSLSZ; i++ ) for( ; i < DSLSZ; i++ )
{ {
m_sheets[i] = 0; m_sheets[i] = 0;
} }
...@@ -249,7 +257,7 @@ bool DrawSheetPath::operator==( const DrawSheetPath& d1 ) ...@@ -249,7 +257,7 @@ bool DrawSheetPath::operator==( const DrawSheetPath& d1 )
{ {
if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets )
return false; 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] ) if( m_sheets[i] != d1.m_sheets[i] )
return false; return false;
...@@ -263,7 +271,7 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 ) ...@@ -263,7 +271,7 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
{ {
if( m_numSheets != d1.m_numSheets ) if( m_numSheets != d1.m_numSheets )
return true; 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] ) if( m_sheets[i] != d1.m_sheets[i] )
return true; return true;
...@@ -280,13 +288,12 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 ) ...@@ -280,13 +288,12 @@ bool DrawSheetPath::operator!=( const DrawSheetPath& d1 )
/*******************************************************/ /*******************************************************/
EDA_SheetList::EDA_SheetList( DrawSheetStruct* aSheet ) EDA_SheetList::EDA_SheetList( DrawSheetStruct* aSheet )
{
/*******************************************************/ /*******************************************************/
/* The constructor: build the list of sheets from aSheet. /* The constructor: build the list of sheets from aSheet.
* If aSheet == NULL (default) build the whole list of sheets in hierarchy * If aSheet == NULL (default) build the whole list of sheets in hierarchy
* So usually call it with no param. * So usually call it with no param.
*/ */
{
m_index = 0; m_index = 0;
m_count = 0; m_count = 0;
m_List = NULL; m_List = NULL;
...@@ -298,12 +305,11 @@ EDA_SheetList::EDA_SheetList( DrawSheetStruct* aSheet ) ...@@ -298,12 +305,11 @@ EDA_SheetList::EDA_SheetList( DrawSheetStruct* aSheet )
/*****************************************/ /*****************************************/
DrawSheetPath* EDA_SheetList::GetFirst() DrawSheetPath* EDA_SheetList::GetFirst()
{
/*****************************************/ /*****************************************/
/** Function GetFirst /** Function GetFirst
* @return the first item (sheet) in m_List and prepare calls to GetNext() * @return the first item (sheet) in m_List and prepare calls to GetNext()
*/ */
{
m_index = 0; m_index = 0;
if( GetCount() > 0 ) if( GetCount() > 0 )
return &( m_List[0] ); return &( m_List[0] );
...@@ -313,12 +319,12 @@ DrawSheetPath* EDA_SheetList::GetFirst() ...@@ -313,12 +319,12 @@ DrawSheetPath* EDA_SheetList::GetFirst()
/*****************************************/ /*****************************************/
DrawSheetPath* EDA_SheetList::GetNext() DrawSheetPath* EDA_SheetList::GetNext()
{
/*****************************************/ /*****************************************/
/** Function 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() ) if( m_index < GetCount() )
m_index++; m_index++;
return GetSheet( m_index ); return GetSheet( m_index );
...@@ -327,29 +333,29 @@ DrawSheetPath* EDA_SheetList::GetNext() ...@@ -327,29 +333,29 @@ DrawSheetPath* EDA_SheetList::GetNext()
/************************************************/ /************************************************/
DrawSheetPath* EDA_SheetList::GetSheet( int aIndex ) DrawSheetPath* EDA_SheetList::GetSheet( int aIndex )
{
/************************************************/ /************************************************/
/** Function GetSheet /** 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 * @param aIndex = index in sheet list to get the sheet
*/ */
{
if( aIndex < GetCount() ) if( aIndex < GetCount() )
return &(m_List[aIndex]); return &( m_List[aIndex] );
return NULL; return NULL;
} }
/************************************************************************/ /************************************************************************/
void EDA_SheetList::BuildSheetList( DrawSheetStruct* aSheet ) void EDA_SheetList::BuildSheetList( DrawSheetStruct* aSheet )
{
/************************************************************************/ /************************************************************************/
/** Function BuildSheetList /** Function BuildSheetList
* Build the list of sheets and their sheet path from the aSheet sheet * 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 * @param aSheet = the starting sheet to build list
*/ */
{
if( m_List == NULL ) if( m_List == NULL )
{ {
int count = aSheet->CountSheets(); int count = aSheet->CountSheets();
......
/********************************************/ /********************************************/
/* Definitions for the EESchema program: */ /* Definitions for the EESchema program: */
/********************************************/ /********************************************/
#ifndef CLASS_DRAWSHEET_PATH_H #ifndef CLASS_DRAWSHEET_PATH_H
...@@ -8,51 +8,60 @@ ...@@ -8,51 +8,60 @@
#include "base_struct.h" #include "base_struct.h"
/** Info about complex hierarchies handling: /** Info about complex hierarchies handling:
* A hierarchical schematic uses sheets (hierachical sheets) included in a given sheet. * A hierarchical schematic uses sheets (hierarchical sheets) included in a
* each sheet corresponds to a schematic drawing handled by a SCH_SCREEN structure * given sheet. Rach sheet corresponds to a schematic drawing handled by a
* a SCH_SCREEN structure contains drawings, and have a filename to write to its data. * SCH_SCREEN structure. A SCH_SCREEN structure contains drawings, and have
* Also a SCH_SCREEN display a sheet number and the name of the sheet * a filename to write it's data. Also a SCH_SCREEN display a sheet number
* In simple (and flat) hierarchies a sheet is linked to a SCH_SCREEN, * 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. * 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. * In complex hierarchies the same SCH_SCREEN (and its data) is shared between
* Therefore subsheets (like subsheets in a SCH_SCREEN shared by many sheets) can be also shared * more than one sheet. Therefore subsheets (like subsheets in a SCH_SCREEN
* So the same SCH_SCREEN must handle differents components references and parts selection * shared by many sheets) can be also shared. So the same SCH_SCREEN must
* depending on which sheet is currently selected, and how a given subsheet is selected. * handle different components references and parts selection depending on
* 2 sheets share the same SCH_SCREEN (the same drawings) if they have the same filename. * 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. * In Kicad each component and sheet receives (when created) an unique
* So each sheet have 2 id : its time stamp (that cannot change) and its name * identification called Time Stamp. So each sheet has 2 ids: its time stamp
* ( that can be edited and therefore is not reliable for strong identification) * (that cannot change) and its name ( that can be edited and therefore is
* Kicad uses therefore Time Stamp ( an unique 32 bit id), to identify sheets in hierarchies. * not reliable for strong identification). Kicad uses Time Stamp ( a unique
* A given sheet in a hierarchy is fully labelled by its path (or sheet path) * 32 bit id), to identify sheets in hierarchies.
* that is the list of timestamp found to access it through the hierarchy * A given sheet in a hierarchy is fully labeled by its path (or sheet path)
* the root sheet is / * that is the list of time stamp found to access it through the hierarchy
* others have a path like /1234ABCD ou /4567FEDC/AA2233DD/ * the root sheet is /. All other sheets have a path like /1234ABCD or
* of course this path can be displayed as human readable sheet name like : * /4567FEDC/AA2233DD/. This path can be displayed as human readable sheet
* / or /sheet1/include_sheet/ or /sheet2/include_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: * So to know for a given SCH_SCREEN (a given schematic drawings) we must:
* Handle all references possibilities. * 1) Handle all references possibilities.
* When acceded by a given selected sheet, display (update) the corresponding references and sheet path * 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 DrawSheetPath handles paths used to access a sheet. The class
* the class EDA_SheetList allows to handle the full (or partial) list of sheets and their paths in a complex hierarchy. * EDA_SheetList allows to handle the full (or partial) list of sheets and
* the class EDA_ScreenList allow to handle the list of SCH_SCREEN. It is useful to clear or save data, * their paths in a complex hierarchy. The class EDA_ScreenList allow to
* but is not suitable to handle the full complex hierarchy possibilities (useable in flat and simple hierarchies). * 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.. */ /* a 'path' so to speak.. */
/****************************************/ /****************************************/
/* /*
* The member m_sheets stores the list of sheets from the first (usually g_RootSheet) * The member m_sheets stores the list of sheets from the first (usually
* to a given sheet in last position. * g_RootSheet)
* The last sheet is usually the sheet we want to select or reach. So Last() return this last sheet * to a given sheet in last position.
* Others sheets are the "path" from the first to the last sheet * 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 class DrawSheetPath
{ {
...@@ -61,94 +70,103 @@ private: ...@@ -61,94 +70,103 @@ private:
public: public:
#define DSLSZ 32 // Max number of levels for a sheet path #define DSLSZ 32 // Max number of levels for a sheet path
DrawSheetStruct* m_sheets[DSLSZ]; DrawSheetStruct * m_sheets[DSLSZ];
public: public: DrawSheetPath();
DrawSheetPath();
~DrawSheetPath() { }; ~DrawSheetPath() { };
void Clear() void Clear()
{ m_numSheets = 0; {
m_numSheets = 0;
} }
unsigned GetSheetsCount() unsigned GetSheetsCount()
{ {
return m_numSheets; return m_numSheets;
} }
/** Function Cmp /** Function Cmp
* Compare if this is the same sheet path as aSheetPathToTest * Compare if this is the same sheet path as aSheetPathToTest
* @param aSheetPathToTest = sheet path to compare * @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 /** Function Last
* returns a pointer to the last sheet of the list * returns a pointer to the last sheet of the list
* One can see the others sheet as the "path" to reach this last sheet * One can see the others sheet as the "path" to reach this last sheet
*/ */
DrawSheetStruct* Last(); DrawSheetStruct* Last();
/** Function LastScreen /** Function LastScreen
* @return the SCH_SCREEN relative to the last sheet in list * @return the SCH_SCREEN relative to the last sheet in list
*/ */
SCH_SCREEN* LastScreen(); SCH_SCREEN* LastScreen();
/** Function LastScreen /** Function LastScreen
* @return a pointer to the first schematic item handled by the * @return a pointer to the first schematic item handled by the
* SCH_SCREEN relative to the last sheet in list * SCH_SCREEN relative to the last sheet in list
*/ */
SCH_ITEM* LastDrawList(); SCH_ITEM* LastDrawList();
/** Function Push /** Function Push
* store (push) aSheet in list * store (push) aSheet in list
* @param aSheet = pointer to the DrawSheetStruct to store 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 * This is like cd <directory> in directories navigation
*/ */
void Push( DrawSheetStruct* aSheet ); void Push( DrawSheetStruct* aSheet );
/** Function Pop /** Function Pop
* retrieves (pop) the last entered sheet and remove it from list * retrieves (pop) the last entered sheet and remove it from list
* @return a DrawSheetStruct* pointer to the removed sheet in 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 * This is like cd .. in directories navigation
*/ */
DrawSheetStruct* Pop(); DrawSheetStruct* Pop();
/** Function 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 * a path is something like / (root) or /34005677 or /34005677/00AE4523
*/ */
wxString Path(); wxString Path();
/** Function PathHumanReadable /** Function PathHumanReadable
* Return the sheet path in a readable form, i.e. * Return the sheet path in a readable form, i.e.
* as a path made from sheet names. * 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 /** 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) * @param aPath = path of the sheet to reach (in non human readable format)
* @return true if success else false * @return true if success else false
*/ */
bool BuildSheetPathInfoFromSheetPathValue(const wxString & aPath, bool aFound = false ); bool BuildSheetPathInfoFromSheetPathValue(
const wxString& aPath,
bool aFound = false );
/** /**
* Function UpdateAllScreenReferences * Function UpdateAllScreenReferences
* updates the reference and the m_Multi parameter (part selection) for all * updates the reference and the m_Multi parameter (part selection) for all
* components on a screen depending on the actual sheet path. * components on a screen depending on the actual sheet path.
* Mandatory in complex hierarchies because sheets use the same screen (basic schematic) * Mandatory in complex hierarchies because sheets use the same screen
* but with different references and part selections according to the displayed sheet * (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 ...@@ -167,16 +185,19 @@ class EDA_SheetList
private: private:
DrawSheetPath* m_List; DrawSheetPath* m_List;
int m_count; /* Number of sheets included in hierarchy, 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() int m_index; /* internal variable to handle GetNext():
* and incremented by GetNext() after returning the next item in m_List * cleared by GetFirst()
* Also used for internal calculations in BuildSheetList() * 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: public:
/* The constructor: build the list of sheets from aSheet. /* The constructor: build the list of sheets from aSheet.
* If aSheet == NULL (default) build the whole list of sheets in hierarchy * If aSheet == NULL (default) build the whole list of sheets in hierarchy
* So usually call it with no param. * So usually call it with no param.
...@@ -200,18 +221,20 @@ public: ...@@ -200,18 +221,20 @@ public:
/** Function GetFirst /** Function GetFirst
* @return the first item (sheet) in m_List and prepare calls to GetNext() * @return the first item (sheet) in m_List and prepare calls to GetNext()
*/ */
DrawSheetPath* GetFirst(); DrawSheetPath* GetFirst();
/** Function 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
*/ */
DrawSheetPath* GetNext(); DrawSheetPath* GetNext();
/** Function GetSheet /** 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 * @param aIndex = index in sheet list to get the sheet
*/ */
DrawSheetPath* GetSheet( int aIndex ); DrawSheetPath* GetSheet( int aIndex );
private: private:
...@@ -220,7 +243,7 @@ private: ...@@ -220,7 +243,7 @@ private:
* if aSheet = g_RootSheet, the full sheet path and sheet list is built * if aSheet = g_RootSheet, the full sheet path and sheet list is built
* @param aSheet = the starting sheet from the built is made * @param aSheet = the starting sheet from the built is made
*/ */
void BuildSheetList( DrawSheetStruct* sheet ); void BuildSheetList( DrawSheetStruct* sheet );
}; };
#endif /* CLASS_DRAWSHEET_PATH_H */ #endif /* CLASS_DRAWSHEET_PATH_H */
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: class_hierarchical_PIN_sheet.cpp // Name: class_hierarchical_PIN_sheet.cpp
// Purpose: member functions Hierarchical_PIN_Sheet_Struct // Purpose: member functions Hierarchical_PIN_Sheet_Struct
// header = class_drawsheet.h // header = class_drawsheet.h
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Created: 08/02/2006 18:37:02 // Created: 08/02/2006 18:37:02
// RCS-ID: // RCS-ID:
// Copyright: License GNU // Copyright: License GNU
// Licence: // License:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "fctsys.h" #include "fctsys.h"
...@@ -23,13 +23,14 @@ ...@@ -23,13 +23,14 @@
/*******************************************************************/ /*******************************************************************/
Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* parent, Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct(
const wxPoint& pos, DrawSheetStruct* parent,
const wxString& text ) : const wxPoint& pos,
const wxString& text ) :
SCH_ITEM( parent, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ), SCH_ITEM( parent, DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE ),
EDA_TextStruct( text ) EDA_TextStruct( text )
/*******************************************************************/
{ {
/*******************************************************************/
wxASSERT( parent ); wxASSERT( parent );
wxASSERT( Pnext == NULL ); wxASSERT( Pnext == NULL );
m_Layer = LAYER_SHEETLABEL; m_Layer = LAYER_SHEETLABEL;
...@@ -43,10 +44,11 @@ Hierarchical_PIN_Sheet_Struct::Hierarchical_PIN_Sheet_Struct( DrawSheetStruct* p ...@@ -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* Hierarchical_PIN_Sheet_Struct::GenCopy()
/***********************************************************/
{ {
/***********************************************************/
Hierarchical_PIN_Sheet_Struct* newitem = 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_Edge = m_Edge;
newitem->m_Shape = m_Shape; newitem->m_Shape = m_Shape;
...@@ -59,25 +61,28 @@ Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy() ...@@ -59,25 +61,28 @@ Hierarchical_PIN_Sheet_Struct* Hierarchical_PIN_Sheet_Struct::GenCopy()
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @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; return g_DrawDefaultLineThickness;
} }
/********************************************************************************************/ /*****************************************************************************/
void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel,
int DrawMode, int Color ) wxDC* DC,
/********************************************************************************************/ const wxPoint& offset,
/* Routine de dessin des Labels type hierarchie */ int DrawMode,
int Color )
{ {
GRTextHorizJustifyType side; /*****************************************************************************/
EDA_Colors txtcolor; /* Routine to create hierarchical labels */
GRTextHorizJustifyType side;
EDA_Colors txtcolor;
int posx, tposx, posy; int posx, tposx, posy;
static std::vector <wxPoint> Poly; static std::vector <wxPoint> Poly;
int LineWidth = GetPenSize( ); int LineWidth = GetPenSize();
if( Color >= 0 ) if( Color >= 0 )
txtcolor = (EDA_Colors) Color; txtcolor = (EDA_Colors) Color;
...@@ -85,8 +90,8 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con ...@@ -85,8 +90,8 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
txtcolor = ReturnLayerColor( m_Layer ); txtcolor = ReturnLayerColor( m_Layer );
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
posx = m_Pos.x + offset.x; posx = m_Pos.x + offset.x;
posy = m_Pos.y + offset.y; posy = m_Pos.y + offset.y;
wxSize size = m_Size; wxSize size = m_Size;
if( !m_Text.IsEmpty() ) if( !m_Text.IsEmpty() )
...@@ -102,15 +107,15 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con ...@@ -102,15 +107,15 @@ void Hierarchical_PIN_Sheet_Struct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, con
side = GR_TEXT_HJUSTIFY_LEFT; side = GR_TEXT_HJUSTIFY_LEFT;
} }
DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor, DrawGraphicText( panel, DC, wxPoint( tposx, posy ), txtcolor,
m_Text, TEXT_ORIENT_HORIZ, size, m_Text, TEXT_ORIENT_HORIZ, size, side,
side, GR_TEXT_VJUSTIFY_CENTER, LineWidth, false, false ); GR_TEXT_VJUSTIFY_CENTER, LineWidth, false, false );
} }
/* Draw the graphic symbol */ /* Draw the graphic symbol */
CreateGraphicShape( Poly, m_Pos + offset ); CreateGraphicShape( Poly, m_Pos + offset );
int FillShape = false; int FillShape = false;
GRPoly( &panel->m_ClipBox, DC, Poly.size(), &Poly[0], 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 ...@@ -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 aCorner_list = list to fill with polygon corners coordinates
* @param Pos = Position of the shape * @param Pos = Position of the shape
*/ */
void Hierarchical_PIN_Sheet_Struct::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, void Hierarchical_PIN_Sheet_Struct::CreateGraphicShape(
const wxPoint& Pos ) std::vector <wxPoint>& aCorner_list,
const wxPoint& Pos )
{ {
wxSize size = m_Size; wxSize size = m_Size;
...@@ -206,8 +212,7 @@ bool Hierarchical_PIN_Sheet_Struct::Save( FILE* aFile ) const ...@@ -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, if( fprintf( aFile, "F%d \"%s\" %c %c %-3d %-3d %-3d\n", m_Number,
CONV_TO_UTF8( m_Text ), type, side, CONV_TO_UTF8( m_Text ), type, side, m_Pos.x, m_Pos.y,
m_Pos.x, m_Pos.y,
m_Size.x ) == EOF ) m_Size.x ) == EOF )
{ {
return false; return false;
...@@ -224,9 +229,8 @@ void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os ) ...@@ -224,9 +229,8 @@ void Hierarchical_PIN_Sheet_Struct::Show( int nestLevel, std::ostream& os )
wxString s = GetClass(); wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">"
<< " pin_name=\"" << CONV_TO_UTF8( m_Text ) << '"' << " pin_name=\"" << CONV_TO_UTF8( m_Text )
<< "/>\n" << '"' << "/>\n" << std::flush;
<< std::flush;
// NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n"; // NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n";
} }
......
...@@ -393,7 +393,6 @@ bool LIB_FIELD::HitTest( wxPoint aPosRef, int aThreshold, ...@@ -393,7 +393,6 @@ bool LIB_FIELD::HitTest( wxPoint aPosRef, int aThreshold,
return hit; return hit;
} }
// Creation et Duplication d'un field
LIB_DRAW_ITEM* LIB_FIELD::DoGenCopy() LIB_DRAW_ITEM* LIB_FIELD::DoGenCopy()
{ {
LIB_FIELD* newfield = new LIB_FIELD( m_FieldId ); 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 #ifndef CLASS_LIBENTRY_FIELDS_H
......
...@@ -76,7 +76,7 @@ bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 ) ...@@ -76,7 +76,7 @@ bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 )
CMP_LIBRARY::CMP_LIBRARY( int type, const wxFileName& fileName ) CMP_LIBRARY::CMP_LIBRARY( int type, const wxFileName& fileName )
{ {
m_Type = type; /* type indicator */ m_Type = type; /* type indicator */
m_IsModified = false; /* flag indicateur d'edition */ m_IsModified = false; /* modified indicator */
m_TimeStamp = 0; m_TimeStamp = 0;
m_Flags = 0; m_Flags = 0;
m_IsCache = false; m_IsCache = false;
...@@ -505,7 +505,7 @@ bool CMP_LIBRARY::Load( wxString& errMsg ) ...@@ -505,7 +505,7 @@ bool CMP_LIBRARY::Load( wxString& errMsg )
* apparently started with EESchema-LIB. Sometime after 2.0, it * apparently started with EESchema-LIB. Sometime after 2.0, it
* was changed to EESchema-LIBRARY. Therefore, the test for * was changed to EESchema-LIBRARY. Therefore, the test for
* EESchema-LIB will work in both cases. Don't change this unless * 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() if( !tkn.HasMoreTokens()
|| !tkn.GetNextToken().Upper().StartsWith(wxT( "EESCHEMA-LIB" ) ) ) || !tkn.GetNextToken().Upper().StartsWith(wxT( "EESCHEMA-LIB" ) ) )
...@@ -559,7 +559,7 @@ the current schematic." ), ...@@ -559,7 +559,7 @@ the current schematic." ),
{ {
if( !LoadHeader( f, &LineNum ) ) if( !LoadHeader( f, &LineNum ) )
{ {
errMsg = _( "An error occured attempting to read the header." ); errMsg = _( "An error occurred attempting to read the header." );
return false; return false;
} }
...@@ -659,14 +659,14 @@ bool CMP_LIBRARY::LoadDocs( wxString& errMsg ) ...@@ -659,14 +659,14 @@ bool CMP_LIBRARY::LoadDocs( wxString& errMsg )
if( f == NULL ) 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() ) ); GetChars( fn.GetFullPath() ) );
return false; return false;
} }
if( GetLine( f, Line, &LineNum, sizeof(Line) ) == NULL ) 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() ) ); GetChars( fn.GetFullPath() ) );
fclose( f ); fclose( f );
return false; return false;
...@@ -765,7 +765,6 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName, bool oldDocFormat ) ...@@ -765,7 +765,6 @@ bool CMP_LIBRARY::Save( const wxString& FullFileName, bool oldDocFormat )
m_IsModified = false; m_IsModified = false;
/* Creation de l'entete de la librairie */
m_TimeStamp = GetTimeStamp(); m_TimeStamp = GetTimeStamp();
if( !SaveHeader( libfile ) ) if( !SaveHeader( libfile ) )
{ {
......
...@@ -89,8 +89,7 @@ public: ...@@ -89,8 +89,7 @@ public:
* @param oldDocFormat - Save the document information in a separate * @param oldDocFormat - Save the document information in a separate
* file if true. The default is to save as the * file if true. The default is to save as the
* current library file format. * current library file format.
* * @return True if success writing else false.
* @return bool - true if success writing else false.
*/ */
bool Save( const wxString& aFullFileName, bool oldDocFormat = false ); bool Save( const wxString& aFullFileName, bool oldDocFormat = false );
...@@ -101,8 +100,7 @@ public: ...@@ -101,8 +100,7 @@ public:
* file *.bck. * file *.bck.
* *
* @param aFullFileName - The library filename with path. * @param aFullFileName - The library filename with path.
* * @return True if success writing else false.
* @return bool - true if success writing else false.
*/ */
bool SaveDocFile( const wxString& FullFileName ); bool SaveDocFile( const wxString& FullFileName );
...@@ -110,8 +108,7 @@ public: ...@@ -110,8 +108,7 @@ public:
* Load library from file. * Load library from file.
* *
* @param errMsg - Error message if load fails. * @param errMsg - Error message if load fails.
* * @return True if load was successful otherwise false.
* @return bool - True if load was successful otherwise false.
*/ */
bool Load( wxString& errMsg ); bool Load( wxString& errMsg );
...@@ -129,7 +126,7 @@ public: ...@@ -129,7 +126,7 @@ public:
/** /**
* Get library entry status. * 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 bool IsEmpty() const
{ {
...@@ -151,16 +148,12 @@ public: ...@@ -151,16 +148,12 @@ public:
return m_IsModified; return m_IsModified;
} }
bool IsCache() const { return m_IsCache; } bool IsCache() const { return m_IsCache; }
void SetModified( void ) { m_IsModified = true; } void SetModified( void ) { m_IsModified = true; }
void SetCache( void ) { m_IsCache = true; } void SetCache( void ) { m_IsCache = true; }
/** /**
* Load a string array with the names of all the entries in this library. * Load a string array with the names of all the entries in this library.
* *
...@@ -202,7 +195,6 @@ public: ...@@ -202,7 +195,6 @@ public:
* Find entry by name. * Find entry by name.
* *
* @param name - Name of entry, case insensitive. * @param name - Name of entry, case insensitive.
*
* @return Pointer to entry if found. NULL if not found. * @return Pointer to entry if found. NULL if not found.
*/ */
CMP_LIB_ENTRY* FindEntry( const wxChar* name ); CMP_LIB_ENTRY* FindEntry( const wxChar* name );
...@@ -212,7 +204,6 @@ public: ...@@ -212,7 +204,6 @@ public:
* *
* @param name - Name of entry, case insensitive. * @param name - Name of entry, case insensitive.
* @param type - Type of entry, root or alias. * @param type - Type of entry, root or alias.
*
* @return Pointer to entry if found. NULL if not found. * @return Pointer to entry if found. NULL if not found.
*/ */
CMP_LIB_ENTRY* FindEntry( const wxChar* name, LibrEntryType type ); CMP_LIB_ENTRY* FindEntry( const wxChar* name, LibrEntryType type );
...@@ -226,7 +217,6 @@ public: ...@@ -226,7 +217,6 @@ public:
* @param name - Name of component, case insensitive. * @param name - Name of component, case insensitive.
* @param searchAliases - Searches for component by alias name as well as * @param searchAliases - Searches for component by alias name as well as
* component name if true. * component name if true.
*
* @return Pointer to component if found. NULL if not found. * @return Pointer to component if found. NULL if not found.
*/ */
LIB_COMPONENT* FindComponent( const wxChar* name ); LIB_COMPONENT* FindComponent( const wxChar* name );
...@@ -238,7 +228,6 @@ public: ...@@ -238,7 +228,6 @@ public:
* a LIB_ALIAS pointer is not required. * a LIB_ALIAS pointer is not required.
* *
* @param name - Name of alias, case insensitive. * @param name - Name of alias, case insensitive.
*
* @return Pointer to alias if found. NULL if not found. * @return Pointer to alias if found. NULL if not found.
*/ */
LIB_ALIAS* FindAlias( const wxChar* name ) LIB_ALIAS* FindAlias( const wxChar* name )
...@@ -256,9 +245,7 @@ public: ...@@ -256,9 +245,7 @@ public:
* remove the alias from the library. * remove the alias from the library.
* *
* @param alias - Alias to add to library. * @param alias - Alias to add to library.
* * @return True if alias added to library. False if conflict exists.
* @return bool - True if alias added to library. False if conflict
* exists.
*/ */
bool AddAlias( LIB_ALIAS* alias ); bool AddAlias( LIB_ALIAS* alias );
...@@ -266,7 +253,6 @@ public: ...@@ -266,7 +253,6 @@ public:
* Add component entry to library. * Add component entry to library.
* *
* @param cmp - Component to add. * @param cmp - Component to add.
*
* @return Pointer to added component if successful. * @return Pointer to added component if successful.
*/ */
LIB_COMPONENT* AddComponent( LIB_COMPONENT* cmp ); LIB_COMPONENT* AddComponent( LIB_COMPONENT* cmp );
...@@ -311,9 +297,7 @@ public: ...@@ -311,9 +297,7 @@ public:
* entry in the list is returned. * entry in the list is returned.
* *
* @param name - Name of current entry. * @param name - Name of current entry.
* * @return Pointer to next entry if entry name is found. Otherwise NULL.
* @return CMP_LIB_ENTRY - Pointer to next entry if entry name is found.
* Otherwise NULL.
*/ */
CMP_LIB_ENTRY* GetNextEntry( const wxChar* name ); CMP_LIB_ENTRY* GetNextEntry( const wxChar* name );
...@@ -325,23 +309,21 @@ public: ...@@ -325,23 +309,21 @@ public:
* entry in the list is returned. * entry in the list is returned.
* *
* @param name - Name of current entry. * @param name - Name of current entry.
* * @return Previous entry if entry name is found, otherwise NULL.
* @return CMP_LIB_ENTRY - Pointer to previous entry if entry name is found.
* Otherwise NULL.
*/ */
CMP_LIB_ENTRY* GetPreviousEntry( const wxChar* name ); CMP_LIB_ENTRY* GetPreviousEntry( const wxChar* name );
/** /**
* Return the file name without path or extension. * 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(); } wxString GetName() const { return m_fileName.GetName(); }
/** /**
* Return the full file library name with path and extension. * 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(); } wxString GetFullFileName() { return m_fileName.GetFullPath(); }
...@@ -368,9 +350,8 @@ public: ...@@ -368,9 +350,8 @@ public:
* *
* @param fileName - File name of the component library to load. * @param fileName - File name of the component library to load.
* @param errMsg - Error message if the component library failed to load. * @param errMsg - Error message if the component library failed to load.
* * @return Library object if library file loaded successfully,
* @return Pointer to library object if library file loaded successfully. * otherwise NULL.
* Otherwise NULL.
*/ */
static CMP_LIBRARY* LoadLibrary( const wxFileName& fileName, static CMP_LIBRARY* LoadLibrary( const wxFileName& fileName,
wxString& errMsg ); wxString& errMsg );
...@@ -380,8 +361,7 @@ public: ...@@ -380,8 +361,7 @@ public:
* *
* @param fileName - File name object of component library. * @param fileName - File name object of component library.
* @param errMsg - Error message if the component library failed to load. * @param errMsg - Error message if the component library failed to load.
* * @return True if library loaded properly otherwise false.
* @return bool - True if library loaded properly otherwise false.
*/ */
static bool AddLibrary( const wxFileName& fileName, wxString& errMsg ); static bool AddLibrary( const wxFileName& fileName, wxString& errMsg );
...@@ -391,8 +371,7 @@ public: ...@@ -391,8 +371,7 @@ public:
* @param fileName - File name object of component library. * @param fileName - File name object of component library.
* @param errMsg - Error message if the component library failed to load. * @param errMsg - Error message if the component library failed to load.
* @param i - Iterator to insert library in front of. * @param i - Iterator to insert library in front of.
* * @return True if library loaded properly otherwise false.
* @return bool - True if library loaded properly otherwise false.
*/ */
static bool AddLibrary( const wxFileName& fileName, wxString& errMsg, static bool AddLibrary( const wxFileName& fileName, wxString& errMsg,
CMP_LIBRARY_LIST::iterator& i ); CMP_LIBRARY_LIST::iterator& i );
...@@ -408,9 +387,7 @@ public: ...@@ -408,9 +387,7 @@ public:
* Find component library by name. * Find component library by name.
* *
* @param name - Library file name without path or extension to find. * @param name - Library file name without path or extension to find.
* * @return Pointer to component library if found, otherwise NULL.
* @return CMP_LIBRARY* - Pointer to component library if found,
* otherwise NULL.
*/ */
static CMP_LIBRARY* FindLibrary( const wxString& name ); static CMP_LIBRARY* FindLibrary( const wxString& name );
...@@ -419,8 +396,7 @@ public: ...@@ -419,8 +396,7 @@ public:
* *
* @param sorted - Sort the list of name if true. Otherwise use the * @param sorted - Sort the list of name if true. Otherwise use the
* library load order. * library load order.
* * @return The list of library names.
* @return wxArrayString - The list of library names.
*/ */
static wxArrayString GetLibraryNames( bool sorted = true ); static wxArrayString GetLibraryNames( bool sorted = true );
...@@ -432,8 +408,7 @@ public: ...@@ -432,8 +408,7 @@ public:
* *
* @param name - Name of component to search for. * @param name - Name of component to search for.
* @param libNaem - Name of the library to search for component. * @param libNaem - Name of the library to search for component.
* * @return The component object if found, otherwise NULL.
* @return Pointer to a valid component object if found. Otherwise NULL.
*/ */
static LIB_COMPONENT* FindLibraryComponent( static LIB_COMPONENT* FindLibraryComponent(
const wxString& name, const wxString& libName = wxEmptyString ); const wxString& name, const wxString& libName = wxEmptyString );
...@@ -445,8 +420,7 @@ public: ...@@ -445,8 +420,7 @@ public:
* *
* @param name - Name of component to search for. * @param name - Name of component to search for.
* @param libNaem - Name of the library to search for entry. * @param libNaem - Name of the library to search for entry.
* * @return The entry object if found, otherwise NULL.
* @return Pointer to a valid entry object if found. Otherwise NULL.
*/ */
static CMP_LIB_ENTRY* FindLibraryEntry( static CMP_LIB_ENTRY* FindLibraryEntry(
const wxString& name, const wxString& name,
......
...@@ -66,9 +66,7 @@ int SCH_CMP_FIELD::GetPenSize() ...@@ -66,9 +66,7 @@ int SCH_CMP_FIELD::GetPenSize()
/** /**
* Routine de trace des textes type Field du composant. * Draw schematic component fields.
* entree:
* DrawMode: mode de trace
*/ */
void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color ) const wxPoint& offset, int DrawMode, int Color )
...@@ -98,7 +96,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -98,7 +96,7 @@ void SCH_CMP_FIELD::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
/* Calculate the text orientation, according to the component orientation/mirror */ /* Calculate the text orientation, according to the component orientation/mirror */
orient = m_Orient; 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 ) if( orient == TEXT_ORIENT_HORIZ )
orient = TEXT_ORIENT_VERT; orient = TEXT_ORIENT_VERT;
......
/***********************************************************************/ /*****************************/
/* Methodes de base de gestion des classes des elements de schematique */ /* class_schematic_items.cpp */
/***********************************************************************/ /*****************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -60,7 +60,7 @@ DrawBusEntryStruct* DrawBusEntryStruct::GenCopy() ...@@ -60,7 +60,7 @@ DrawBusEntryStruct* DrawBusEntryStruct::GenCopy()
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
...@@ -162,7 +162,7 @@ DrawJunctionStruct* DrawJunctionStruct::GenCopy() ...@@ -162,7 +162,7 @@ DrawJunctionStruct* DrawJunctionStruct::GenCopy()
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
...@@ -202,7 +202,7 @@ bool DrawJunctionStruct::HitTest( const wxPoint& aPosRef ) ...@@ -202,7 +202,7 @@ bool DrawJunctionStruct::HitTest( const wxPoint& aPosRef )
wxPoint dist = aPosRef - m_Pos; wxPoint dist = aPosRef - m_Pos;
return sqrt( ( (double) ( dist.x * dist.x ) ) + 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() ...@@ -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, void DrawJunctionStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int DrawMode, int Color ) const wxPoint& offset, int DrawMode, int Color )
...@@ -231,7 +231,8 @@ void DrawJunctionStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -231,7 +231,8 @@ void DrawJunctionStruct::Draw( WinEDA_DrawPanel* panel, wxDC* DC,
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( DC, DrawMode );
GRFilledCircle( &panel->m_ClipBox, DC, m_Pos.x + offset.x, 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() ...@@ -274,7 +275,7 @@ EDA_Rect DrawNoConnectStruct::GetBoundingBox()
{ {
const int DELTA = DRAWNOCONNECT_SIZE / 2; const int DELTA = DRAWNOCONNECT_SIZE / 2;
EDA_Rect box( wxPoint( m_Pos.x - DELTA, m_Pos.y - DELTA ), EDA_Rect box( wxPoint( m_Pos.x - DELTA, m_Pos.y - DELTA ),
wxSize( 2 * DELTA, 2 * DELTA ) ); wxSize( 2 * DELTA, 2 * DELTA ) );
box.Normalize(); box.Normalize();
return box; return box;
...@@ -301,7 +302,7 @@ bool DrawNoConnectStruct::HitTest( const wxPoint& aPosRef ) ...@@ -301,7 +302,7 @@ bool DrawNoConnectStruct::HitTest( const wxPoint& aPosRef )
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
...@@ -364,7 +365,7 @@ EDA_DrawLineStruct::EDA_DrawLineStruct( const wxPoint& pos, int layer ) : ...@@ -364,7 +365,7 @@ EDA_DrawLineStruct::EDA_DrawLineStruct( const wxPoint& pos, int layer ) :
switch( layer ) switch( layer )
{ {
default: default:
m_Layer = LAYER_NOTES; /* Mettre ds Notes */ m_Layer = LAYER_NOTES;
break; break;
case LAYER_WIRE: case LAYER_WIRE:
...@@ -435,7 +436,7 @@ EDA_Rect EDA_DrawLineStruct::GetBoundingBox() ...@@ -435,7 +436,7 @@ EDA_Rect EDA_DrawLineStruct::GetBoundingBox()
// return a rectangle which is [pos,dim) in nature. therefore the +1 // return a rectangle which is [pos,dim) in nature. therefore the +1
EDA_Rect ret( wxPoint( xmin, ymin ), EDA_Rect ret( wxPoint( xmin, ymin ),
wxSize( xmax - xmin + 1, ymax - ymin + 1 ) ); wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
return ret; return ret;
} }
...@@ -443,7 +444,7 @@ EDA_Rect EDA_DrawLineStruct::GetBoundingBox() ...@@ -443,7 +444,7 @@ EDA_Rect EDA_DrawLineStruct::GetBoundingBox()
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
...@@ -559,7 +560,7 @@ DrawPolylineStruct* DrawPolylineStruct::GenCopy() ...@@ -559,7 +560,7 @@ DrawPolylineStruct* DrawPolylineStruct::GenCopy()
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
...@@ -575,7 +576,7 @@ bool DrawPolylineStruct::Save( FILE* aFile ) const ...@@ -575,7 +576,7 @@ bool DrawPolylineStruct::Save( FILE* aFile ) const
if( GetLayer() == LAYER_BUS ) if( GetLayer() == LAYER_BUS )
layer = "Bus"; layer = "Bus";
if( fprintf( aFile, "Poly %s %s %d\n", if( fprintf( aFile, "Poly %s %s %d\n",
width, layer, GetCornerCount() ) == EOF ) width, layer, GetCornerCount() ) == EOF )
{ {
return false; return false;
} }
......
...@@ -5,17 +5,18 @@ ...@@ -5,17 +5,18 @@
#ifndef CLASS_SCHEMATIC_ITEMS_H #ifndef CLASS_SCHEMATIC_ITEMS_H
#define CLASS_SCHEMATIC_ITEMS_H #define CLASS_SCHEMATIC_ITEMS_H
#define DRAWJUNCTION_DIAMETER 32 /* Size (diameter) of junctions between wires */ #define DRAWJUNCTION_DIAMETER 32 /* Diameter of junction symbol between
#define DRAWNOCONNECT_SIZE 48 /* Rayon du symbole No Connexion */ * 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 WIRE_TO_BUS 0
#define BUS_TO_BUS 1 #define BUS_TO_BUS 1
/** /**
* Class EDA_DrawLineStruct * 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 ...) * points (track, wire, draw line ...)
*/ */
class EDA_DrawLineStruct : public SCH_ITEM class EDA_DrawLineStruct : public SCH_ITEM
...@@ -26,7 +27,7 @@ public: ...@@ -26,7 +27,7 @@ public:
wxPoint m_End; // Line end point wxPoint m_End; // Line end point
bool m_StartIsDangling; 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: public:
EDA_DrawLineStruct( const wxPoint& pos, int layer ); EDA_DrawLineStruct( const wxPoint& pos, int layer );
...@@ -57,7 +58,7 @@ public: ...@@ -57,7 +58,7 @@ public:
/** /**
* Function Save * 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. * format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
...@@ -72,7 +73,7 @@ public: ...@@ -72,7 +73,7 @@ public:
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * 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)
{ {
...@@ -102,7 +103,7 @@ public: ...@@ -102,7 +103,7 @@ public:
}; };
class DrawNoConnectStruct : public SCH_ITEM /* Symboles de non connexion */ class DrawNoConnectStruct : public SCH_ITEM
{ {
public: public:
wxPoint m_Pos; /* XY coordinates of NoConnect. */ wxPoint m_Pos; /* XY coordinates of NoConnect. */
...@@ -129,7 +130,7 @@ public: ...@@ -129,7 +130,7 @@ public:
/** /**
* Function Save * 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. * format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
...@@ -146,7 +147,7 @@ public: ...@@ -146,7 +147,7 @@ public:
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * 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)
{ {
...@@ -168,7 +169,8 @@ public: ...@@ -168,7 +169,8 @@ public:
/** /**
* Class DrawBusEntryStruct * 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 class DrawBusEntryStruct : public SCH_ITEM
{ {
...@@ -188,14 +190,14 @@ public: ...@@ -188,14 +190,14 @@ public:
DrawBusEntryStruct* GenCopy(); 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, virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC,
const wxPoint& offset, int draw_mode, const wxPoint& offset, int draw_mode,
int Color = -1 ); int Color = -1 );
/** /**
* Function Save * 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. * format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
...@@ -212,7 +214,7 @@ public: ...@@ -212,7 +214,7 @@ public:
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * 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)
{ {
...@@ -232,10 +234,10 @@ public: ...@@ -232,10 +234,10 @@ public:
} }
}; };
class DrawPolylineStruct : public SCH_ITEM /* Polyligne (serie de segments) */ class DrawPolylineStruct : public SCH_ITEM
{ {
public: public:
int m_Width; /* Tickness */ int m_Width; /* Thickness */
std::vector<wxPoint> m_PolyPoints; // list of points (>= 2) std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
public: public:
...@@ -255,7 +257,7 @@ public: ...@@ -255,7 +257,7 @@ public:
/** /**
* Function Save * 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. * format.
* @param aFile The FILE to write to. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
...@@ -284,7 +286,7 @@ public: ...@@ -284,7 +286,7 @@ public:
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * 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)
{ {
...@@ -342,7 +344,8 @@ public: ...@@ -342,7 +344,8 @@ public:
int Color = -1 ); int Color = -1 );
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
...@@ -351,7 +354,7 @@ public: ...@@ -351,7 +354,7 @@ public:
// Geometric transforms (used in block operations): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * 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)
{ {
......
/***********************************************************************/ /*********************************************/
/* Methodes de base de gestion des classes des elements de schematique */ /* Code for handling schematic sheet labels. */
/***********************************************************************/ /*********************************************/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
/* class SCH_HIERLABEL */ /* class SCH_HIERLABEL */
/************************/ /************************/
/* Messages correspondants aux types ou forme des labels */ /* Names of sheet label types. */
const char* SheetLabelType[] = const char* SheetLabelType[] =
{ {
"Input", "Input",
...@@ -65,20 +65,25 @@ static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 }; ...@@ -65,20 +65,25 @@ static int Template3STATE_BOTTOM[] = { 5, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0 };
static int* TemplateShape[5][4] = static int* TemplateShape[5][4] =
{ {
{ TemplateIN_HN, TemplateIN_UP, TemplateIN_HI, TemplateIN_BOTTOM }, { TemplateIN_HN, TemplateIN_UP, TemplateIN_HI,
{ TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI, TemplateOUT_BOTTOM }, TemplateIN_BOTTOM },
{ TemplateBIDI_HN, TemplateBIDI_UP, TemplateBIDI_HI, TemplateBIDI_BOTTOM }, { TemplateOUT_HN, TemplateOUT_UP, TemplateOUT_HI,
{ Template3STATE_HN, Template3STATE_UP, Template3STATE_HI, Template3STATE_BOTTOM }, TemplateOUT_BOTTOM },
{ TemplateUNSPC_HN, TemplateUNSPC_UP, TemplateUNSPC_HI, TemplateUNSPC_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_TEXT::SCH_TEXT( const wxPoint& pos, const wxString& text,
SCH_ITEM( NULL, aType ), KICAD_T aType ) :
EDA_TextStruct( text ) SCH_ITEM( NULL, aType ), EDA_TextStruct( text )
/**************************************************************************/
{ {
/**************************************************************************/
m_Layer = LAYER_NOTES; m_Layer = LAYER_NOTES;
m_Pos = pos; m_Pos = pos;
m_Shape = 0; m_Shape = 0;
...@@ -100,8 +105,8 @@ bool SCH_TEXT::HitTest( const wxPoint& aPosRef ) ...@@ -100,8 +105,8 @@ bool SCH_TEXT::HitTest( const wxPoint& aPosRef )
/*********************************************/ /*********************************************/
SCH_TEXT* SCH_TEXT::GenCopy() SCH_TEXT* SCH_TEXT::GenCopy()
/*********************************************/
{ {
/*********************************************/
SCH_TEXT* newitem; SCH_TEXT* newitem;
switch( Type() ) switch( Type() )
...@@ -124,8 +129,8 @@ SCH_TEXT* SCH_TEXT::GenCopy() ...@@ -124,8 +129,8 @@ SCH_TEXT* SCH_TEXT::GenCopy()
break; break;
} }
newitem->m_Layer = m_Layer; newitem->m_Layer = m_Layer;
newitem->m_Shape = m_Shape; newitem->m_Shape = m_Shape;
newitem->m_Orient = m_Orient; newitem->m_Orient = m_Orient;
newitem->m_Size = m_Size; newitem->m_Size = m_Size;
newitem->m_Width = m_Width; newitem->m_Width = m_Width;
...@@ -141,7 +146,8 @@ SCH_TEXT* SCH_TEXT::GenCopy() ...@@ -141,7 +146,8 @@ SCH_TEXT* SCH_TEXT::GenCopy()
/** function GetSchematicTextOffset (virtual) /** 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 * 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)
*/ */
...@@ -149,7 +155,8 @@ wxPoint SCH_TEXT::GetSchematicTextOffset() ...@@ -149,7 +155,8 @@ wxPoint SCH_TEXT::GetSchematicTextOffset()
{ {
wxPoint text_offset; 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 ) switch( m_SchematicOrientation )
{ {
default: default:
...@@ -175,7 +182,8 @@ wxPoint SCH_TEXT::GetSchematicTextOffset() ...@@ -175,7 +182,8 @@ wxPoint SCH_TEXT::GetSchematicTextOffset()
/** function GetSchematicTextOffset (virtual) /** 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 * 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)
*/ */
...@@ -189,29 +197,33 @@ wxPoint SCH_LABEL::GetSchematicTextOffset() ...@@ -189,29 +197,33 @@ wxPoint SCH_LABEL::GetSchematicTextOffset()
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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 // Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text // 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 px = m_Pos.x;
int dx; int dx;
if( m_Orient == 0 ) /* horizontal text */
if( m_Orient == 0 ) /* horizontal text */
dx = LenSize( m_Text ) / 2; 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; dx = -LenSize( m_Text ) / 2;
else else
dx = 0; dx = 0;
px += dx; px += dx;
px -= aYaxis_position; px -= aYaxis_position;
NEGATE(px); NEGATE( px );
px += aYaxis_position; px += aYaxis_position;
px -= dx; px -= dx;
m_Pos.x = px; m_Pos.x = px;
} }
/** function GetSchematicTextOffset (virtual) /** 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 * 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)
*/ */
...@@ -245,44 +257,50 @@ wxPoint SCH_HIERLABEL::GetSchematicTextOffset() ...@@ -245,44 +257,50 @@ wxPoint SCH_HIERLABEL::GetSchematicTextOffset()
return text_offset; return text_offset;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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 // Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text // 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
if( m_Orient == 0 ) /* horizontal text */ // horizontal len
if( m_Orient == 0 ) /* horizontal text */
m_Orient = 2; m_Orient = 2;
else if( m_Orient == 2 ) /* invert horizontal text*/ else if( m_Orient == 2 ) /* invert horizontal text*/
m_Orient = 0; m_Orient = 0;
m_Pos.x -= aYaxis_position; m_Pos.x -= aYaxis_position;
NEGATE(m_Pos.x); NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position; m_Pos.x += aYaxis_position;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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 // Text is NOT really mirrored; it is moved to a suitable position
// which is the closest position for a true mirrored text // 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
if( m_Orient == 0 ) /* horizontal text */ // horizontal len
if( m_Orient == 0 ) /* horizontal text */
m_Orient = 2; m_Orient = 2;
else if( m_Orient == 2 ) /* invert horizontal text*/ else if( m_Orient == 2 ) /* invert horizontal text*/
m_Orient = 0; m_Orient = 0;
m_Pos.x -= aYaxis_position; m_Pos.x -= aYaxis_position;
NEGATE(m_Pos.x); NEGATE( m_Pos.x );
m_Pos.x += aYaxis_position; m_Pos.x += aYaxis_position;
} }
/** function GetSchematicTextOffset (virtual) /** 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 * 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)
*/ */
...@@ -314,7 +332,7 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() ...@@ -314,7 +332,7 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset()
switch( m_SchematicOrientation ) switch( m_SchematicOrientation )
{ {
case 0: /* Orientation horiz normale */ case 0: /* Orientation horiz normal */
text_offset.x -= offset; text_offset.x -= offset;
break; break;
...@@ -337,12 +355,14 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset() ...@@ -337,12 +355,14 @@ wxPoint SCH_GLOBALLABEL::GetSchematicTextOffset()
/** function SetTextOrientAndJustifyParmeters (virtual) /** function SetTextOrientAndJustifyParmeters (virtual)
* Set m_SchematicOrientation, and initialize * 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 * must be called after changing m_SchematicOrientation
* @param aSchematicOrientation = * @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 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 * 3 = bottom . This can be seen as the mirrored position of up
*/ */
void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation ) void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation )
...@@ -381,12 +401,14 @@ void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation ) ...@@ -381,12 +401,14 @@ void SCH_TEXT::SetSchematicTextOrientation( int aSchematicOrientation )
/** function SetTextOrientAndJustifyParmeters /** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize * 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 * must be called after changing m_SchematicOrientation
* @param aSchematicOrientation = * @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 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 * 3 = bottom . This can be seen as the mirrored position of up
*/ */
void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation ) void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation )
...@@ -397,12 +419,14 @@ void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation ) ...@@ -397,12 +419,14 @@ void SCH_LABEL::SetSchematicTextOrientation( int aSchematicOrientation )
/** function SetTextOrientAndJustifyParmeters /** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize * 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 * must be called after changing m_SchematicOrientation
* @param aSchematicOrientation = * @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 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 * 3 = bottom . This can be seen as the mirrored position of up
*/ */
void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
...@@ -441,12 +465,14 @@ void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) ...@@ -441,12 +465,14 @@ void SCH_GLOBALLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
/** function SetTextOrientAndJustifyParmeters /** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize * 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 * must be called after changing m_SchematicOrientation
* @param aSchematicOrientation = * @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 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 * 3 = bottom . This can be seen as the mirrored position of up
*/ */
void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
...@@ -485,8 +511,8 @@ void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation ) ...@@ -485,8 +511,8 @@ void SCH_HIERLABEL::SetSchematicTextOrientation( int aSchematicOrientation )
/********************************************************/ /********************************************************/
void SCH_TEXT::SwapData( SCH_TEXT* copyitem ) void SCH_TEXT::SwapData( SCH_TEXT* copyitem )
/********************************************************/
{ {
/********************************************************/
EXCHG( m_Text, copyitem->m_Text ); EXCHG( m_Text, copyitem->m_Text );
EXCHG( m_Pos, copyitem->m_Pos ); EXCHG( m_Pos, copyitem->m_Pos );
EXCHG( m_Size, copyitem->m_Size ); EXCHG( m_Size, copyitem->m_Size );
...@@ -504,8 +530,8 @@ void SCH_TEXT::SwapData( SCH_TEXT* copyitem ) ...@@ -504,8 +530,8 @@ void SCH_TEXT::SwapData( SCH_TEXT* copyitem )
/***************************************************************/ /***************************************************************/
void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/***************************************************************/
{ {
/***************************************************************/
/* save old text in undo list */ /* save old text in undo list */
if( g_ItemToUndoCopy && ( (m_Flags & IS_NEW) == 0 ) ) if( g_ItemToUndoCopy && ( (m_Flags & IS_NEW) == 0 ) )
{ {
...@@ -528,9 +554,9 @@ void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -528,9 +554,9 @@ void SCH_TEXT::Place( WinEDA_SchematicFrame* frame, wxDC* DC )
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @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 if( pensize == 0 ) // Use default values for pen size
{ {
...@@ -539,22 +565,24 @@ int SCH_TEXT::GetPenSize( ) ...@@ -539,22 +565,24 @@ int SCH_TEXT::GetPenSize( )
else else
pensize = g_DrawDefaultLineThickness; pensize = g_DrawDefaultLineThickness;
} }
// Clip pen size for small texts: // Clip pen size for small texts:
pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold ); pensize = Clamp_Text_PenSize( pensize, m_Size, m_Bold );
return pensize; return pensize;
} }
/*******************************************************************************************/ /****************************************************************************/
void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
int DrawMode, int Color ) 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; 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 ); 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, ...@@ -567,7 +595,8 @@ void SCH_TEXT::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset,
wxPoint text_offset = aOffset + GetSchematicTextOffset(); wxPoint text_offset = aOffset + GetSchematicTextOffset();
EXCHG( linewidth, m_Width ); // Set the minimum width 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 EXCHG( linewidth, m_Width ); // set initial value
if( m_IsDangling ) if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
...@@ -601,10 +630,8 @@ bool SCH_TEXT::Save( FILE* aFile ) const ...@@ -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", if( fprintf( aFile, "Text Notes %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x,
m_SchematicOrientation, m_Size.x, shape, m_Width, CONV_TO_UTF8( text ) ) == EOF )
shape, m_Width,
CONV_TO_UTF8( text ) ) == EOF )
{ {
success = false; success = false;
} }
...@@ -635,8 +662,8 @@ void SCH_TEXT::Show( int nestLevel, std::ostream& os ) ...@@ -635,8 +662,8 @@ void SCH_TEXT::Show( int nestLevel, std::ostream& os )
/****************************************************************************/ /****************************************************************************/
SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) : SCH_LABEL::SCH_LABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_LABEL ) SCH_TEXT( pos, text, TYPE_SCH_LABEL )
/****************************************************************************/
{ {
/****************************************************************************/
m_Layer = LAYER_LOCLABEL; m_Layer = LAYER_LOCLABEL;
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = TRUE;
...@@ -659,9 +686,8 @@ bool SCH_LABEL::Save( FILE* aFile ) const ...@@ -659,9 +686,8 @@ bool SCH_LABEL::Save( FILE* aFile ) const
shape = "Italic"; shape = "Italic";
if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n", if( fprintf( aFile, "Text Label %-4d %-4d %-4d %-4d %s %d\n%s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x, shape,
m_SchematicOrientation, m_Size.x, shape, m_Width, m_Width, CONV_TO_UTF8( m_Text ) ) == EOF )
CONV_TO_UTF8( m_Text ) ) == EOF )
{ {
success = false; success = false;
} }
...@@ -670,11 +696,11 @@ bool SCH_LABEL::Save( FILE* aFile ) const ...@@ -670,11 +696,11 @@ bool SCH_LABEL::Save( FILE* aFile ) const
} }
/***********************************************************************************/ /*****************************************************************************/
SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) : SCH_GLOBALLABEL::SCH_GLOBALLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL ) SCH_TEXT( pos, text, TYPE_SCH_GLOBALLABEL )
/***********************************************************************************/
{ {
/*****************************************************************************/
m_Layer = LAYER_GLOBLABEL; m_Layer = LAYER_GLOBLABEL;
m_Shape = NET_BIDI; m_Shape = NET_BIDI;
m_IsDangling = TRUE; m_IsDangling = TRUE;
...@@ -696,11 +722,9 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const ...@@ -696,11 +722,9 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
if( m_Italic ) if( m_Italic )
shape = "Italic"; shape = "Italic";
if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", if( fprintf( aFile, "Text GLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x,
m_SchematicOrientation, m_Size.x, SheetLabelType[m_Shape], shape, m_Width,
SheetLabelType[m_Shape], CONV_TO_UTF8( m_Text ) ) == EOF )
shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
{ {
success = false; success = false;
} }
...@@ -711,24 +735,23 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const ...@@ -711,24 +735,23 @@ bool SCH_GLOBALLABEL::Save( FILE* aFile ) const
/************************************************/ /************************************************/
bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef ) bool SCH_GLOBALLABEL::HitTest( const wxPoint& aPosRef )
{
/************************************************/ /************************************************/
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
{
EDA_Rect rect = GetBoundingBox(); EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef ); return rect.Inside( aPosRef );
} }
/***********************************************************************************/ /*****************************************************************************/
SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) : SCH_HIERLABEL::SCH_HIERLABEL( const wxPoint& pos, const wxString& text ) :
SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL ) SCH_TEXT( pos, text, TYPE_SCH_HIERLABEL )
/***********************************************************************************/
{ {
/*****************************************************************************/
m_Layer = LAYER_HIERLABEL; m_Layer = LAYER_HIERLABEL;
m_Shape = NET_INPUT; m_Shape = NET_INPUT;
m_IsDangling = TRUE; m_IsDangling = TRUE;
...@@ -750,11 +773,9 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const ...@@ -750,11 +773,9 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
if( m_Italic ) if( m_Italic )
shape = "Italic"; shape = "Italic";
if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n", if( fprintf( aFile, "Text HLabel %-4d %-4d %-4d %-4d %s %s %d\n%s\n",
m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, m_SchematicOrientation, m_Size.x,
m_SchematicOrientation, m_Size.x, SheetLabelType[m_Shape], shape, m_Width,
SheetLabelType[m_Shape], CONV_TO_UTF8( m_Text ) ) == EOF )
shape, m_Width,
CONV_TO_UTF8( m_Text ) ) == EOF )
{ {
success = false; success = false;
} }
...@@ -765,13 +786,12 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const ...@@ -765,13 +786,12 @@ bool SCH_HIERLABEL::Save( FILE* aFile ) const
/************************************************/ /************************************************/
bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef ) bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef )
{
/************************************************/ /************************************************/
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
{
EDA_Rect rect = GetBoundingBox(); EDA_Rect rect = GetBoundingBox();
return rect.Inside( aPosRef ); return rect.Inside( aPosRef );
...@@ -781,23 +801,28 @@ bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef ) ...@@ -781,23 +801,28 @@ bool SCH_HIERLABEL::HitTest( const wxPoint& aPosRef )
/*********************************************************************************************/ /*********************************************************************************************/
void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void SCH_LABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset,
int DrawMode, int Color ) int DrawMode, int Color )
/*********************************************************************************************/
{ {
/*********************************************************************************************/
SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color ); SCH_TEXT::Draw( panel, DC, offset, DrawMode, Color );
} }
/*******************************************************************************************/ /*****************************************************************************/
void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel,
int DrawMode, int Color ) wxDC* DC,
/******************************************************************************************/ const wxPoint& offset,
int DrawMode,
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon int Color )
*/
{ {
/*****************************************************************************/
/* Texts type Global Label have 4 directions, and the Text origin is the
* graphic icon
*/
static std::vector <wxPoint> Poly; static std::vector <wxPoint> Poly;
EDA_Colors color; 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 ); linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
if( Color >= 0 ) if( Color >= 0 )
...@@ -809,11 +834,13 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs ...@@ -809,11 +834,13 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs
EXCHG( linewidth, m_Width ); // Set the minimum width EXCHG( linewidth, m_Width ); // Set the minimum width
wxPoint text_offset = offset + GetSchematicTextOffset(); 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 EXCHG( linewidth, m_Width ); // set initial value
CreateGraphicShape( Poly, m_Pos + offset ); 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 ) if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + offset, color ); DrawDanglingSymbol( panel, DC, m_Pos + offset, color );
...@@ -825,7 +852,8 @@ void SCH_HIERLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offs ...@@ -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 aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape * @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* Template = TemplateShape[m_Shape][m_SchematicOrientation];
int HalfSize = m_Size.x / 2; int HalfSize = m_Size.x / 2;
...@@ -849,8 +877,8 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, con ...@@ -849,8 +877,8 @@ void SCH_HIERLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, con
/****************************************/ /****************************************/
EDA_Rect SCH_HIERLABEL::GetBoundingBox() EDA_Rect SCH_HIERLABEL::GetBoundingBox()
/****************************************/
{ {
/****************************************/
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
x = m_Pos.x; x = m_Pos.x;
...@@ -865,7 +893,8 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox() ...@@ -865,7 +893,8 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
switch( m_SchematicOrientation ) // respect orientation switch( m_SchematicOrientation ) // respect orientation
{ {
case 0: /* Horiz Normal Orientation (left justified) */ case 0: /* Horiz Normal Orientation (left
*justified) */
dx = -length; dx = -length;
dy = height; dy = height;
x += DANGLING_SYMBOL_SIZE; x += DANGLING_SYMBOL_SIZE;
...@@ -900,14 +929,17 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox() ...@@ -900,14 +929,17 @@ EDA_Rect SCH_HIERLABEL::GetBoundingBox()
} }
/*******************************************************************************************/ /*****************************************************************************/
void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aOffset, void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel,
int DrawMode, int Color ) wxDC* DC,
/******************************************************************************************/ const wxPoint& aOffset,
int DrawMode,
/* Texts type Global Label have 4 directions, and the Text origin is the graphic icon int Color )
*/
{ {
/*****************************************************************************/
/* Texts type Global Label have 4 directions, and the Text origin is the
* graphic icon
*/
static std::vector <wxPoint> Poly; static std::vector <wxPoint> Poly;
EDA_Colors color; EDA_Colors color;
wxPoint text_offset = aOffset + GetSchematicTextOffset(); wxPoint text_offset = aOffset + GetSchematicTextOffset();
...@@ -923,11 +955,13 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aO ...@@ -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; int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold ); linewidth = Clamp_Text_PenSize( linewidth, m_Size, m_Bold );
EXCHG( linewidth, m_Width ); // Set the minimum width 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 EXCHG( linewidth, m_Width ); // set initial value
CreateGraphicShape( Poly, m_Pos + aOffset ); 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 ) if( m_IsDangling )
DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color ); DrawDanglingSymbol( panel, DC, m_Pos + aOffset, color );
...@@ -939,7 +973,8 @@ void SCH_GLOBALLABEL::Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& aO ...@@ -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 aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Position of the shape * @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 HalfSize = m_Size.y / 2;
int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; int linewidth = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
...@@ -948,17 +983,20 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c ...@@ -948,17 +983,20 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
aCorner_list.clear(); aCorner_list.clear();
int symb_len = LenSize( m_Text ) + (TXTMARGE * 2); int symb_len = LenSize( m_Text ) + ( TXTMARGE * 2 );
// Create outline shape : 6 points // Create outline shape : 6 points
int x = symb_len + linewidth + 3; 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) // 50% more for negation bar
aCorner_list.push_back( wxPoint( 0, -y ) ); // Up int y = wxRound( (double) HalfSize * 1.5 + (double) linewidth + 3.0 );
aCorner_list.push_back( wxPoint( -x, -y ) ); // left Up // Starting point(anchor)
aCorner_list.push_back( wxPoint( -x, 0 ) ); // left aCorner_list.push_back( wxPoint( 0, 0 ) );
aCorner_list.push_back( wxPoint( -x, y ) ); // left down aCorner_list.push_back( wxPoint( 0, -y ) ); // Up
aCorner_list.push_back( wxPoint( 0, y ) ); // down 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; int x_offset = 0;
...@@ -989,7 +1027,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c ...@@ -989,7 +1027,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
switch( m_SchematicOrientation ) switch( m_SchematicOrientation )
{ {
case 0: /* Orientation horiz normale */ case 0: /* Orientation horiz normal */
break; break;
case 1: /* Orientation vert UP */ case 1: /* Orientation vert UP */
...@@ -1020,8 +1058,8 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c ...@@ -1020,8 +1058,8 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aCorner_list, c
/******************************************/ /******************************************/
EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
/******************************************/
{ {
/******************************************/
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
x = m_Pos.x; x = m_Pos.x;
...@@ -1030,14 +1068,12 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() ...@@ -1030,14 +1068,12 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width; int width = (m_Width == 0) ? g_DrawDefaultLineThickness : m_Width;
height = ( (m_Size.y * 15) / 10 ) + width + 2 * TXTMARGE; height = ( (m_Size.y * 15) / 10 ) + width + 2 * TXTMARGE;
length = // text X size add height for triangular shapes(bidirectional)
LenSize( m_Text ) // text X size length = LenSize( m_Text ) + height + DANGLING_SYMBOL_SIZE;
+ height // add height for triangular shapes (bidirectional)
+ DANGLING_SYMBOL_SIZE;
switch( m_SchematicOrientation ) // respect orientation switch( m_SchematicOrientation ) // respect orientation
{ {
case 0: /* Horiz Normal Orientation (left justified) */ case 0: /* Horiz Normal Orientation (left justified) */
dx = -length; dx = -length;
dy = height; dy = height;
x += DANGLING_SYMBOL_SIZE; x += DANGLING_SYMBOL_SIZE;
...@@ -1074,8 +1110,8 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox() ...@@ -1074,8 +1110,8 @@ EDA_Rect SCH_GLOBALLABEL::GetBoundingBox()
/***********************************/ /***********************************/
EDA_Rect SCH_TEXT::GetBoundingBox() EDA_Rect SCH_TEXT::GetBoundingBox()
/***********************************/
{ {
/***********************************/
int x, y, dx, dy, length, height; int x, y, dx, dy, length, height;
x = m_Pos.x; x = m_Pos.x;
......
/********************************************/ /********************************************/
/* Definitions for the EESchema program: */ /* Definitions for the EESchema program: */
/********************************************/ /********************************************/
#ifndef CLASS_TEXT_LABEL_H #ifndef CLASS_TEXT_LABEL_H
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
/* Type of SCH_HIERLABEL and SCH_GLOBALLABEL /* Type of SCH_HIERLABEL and SCH_GLOBALLABEL
* mainly used to handle the graphic associated shape * mainly used to handle the graphic associated shape
*/ */
typedef enum { typedef enum {
NET_INPUT, NET_INPUT,
NET_OUTPUT, NET_OUTPUT,
...@@ -29,20 +29,30 @@ class SCH_TEXT : public SCH_ITEM, ...@@ -29,20 +29,30 @@ class SCH_TEXT : public SCH_ITEM,
public: public:
int m_Layer; int m_Layer;
int m_Shape; 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: protected:
int m_SchematicOrientation; /* orientation of texts (comments) and labels in schematic int m_SchematicOrientation; /* orientation of texts (comments) and
* 0 = normal (horizontal, left justified). * labels in schematic
* 0 = normal (horizontal, left
* justified).
* 1 = up (vertical) * 1 = up (vertical)
* 2 = (horizontal, rignt justified). This can be seen as the mirrored position of 0 * 2 = (horizontal, right justified).
* 3 = bottom . This can be seen as the mirrored position of up * This can be seen as the mirrored
* this is perhaps a duplicate of m_Orient and m_HJustified or m_VJustified, * position of 0
* but is more easy to handle that 3 parmeters in editions, Reading and Saving file * 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: 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 ); KICAD_T aType = TYPE_SCH_TEXT );
~SCH_TEXT() { } ~SCH_TEXT() { }
...@@ -54,69 +64,79 @@ public: ...@@ -54,69 +64,79 @@ public:
/** function SetTextOrientAndJustifyParmeters /** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize * 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 * must be called after changing m_SchematicOrientation
* @param aSchematicOrientation = * @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 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 * 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) /** 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 * 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(); SCH_TEXT* GenCopy();
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, virtual void Draw( WinEDA_DrawPanel* panel,
int Color = -1 ); 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 /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
bool HitTest( const wxPoint& aPosRef ); bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
/** /**
* Function Save * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function GetPenSize /** Function GetPenSize
* @return the size of the "pen" that be used to draw or plot this item * @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): // Geometric transforms (used in block operations):
/** virtual function Move /** virtual function Move
* move item to a new position. * 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; m_Pos += aMoveVector;
} }
/** virtual function Mirror_Y /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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)
void Show( int nestLevel, std::ostream& os ); void Show( int nestLevel, std::ostream& os );
...@@ -128,10 +148,14 @@ public: ...@@ -128,10 +148,14 @@ public:
class SCH_LABEL : public SCH_TEXT class SCH_LABEL : public SCH_TEXT
{ {
public: 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() { } ~SCH_LABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, virtual void Draw( WinEDA_DrawPanel* panel,
int Color = -1 ); wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -141,30 +165,35 @@ public: ...@@ -141,30 +165,35 @@ public:
/** function SetTextOrientAndJustifyParmeters /** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize * 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 * must be called after changing m_SchematicOrientation
* @param aSchematicOrientation = * @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 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 * 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) /** 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 * 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 * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
}; };
...@@ -174,8 +203,11 @@ public: ...@@ -174,8 +203,11 @@ public:
SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ), SCH_GLOBALLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString ); const wxString& text = wxEmptyString );
~SCH_GLOBALLABEL() { } ~SCH_GLOBALLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, virtual void Draw( WinEDA_DrawPanel* panel,
int Color = -1 ); wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -185,51 +217,57 @@ public: ...@@ -185,51 +217,57 @@ public:
/** function SetTextOrientAndJustifyParmeters /** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize * 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 * must be called after changing m_SchematicOrientation
* @param aSchematicOrientation = * @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 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 * 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) /** 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 * 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 * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @param aPosRef = a wxPoint to test
*/ */
bool HitTest( const wxPoint& aPosRef ); bool HitTest( const wxPoint& aPosRef );
EDA_Rect GetBoundingBox(); EDA_Rect GetBoundingBox();
/** function CreateGraphicShape /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates * @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Position of the shape * @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 /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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: ...@@ -239,8 +277,11 @@ public:
SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ), SCH_HIERLABEL( const wxPoint& pos = wxPoint( 0, 0 ),
const wxString& text = wxEmptyString ); const wxString& text = wxEmptyString );
~SCH_HIERLABEL() { } ~SCH_HIERLABEL() { }
virtual void Draw( WinEDA_DrawPanel* panel, wxDC* DC, const wxPoint& offset, int draw_mode, virtual void Draw( WinEDA_DrawPanel* panel,
int Color = -1 ); wxDC* DC,
const wxPoint& offset,
int draw_mode,
int Color = -1 );
virtual wxString GetClass() const virtual wxString GetClass() const
{ {
...@@ -250,50 +291,57 @@ public: ...@@ -250,50 +291,57 @@ public:
/** function SetTextOrientAndJustifyParmeters /** function SetTextOrientAndJustifyParmeters
* Set m_SchematicOrientation, and initialize * 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 * must be called after changing m_SchematicOrientation
* @param aSchematicOrientation = * @param aSchematicOrientation =
* 0 = normal (horizontal, left justified). * 0 = normal (horizontal, left justified).
* 1 = up (vertical) * 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 * 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) /** 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 * 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 /** function CreateGraphicShape
* Calculates the graphic shape (a polygon) associated to the text * Calculates the graphic shape (a polygon) associated to the text
* @param aCorner_list = a buffer to fill with polygon corners coordinates * @param aCorner_list = a buffer to fill with polygon corners coordinates
* @param Pos = Postion of the shape * @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 * 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. * @param aFile The FILE to write to.
* @return bool - true if success writing else false. * @return bool - true if success writing else false.
*/ */
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;
/** Function HitTest /** Function HitTest
* @return true if the point aPosRef is within item area * @return true if the point aPosRef is within item area
* @param aPosRef = a wxPoint to test * @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 /** virtual function Mirror_Y
* mirror item relative to an Y axis * mirror item relative to an Y axis
* @param aYaxis_position = the y axis position * @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 */ #endif /* CLASS_TEXT_LABEL_H */
/*********************************/ /**************************************/
/* Module de nettoyage du schema */ /* Code to handle schematic clean up. */
/*********************************/ /**************************************/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -15,21 +15,18 @@ ...@@ -15,21 +15,18 @@
#include "netlist.h" #include "netlist.h"
/* Routines locales */ static int TstAlignSegment( EDA_DrawLineStruct* RefSegm,
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm, EDA_DrawLineStruct* TstSegm ); EDA_DrawLineStruct* TstSegm );
/* Variable locales */
/*******************************************/ /*******************************************/
bool SCH_SCREEN::SchematicCleanUp( wxDC* DC ) bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
{
/*******************************************/ /*******************************************/
/* Routine cleaning:
/* Routine de nettoyage: * - Includes segments or buses aligned in only 1 segment
* - regroupe les segments de fils (ou de bus) alignes en 1 seul segment * - Detects identical objects superimposed
* - Detecte les objets identiques superposes
*/ */
{
SCH_ITEM* DrawList, * TstDrawList; SCH_ITEM* DrawList, * TstDrawList;
int flag; int flag;
bool Modify = FALSE; bool Modify = FALSE;
...@@ -50,9 +47,10 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC ) ...@@ -50,9 +47,10 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
{ {
flag = TstAlignSegment( (EDA_DrawLineStruct*) DrawList, flag = TstAlignSegment( (EDA_DrawLineStruct*) DrawList,
(EDA_DrawLineStruct*) TstDrawList ); (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; DrawList->m_Flags |= TstDrawList->m_Flags;
EraseStruct( TstDrawList, this ); EraseStruct( TstDrawList, this );
SetRefreshReq(); SetRefreshReq();
...@@ -75,18 +73,16 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC ) ...@@ -75,18 +73,16 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC )
/***********************************************/ /***********************************************/
void BreakSegmentOnJunction( SCH_SCREEN* Screen ) void BreakSegmentOnJunction( SCH_SCREEN* Screen )
{
/************************************************/ /************************************************/
/* Routine to start/end segment (BUS or wires) on junctions.
/* Routine creant des debuts / fin de segment (BUS ou WIRES) sur les jonctions
* et les raccords
*/ */
{
SCH_ITEM* DrawList; SCH_ITEM* DrawList;
if( Screen == NULL ) if( Screen == NULL )
{ {
DisplayError( NULL, DisplayError( NULL,
wxT( "BreakSegmentOnJunction() error: NULL screen" ) ); wxT( "BreakSegmentOnJunction() error: NULL screen" ) );
return; return;
} }
...@@ -134,24 +130,28 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen ) ...@@ -134,24 +130,28 @@ void BreakSegmentOnJunction( SCH_SCREEN* Screen )
* ( excluding ends) * ( excluding ends)
* fill aPicklist with modified items if non null * 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; 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 ) if( DrawList->Type() != DRAW_SEGMENT_STRUCT_TYPE )
continue; continue;
segment = (EDA_DrawLineStruct*) DrawList; segment = (EDA_DrawLineStruct*) DrawList;
if( !TestSegmentHit( aBreakpoint, segment->m_Start, segment->m_End, 0 ) ) if( !TestSegmentHit( aBreakpoint, segment->m_Start, segment->m_End, 0 ) )
continue; 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 */ * pas une extremite */
if( (segment->m_Start == aBreakpoint) || (segment->m_End == aBreakpoint ) ) if( ( segment->m_Start == aBreakpoint )
|| ( segment->m_End == aBreakpoint ) )
continue; continue;
/* Ici il faut couper le segment en 2 */ /* Here we must cut the segment into 2. */
NewSegment = segment->GenCopy(); NewSegment = segment->GenCopy();
NewSegment->m_Start = aBreakpoint; NewSegment->m_Start = aBreakpoint;
segment->m_End = NewSegment->m_Start; segment->m_End = NewSegment->m_Start;
...@@ -165,35 +165,36 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint ) ...@@ -165,35 +165,36 @@ void BreakSegment(SCH_SCREEN * aScreen, wxPoint aBreakpoint )
/***********************************************************/ /***********************************************************/
static int TstAlignSegment( EDA_DrawLineStruct* RefSegm, static int TstAlignSegment( EDA_DrawLineStruct* RefSegm,
EDA_DrawLineStruct* TstSegm ) EDA_DrawLineStruct* TstSegm )
{
/***********************************************************/ /***********************************************************/
/* Search if the 2 segments RefSegm and TstSegm are on a line. /* 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 * 1 if yes, and RefSegm is modified to be the equivalent segment
*/ */
{
if( RefSegm == TstSegm ) if( RefSegm == TstSegm )
return 0; return 0;
if( RefSegm->GetLayer() != TstSegm->GetLayer() ) if( RefSegm->GetLayer() != TstSegm->GetLayer() )
return 0; 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_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; 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 ) else if( RefSegm->m_Start == TstSegm->m_End )
{ {
EXCHG( RefSegm->m_Start, RefSegm->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 ) 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; return 0;
/* Test alignment: */ /* Test alignment: */
......
...@@ -18,12 +18,13 @@ ...@@ -18,12 +18,13 @@
#include "class_marker_sch.h" #include "class_marker_sch.h"
/**************************************************************************************/ /*****************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool IncludePin ) SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay(
/**************************************************************************************/ bool IncludePin )
{
/*****************************************************************************/
/** Function SchematicGeneralLocateAndDisplay /** Function SchematicGeneralLocateAndDisplay
* Overlayed function * Overlaid function
* Find the schematic item at cursor position * Find the schematic item at cursor position
* the priority order is: * the priority order is:
* - marker * - marker
...@@ -34,11 +35,10 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include ...@@ -34,11 +35,10 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
* - pin * - pin
* - component * - component
* @return an EDA_BaseStruct pointer on the item or NULL if no item found * @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; SCH_ITEM* DrawStruct;
wxString msg; wxString msg;
wxPoint mouse_position = GetScreen()->m_MousePosition; wxPoint mouse_position = GetScreen()->m_MousePosition;
...@@ -67,7 +67,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include ...@@ -67,7 +67,7 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur, Pin = LocateAnyPin( GetScreen()->EEDrawList, GetScreen()->m_Curseur,
&LibItem ); &LibItem );
if( Pin ) if( Pin )
break; // Priority is probing a pin first break; // Priority is probing a pin first
LibItem = (SCH_COMPONENT*) DrawStruct; LibItem = (SCH_COMPONENT*) DrawStruct;
SendMessageToPCBNEW( DrawStruct, LibItem ); SendMessageToPCBNEW( DrawStruct, LibItem );
break; break;
...@@ -92,20 +92,22 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include ...@@ -92,20 +92,22 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( bool Include
LibItem->GetField( VALUE )->m_Text, DARKCYAN ); LibItem->GetField( VALUE )->m_Text, DARKCYAN );
// Cross probing:2 - pin found, and send a locate pin command to // Cross probing:2 - pin found, and send a locate pin command to
// pcbnew (hightlight net) // pcbnew (highlight net)
SendMessageToPCBNEW( Pin, LibItem ); SendMessageToPCBNEW( Pin, LibItem );
} }
return DrawStruct; return DrawStruct;
} }
/********************************************************************************************/ /*****************************************************************************/
SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint& refpoint, SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay(
bool IncludePin ) const wxPoint& refpoint,
/********************************************************************************************/ bool
IncludePin )
{
/*****************************************************************************/
/** Function SchematicGeneralLocateAndDisplay /** Function SchematicGeneralLocateAndDisplay
* Overlayed function * Overlaid function
* Find the schematic item at a given position * Find the schematic item at a given position
* the priority order is: * the priority order is:
* - marker * - marker
...@@ -116,12 +118,11 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint ...@@ -116,12 +118,11 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
* - pin * - pin
* - component * - component
* @return an EDA_BaseStruct pointer on the item or NULL if no item found * @return an EDA_BaseStruct pointer on the item or NULL if no item found
* @param refpoint = the wxPoint loaction where to search * @param refpoint = the wxPoint location where to search
* @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; SCH_ITEM* DrawStruct;
LIB_PIN* Pin; LIB_PIN* Pin;
SCH_COMPONENT* LibItem; SCH_COMPONENT* LibItem;
...@@ -148,10 +149,14 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint ...@@ -148,10 +149,14 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
return DrawStruct; return DrawStruct;
} }
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), WIREITEM | BUSITEM | RACCORDITEM ); DrawStruct = (SCH_ITEM*) PickStruct( refpoint,
if( DrawStruct ) // We have found a wire: Search for a connected pin at the same location 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 ) if( Pin )
{ {
Pin->DisplayInfo( this ); Pin->DisplayInfo( this );
...@@ -176,7 +181,7 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint ...@@ -176,7 +181,7 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
/* search for a pin */ /* search for a pin */
Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint, Pin = LocateAnyPin( (SCH_ITEM*) m_CurrentSheet->LastDrawList(), refpoint,
&LibItem ); &LibItem );
if( Pin ) if( Pin )
{ {
Pin->DisplayInfo( this ); Pin->DisplayInfo( this );
...@@ -203,7 +208,6 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint ...@@ -203,7 +208,6 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint
return DrawStruct; return DrawStruct;
} }
// Recherche des autres elements
DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), SEARCHALL ); DrawStruct = (SCH_ITEM*) PickStruct( refpoint, GetScreen(), SEARCHALL );
if( DrawStruct ) if( DrawStruct )
{ {
...@@ -215,7 +219,7 @@ SCH_ITEM* WinEDA_SchematicFrame::SchematicGeneralLocateAndDisplay( const wxPoint ...@@ -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 ) wxPoint MousePositionInPixels )
{ {
wxRealPoint delta; wxRealPoint delta;
...@@ -241,27 +245,27 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, ...@@ -241,27 +245,27 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
case 0: case 0:
break; break;
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_NUMPAD8:
case WXK_UP: case WXK_UP:
MousePositionInPixels.y -= wxRound(delta.y); MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_NUMPAD2:
case WXK_DOWN: case WXK_DOWN:
MousePositionInPixels.y += wxRound(delta.y); MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_NUMPAD4:
case WXK_LEFT: case WXK_LEFT:
MousePositionInPixels.x -= wxRound(delta.x); MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_NUMPAD6:
case WXK_RIGHT: case WXK_RIGHT:
MousePositionInPixels.x += wxRound(delta.x); MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
...@@ -270,10 +274,10 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, ...@@ -270,10 +274,10 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
break; break;
} }
/* Recalcul de la position du curseur schema */ /* Update cursor position. */
screen->m_Curseur = curpos; screen->m_Curseur = curpos;
/* Placement sur la grille generale */ /* Snap cursor to grid. */
PutOnGrid( &(screen->m_Curseur) ); PutOnGrid( &(screen->m_Curseur) );
if( screen->IsRefreshReq() ) if( screen->IsRefreshReq() )
...@@ -303,12 +307,12 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, ...@@ -303,12 +307,12 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC,
OnHotKey( DC, hotkey, NULL ); OnHotKey( DC, hotkey, NULL );
} }
UpdateStatusBar(); /* Display cursor coordintes info */ UpdateStatusBar(); /* Display cursor coordinates info */
SetToolbars(); SetToolbars();
} }
void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
wxPoint MousePositionInPixels ) wxPoint MousePositionInPixels )
{ {
wxRealPoint delta; wxRealPoint delta;
...@@ -334,27 +338,27 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, ...@@ -334,27 +338,27 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
case 0: case 0:
break; break;
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_NUMPAD8:
case WXK_UP: case WXK_UP:
MousePositionInPixels.y -= wxRound(delta.y); MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_NUMPAD2:
case WXK_DOWN: case WXK_DOWN:
MousePositionInPixels.y += wxRound(delta.y); MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_NUMPAD4:
case WXK_LEFT: case WXK_LEFT:
MousePositionInPixels.x -= wxRound(delta.x); MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_NUMPAD6:
case WXK_RIGHT: case WXK_RIGHT:
MousePositionInPixels.x += wxRound(delta.x); MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
...@@ -363,10 +367,10 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, ...@@ -363,10 +367,10 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
break; break;
} }
/* Recalcul de la position du curseur schema */ /* Update the cursor position. */
screen->m_Curseur = curpos; screen->m_Curseur = curpos;
/* Placement sur la grille generale */ /* Snap cursor to grid. */
PutOnGrid( &(screen->m_Curseur) ); PutOnGrid( &(screen->m_Curseur) );
if( screen->IsRefreshReq() ) if( screen->IsRefreshReq() )
...@@ -396,7 +400,7 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, ...@@ -396,7 +400,7 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC,
OnHotKey( DC, hotkey, NULL ); OnHotKey( DC, hotkey, NULL );
} }
UpdateStatusBar(); /* Affichage des coord curseur */ UpdateStatusBar();
} }
...@@ -426,27 +430,27 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, ...@@ -426,27 +430,27 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
case 0: case 0:
break; break;
case WXK_NUMPAD8: /* Deplacement curseur vers le haut */ case WXK_NUMPAD8:
case WXK_UP: case WXK_UP:
MousePositionInPixels.y -= wxRound(delta.y); MousePositionInPixels.y -= wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD2: /* Deplacement curseur vers le bas */ case WXK_NUMPAD2:
case WXK_DOWN: case WXK_DOWN:
MousePositionInPixels.y += wxRound(delta.y); MousePositionInPixels.y += wxRound( delta.y );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD4: /* Deplacement curseur vers la gauche */ case WXK_NUMPAD4:
case WXK_LEFT: case WXK_LEFT:
MousePositionInPixels.x -= wxRound(delta.x); MousePositionInPixels.x -= wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
case WXK_NUMPAD6: /* Deplacement curseur vers la droite */ case WXK_NUMPAD6:
case WXK_RIGHT: case WXK_RIGHT:
MousePositionInPixels.x += wxRound(delta.x); MousePositionInPixels.x += wxRound( delta.x );
DrawPanel->MouseTo( MousePositionInPixels ); DrawPanel->MouseTo( MousePositionInPixels );
break; break;
...@@ -455,10 +459,10 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, ...@@ -455,10 +459,10 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
break; break;
} }
/* Recalcul de la position du curseur schema */ /* Update cursor position. */
screen->m_Curseur = curpos; screen->m_Curseur = curpos;
/* Placement sur la grille generale */ /* Snap cursor to grid. */
PutOnGrid( &(screen->m_Curseur) ); PutOnGrid( &(screen->m_Curseur) );
if( screen->IsRefreshReq() ) if( screen->IsRefreshReq() )
...@@ -488,6 +492,6 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, ...@@ -488,6 +492,6 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC,
OnHotKey( DC, hotkey, NULL ); OnHotKey( DC, hotkey, NULL );
} }
UpdateStatusBar(); /* Affichage des coord curseur */ UpdateStatusBar();
SetToolbars(); SetToolbars();
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "program.h" #include "program.h"
#include "general.h" #include "general.h"
#include "netlist.h" /* Definitions generales liees au calcul de netliste */ #include "netlist.h"
#include "protos.h" #include "protos.h"
#include "class_library.h" #include "class_library.h"
...@@ -34,7 +34,8 @@ public: ...@@ -34,7 +34,8 @@ public:
int m_Type; int m_Type;
DanglingEndHandle* m_Pnext; DanglingEndHandle* m_Pnext;
DanglingEndHandle( int type ) { DanglingEndHandle( int type )
{
m_Item = NULL; m_Item = NULL;
m_Type = type; m_Type = type;
m_Pnext = NULL; m_Pnext = NULL;
...@@ -43,21 +44,21 @@ public: ...@@ -43,21 +44,21 @@ public:
DanglingEndHandle* ItemList; DanglingEndHandle* ItemList;
static void TestWireForDangling( EDA_DrawLineStruct* DrawRef, static void TestWireForDangling( EDA_DrawLineStruct* DrawRef,
WinEDA_SchematicFrame* frame, wxDC* DC ); WinEDA_SchematicFrame* frame, wxDC* DC );
void TestLabelForDangling( SCH_TEXT* label, void TestLabelForDangling( SCH_TEXT* label,
WinEDA_SchematicFrame* frame, wxDC* DC ); WinEDA_SchematicFrame* frame,
DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ); wxDC* DC );
DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList );
/**********************************************************/ /**********************************************************/
bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2, bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2,
int Px1, int Py1 ) int Px1, int Py1 )
{
/**********************************************************/ /**********************************************************/
/* Returns TRUE if the point P is on the segment S.
/* Retourne TRUE si le point P est sur le segment S. * The segment is assumed horizontal or vertical.
* Le segment est suppose horizontal ou vertical.
*/ */
{
int Sxmin, Sxmax, Symin, Symax; int Sxmin, Sxmax, Symin, Symax;
if( Sx1 == Sx2 ) /* Line S is vertical. */ if( Sx1 == Sx2 ) /* Line S is vertical. */
...@@ -81,29 +82,26 @@ bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2, ...@@ -81,29 +82,26 @@ bool SegmentIntersect( int Sx1, int Sy1, int Sx2, int Sy2,
if( Py1 != Sy1 ) if( Py1 != Sy1 )
return FALSE; return FALSE;
if( Px1 >= Sxmin && Px1 <= Sxmax ) if( Px1 >= Sxmin && Px1 <= Sxmax )
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
else else
return FALSE; // Segments quelconques return FALSE;
} }
/******************************************************************************/
void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
/******************************************************************************/
/* Met a jour les membres m_Dangling des wires, bus, labels
*/
{ {
if( ItemList ) if( ItemList )
{ {
const DanglingEndHandle* DanglingItem; const DanglingEndHandle* DanglingItem;
const DanglingEndHandle* nextitem; const DanglingEndHandle* nextitem;
for( DanglingItem = ItemList; DanglingItem != NULL; DanglingItem = nextitem ) for( DanglingItem = ItemList;
DanglingItem != NULL;
DanglingItem = nextitem )
{ {
nextitem = DanglingItem->m_Pnext; nextitem = DanglingItem->m_Pnext;
SAFE_DELETE( DanglingItem ); SAFE_DELETE( DanglingItem );
...@@ -112,8 +110,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) ...@@ -112,8 +110,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
ItemList = RebuildEndList( DrawList ); 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() ) switch( item->Type() )
{ {
...@@ -135,8 +132,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) ...@@ -135,8 +132,7 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
break; break;
if( STRUCT->GetLayer() == LAYER_BUS ) if( STRUCT->GetLayer() == LAYER_BUS )
{ {
STRUCT->m_StartIsDangling = STRUCT->m_StartIsDangling = STRUCT->m_EndIsDangling = FALSE;
STRUCT->m_EndIsDangling = FALSE;
break; break;
} }
break; break;
...@@ -148,7 +144,6 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) ...@@ -148,7 +144,6 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC )
} }
/** /**
* Test if point pos is on a pin end. * Test if point pos is on a pin end.
* *
...@@ -156,8 +151,8 @@ void WinEDA_SchematicFrame::TestDanglingEnds( SCH_ITEM* DrawList, wxDC* DC ) ...@@ -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. * @return LIB_PIN - Pointer to the located pin or NULL if no pin was found.
*/ */
LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList, LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList,
const wxPoint& pos ) const wxPoint& pos )
{ {
SCH_COMPONENT* DrawLibItem; SCH_COMPONENT* DrawLibItem;
LIB_PIN* Pin; LIB_PIN* Pin;
...@@ -173,7 +168,7 @@ LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList, ...@@ -173,7 +168,7 @@ LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList,
NEGATE( pinpos.y ); NEGATE( pinpos.y );
else else
pinpos = TransformCoordinate( DrawLibItem->m_Transform, pinpos); pinpos = TransformCoordinate( DrawLibItem->m_Transform, pinpos );
if( pos == pinpos ) if( pos == pinpos )
return Pin; return Pin;
...@@ -184,8 +179,8 @@ LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList, ...@@ -184,8 +179,8 @@ LIB_PIN* WinEDA_SchematicFrame::LocatePinEnd( SCH_ITEM* DrawList,
/****************************************************************************/ /****************************************************************************/
void TestWireForDangling( EDA_DrawLineStruct* DrawRef, void TestWireForDangling( EDA_DrawLineStruct* DrawRef,
WinEDA_SchematicFrame* frame, wxDC* DC ) WinEDA_SchematicFrame* frame, wxDC* DC )
/****************************************************************************/
{ {
/****************************************************************************/
DanglingEndHandle* terminal_item; DanglingEndHandle* terminal_item;
bool Sdangstate = TRUE, Edangstate = TRUE; bool Sdangstate = TRUE, Edangstate = TRUE;
...@@ -215,16 +210,17 @@ void TestWireForDangling( EDA_DrawLineStruct* DrawRef, ...@@ -215,16 +210,17 @@ void TestWireForDangling( EDA_DrawLineStruct* DrawRef,
DrawRef->m_StartIsDangling = Sdangstate; DrawRef->m_StartIsDangling = Sdangstate;
DrawRef->m_EndIsDangling = Edangstate; DrawRef->m_EndIsDangling = Edangstate;
if( DC ) if( DC )
RedrawOneStruct( frame->DrawPanel, DC, DrawRef, GR_DEFAULT_DRAWMODE ); RedrawOneStruct( frame->DrawPanel, DC, DrawRef,
GR_DEFAULT_DRAWMODE );
} }
} }
/********************************************************/ /********************************************************/
void TestLabelForDangling( SCH_TEXT* label, void TestLabelForDangling( SCH_TEXT* label, WinEDA_SchematicFrame* frame,
WinEDA_SchematicFrame* frame, wxDC* DC ) wxDC* DC )
/********************************************************/
{ {
/********************************************************/
DanglingEndHandle* terminal_item; DanglingEndHandle* terminal_item;
bool dangstate = TRUE; bool dangstate = TRUE;
...@@ -239,8 +235,8 @@ void TestLabelForDangling( SCH_TEXT* label, ...@@ -239,8 +235,8 @@ void TestLabelForDangling( SCH_TEXT* label,
case PIN_END: case PIN_END:
case LABEL_END: case LABEL_END:
case SHEET_LABEL_END: case SHEET_LABEL_END:
if( (label->m_Pos.x == terminal_item->m_Pos.x) if( ( label->m_Pos.x == terminal_item->m_Pos.x )
&& (label->m_Pos.y == terminal_item->m_Pos.y) ) && ( label->m_Pos.y == terminal_item->m_Pos.y ) )
dangstate = FALSE; dangstate = FALSE;
break; break;
...@@ -277,9 +273,8 @@ void TestLabelForDangling( SCH_TEXT* label, ...@@ -277,9 +273,8 @@ void TestLabelForDangling( SCH_TEXT* label,
} }
/* Returns the physical position of the pin relative to the component
/* Retourne la position physique de la pin, qui d�pend de l'orientation * orientation. */
* du composant */
wxPoint ReturnPinPhysicalPosition( LIB_PIN* Pin, SCH_COMPONENT* DrawLibItem ) wxPoint ReturnPinPhysicalPosition( LIB_PIN* Pin, SCH_COMPONENT* DrawLibItem )
{ {
wxPoint PinPos = Pin->m_Pos; wxPoint PinPos = Pin->m_Pos;
...@@ -297,8 +292,8 @@ wxPoint ReturnPinPhysicalPosition( LIB_PIN* Pin, SCH_COMPONENT* DrawLibItem ) ...@@ -297,8 +292,8 @@ wxPoint ReturnPinPhysicalPosition( LIB_PIN* Pin, SCH_COMPONENT* DrawLibItem )
/***********************************************************/ /***********************************************************/
DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
/***********************************************************/
{ {
/***********************************************************/
DanglingEndHandle* StartList = NULL, * item, * lastitem = NULL; DanglingEndHandle* StartList = NULL, * item, * lastitem = NULL;
EDA_BaseStruct* DrawItem; EDA_BaseStruct* DrawItem;
...@@ -327,10 +322,12 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) ...@@ -327,10 +322,12 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
#define STRUCT ( (EDA_DrawLineStruct*) DrawItem ) #define STRUCT ( (EDA_DrawLineStruct*) DrawItem )
if( STRUCT->GetLayer() == LAYER_NOTES ) if( STRUCT->GetLayer() == LAYER_NOTES )
break; 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) ? item = new DanglingEndHandle(
BUS_START_END : WIRE_START_END ); (STRUCT->GetLayer() == LAYER_BUS) ?
BUS_START_END : WIRE_START_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_Start; item->m_Pos = STRUCT->m_Start;
...@@ -339,11 +336,12 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) ...@@ -339,11 +336,12 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
else else
StartList = item; StartList = item;
lastitem = item; lastitem = item;
item = new DanglingEndHandle( (STRUCT->GetLayer() == LAYER_BUS) ? item =
BUS_END_END : WIRE_END_END ); new DanglingEndHandle( (STRUCT->GetLayer() == LAYER_BUS) ?
BUS_END_END : WIRE_END_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_End; item->m_Pos = STRUCT->m_End;
lastitem->m_Pnext = item; lastitem->m_Pnext = item;
lastitem = item; lastitem = item;
} }
...@@ -375,10 +373,10 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) ...@@ -375,10 +373,10 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
else else
StartList = item; StartList = item;
lastitem = item; lastitem = item;
item = new DanglingEndHandle( ENTRY_END ); item = new DanglingEndHandle( ENTRY_END );
item->m_Item = DrawItem; item->m_Item = DrawItem;
item->m_Pos = STRUCT->m_End(); item->m_Pos = STRUCT->m_End();
lastitem->m_Pnext = item; lastitem->m_Pnext = item;
lastitem = item; lastitem = item;
break; break;
...@@ -402,7 +400,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) ...@@ -402,7 +400,7 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
continue; continue;
if( Pin->m_Convert && STRUCT->m_Convert if( Pin->m_Convert && STRUCT->m_Convert
&& ( STRUCT->m_Convert != Pin->m_Convert ) ) && ( STRUCT->m_Convert != Pin->m_Convert ) )
continue; continue;
item = new DanglingEndHandle( PIN_END ); item = new DanglingEndHandle( PIN_END );
...@@ -420,26 +418,29 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList ) ...@@ -420,26 +418,29 @@ DanglingEndHandle* RebuildEndList( EDA_BaseStruct* DrawList )
} }
case DRAW_SHEET_STRUCT_TYPE: 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; wxASSERT( pinsheet->Type() ==
for( pinsheet = ((DrawSheetStruct*)DrawItem)->m_Label; pinsheet; pinsheet = pinsheet->Next() ) 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_Item = pinsheet;
item->m_Pos = pinsheet->m_Pos; item->m_Pos = pinsheet->m_Pos;
if( lastitem ) if( lastitem )
lastitem->m_Pnext = item; lastitem->m_Pnext = item;
else else
StartList = item; StartList = item;
lastitem = item; lastitem = item;
}
} }
break; }
break;
default: default:
; ;
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
/* EESchema - database.cpp */ /* EESchema - database.cpp */
/****************************/ /****************************/
/* Routine de selection d'un composant en librairie
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
#include "common.h" #include "common.h"
...@@ -21,16 +18,16 @@ ...@@ -21,16 +18,16 @@
/* /*
* Routine de selection du nom d'un composant en librairie pour chargement, * Routine name selection of a component library for loading,
* Keys pointe la liste des mots cles de filtrage * Keys leading the list of the keywords filter
* Si Keys = "", recherche des composants qui correspondent * If Keys = "", research components that correspond
* au masque BufName( avec * et ? ) * BufName mask (with * and?)
* *
* Retourne * Returns
* TRUE si composant selectionne * TRUE if the selected component
* FALSE si commande annulee * FALSE canceled order
* place le nom du composant a charger, selectionne a partir d'une liste dans * Place the name of the component has loaded, select from a list in
* BufName * BufName
*/ */
wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
wxString& BufName ) wxString& BufName )
...@@ -41,7 +38,7 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys, ...@@ -41,7 +38,7 @@ wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
BufName.MakeUpper(); BufName.MakeUpper();
Keys.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() ) BOOST_FOREACH( CMP_LIBRARY& lib, CMP_LIBRARY::GetLibraryList() )
{ {
lib.SearchEntryNames( nameList, BufName, Keys ); lib.SearchEntryNames( nameList, BufName, Keys );
......
/************************************/ /************************************/
/* Delete.cpp: routines d'effacement */ /* delete.cpp */
/************************************/ /************************************/
#include "fctsys.h" #include "fctsys.h"
...@@ -41,10 +41,10 @@ static int CountConnectedItems( WinEDA_SchematicFrame* frame, ...@@ -41,10 +41,10 @@ static int CountConnectedItems( WinEDA_SchematicFrame* frame,
continue; continue;
if( TstJunction && (Struct->Type() == DRAW_JUNCTION_STRUCT_TYPE) ) if( TstJunction && ( Struct->Type() == DRAW_JUNCTION_STRUCT_TYPE ) )
{ {
#define JUNCTION ( (DrawJunctionStruct*) Struct ) #define JUNCTION ( (DrawJunctionStruct*) Struct )
if( (JUNCTION->m_Pos.x == pos.x) && (JUNCTION->m_Pos.y == pos.y) ) if( JUNCTION->m_Pos == pos )
count++; count++;
#undef JUNCTION #undef JUNCTION
} }
...@@ -201,7 +201,7 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection ) ...@@ -201,7 +201,7 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection )
removed_struct != NULL; removed_struct != NULL;
removed_struct = removed_struct->Next() ) removed_struct = removed_struct->Next() )
{ {
if( (removed_struct->m_Flags & STRUCT_DELETED) == 0 ) if( ( removed_struct->m_Flags & STRUCT_DELETED ) == 0 )
continue; continue;
if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE ) if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
...@@ -223,7 +223,7 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection ) ...@@ -223,7 +223,7 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection )
removed_struct != NULL; removed_struct != NULL;
removed_struct = removed_struct->Next() ) removed_struct = removed_struct->Next() )
{ {
if( (removed_struct->m_Flags & STRUCT_DELETED) == 0 ) if( ( removed_struct->m_Flags & STRUCT_DELETED ) == 0 )
continue; continue;
if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE ) if( removed_struct->Type() != DRAW_SEGMENT_STRUCT_TYPE )
continue; continue;
...@@ -324,12 +324,12 @@ void WinEDA_SchematicFrame::DeleteConnection( bool DeleteFullConnection ) ...@@ -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: * If more than one item found: the priority order is:
* 1 : MARKER * 1 : MARKER
* 2 : JUNCTION * 2 : JUNCTION
* 2 : NOCONNECT * 2 : NOCONNECT
* 3 : WIRE ou BUS * 3 : WIRE or BUS
* 4 : DRAWITEM * 4 : DRAWITEM
* 5 : TEXT * 5 : TEXT
* 6 : COMPOSANT * 6 : COMPOSANT
...@@ -376,16 +376,15 @@ bool LocateAndDeleteItem( WinEDA_SchematicFrame* frame, wxDC* DC ) ...@@ -376,16 +376,15 @@ bool LocateAndDeleteItem( WinEDA_SchematicFrame* frame, wxDC* DC )
/* /*
* Suppression definitive d'une structure dans une liste chainee * Remove definition of a structure in a linked list
* d'elements de dessin * Elements of Drawing
* DrawStruct = pointeur sur la structure * DrawStruct * = pointer to the structure
* Screen = pointeur sur l'ecran d'appartenance * Screen = pointer on the screen of belonging
* Le chainage de la liste est modifie.
* *
* Remarque: * Note:
* pour les structures DRAW_SHEET_STRUCT_TYPE, l'ecran et les structures * DRAW_SHEET_STRUCT_TYPE structures for the screen and structures
* correspondantes ne sont pas touches. * Corresponding keys are not.
* Ils doivent etre traites separement * They must be treated separately
*/ */
void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
{ {
...@@ -424,7 +423,7 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) ...@@ -424,7 +423,7 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
} }
else else
{ {
while( SheetLabel->Next() ) /* Examen de la liste dependante */ while( SheetLabel->Next() )
{ {
NextLabel = NextLabel =
(Hierarchical_PIN_Sheet_Struct*) SheetLabel->Next(); (Hierarchical_PIN_Sheet_Struct*) SheetLabel->Next();
...@@ -468,9 +467,6 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen ) ...@@ -468,9 +467,6 @@ void EraseStruct( SCH_ITEM* DrawStruct, SCH_SCREEN* Screen )
} }
/*
* Effacement des marqueurs du type "type"
*/
void DeleteAllMarkers( int type ) void DeleteAllMarkers( int type )
{ {
SCH_SCREEN* screen; SCH_SCREEN* screen;
...@@ -489,12 +485,11 @@ void DeleteAllMarkers( int type ) ...@@ -489,12 +485,11 @@ void DeleteAllMarkers( int type )
if( DrawStruct->Type() != TYPE_MARKER_SCH ) if( DrawStruct->Type() != TYPE_MARKER_SCH )
continue; continue;
/* Marqueur trouve */
Marker = (MARKER_SCH*) DrawStruct; Marker = (MARKER_SCH*) DrawStruct;
if( Marker->GetMarkerType() != type ) if( Marker->GetMarkerType() != type )
continue; continue;
/* Suppression du marqueur */ /* Remove marker */
EraseStruct( DrawStruct, screen ); EraseStruct( DrawStruct, screen );
} }
} }
......
/*******************************************************/ /****************/
/* delsheet.cpp Routine d'effacement d'une hierarchie */ /* delsheet.cpp */
/*******************************************************/ /****************/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -38,7 +38,6 @@ void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion ) ...@@ -38,7 +38,6 @@ void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion )
return; return;
} }
/* effacement du sous schema correspondant */
if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion ) if( FirstSheet->m_AssociatedScreen->IsModify() && confirm_deletion )
{ {
msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ), msg.Printf( _( "Sheet %s (file %s) modified. Save it?" ),
...@@ -65,7 +64,6 @@ void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion ) ...@@ -65,7 +64,6 @@ void DeleteSubHierarchy( DrawSheetStruct* FirstSheet, bool confirm_deletion )
} }
} }
/* Effacement des elements de la feuille courante */
FirstSheet->m_AssociatedScreen->FreeDrawList(); FirstSheet->m_AssociatedScreen->FreeDrawList();
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// Author: jean-pierre Charras // Author: jean-pierre Charras
// Modified by: // Modified by:
// Created: 02/07/2000 // Created: 02/07/2000
// Licence: GPL // License: GPL
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
...@@ -24,13 +24,11 @@ ...@@ -24,13 +24,11 @@
BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE ) BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE )
EVT_COMMAND_RANGE( ID_MATRIX_0, EVT_COMMAND_RANGE( ID_MATRIX_0, ID_MATRIX_0 + ( PIN_NMAX * PIN_NMAX ) - 1,
ID_MATRIX_0 + (PIN_NMAX * PIN_NMAX) - 1, wxEVT_COMMAND_BUTTON_CLICKED,
wxEVT_COMMAND_BUTTON_CLICKED, DIALOG_ERC::ChangeErrorLevel )
DIALOG_ERC::ChangeErrorLevel )
END_EVENT_TABLE() END_EVENT_TABLE()
DIALOG_ERC::DIALOG_ERC( WinEDA_SchematicFrame* parent ) : DIALOG_ERC::DIALOG_ERC( WinEDA_SchematicFrame* parent ) :
DIALOG_ERC_BASE( parent ) DIALOG_ERC_BASE( parent )
{ {
...@@ -56,7 +54,9 @@ void DIALOG_ERC::Init() ...@@ -56,7 +54,9 @@ void DIALOG_ERC::Init()
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc ); num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc );
m_TotalErrCount->SetLabel( num ); 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 ); m_LastErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc ); num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc );
...@@ -71,10 +71,9 @@ void DIALOG_ERC::Init() ...@@ -71,10 +71,9 @@ void DIALOG_ERC::Init()
/* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS */ /* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS */
void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event ) void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event )
{
/* Delete the old ERC markers, over the whole hierarchy /* Delete the old ERC markers, over the whole hierarchy
*/ */
{
DeleteAllMarkers( MARK_ERC ); DeleteAllMarkers( MARK_ERC );
m_MarkersList->ClearList(); m_MarkersList->ClearList();
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
...@@ -104,8 +103,8 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event ) ...@@ -104,8 +103,8 @@ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event )
wxSafeYield(); // m_MarkersList must be redraw wxSafeYield(); // m_MarkersList must be redraw
wxArrayString messageList; wxArrayString messageList;
TestErc( &messageList ); TestErc( &messageList );
for ( unsigned ii = 0; ii < messageList.GetCount(); ii++ ) for( unsigned ii = 0; ii < messageList.GetCount(); ii++ )
m_MessagesList->AppendText(messageList[ii]); m_MessagesList->AppendText( messageList[ii] );
} }
...@@ -132,9 +131,11 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event ) ...@@ -132,9 +131,11 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
NotFound = TRUE; NotFound = TRUE;
/* Search for the selected marker */ /* 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 ) while( item && NotFound )
{ {
if( item == marker ) if( item == marker )
...@@ -160,7 +161,7 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event ) ...@@ -160,7 +161,7 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
{ {
sheet->LastScreen()->SetZoom( m_Parent->GetScreen()->GetZoom() ); sheet->LastScreen()->SetZoom( m_Parent->GetScreen()->GetZoom() );
*m_Parent->m_CurrentSheet = *sheet; *m_Parent->m_CurrentSheet = *sheet;
ActiveScreen = m_Parent->m_CurrentSheet->LastScreen(); ActiveScreen = m_Parent->m_CurrentSheet->LastScreen();
m_Parent->m_CurrentSheet->UpdateAllScreenReferences(); m_Parent->m_CurrentSheet->UpdateAllScreenReferences();
} }
...@@ -171,11 +172,10 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event ) ...@@ -171,11 +172,10 @@ void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event )
/*********************************************/ /*********************************************/
void DIALOG_ERC::ReBuildMatrixPanel() void DIALOG_ERC::ReBuildMatrixPanel()
{
/*********************************************/ /*********************************************/
/* Build or rebuild the panel showing the ERC conflict matrix
/* Build or rebuild the panel showing the ERC confict matrix
*/ */
{
int ii, jj, event_id, text_height; int ii, jj, event_id, text_height;
wxPoint pos, BoxMatrixPosition; wxPoint pos, BoxMatrixPosition;
...@@ -191,8 +191,8 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -191,8 +191,8 @@ void DIALOG_ERC::ReBuildMatrixPanel()
DiagErcTableInit = TRUE; DiagErcTableInit = TRUE;
} }
// Get the current text size : // Get the current text size: this is a dummy text.
text = new wxStaticText( m_PanelERCOptions, -1, wxT( "W" ), pos ); // this is a dummy text text = new wxStaticText( m_PanelERCOptions, -1, wxT( "W" ), pos );
text_height = text->GetRect().GetHeight(); text_height = text->GetRect().GetHeight();
bitmap_size = MAX( bitmap_size, text_height ); bitmap_size = MAX( bitmap_size, text_height );
...@@ -218,7 +218,8 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -218,7 +218,8 @@ void DIALOG_ERC::ReBuildMatrixPanel()
for( ii = 0; ii < PIN_NMAX; ii++ ) for( ii = 0; ii < PIN_NMAX; ii++ )
{ {
y = pos.y + (ii * bitmap_size); 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(); x = text->GetRect().GetRight();
pos.x = MAX( pos.x, x ); pos.x = MAX( pos.x, x );
...@@ -239,37 +240,42 @@ void DIALOG_ERC::ReBuildMatrixPanel() ...@@ -239,37 +240,42 @@ void DIALOG_ERC::ReBuildMatrixPanel()
if( (ii == jj) && !m_Initialized ) if( (ii == jj) && !m_Initialized )
{ {
wxPoint txtpos; wxPoint txtpos;
txtpos.x = x + 6; txtpos.y = y - bitmap_size; txtpos.x = x + 6;
text = new wxStaticText( m_PanelERCOptions, -1, CommentERC_V[ii], txtpos ); txtpos.y = y - bitmap_size;
text = new wxStaticText( m_PanelERCOptions,
BoxMatrixMinSize.x = MAX( BoxMatrixMinSize.x, text->GetRect().GetRight() ); -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]; delete m_ButtonList[ii][jj];
switch( diag ) switch( diag )
{ {
case OK: case OK:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions, m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id, event_id,
wxBitmap( erc_green_xpm ), wxBitmap( erc_green_xpm ),
wxPoint( x, y ) ); wxPoint( x, y ) );
break; break;
case WAR: case WAR:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions, m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id, event_id,
wxBitmap( warning_xpm ), wxBitmap( warning_xpm ),
wxPoint( x, y ) ); wxPoint( x, y ) );
break; break;
case ERR: case ERR:
m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions, m_ButtonList[ii][jj] = new wxBitmapButton( m_PanelERCOptions,
event_id, event_id,
wxBitmap( error_xpm ), wxBitmap( error_xpm ),
wxPoint( x, y ) ); wxPoint( x, y ) );
break; break;
} }
...@@ -296,7 +302,9 @@ void DIALOG_ERC::DisplayERC_MarkersList() ...@@ -296,7 +302,9 @@ void DIALOG_ERC::DisplayERC_MarkersList()
m_MarkersList->ClearList(); 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(); SCH_ITEM* DrawStruct = Sheet->LastDrawList();
for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() ) for( ; DrawStruct != NULL; DrawStruct = DrawStruct->Next() )
...@@ -304,7 +312,6 @@ void DIALOG_ERC::DisplayERC_MarkersList() ...@@ -304,7 +312,6 @@ void DIALOG_ERC::DisplayERC_MarkersList()
if( DrawStruct->Type() != TYPE_MARKER_SCH ) if( DrawStruct->Type() != TYPE_MARKER_SCH )
continue; continue;
/* Marqueur trouve */
MARKER_SCH* Marker = (MARKER_SCH*) DrawStruct; MARKER_SCH* Marker = (MARKER_SCH*) DrawStruct;
if( Marker->GetMarkerType() != MARK_ERC ) if( Marker->GetMarkerType() != MARK_ERC )
continue; continue;
...@@ -312,7 +319,8 @@ void DIALOG_ERC::DisplayERC_MarkersList() ...@@ -312,7 +319,8 @@ void DIALOG_ERC::DisplayERC_MarkersList()
/* Display diag */ /* Display diag */
// wxString msg; // 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(); // msg += Marker->GetReporter().ShowHtml();
// m_MarkersList->Append( msg ); // m_MarkersList->Append( msg );
m_MarkersList->AppendToList( Marker ); m_MarkersList->AppendToList( Marker );
...@@ -323,11 +331,10 @@ void DIALOG_ERC::DisplayERC_MarkersList() ...@@ -323,11 +331,10 @@ void DIALOG_ERC::DisplayERC_MarkersList()
/**************************************************************/ /**************************************************************/
void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event ) void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
{
/**************************************************************/ /**************************************************************/
/* Resets the default values of the ERC matrix.
/* Remet aux valeurs par defaut la matrice de diagnostic
*/ */
{
memcpy( DiagErc, DefaultDiagErc, sizeof(DiagErc) ); memcpy( DiagErc, DefaultDiagErc, sizeof(DiagErc) );
ReBuildMatrixPanel(); ReBuildMatrixPanel();
} }
...@@ -335,11 +342,10 @@ void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event ) ...@@ -335,11 +342,10 @@ void DIALOG_ERC::ResetDefaultERCDiag( wxCommandEvent& event )
/************************************************************/ /************************************************************/
void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event ) void DIALOG_ERC::ChangeErrorLevel( wxCommandEvent& event )
{
/************************************************************/ /************************************************************/
/* Change the error level for the pressed button, on the matrix table /* Change the error level for the pressed button, on the matrix table
*/ */
{
int id, level, ii, x, y; int id, level, ii, x, y;
wxBitmapButton* Butt; wxBitmapButton* Butt;
const char** new_bitmap_xpm = NULL; const char** new_bitmap_xpm = NULL;
......
...@@ -14,18 +14,16 @@ ...@@ -14,18 +14,16 @@
#include "class_library.h" #include "class_library.h"
/* Fonctions locales */
static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ); static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC );
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
/************************************************************************************/ /******************************************************************************/
void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC ) 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; LIB_COMPONENT* Entry;
SetCurrentField( aField ); SetCurrentField( aField );
...@@ -38,7 +36,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC ) ...@@ -38,7 +36,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
return; return;
} }
wxPoint pos, newpos; wxPoint pos, newpos;
SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent(); SCH_COMPONENT* comp = (SCH_COMPONENT*) aField->GetParent();
SAFE_DELETE( g_ItemToUndoCopy ); SAFE_DELETE( g_ItemToUndoCopy );
...@@ -46,8 +44,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC ) ...@@ -46,8 +44,7 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
pos = comp->m_Pos; pos = comp->m_Pos;
/* Les positions sont calculees par la matrice TRANSPOSEE de la matrice /* Positions are computed by the transpose matrix. Rotating mirror. */
* de rotation-miroir */
newpos = aField->m_Pos - pos; newpos = aField->m_Pos - pos;
// Empirically this is necessary. The Y coordinate appears to be inverted // 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 ) ...@@ -55,9 +52,9 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
// combinations of mirroring and rotation. The following clause is true // combinations of mirroring and rotation. The following clause is true
// when the number of rotations and the number of mirrorings are both odd. // 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 ) 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 ); DrawPanel->CursorOff( DC );
GetScreen()->m_Curseur = newpos; GetScreen()->m_Curseur = newpos;
...@@ -84,12 +81,12 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC ) ...@@ -84,12 +81,12 @@ void WinEDA_SchematicFrame::StartMoveCmpField( SCH_CMP_FIELD* aField, wxDC* DC )
} }
/**********************************************************************************/ /******************************************************************************/
void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, 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; LIB_COMPONENT* Entry;
if( Field == NULL ) if( Field == NULL )
...@@ -107,10 +104,8 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -107,10 +104,8 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
if( Entry && (Entry->m_Options == ENTRY_POWER) ) if( Entry && (Entry->m_Options == ENTRY_POWER) )
{ {
DisplayInfoMessage( this, DisplayInfoMessage( this, _( "Part is a POWER, value cannot be \
_( modified!\nYou must create a new power" ) );
"Part is a POWER, value cannot be modified!\nYou must create a new power" )
);
return; return;
} }
} }
...@@ -134,12 +129,12 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -134,12 +129,12 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
wxString newtext = Field->m_Text; wxString newtext = Field->m_Text;
DrawPanel->m_IgnoreMouseEvents = TRUE; 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->MouseToCursorSchema();
DrawPanel->m_IgnoreMouseEvents = FALSE; DrawPanel->m_IgnoreMouseEvents = FALSE;
Field->m_AddExtraText = flag; 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() ) if( !newtext.IsEmpty() )
{ {
...@@ -149,11 +144,12 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -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_Size.x = Field->m_Size.y = m_TextFieldSize;
} }
Field->m_Text = newtext; Field->m_Text = newtext;
if( fieldNdx == REFERENCE ){ if( fieldNdx == REFERENCE )
Cmp->SetRef(GetSheet(), newtext); {
Cmp->SetRef( GetSheet(), newtext );
} }
} }
else /* Nouveau texte NULL */ else
{ {
if( fieldNdx == REFERENCE ) if( fieldNdx == REFERENCE )
{ {
...@@ -169,7 +165,7 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -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 ); Cmp->DisplayInfo( this );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
...@@ -177,18 +173,16 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -177,18 +173,16 @@ void WinEDA_SchematicFrame::EditCmpFieldText( SCH_CMP_FIELD* Field, wxDC* DC )
/************************************************************************/ /************************************************************************/
static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) 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; wxPoint pos;
int x1, y1; int x1, y1;
int fieldNdx; int fieldNdx;
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->GetParent(); WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) panel->GetParent();
SCH_CMP_FIELD* currentField = frame->GetCurrentField(); SCH_CMP_FIELD* currentField = frame->GetCurrentField();
if( currentField == NULL ) if( currentField == NULL )
return; return;
...@@ -196,45 +190,44 @@ static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -196,45 +190,44 @@ static void MoveCmpField( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
SCH_COMPONENT* component = (SCH_COMPONENT*) currentField->GetParent(); SCH_COMPONENT* component = (SCH_COMPONENT*) currentField->GetParent();
fieldNdx = currentField->m_FieldId; fieldNdx = currentField->m_FieldId;
// Effacement:
currentField->m_AddExtraText = frame->m_Multiflag; currentField->m_AddExtraText = frame->m_Multiflag;
if( erase ) 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; pos = ( (SCH_COMPONENT*) currentField->GetParent() )->m_Pos;
/* Les positions sont caculees par la matrice TRANSPOSEE de la matrice /* Positions are calculated by the transpose matrix, Rotating mirror. */
* de rotation-miroir
*/
x1 = panel->GetScreen()->m_Curseur.x - pos.x; x1 = panel->GetScreen()->m_Curseur.x - pos.x;
y1 = panel->GetScreen()->m_Curseur.y - pos.y; 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.x = pos.x + component->m_Transform[0][0] * x1 +
currentField->m_Pos.y = pos.y + component->m_Transform[0][1] * x1 + component->m_Transform[1][1] * y1; 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 ) static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
/******************************************************************/
{ {
/******************************************************************/
Panel->ForceCloseManageCurseur = NULL; Panel->ForceCloseManageCurseur = NULL;
Panel->ManageCurseur = NULL; Panel->ManageCurseur = NULL;
WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) Panel->GetParent(); WinEDA_SchematicFrame* frame = (WinEDA_SchematicFrame*) Panel->GetParent();
SCH_CMP_FIELD* currentField = frame->GetCurrentField(); SCH_CMP_FIELD* currentField = frame->GetCurrentField();
if( currentField ) if( currentField )
{ {
currentField->m_AddExtraText = frame->m_Multiflag; 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_Flags = 0;
currentField->m_Pos = frame->m_OldPos; 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 ); frame->SetCurrentField( NULL );
...@@ -245,9 +238,9 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -245,9 +238,9 @@ static void AbortMoveCmpField( WinEDA_DrawPanel* Panel, wxDC* DC )
/*********************************************************************************/ /*********************************************************************************/
void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
/*********************************************************************************/
{ {
int fieldNdx, flag; /*********************************************************************************/
int fieldNdx, flag;
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
if( Field == NULL ) if( Field == NULL )
...@@ -258,7 +251,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -258,7 +251,7 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->GetParent(); SCH_COMPONENT* Cmp = (SCH_COMPONENT*) Field->GetParent();
fieldNdx = Field->m_FieldId; fieldNdx = Field->m_FieldId;
flag = 0; flag = 0;
if( fieldNdx == REFERENCE ) if( fieldNdx == REFERENCE )
{ {
Entry = CMP_LIBRARY::FindLibraryComponent( Entry = CMP_LIBRARY::FindLibraryComponent(
...@@ -276,25 +269,26 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC ) ...@@ -276,25 +269,26 @@ void WinEDA_SchematicFrame::RotateCmpField( SCH_CMP_FIELD* Field, wxDC* DC )
SaveCopyInUndoList( Cmp, UR_CHANGED ); SaveCopyInUndoList( Cmp, UR_CHANGED );
Field->m_AddExtraText = flag; 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 ) if( Field->m_Orient == TEXT_ORIENT_HORIZ )
Field->m_Orient = TEXT_ORIENT_VERT; Field->m_Orient = TEXT_ORIENT_VERT;
else else
Field->m_Orient = TEXT_ORIENT_HORIZ; 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(); GetScreen()->SetModify();
} }
/**************************************************************************************************/ /****************************************************************************/
void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ) void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp,
/**************************************************************************************************/ wxDC* DC )
/* Edit the component text reference*/
{ {
/****************************************************************************/
/* Edit the component text reference*/
LIB_COMPONENT* Entry; LIB_COMPONENT* Entry;
int flag = 0; int flag = 0;
if( Cmp == NULL ) if( Cmp == NULL )
return; return;
...@@ -307,33 +301,37 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -307,33 +301,37 @@ void WinEDA_SchematicFrame::EditComponentReference( SCH_COMPONENT* Cmp, wxDC* DC
if( Entry->GetPartCount() > 1 ) if( Entry->GetPartCount() > 1 )
flag = 1; flag = 1;
wxString ref = Cmp->GetRef(GetSheet()); wxString ref = Cmp->GetRef( GetSheet() );
Get_Message( _( "Reference" ), _("Component reference"), ref, this ); Get_Message( _( "Reference" ), _( "Component reference" ), ref, this );
if( !ref.IsEmpty() ) // New text entered if( !ref.IsEmpty() ) // New text entered
{ {
/* save old cmp in undo list if not already in edit, or moving ... */ /* save old cmp in undo list if not already in edit, or moving ... */
if( Cmp->m_Flags == 0 ) if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, UR_CHANGED ); SaveCopyInUndoList( Cmp, UR_CHANGED );
Cmp->SetRef(GetSheet(), ref); Cmp->SetRef( GetSheet(), ref );
Cmp->GetField( REFERENCE )->m_AddExtraText = flag; Cmp->GetField( REFERENCE )->m_AddExtraText = flag;
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode ); Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0,
Cmp->SetRef(GetSheet(), ref ); 0 ),
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint(0,0), g_XorMode );
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); Cmp->SetRef( GetSheet(), ref );
Cmp->GetField( REFERENCE )->Draw( DrawPanel, DC, wxPoint( 0,
0 ),
Cmp->m_Flags ? g_XorMode :
GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
Cmp->DisplayInfo( this ); Cmp->DisplayInfo( this );
} }
/*****************************************************************************************/ /*****************************************************************************/
void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) 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; LIB_COMPONENT* Entry;
if( Cmp == NULL ) if( Cmp == NULL )
...@@ -347,19 +345,19 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) ...@@ -347,19 +345,19 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC )
SCH_CMP_FIELD* TextField = Cmp->GetField( VALUE ); SCH_CMP_FIELD* TextField = Cmp->GetField( VALUE );
message = TextField->m_Text; message = TextField->m_Text;
if( Get_Message( _( "Value" ), _("Component value"), message, this ) ) if( Get_Message( _( "Value" ), _( "Component value" ), message, this ) )
message.Empty(); //allow the user to remove the value. 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 ... */ /* save old cmp in undo list if not already in edit, or moving ... */
if( Cmp->m_Flags == 0 ) if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, UR_CHANGED ); 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->m_Text = message;
TextField->Draw( DrawPanel, DC, wxPoint(0,0), TextField->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify(); GetScreen()->SetModify();
} }
...@@ -367,13 +365,14 @@ void WinEDA_SchematicFrame::EditComponentValue( SCH_COMPONENT* Cmp, wxDC* DC ) ...@@ -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; LIB_COMPONENT* Entry;
bool wasEmpty = false; bool wasEmpty = false;
if( Cmp == NULL ) if( Cmp == NULL )
return; return;
...@@ -386,16 +385,18 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -386,16 +385,18 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
SCH_CMP_FIELD* TextField = Cmp->GetField( FOOTPRINT ); SCH_CMP_FIELD* TextField = Cmp->GetField( FOOTPRINT );
message = TextField->m_Text; message = TextField->m_Text;
if(message.IsEmpty() ) if( message.IsEmpty() )
wasEmpty = true; 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. message.Empty(); // allow the user to remove the value.
// save old cmp in undo list if not already in edit, or moving ... // save old cmp in undo list if not already in edit, or moving ...
if( Cmp->m_Flags == 0 ) if( Cmp->m_Flags == 0 )
SaveCopyInUndoList( Cmp, UR_CHANGED ); 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. // move the field if it was new.
if( wasEmpty && !message.IsEmpty() ) if( wasEmpty && !message.IsEmpty() )
...@@ -404,21 +405,24 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC ...@@ -404,21 +405,24 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
// add offset here - ? suitable heuristic below? // add offset here - ? suitable heuristic below?
Cmp->GetField( FOOTPRINT )->m_Pos.x += Cmp->GetField( FOOTPRINT )->m_Pos.x +=
(Cmp->GetField( REFERENCE )->m_Pos.x - Cmp->m_Pos.x) > 0 ? ( 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_Size.x ) :
( -1 * Cmp->GetField( REFERENCE )->m_Size.x );
Cmp->GetField( FOOTPRINT )->m_Pos.y += Cmp->GetField( FOOTPRINT )->m_Pos.y +=
(Cmp->GetField( REFERENCE )->m_Pos.y - Cmp->m_Pos.y) > 0 ? ( 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_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; TextField->m_Text = message;
Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint(0,0), Cmp->GetField( FOOTPRINT )->Draw( DrawPanel, DC, wxPoint( 0, 0 ),
Cmp->m_Flags ? g_XorMode : GR_DEFAULT_DRAWMODE ); Cmp->m_Flags ? g_XorMode :
GR_DEFAULT_DRAWMODE );
GetScreen()->SetModify(); GetScreen()->SetModify();
Cmp->DisplayInfo( this ); Cmp->DisplayInfo( this );
} }
/**********************************************/ /**********************************/
/* EESchema - symbtext.cpp for Library Editor */ /* edit_graphic_bodyitem_text.cpp */
/**********************************************/ /**********************************/
/* Menu et routines de creation, modification, suppression de textes /* Code for editing component library text items, not fields. */
du type symbole
(textes autres que Fields)
*/
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -143,8 +140,7 @@ void Dialog_BodyGraphicText_Properties::OnCancelClick( wxCommandEvent& event ) ...@@ -143,8 +140,7 @@ void Dialog_BodyGraphicText_Properties::OnCancelClick( wxCommandEvent& event )
/***************************************************************************/ /***************************************************************************/
void Dialog_BodyGraphicText_Properties::OnOkClick( 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; wxString Line;
...@@ -234,7 +230,7 @@ void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem) ...@@ -234,7 +230,7 @@ void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem)
|| ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) ) || ( DrawItem->Type() != COMPONENT_GRAPHIC_TEXT_DRAW_TYPE ) )
return; return;
/* Effacement ancien texte */ /* Deleting old text. */
if( DC) if( DC)
DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, DrawMode, NULL, DrawItem->Draw( DrawPanel, DC, wxPoint( 0, 0 ), -1, DrawMode, NULL,
DefaultTransformMatrix ); DefaultTransformMatrix );
...@@ -247,7 +243,7 @@ void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem) ...@@ -247,7 +243,7 @@ void WinEDA_LibeditFrame::EditSymbolText(wxDC* DC, LIB_DRAW_ITEM* DrawItem)
frame->Destroy(); frame->Destroy();
GetScreen()->SetModify(); GetScreen()->SetModify();
/* Affichage nouveau texte */ /* Display new text. */
if( DC ) if( DC )
{ {
if ( ( DrawItem->m_Flags & IS_MOVED ) == 0 ) if ( ( DrawItem->m_Flags & IS_MOVED ) == 0 )
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
#include "dialog_edit_label.h" #include "dialog_edit_label.h"
/* Fonctions locales */
static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ); static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase );
static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC ); static void ExitMoveTexte( WinEDA_DrawPanel* panel, wxDC* DC );
/* Variables locales */
static wxPoint ItemInitialPosition; static wxPoint ItemInitialPosition;
static int OldOrient; static int OldOrient;
static wxSize OldSize; static wxSize OldSize;
...@@ -31,8 +31,8 @@ static int s_DefaultOrientGLabel = 0; ...@@ -31,8 +31,8 @@ static int s_DefaultOrientGLabel = 0;
/****************************************************************************/ /****************************************************************************/
void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
/****************************************************************************/
{ {
/****************************************************************************/
wxString text; wxString text;
int value; int value;
...@@ -48,7 +48,8 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) ...@@ -48,7 +48,8 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() ); m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue(); 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; m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if( m_TextShape ) if( m_TextShape )
m_CurrentText->m_Shape = m_TextShape->GetSelection(); m_CurrentText->m_Shape = m_TextShape->GetSelection();
...@@ -81,10 +82,10 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event ) ...@@ -81,10 +82,10 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& event )
} }
/********************************************************************************/ /*****************************************************************************/
void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC ) void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
/********************************************************************************/
{ {
/*****************************************************************************/
if( TextStruct == NULL ) if( TextStruct == NULL )
return; return;
...@@ -130,12 +131,11 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -130,12 +131,11 @@ void WinEDA_SchematicFrame::StartMoveTexte( SCH_TEXT* TextStruct, wxDC* DC )
/*************************************************************************/ /*************************************************************************/
void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct, void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct,
wxDC* DC ) wxDC* DC )
{
/*************************************************************************/ /*************************************************************************/
/* Edit the properties of the text (Label, Global label, graphic text).. ) /* Edit the properties of the text (Label, Global label, graphic text).. )
* pointed by "TextStruct" * pointed by "TextStruct"
*/ */
{
if( TextStruct == NULL ) if( TextStruct == NULL )
return; return;
...@@ -152,10 +152,10 @@ void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct, ...@@ -152,10 +152,10 @@ void WinEDA_SchematicFrame::EditSchematicText( SCH_TEXT* TextStruct,
} }
/***********************************************************************************/ /*****************************************************************************/
void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
/***********************************************************************************/
{ {
/*****************************************************************************/
if( TextStruct == NULL ) if( TextStruct == NULL )
TextStruct = (SCH_TEXT*) PickStruct( GetScreen()->m_Curseur, TextStruct = (SCH_TEXT*) PickStruct( GetScreen()->m_Curseur,
GetScreen(), TEXTITEM | LABELITEM ); GetScreen(), TEXTITEM | LABELITEM );
...@@ -170,7 +170,6 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -170,7 +170,6 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
DrawPanel->CursorOff( DC ); DrawPanel->CursorOff( DC );
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
/* Rot text */
int orient; int orient;
switch( TextStruct->Type() ) switch( TextStruct->Type() )
...@@ -189,8 +188,6 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -189,8 +188,6 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
} }
GetScreen()->SetModify(); GetScreen()->SetModify();
/* redraw the new tewt */
RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode ); RedrawOneStruct( DrawPanel, DC, TextStruct, g_XorMode );
DrawPanel->CursorOn( DC ); DrawPanel->CursorOn( DC );
} }
...@@ -198,11 +195,10 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC ) ...@@ -198,11 +195,10 @@ void WinEDA_SchematicFrame::ChangeTextOrient( SCH_TEXT* TextStruct, wxDC* DC )
/*************************************************************************/ /*************************************************************************/
SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
{
/*************************************************************************/ /*************************************************************************/
/* Routine to create new text struct (GraphicText, label or Glabel). /* Routine to create new text struct (GraphicText, label or Glabel).
*/ */
{
SCH_TEXT* NewText = NULL; SCH_TEXT* NewText = NULL;
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
...@@ -230,7 +226,8 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type ) ...@@ -230,7 +226,8 @@ SCH_TEXT* WinEDA_SchematicFrame::CreateNewText( wxDC* DC, int type )
break; break;
default: default:
DisplayError( this, wxT( "WinEDA_SchematicFrame::CreateNewText() Internal error" ) ); DisplayError( this,
wxT( "WinEDA_SchematicFrame::CreateNewText() Internal error" ) );
return NULL; return NULL;
} }
...@@ -293,9 +290,9 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) ...@@ -293,9 +290,9 @@ static void ShowWhileMoving( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
/*************************************************************/ /*************************************************************/
static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
{
/*************************************************************/ /*************************************************************/
/* Abort function for the command move text */ /* Abort function for the command move text */
{
BASE_SCREEN* screen = Panel->GetScreen(); BASE_SCREEN* screen = Panel->GetScreen();
SCH_ITEM* Struct = (SCH_ITEM*) screen->GetCurItem(); SCH_ITEM* Struct = (SCH_ITEM*) screen->GetCurItem();
...@@ -308,7 +305,8 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -308,7 +305,8 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
return; 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 ); RedrawOneStruct( Panel, DC, Struct, g_XorMode );
if( Struct->m_Flags & IS_NEW ) if( Struct->m_Flags & IS_NEW )
...@@ -316,7 +314,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -316,7 +314,7 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
SAFE_DELETE( Struct ); SAFE_DELETE( Struct );
screen->SetCurItem( NULL ); 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() ) switch( Struct->Type() )
{ {
...@@ -345,13 +343,14 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC ) ...@@ -345,13 +343,14 @@ static void ExitMoveTexte( WinEDA_DrawPanel* Panel, wxDC* DC )
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text, void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
wxDC* DC, int newtype ) wxDC* DC, int newtype )
{
/*****************************************************************************/ /*****************************************************************************/
/* Routine to change a text type to an other one (GraphicText, label or
/* Routine to change a text type to an other one (GraphicText, label or Glabel). * Glabel).
* A new test, label or hierarchical or global label is created from the old text. * A new test, label or hierarchical or global label is created from the old
* text.
* the old text is deleted * the old text is deleted
*/ */
{
if( Text == NULL ) if( Text == NULL )
return; return;
...@@ -406,17 +405,20 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text, ...@@ -406,17 +405,20 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
} }
/* now delete the old 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 not, we must delete it.
*/ */
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur ) if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
{ {
DrawPanel->ForceCloseManageCurseur( DrawPanel, DC ); 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; 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 ); GetScreen()->SetCurItem( NULL );
g_ItemToRepeat = NULL; g_ItemToRepeat = NULL;
} }
...@@ -427,9 +429,11 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text, ...@@ -427,9 +429,11 @@ void WinEDA_SchematicFrame::ConvertTextType( SCH_TEXT* Text,
DrawPanel->CursorOff( DC ); // Erase schematic cursor 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 * 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) * later, at the end of the current command (if not aborted)
*/ */
if( (flags & IS_NEW) == 0 ) if( (flags & IS_NEW) == 0 )
......
...@@ -41,8 +41,8 @@ END_EVENT_TABLE() ...@@ -41,8 +41,8 @@ END_EVENT_TABLE()
/**************************************************************/ /**************************************************************/
void DisplayColorSetupFrame( WinEDA_DrawFrame* parent, void DisplayColorSetupFrame( WinEDA_DrawFrame* parent,
const wxPoint& framepos ) const wxPoint& framepos )
/**************************************************************/
{ {
/**************************************************************/
WinEDA_SetColorsFrame* frame = WinEDA_SetColorsFrame* frame =
new WinEDA_SetColorsFrame( parent, framepos ); new WinEDA_SetColorsFrame( parent, framepos );
...@@ -61,7 +61,7 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame() ...@@ -61,7 +61,7 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame()
// Standard Constructor // Standard Constructor
WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
const wxPoint& framepos ) const wxPoint& framepos )
{ {
m_Parent = parent; m_Parent = parent;
Init(); Init();
...@@ -75,22 +75,27 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent, ...@@ -75,22 +75,27 @@ WinEDA_SetColorsFrame::WinEDA_SetColorsFrame( WinEDA_DrawFrame* parent,
// Destructor // Destructor
WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame() { } WinEDA_SetColorsFrame::~WinEDA_SetColorsFrame()
{
}
/**********************************************************/ /**********************************************************/
bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id, bool WinEDA_SetColorsFrame::Create( wxWindow* parent,
const wxString& caption, const wxPoint& pos, wxWindowID id,
const wxSize& size, long style ) 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 ); wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls(); CreateControls();
if (GetSizer()) if( GetSizer() )
{ {
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
} }
return true; return true;
} }
...@@ -98,33 +103,33 @@ bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id, ...@@ -98,33 +103,33 @@ bool WinEDA_SetColorsFrame::Create( wxWindow* parent, wxWindowID id,
/**********************************************************/ /**********************************************************/
void WinEDA_SetColorsFrame::Init() void WinEDA_SetColorsFrame::Init()
/**********************************************************/
{ {
OuterBoxSizer = NULL; /**********************************************************/
MainBoxSizer = NULL; OuterBoxSizer = NULL;
ColumnBoxSizer = NULL; MainBoxSizer = NULL;
RowBoxSizer = NULL; ColumnBoxSizer = NULL;
Label = NULL; RowBoxSizer = NULL;
BitmapButton = NULL; Label = NULL;
m_ShowGrid = NULL; BitmapButton = NULL;
m_SelBgColor = NULL; m_ShowGrid = NULL;
Line = NULL; m_SelBgColor = NULL;
Line = NULL;
StdDialogButtonSizer = NULL; StdDialogButtonSizer = NULL;
Button = NULL; Button = NULL;
} }
/**********************************************************/ /**********************************************************/
void WinEDA_SetColorsFrame::CreateControls() void WinEDA_SetColorsFrame::CreateControls()
/**********************************************************/
{ {
/**********************************************************/
int lyr, grp, butt_ID, buttcolor; int lyr, grp, butt_ID, buttcolor;
OuterBoxSizer = new wxBoxSizer(wxVERTICAL); OuterBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer(OuterBoxSizer); SetSizer( OuterBoxSizer );
MainBoxSizer = new wxBoxSizer(wxHORIZONTAL); MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
OuterBoxSizer->Add(MainBoxSizer, 1, wxGROW|wxLEFT|wxRIGHT, 5); OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT, 5 );
// Add various items to the dialog box, as determined by the // Add various items to the dialog box, as determined by the
// details of each element contained within laytool_list[] // details of each element contained within laytool_list[]
...@@ -143,36 +148,45 @@ void WinEDA_SetColorsFrame::CreateControls() ...@@ -143,36 +148,45 @@ void WinEDA_SetColorsFrame::CreateControls()
// associated with the preceeding group.) // associated with the preceeding group.)
if( grp < BUTTON_GROUPS - 1 ) if( grp < BUTTON_GROUPS - 1 )
{ {
ColumnBoxSizer = new wxBoxSizer(wxVERTICAL); ColumnBoxSizer = new wxBoxSizer( wxVERTICAL );
MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_TOP|wxLEFT|wxTOP, 5); MainBoxSizer->Add( ColumnBoxSizer,
1,
wxALIGN_TOP | wxLEFT | wxTOP,
5 );
} }
else else
{ {
// Add a spacer to better separate the text string (which is // Add a spacer to better separate the text string (which is
// about to be added) from the items located above it. // about to be added) from the items located above it.
ColumnBoxSizer->AddSpacer(5); ColumnBoxSizer->AddSpacer( 5 );
} }
RowBoxSizer = new wxBoxSizer(wxHORIZONTAL); RowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
ColumnBoxSizer->Add(RowBoxSizer, 0, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5); ColumnBoxSizer->Add( RowBoxSizer,
0,
wxGROW | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
// Add a text string to identify the following set of controls // Add a text string to identify the following set of controls
Label = new wxStaticText( this, -1, laytool_index[grp]->m_Name, Label = new wxStaticText( this, -1, laytool_index[grp]->m_Name,
wxDefaultPosition, wxDefaultSize, 0 ); wxDefaultPosition, wxDefaultSize, 0 );
// Make this text string bold (so that it stands out better) // Make this text string bold (so that it stands out better)
Label->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxNORMAL_FONT->GetFamily(), Label->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(),
wxNORMAL, wxBOLD, false, wxNORMAL_FONT->GetFaceName() ) ); 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); RowBoxSizer = new wxBoxSizer( wxHORIZONTAL );
ColumnBoxSizer->Add(RowBoxSizer, 0, wxGROW|wxALL, 0); ColumnBoxSizer->Add( RowBoxSizer, 0, wxGROW | wxALL, 0 );
butt_ID = ID_COLOR_SETUP + lyr; butt_ID = ID_COLOR_SETUP + lyr;
laytool_list[lyr]->m_Id = butt_ID; laytool_list[lyr]->m_Id = butt_ID;
wxMemoryDC iconDC; wxMemoryDC iconDC;
wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y ); wxBitmap ButtBitmap( BUTT_SIZE_X, BUTT_SIZE_Y );
iconDC.SelectObject( ButtBitmap ); iconDC.SelectObject( ButtBitmap );
buttcolor = *laytool_list[lyr]->m_Color; buttcolor = *laytool_list[lyr]->m_Color;
...@@ -180,112 +194,136 @@ void WinEDA_SetColorsFrame::CreateControls() ...@@ -180,112 +194,136 @@ void WinEDA_SetColorsFrame::CreateControls()
wxBrush Brush; wxBrush Brush;
iconDC.SelectObject( ButtBitmap ); iconDC.SelectObject( ButtBitmap );
iconDC.SetPen( *wxBLACK_PEN ); iconDC.SetPen( *wxBLACK_PEN );
Brush.SetColour( Brush.SetColour( ColorRefs[buttcolor].m_Red,
ColorRefs[buttcolor].m_Red, ColorRefs[buttcolor].m_Green,
ColorRefs[buttcolor].m_Green, ColorRefs[buttcolor].m_Blue );
ColorRefs[buttcolor].m_Blue
);
Brush.SetStyle( wxSOLID ); Brush.SetStyle( wxSOLID );
iconDC.SetBrush( Brush ); iconDC.SetBrush( Brush );
iconDC.DrawRectangle( 0, 0, BUTT_SIZE_X, BUTT_SIZE_Y ); 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) ); BitmapButton =
RowBoxSizer->Add(BitmapButton, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5); 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; laytool_list[lyr]->m_Button = BitmapButton;
// Add a text string, unless the current value of lyr is NB_BUTT - 1 // Add a text string, unless the current value of lyr is NB_BUTT - 1
if( lyr < NB_BUTT - 1 ) if( lyr < NB_BUTT - 1 )
{ {
Label = new wxStaticText( this, wxID_STATIC, wxGetTranslation( laytool_list[lyr]->m_Name ), Label =
wxDefaultPosition, wxDefaultSize, 0 ); new wxStaticText( this, wxID_STATIC,
RowBoxSizer->Add(Label, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5); wxGetTranslation( laytool_list[lyr]->m_Name ),
wxDefaultPosition, wxDefaultSize, 0 );
RowBoxSizer->Add( Label, 1, wxALIGN_CENTER_VERTICAL | wxBOTTOM, 5 );
} }
else else
{ {
// Special case; provide a checkbox instead (rather than a text string). // Special case; provide a checkbox instead (rather than a text
m_ShowGrid = new wxCheckBox( this, ID_CHECKBOX_SHOW_GRID, _("Grid"), wxDefaultPosition, wxDefaultSize, 0 ); // string).
m_ShowGrid =
new wxCheckBox( this, ID_CHECKBOX_SHOW_GRID, _( "Grid" ),
wxDefaultPosition, wxDefaultSize, 0 );
m_ShowGrid->SetValue( m_Parent->m_Draw_Grid ); 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. // Add a spacer to improve appearance.
ColumnBoxSizer->AddSpacer(5); ColumnBoxSizer->AddSpacer( 5 );
wxArrayString m_SelBgColorStrings; wxArrayString m_SelBgColorStrings;
m_SelBgColorStrings.Add(_("White")); m_SelBgColorStrings.Add( _( "White" ) );
m_SelBgColorStrings.Add(_("Black")); m_SelBgColorStrings.Add( _( "Black" ) );
m_SelBgColor = new wxRadioBox( this, ID_RADIOBOX_BACKGROUND_COLOR, _("Background Color:"), m_SelBgColor =
wxDefaultPosition, wxDefaultSize, m_SelBgColorStrings, 1, wxRA_SPECIFY_COLS ); 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 ); 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 // 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). // "OK", "Cancel", and "Apply" buttons (which will be added after that
Line = new wxStaticLine( this, -1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); // line).
OuterBoxSizer->Add(Line, 0, wxGROW|wxALL, 5); 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 // Provide a StdDialogButtonSizer to accommodate the OK, Cancel, and Apply
// buttons; using that type of sizer results in those buttons being // 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; 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 ); Button = new wxButton( this, wxID_OK, _( "OK" ), wxDefaultPosition,
StdDialogButtonSizer->AddButton(Button); wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton( Button );
Button = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); Button = new wxButton( this, wxID_CANCEL, _( "Cancel" ),
StdDialogButtonSizer->AddButton(Button); wxDefaultPosition, wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton( Button );
Button->SetFocus(); Button->SetFocus();
Button = new wxButton( this, wxID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 ); Button = new wxButton( this, wxID_APPLY, _( "Apply" ), wxDefaultPosition,
StdDialogButtonSizer->AddButton(Button); wxDefaultSize, 0 );
StdDialogButtonSizer->AddButton( Button );
StdDialogButtonSizer->Realize(); 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() bool WinEDA_SetColorsFrame::ShowToolTips()
/**********************************************************/
{ {
/**********************************************************/
return true; return true;
} }
/**********************************************************/ /**********************************************************/
wxBitmap WinEDA_SetColorsFrame::GetBitmapResource( const wxString& name ) wxBitmap WinEDA_SetColorsFrame::GetBitmapResource( const wxString& name )
/**********************************************************/
{ {
wxUnusedVar(name); /**********************************************************/
wxUnusedVar( name );
return wxNullBitmap; return wxNullBitmap;
} }
/**********************************************************/ /**********************************************************/
wxIcon WinEDA_SetColorsFrame::GetIconResource( const wxString& name ) wxIcon WinEDA_SetColorsFrame::GetIconResource( const wxString& name )
/**********************************************************/
{ {
wxUnusedVar(name); /**********************************************************/
wxUnusedVar( name );
return wxNullIcon; return wxNullIcon;
} }
/**********************************************************/ /**********************************************************/
void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event ) void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
/**********************************************************/
{ {
int id = event.GetId(); /**********************************************************/
int color; int id = event.GetId();
int color;
wxBitmapButton* Button; wxBitmapButton* Button;
color = DisplayColorFrame( this, color = DisplayColorFrame( this,
CurrentColor[id - ID_COLOR_SETUP] ); CurrentColor[id - ID_COLOR_SETUP] );
if( color < 0 ) if( color < 0 )
return; return;
...@@ -294,19 +332,17 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event ) ...@@ -294,19 +332,17 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
return; return;
CurrentColor[id - ID_COLOR_SETUP] = color; CurrentColor[id - ID_COLOR_SETUP] = color;
wxMemoryDC iconDC; wxMemoryDC iconDC;
Button = laytool_list[id - ID_COLOR_SETUP]->m_Button; Button = laytool_list[id - ID_COLOR_SETUP]->m_Button;
wxBitmap ButtBitmap = Button->GetBitmapLabel(); wxBitmap ButtBitmap = Button->GetBitmapLabel();
iconDC.SelectObject( ButtBitmap ); iconDC.SelectObject( ButtBitmap );
wxBrush Brush; wxBrush Brush;
iconDC.SetPen( *wxBLACK_PEN ); iconDC.SetPen( *wxBLACK_PEN );
Brush.SetColour( Brush.SetColour( ColorRefs[color].m_Red,
ColorRefs[color].m_Red, ColorRefs[color].m_Green,
ColorRefs[color].m_Green, ColorRefs[color].m_Blue );
ColorRefs[color].m_Blue
);
Brush.SetStyle( wxSOLID ); Brush.SetStyle( wxSOLID );
iconDC.SetBrush( Brush ); iconDC.SetBrush( Brush );
...@@ -320,8 +356,8 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event ) ...@@ -320,8 +356,8 @@ void WinEDA_SetColorsFrame::SetColor( wxCommandEvent& event )
/******************************************************************/ /******************************************************************/
void WinEDA_SetColorsFrame::UpdateLayerSettings() void WinEDA_SetColorsFrame::UpdateLayerSettings()
/******************************************************************/
{ {
/******************************************************************/
// Update colors for each layer // Update colors for each layer
for( int lyr = 0; lyr < NB_BUTT; lyr++ ) for( int lyr = 0; lyr < NB_BUTT; lyr++ )
{ {
...@@ -347,9 +383,9 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings() ...@@ -347,9 +383,9 @@ void WinEDA_SetColorsFrame::UpdateLayerSettings()
/**********************************************************************/ /**********************************************************************/
void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) ) void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED( event ) )
/**********************************************************************/
{ {
/**********************************************************************/
UpdateLayerSettings(); UpdateLayerSettings();
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
EndModal( 1 ); EndModal( 1 );
...@@ -357,28 +393,26 @@ void WinEDA_SetColorsFrame::OnOkClick( wxCommandEvent& WXUNUSED (event) ) ...@@ -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 ); EndModal( -1 );
} }
/*******************************************************************/ /*******************************************************************/
void WinEDA_SetColorsFrame::OnApplyClick( wxCommandEvent& WXUNUSED (event) ) void WinEDA_SetColorsFrame::OnApplyClick( wxCommandEvent& WXUNUSED( event ) )
/*******************************************************************/
{ {
/*******************************************************************/
UpdateLayerSettings(); UpdateLayerSettings();
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
} }
/*************************/ /*************************/
void SeedLayers() void SeedLayers()
/*************************/
{ {
/*************************/
LayerStruct* LayerPointer = &g_LayerDescr; LayerStruct* LayerPointer = &g_LayerDescr;
int pt; int pt;
...@@ -395,14 +429,14 @@ void SeedLayers() ...@@ -395,14 +429,14 @@ void SeedLayers()
} }
LayerPointer->NumberOfLayers = pt - 1; 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 ) EDA_Colors ReturnLayerColor( int Layer )
/****************************************/
{ {
/****************************************/
if( g_LayerDescr.Flags == 0 ) if( g_LayerDescr.Flags == 0 )
return (EDA_Colors) g_LayerDescr.LayerColor[Layer]; return (EDA_Colors) g_LayerDescr.LayerColor[Layer];
else else
......
...@@ -49,9 +49,9 @@ const int BUTT_SIZE_Y = 20; ...@@ -49,9 +49,9 @@ const int BUTT_SIZE_Y = 20;
#define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer]) #define ADR( numlayer ) & (g_LayerDescr.LayerColor[numlayer])
/**********************************/ /********************/
/* Liste des menus de Menu_Layers */ /* Layer menu list. */
/**********************************/ /********************/
struct ColorButton struct ColorButton
{ {
...@@ -239,7 +239,7 @@ static ColorButton* laytool_list[NB_BUTT] = { ...@@ -239,7 +239,7 @@ static ColorButton* laytool_list[NB_BUTT] = {
&Layer_SheetFileName_Item, &Layer_SheetFileName_Item,
&Layer_SheetName_Item, &Layer_SheetName_Item,
&Layer_SheetLabel_Item, &Layer_SheetLabel_Item,
&Layer_HierarchicalLabel_Item, &Layer_HierarchicalLabel_Item,
&Layer_Erc_Warning_Item, &Layer_Erc_Warning_Item,
&Layer_Erc_Error_Item, &Layer_Erc_Error_Item,
...@@ -288,9 +288,9 @@ static ButtonIndex* laytool_index[BUTTON_GROUPS] = { ...@@ -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 class WinEDA_SetColorsFrame: public wxDialog
{ {
...@@ -319,7 +319,7 @@ private: ...@@ -319,7 +319,7 @@ private:
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = SYMBOL_WINEDA_SETCOLORSFRAME_STYLE ); long style = SYMBOL_WINEDA_SETCOLORSFRAME_STYLE );
// Initialises member variables // Initializes member variables
void Init(); void Init();
// Creates the controls and sizers // Creates the controls and sizers
...@@ -342,5 +342,4 @@ public: ...@@ -342,5 +342,4 @@ public:
~WinEDA_SetColorsFrame(); ~WinEDA_SetColorsFrame();
}; };
#endif #endif // _EELAYER_H_
// _EELAYER_H_
...@@ -56,7 +56,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -56,7 +56,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
DC->SetBackground( *wxBLACK_BRUSH ); DC->SetBackground( *wxBLACK_BRUSH );
DC->SetBackgroundMode( wxTRANSPARENT ); DC->SetBackgroundMode( wxTRANSPARENT );
DrawPanel->CursorOff( DC ); // effacement curseur DrawPanel->CursorOff( DC );
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{ {
...@@ -73,7 +73,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -73,7 +73,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness ); TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
DrawPanel->CursorOn( DC ); // reaffichage curseur DrawPanel->CursorOn( DC );
if( DrawPanel->ManageCurseur ) if( DrawPanel->ManageCurseur )
{ {
DrawPanel->ManageCurseur( DrawPanel, DC, FALSE ); DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
...@@ -86,7 +86,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -86,7 +86,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{ {
wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
title.Printf( wxT( "%s [%s]" ), msg.GetData(), title.Printf( wxT( "%s [%s]" ), msg.GetData(),
GetScreen()->m_FileName.GetData() ); GetScreen()->m_FileName.GetData() );
SetTitle( title ); SetTitle( title );
} }
else else
...@@ -109,7 +109,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -109,7 +109,7 @@ void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
*/ */
void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref,
int PrintMask, bool aPrintMirrorMode ) int PrintMask, bool aPrintMirrorMode )
{ {
wxBeginBusyCursor(); wxBeginBusyCursor();
...@@ -133,8 +133,10 @@ void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -133,8 +133,10 @@ void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
{ {
if( !(Structlist->m_Flags & IS_MOVED) ) if( !(Structlist->m_Flags & IS_MOVED) )
{ {
// uncomment line below when there is a virtual EDA_BaseStruct::GetBoundingBox() // uncomment line below when there is a virtual
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox() ) ) // EDA_BaseStruct::GetBoundingBox()
// if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox()
// ) )
RedrawOneStruct( panel, DC, Structlist, DrawMode, Color ); RedrawOneStruct( panel, DC, Structlist, DrawMode, Color );
} }
...@@ -159,13 +161,11 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC, ...@@ -159,13 +161,11 @@ void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
} }
/* Routine for repainting item in ghost mode. Used in the block moves. */
/* Routine de redessin en mode fantome (Dessin simplifie en g_XorMode et void DrawStructsInGhost( WinEDA_DrawPanel* aPanel,
* g_GhostColor wxDC* aDC,
* de structures. SCH_ITEM* aItem,
* Utilisee dans les deplacements de blocs const wxPoint& aOffset )
*/
void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem, const wxPoint & aOffset )
{ {
int DrawMode = g_XorMode; int DrawMode = g_XorMode;
int width = g_DrawDefaultLineThickness; int width = g_DrawDefaultLineThickness;
...@@ -180,8 +180,12 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem ...@@ -180,8 +180,12 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x, GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x,
Struct->m_PolyPoints[0].y + aOffset.y ); Struct->m_PolyPoints[0].y + aOffset.y );
for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ ) for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ )
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_PolyPoints[ii].x + aOffset.x, GRLineTo( &aPanel->m_ClipBox,
Struct->m_PolyPoints[ii].y + aOffset.y, width, g_GhostColor ); aDC,
Struct->m_PolyPoints[ii].x + aOffset.x,
Struct->m_PolyPoints[ii].y + aOffset.y,
width,
g_GhostColor );
break; break;
} }
...@@ -192,7 +196,8 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem ...@@ -192,7 +196,8 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
Struct = (EDA_DrawLineStruct*) aItem; Struct = (EDA_DrawLineStruct*) aItem;
if( (Struct->m_Flags & STARTPOINT) == 0 ) 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 else
{ {
...@@ -214,7 +219,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem ...@@ -214,7 +219,7 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
case DRAW_BUSENTRY_STRUCT_TYPE: case DRAW_BUSENTRY_STRUCT_TYPE:
{ {
DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) aItem; DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) aItem;
wxPoint start = Struct->m_Pos + aOffset; wxPoint start = Struct->m_Pos + aOffset;
GRMoveTo( start.x, start.y ); GRMoveTo( start.x, start.y );
GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_Size.x + start.x, GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_Size.x + start.x,
Struct->m_Size.y + start.y, width, g_GhostColor ); Struct->m_Size.y + start.y, width, g_GhostColor );
...@@ -269,9 +274,14 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem ...@@ -269,9 +274,14 @@ void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
{ {
DrawSheetStruct* Struct = (DrawSheetStruct*) aItem; DrawSheetStruct* Struct = (DrawSheetStruct*) aItem;
GRRect( &aPanel->m_ClipBox, aDC, Struct->m_Pos.x + aOffset.x, GRRect( &aPanel->m_ClipBox,
Struct->m_Pos.y + aOffset.y, Struct->m_Pos.x + Struct->m_Size.x + aOffset.x, aDC,
Struct->m_Pos.y + Struct->m_Size.y + aOffset.y, width, g_GhostColor ); 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; break;
} }
......
...@@ -20,39 +20,38 @@ ...@@ -20,39 +20,38 @@
// Global variables // Global variables
int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que int g_OptNetListUseNames; /* TRUE to use names rather than net
* les numeros (netlist PSPICE seulement) */ * The numbers (PSPICE netlist only) */
SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure SCH_ITEM* g_ItemToRepeat; /* Pointer to the last structure
* dessinee pouvant etre dupliquee par la commande * for duplicatation by the repeat command.
* Repeat ( NULL si aucune struct existe ) */ * (NULL if no struct exists) */
wxSize g_RepeatStep; wxSize g_RepeatStep;
int g_RepeatDeltaLabel; int g_RepeatDeltaLabel;
SCH_ITEM* g_ItemToUndoCopy; /* copy of last modified schematic item SCH_ITEM* g_ItemToUndoCopy; /* copy of last modified schematic item
* before it is modified (used for undo managing * before it is modified (used for undo
* to restore old values ) */ * 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 * False for a schematic item search
* Used for hotkey next search */ * Used for hotkey next search */
/* Block operation (copy, paste) */ /* 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
bool g_HVLines = true; // Bool: force H or V directions (Wires, Bus ..) // directions (Wires, Bus ..)
struct EESchemaVariables g_EESchemaVar; 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; 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 SymbolFileExtension( wxT( "sym" ) );
const wxString CompLibFileExtension( wxT( "lib" ) ); const wxString CompLibFileExtension( wxT( "lib" ) );
...@@ -60,22 +59,30 @@ 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 SymbolFileWildcard( wxT( "Kicad drawing symbol file (*.sym)|*.sym" ) );
const wxString CompLibFileWildcard( wxT( "Kicad component library file (*.lib)|*.lib" ) ); const wxString CompLibFileWildcard( wxT( "Kicad component library file (*.lib)|*.lib" ) );
wxString g_SimulatorCommandLine; // ligne de commande pour l'appel au simulateur (gnucap, spice..) // command line to call the simulator (gnucap, spice..)
wxString g_NetListerCommandLine; // ligne de commande pour l'appel au simulateur (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 LayerStruct g_LayerDescr; /* layer colors. */
* when they are at the same location */
int g_DrawDefaultLineThickness = 6; /* Default line (in EESCHEMA units) thickness bool g_EditPinByPinIsOn = false; /* true to do not synchronize pins
* used to draw/plot items having a default thickness line value (i.e. = 0 ). * edition when they are at the
* 0 = single pixel line width * 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 // Color to draw selected items
int g_ItemSelectetColor = BROWN; 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 g_InvisibleItemColor = DARKGRAY;
int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } }; int DefaultTransformMatrix[2][2] = { { 1, 0 }, { 0, -1 } };
...@@ -94,7 +101,7 @@ IMPLEMENT_APP( WinEDA_App ) ...@@ -94,7 +101,7 @@ IMPLEMENT_APP( WinEDA_App )
bool WinEDA_App::OnInit() bool WinEDA_App::OnInit()
{ {
wxFileName fn; wxFileName fn;
WinEDA_SchematicFrame* frame = NULL; WinEDA_SchematicFrame* frame = NULL;
g_DebugLevel = 0; // Debug level */ g_DebugLevel = 0; // Debug level */
...@@ -113,9 +120,10 @@ bool WinEDA_App::OnInit() ...@@ -113,9 +120,10 @@ bool WinEDA_App::OnInit()
/* init EESCHEMA */ /* init EESCHEMA */
SeedLayers(); 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; bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory); GetSettings( reopenLastUsedDirectory );
Read_Hotkey_Config( frame, false ); /* Must be called before creating Read_Hotkey_Config( frame, false ); /* Must be called before creating
* the main frame in order to * the main frame in order to
......
/******************************************************/ /******************/
/** eeconfig.cpp : routines et menus de configuration */ /** eeconfig.cpp **/
/*******************************************************/ /******************/
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
...@@ -19,9 +19,6 @@ ...@@ -19,9 +19,6 @@
#include "hotkeys.h" #include "hotkeys.h"
/* Variables locales */
#define HOTKEY_FILENAME wxT( "eeschema" ) #define HOTKEY_FILENAME wxT( "eeschema" )
...@@ -41,13 +38,14 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event ) ...@@ -41,13 +38,14 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
DisplayColorSetupFrame( this, pos ); DisplayColorSetupFrame( this, pos );
break; break;
case ID_CONFIG_REQ: // Creation de la fenetre de configuration case ID_CONFIG_REQ: // Display the configuration window.
InstallConfigFrame( pos ); InstallConfigFrame( pos );
break; break;
case ID_OPTIONS_SETUP: case ID_OPTIONS_SETUP:
DisplayOptionFrame( this, pos ); DisplayOptionFrame( this, pos );
DrawPanel->Refresh( TRUE ); // Redraw, because grid settings may have changed. // Redraw, because grid settings may have changed.
DrawPanel->Refresh( TRUE );
break; break;
case ID_CONFIG_SAVE: case ID_CONFIG_SAVE:
...@@ -98,7 +96,8 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event ) ...@@ -98,7 +96,8 @@ void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
HandleHotkeyConfigMenuSelection( this, id ); HandleHotkeyConfigMenuSelection( this, id );
break; 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 ); DisplayHotkeyList( this, s_Schematic_Hokeys_Descr );
break; break;
...@@ -258,8 +257,9 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName, ...@@ -258,8 +257,9 @@ bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
/* User library path takes precedent over default library search paths. */ /* User library path takes precedent over default library search paths. */
wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 ); 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 ) if( m_ComponentLibFiles.GetCount() == 0 )
m_ComponentLibFiles.Add( wxT( "power" ) ); m_ComponentLibFiles.Add( wxT( "power" ) );
......
/************************************************************/ /*****************/
/** eeconfig.h : configuration: definition des structures **/ /** eeconfig.h **/
/************************************************************/ /*****************/
#include "param_config.h" #include "param_config.h"
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
#define GROUPCOMMON wxT( "/common" ) #define GROUPCOMMON wxT( "/common" )
#define GROUPLIB wxT( "libraries" ) #define GROUPLIB wxT( "libraries" )
#include "netlist.h" /* Definitions generales liees au calcul de netliste */ #include "netlist.h"
/* variables importees */
extern int g_PenMinWidth; extern int g_PenMinWidth;
/* saving parameters option : */ /* saving parameters option : */
#define INSETUP TRUE // used when the parameter is saved in general config #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) * 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 "fctsys.h"
#include "common.h" #include "common.h"
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
/* ERC tests : /* ERC tests :
* 1 - conflicts between connected pins ( example: 2 connected outputs ) * 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 bool WriteDiagnosticERC( const wxString& FullFileName );
static void Diagnose( WinEDA_DrawPanel* panel, static void Diagnose( WinEDA_DrawPanel* panel,
NETLIST_OBJECT* NetItemRef, NETLIST_OBJECT* NetItemRef,
...@@ -35,9 +35,9 @@ static void TestOthersItems( WinEDA_DrawPanel* panel, ...@@ -35,9 +35,9 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
unsigned NetItemRef, unsigned NetItemRef,
unsigned NetStart, unsigned NetStart,
int* NetNbItems, int* MinConnexion ); int* NetNbItems, int* MinConnexion );
static void TestLabel( WinEDA_DrawPanel* panel, static void TestLabel( WinEDA_DrawPanel* panel,
unsigned NetItemRef, unsigned NetItemRef,
unsigned StartNet ); unsigned StartNet );
/* Local variables */ /* Local variables */
int WriteFichierERC = FALSE; int WriteFichierERC = FALSE;
...@@ -48,17 +48,22 @@ int WriteFichierERC = FALSE; ...@@ -48,17 +48,22 @@ int WriteFichierERC = FALSE;
* PIN_OUTPUT = usual output * PIN_OUTPUT = usual output
* PIN_BIDI = input or output (like port for a microprocessor) * PIN_BIDI = input or output (like port for a microprocessor)
* PIN_TRISTATE = tris state bus pin * PIN_TRISTATE = tris state bus pin
* PIN_PASSIVE = pin for passive components: must be connected, and can be connected to any pin * PIN_PASSIVE = pin for passive components: must be connected, and can be
* PIN_UNSPECIFIED = unkown electrical properties: creates alway a warning when connected * connected to any pin
* PIN_POWER_IN = power input (GND, VCC for ICs). Must be connected to a power output. * PIN_UNSPECIFIED = unknown electrical properties: creates always a warning
* PIN_POWER_OUT = output of a regulator: intended to be connected to power input pins * 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_OPENCOLLECTOR = pin type open collector
* PIN_OPENEMITTER = pin type open emitter * PIN_OPENEMITTER = pin type open emitter
* PIN_NC = not connected (must be left open) * PIN_NC = not connected (must be left open)
* *
* Minimal requirements: * Minimal requirements:
* All pins *must* be connected (except PIN_NC). * 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. * This ensures a forgotten connection will be detected.
*/ */
...@@ -117,18 +122,18 @@ bool DiagErcTableInit; // go to TRUE after DiagErc init ...@@ -117,18 +122,18 @@ bool DiagErcTableInit; // go to TRUE after DiagErc init
*/ */
int DefaultDiagErc[PIN_NMAX][PIN_NMAX] = int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
{ {
/* I, O, Bi, 3S, Pas, UnS,PwrI,PwrO, OC, OE, NC */ /* I, O, Bi, 3S, Pas, UnS, PwrI, PwrO, OC, OE, NC */
/* I */ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR }, /* I */ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR },
/* O */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, ERR, ERR, 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 }, /* Bi*/ { OK, OK, OK, OK, OK, WAR, OK, WAR, OK, WAR, WAR },
/* 3S*/ { OK, WAR, OK, OK, OK, WAR, WAR, ERR, WAR, 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 }, /*Pas*/ { OK, OK, OK, OK, OK, WAR, OK, OK, OK, OK, WAR },
/*UnS */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, 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 }, /*PwrI*/ { OK, OK, OK, WAR, OK, WAR, OK, OK, OK, OK, ERR },
/*PwrO*/ { OK, ERR, WAR, ERR, OK, WAR, OK, ERR, ERR, ERR, WAR }, /*PwrO*/ { OK, ERR, WAR, ERR, OK, WAR, OK, ERR, ERR, ERR, WAR },
/* OC */ { OK, ERR, OK, WAR, OK, WAR, OK, ERR, OK, OK, 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 }, /* OE */ { OK, ERR, WAR, WAR, OK, WAR, OK, ERR, OK, OK, WAR },
/* NC */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR } /* NC */ { WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR, WAR }
}; };
...@@ -136,9 +141,10 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] = ...@@ -136,9 +141,10 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
#define DRV 3 /* Net driven by a signal (a pin output for instance) */ #define DRV 3 /* Net driven by a signal (a pin output for instance) */
#define NET_NC 2 /* Net "connected" to a "NoConnect symbol" */ #define NET_NC 2 /* Net "connected" to a "NoConnect symbol" */
#define NOD 1 /* Net not driven ( Such as 2 or more connected inputs )*/ #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) * Initial state of a net is NOC (No Connection)
* Can be updated to NET_NC, or NOD (Not Driven) or DRV (DRIven) * Can be updated to NET_NC, or NOD (Not Driven) or DRV (DRIven)
* *
...@@ -149,47 +155,52 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] = ...@@ -149,47 +155,52 @@ int DefaultDiagErc[PIN_NMAX][PIN_NMAX] =
*/ */
static int MinimalReq[PIN_NMAX][PIN_NMAX] = static int MinimalReq[PIN_NMAX][PIN_NMAX] =
{ {
/* In, Out, Bi, 3S, Pas, UnS,PwrI,PwrO, OC, OE, NC */ /* In Out, Bi, 3S, Pas, UnS, PwrI,PwrO,OC, OE, NC */
/* In*/ { NOD, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC }, /* In*/ { NOD, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*Out*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, 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 }, /* Bi*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/* 3S*/ { 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 }, /*Pas*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/*UnS*/ { 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 }, /*PwrI*/ { NOD, DRV, NOD, NOD, NOD, NOD, NOD, DRV, NOD, NOD, NOC },
/*PwrO*/ { DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, DRV, 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 }, /* OC*/ { DRV, DRV, DRV, DRV, DRV, DRV, NOD, DRV, DRV, DRV, NOC },
/* OE*/ { 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 } /* NC*/ { NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC, NOC }
}; };
/** Function TestDuplicateSheetNames( ) /** 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 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 ) if( ref_item->Type() != DRAW_SHEET_STRUCT_TYPE )
continue; continue;
for( SCH_ITEM* item_to_test = ref_item->Next(); for( SCH_ITEM* item_to_test = ref_item->Next();
item_to_test != NULL; item_to_test != NULL;
item_to_test = item_to_test->Next() ) item_to_test = item_to_test->Next() )
{ {
if( item_to_test->Type() != DRAW_SHEET_STRUCT_TYPE ) if( item_to_test->Type() != DRAW_SHEET_STRUCT_TYPE )
continue; continue;
// We have found a second sheet: compare names // We have found a second sheet: compare names
if( ( (DrawSheetStruct*) ref_item )->m_SheetName.CmpNoCase( ( (DrawSheetStruct*) if( ( (DrawSheetStruct*) ref_item )->m_SheetName.CmpNoCase(
item_to_test )-> ( ( DrawSheetStruct* ) item_to_test )-> m_SheetName )
m_SheetName ) == 0 ) == 0 )
{ {
/* Create a new marker type ERC error*/ /* Create a new marker type ERC error*/
MARKER_SCH* Marker = new MARKER_SCH(); MARKER_SCH* Marker = new MARKER_SCH();
...@@ -211,16 +222,17 @@ int TestDuplicateSheetNames( ) ...@@ -211,16 +222,17 @@ int TestDuplicateSheetNames( )
return err_count; return err_count;
} }
/**************************************************/ /**************************************************/
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
/**************************************************/
{ {
wxFileName fn; /**************************************************/
unsigned NetItemRef; wxFileName fn;
unsigned OldItem; unsigned NetItemRef;
unsigned StartNet; unsigned OldItem;
unsigned StartNet;
int NetNbItems, MinConn; int NetNbItems, MinConn;
if( !DiagErcTableInit ) if( !DiagErcTableInit )
{ {
...@@ -251,7 +263,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -251,7 +263,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
/* Cleanup the entire hierarchy */ /* Cleanup the entire hierarchy */
EDA_ScreenList ScreenList; 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; bool ModifyWires;
ModifyWires = Screen->SchematicCleanUp( NULL ); ModifyWires = Screen->SchematicCleanUp( NULL );
...@@ -263,27 +277,29 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -263,27 +277,29 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
} }
/* Test duplicate sheet names /* 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( ); int errcnt = TestDuplicateSheetNames();
g_EESchemaVar.NbErrorErc += errcnt; g_EESchemaVar.NbErrorErc += errcnt;
g_EESchemaVar.NbWarningErc += errcnt; g_EESchemaVar.NbWarningErc += errcnt;
m_Parent->BuildNetListBase(); m_Parent->BuildNetListBase();
/* Reset the flag m_FlagOfConnection, that will be used next, in calculations */ /* Reset the flag m_FlagOfConnection, that will be used next, in
for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ ) * calculations */
g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED; for( unsigned ii = 0; ii < g_NetObjectslist.size(); ii++ )
g_NetObjectslist[ii]->m_FlagOfConnection = UNCONNECTED;
StartNet = OldItem = 0; StartNet = OldItem = 0;
NetNbItems = 0; NetNbItems = 0;
MinConn = NOC; MinConn = NOC;
for( NetItemRef = 0; NetItemRef < g_NetObjectslist.size(); NetItemRef++ ) for( NetItemRef = 0; NetItemRef < g_NetObjectslist.size(); NetItemRef++ )
{ {
/* Tst changement de net */ if( g_NetObjectslist[OldItem]->GetNet() !=
if( g_NetObjectslist[OldItem]->GetNet() != g_NetObjectslist[NetItemRef]->GetNet() ) g_NetObjectslist[NetItemRef]->GetNet() )
{ {
MinConn = NOC; MinConn = NOC;
NetNbItems = 0; NetNbItems = 0;
...@@ -310,19 +326,20 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -310,19 +326,20 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
case NET_SHEETLABEL: case NET_SHEETLABEL:
case NET_SHEETBUSLABELMEMBER: case NET_SHEETBUSLABELMEMBER:
// ERC problems when pin sheets do not match hierachical labels. // ERC problems when pin sheets do not match hierarchical labels.
// Each pin sheet must match a hierachical label // Each pin sheet must match a hierarchical label
// Each hierachicallabel must match a pin sheet // Each hierarchical label must match a pin sheet
TestLabel( m_Parent->DrawPanel, NetItemRef, StartNet ); TestLabel( m_Parent->DrawPanel, NetItemRef, StartNet );
break; break;
case NET_NOCONNECT: 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; MinConn = NET_NC;
if( NetNbItems != 0 ) if( NetNbItems != 0 )
Diagnose( m_Parent->DrawPanel, Diagnose( m_Parent->DrawPanel,
g_NetObjectslist[NetItemRef], NULL, MinConn, UNC ); g_NetObjectslist[NetItemRef], NULL, MinConn, UNC );
break; break;
case NET_PIN: case NET_PIN:
...@@ -341,7 +358,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -341,7 +358,9 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc ); num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc );
m_TotalErrCount->SetLabel( num ); 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 ); m_LastErrCount->SetLabel( num );
num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc ); num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc );
...@@ -353,7 +372,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -353,7 +372,6 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
// Display new markers: // Display new markers:
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
/* Generation ouverture fichier diag */
if( WriteFichierERC == TRUE ) if( WriteFichierERC == TRUE )
{ {
fn = g_RootSheet->m_AssociatedScreen->m_FileName; fn = g_RootSheet->m_AssociatedScreen->m_FileName;
...@@ -370,7 +388,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) ...@@ -370,7 +388,7 @@ void DIALOG_ERC::TestErc( wxArrayString* aMessagesList )
{ {
Close( TRUE ); Close( TRUE );
ExecuteFile( this, wxGetApp().GetEditorName(), ExecuteFile( this, wxGetApp().GetEditorName(),
QuoteFullPath( fn ) ); QuoteFullPath( fn ) );
} }
} }
} }
...@@ -381,13 +399,12 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -381,13 +399,12 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
NETLIST_OBJECT* aNetItemRef, NETLIST_OBJECT* aNetItemRef,
NETLIST_OBJECT* aNetItemTst, NETLIST_OBJECT* aNetItemTst,
int aMinConn, int aDiag ) int aMinConn, int aDiag )
{
/********************************************************/ /********************************************************/
/* Creates an ERC marker to show the ERC problem about aNetItemRef /* Creates an ERC marker to show the ERC problem about aNetItemRef
* or between aNetItemRef and aNetItemTst * or between aNetItemRef and aNetItemTst
* if MinConn < 0: this is an error on labels * if MinConn < 0: this is an error on labels
*/ */
{
MARKER_SCH* Marker = NULL; MARKER_SCH* Marker = NULL;
SCH_SCREEN* screen; SCH_SCREEN* screen;
int ii, jj; int ii, jj;
...@@ -395,7 +412,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -395,7 +412,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
if( aDiag == OK ) if( aDiag == OK )
return; return;
/* Creation du nouveau marqueur type Erreur ERC */ /* Create new marker for ERC error. */
Marker = new MARKER_SCH(); Marker = new MARKER_SCH();
Marker->m_TimeStamp = GetTimeStamp(); Marker->m_TimeStamp = GetTimeStamp();
...@@ -408,19 +425,22 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -408,19 +425,22 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
g_EESchemaVar.NbWarningErc++; g_EESchemaVar.NbWarningErc++;
wxString msg; wxString msg;
if( aMinConn < 0 ) // Traitement des erreurs sur labels if( aMinConn < 0 )
{ {
if( (aNetItemRef->m_Type == NET_HIERLABEL) if( (aNetItemRef->m_Type == NET_HIERLABEL)
|| (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) ) || (aNetItemRef->m_Type == NET_HIERBUSLABELMEMBER) )
{ {
msg.Printf( _( "HLabel %s not connected to SheetLabel" ), msg.Printf( _( "HLabel %s not connected to SheetLabel" ),
aNetItemRef->m_Label->GetData() ); aNetItemRef->m_Label->GetData() );
} }
else else
msg.Printf( _( "SheetLabel %s not connected to HLabel" ), 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; return;
} }
...@@ -433,11 +453,12 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -433,11 +453,12 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
string_pinnum = CONV_FROM_UTF8( ascii_buf ); string_pinnum = CONV_FROM_UTF8( ascii_buf );
cmp_ref = wxT( "?" ); cmp_ref = wxT( "?" );
if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link ) 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( 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" ), msg.Printf( _( "Cmp %s, Pin %s (%s) Unconnected" ),
cmp_ref.GetData(), string_pinnum.GetData(), cmp_ref.GetData(), string_pinnum.GetData(),
...@@ -449,15 +470,14 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -449,15 +470,14 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
return; 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 ) if( aNetItemRef->m_Type == NET_PIN && aNetItemRef->m_Link )
cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef( cmp_ref = ( (SCH_COMPONENT*) aNetItemRef->m_Link )->GetRef(
&aNetItemRef->m_SheetList ); &aNetItemRef->m_SheetList );
msg.Printf( msg.Printf( _( "Cmp %s, Pin %s (%s) not driven (Net %d)" ),
_( "Cmp %s, Pin %s (%s) not driven (Net %d)" ), cmp_ref.GetData(), string_pinnum.GetData(),
cmp_ref.GetData(), string_pinnum.GetData(), MsgPinElectricType[ii], aNetItemRef->GetNet() );
MsgPinElectricType[ii], aNetItemRef->GetNet() );
Marker->SetData( ERCE_PIN_NOT_DRIVEN, Marker->SetData( ERCE_PIN_NOT_DRIVEN,
aNetItemRef->m_Start, aNetItemRef->m_Start,
msg, msg,
...@@ -477,7 +497,7 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -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; jj = aNetItemTst->m_ElectricalType;
int errortype = ERCE_PIN_TO_PIN_WARNING; int errortype = ERCE_PIN_TO_PIN_WARNING;
...@@ -493,16 +513,19 @@ static void Diagnose( WinEDA_DrawPanel* aPanel, ...@@ -493,16 +513,19 @@ static void Diagnose( WinEDA_DrawPanel* aPanel,
alt_string_pinnum = CONV_FROM_UTF8( ascii_buf ); alt_string_pinnum = CONV_FROM_UTF8( ascii_buf );
alt_cmp = wxT( "?" ); alt_cmp = wxT( "?" );
if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link ) if( aNetItemTst->m_Type == NET_PIN && aNetItemTst->m_Link )
alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef( &aNetItemTst->m_SheetList ); alt_cmp = ( (SCH_COMPONENT*) aNetItemTst->m_Link )->GetRef(
msg.Printf( _("Cmp %s, Pin %s (%s) connected to " ), &aNetItemTst->m_SheetList );
cmp_ref.GetData(), string_pinnum.GetData(), MsgPinElectricType[ii] ); msg.Printf( _( "Cmp %s, Pin %s (%s) connected to " ),
cmp_ref.GetData(),
string_pinnum.GetData(), MsgPinElectricType[ii] );
Marker->SetData( errortype, Marker->SetData( errortype,
aNetItemRef->m_Start, aNetItemRef->m_Start,
msg, msg,
aNetItemRef->m_Start ); aNetItemRef->m_Start );
msg.Printf( _("Cmp %s, Pin %s (%s) (net %d)" ), msg.Printf( _( "Cmp %s, Pin %s (%s) (net %d)" ),
alt_cmp.GetData(), alt_string_pinnum.GetData(), MsgPinElectricType[jj], alt_cmp.GetData(),
aNetItemRef->GetNet() ); alt_string_pinnum.GetData(), MsgPinElectricType[jj],
aNetItemRef->GetNet() );
Marker->SetAuxiliaryData( msg, aNetItemTst->m_Start ); Marker->SetAuxiliaryData( msg, aNetItemTst->m_Start );
} }
} }
...@@ -513,68 +536,90 @@ static void TestOthersItems( WinEDA_DrawPanel* panel, ...@@ -513,68 +536,90 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
unsigned NetItemRef, unsigned NetItemRef,
unsigned netstart, unsigned netstart,
int* NetNbItems, int* MinConnexion ) int* NetNbItems, int* MinConnexion )
{
/********************************************************************/ /********************************************************************/
/* Routine testing electrical conflicts between NetItemRef and other items
/* Routine testant les conflits electriques entre * of the same net
* NetItemRef
* et les autres items du meme net
*/ */
{
unsigned NetItemTst; unsigned NetItemTst;
int ref_elect_type, jj, erc = OK, local_minconn; int ref_elect_type, jj, erc = OK, local_minconn;
/* Analyse de la table des connexions : */
/* Analysis of the table of connections. */
ref_elect_type = g_NetObjectslist[NetItemRef]->m_ElectricalType; ref_elect_type = g_NetObjectslist[NetItemRef]->m_ElectricalType;
NetItemTst = netstart; NetItemTst = netstart;
local_minconn = NOC; local_minconn = NOC;
/* Test pins Pins connected to NetItemRef */ /* Test pins connected to NetItemRef */
for( ; ; NetItemTst++ ) for( ; ; NetItemTst++ )
{ {
if( NetItemRef == NetItemTst ) if( NetItemRef == NetItemTst )
continue; continue;
/* We examine only a given net. We stop the search if the net changes */ /* 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 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 */ /* End net code found: minimum connection test. */
if( (*MinConnexion < NET_NC ) && (local_minconn < NET_NC ) ) /* Not connected or not driven pin */ if( (*MinConnexion < NET_NC ) && (local_minconn < NET_NC ) )
{ {
/* Not connected or not driven pin. */
bool seterr = true; 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, /* This pin is not connected: for multiple part per
* search for an other instance of this pin * package, and duplicated pin,
* this will be flagged only is all instances of this pin are not connected * search for an other instance of this pin
* TODO test also if instances connected are connected to the same net * this will be flagged only is all instances of this pin
*/ * are not connected
for ( unsigned duppin = 0; duppin < g_NetObjectslist.size(); duppin ++ ) * 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; continue;
if( duppin == NetItemRef ) if( duppin == NetItemRef )
continue; continue;
if ( g_NetObjectslist[NetItemRef]->m_PinNum != g_NetObjectslist[duppin]->m_PinNum ) if( g_NetObjectslist[NetItemRef]->m_PinNum !=
g_NetObjectslist[duppin]->m_PinNum )
continue; continue;
if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->m_Link )->GetRef(&g_NetObjectslist[NetItemRef]->m_SheetList) != if( ( (SCH_COMPONENT*) g_NetObjectslist[NetItemRef]->
((SCH_COMPONENT*) g_NetObjectslist[duppin]->m_Link )->GetRef(&g_NetObjectslist[duppin]->m_SheetList) ) m_Link )->GetRef( &g_NetObjectslist[NetItemRef]->
m_SheetList ) !=
( (SCH_COMPONENT*) g_NetObjectslist[duppin]->m_Link )
->GetRef( &g_NetObjectslist[duppin]->m_SheetList ) )
continue; 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) // Same component and same pin. Do dot create error for
if ( (duppin > 0) && (g_NetObjectslist[duppin]->GetNet() == g_NetObjectslist[duppin-1]->GetNet())) // 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; 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; seterr = false;
} }
} }
if ( seterr ) if( seterr )
Diagnose( panel, g_NetObjectslist[NetItemRef], NULL, local_minconn, WAR ); Diagnose( panel,
*MinConnexion = DRV; // inhibition autres messages de ce type pour ce net g_NetObjectslist[NetItemRef],
NULL,
local_minconn,
WAR );
*MinConnexion = DRV; // inhibiting other messages of this
// type for the net.
} }
return; return;
} }
...@@ -608,15 +653,20 @@ static void TestOthersItems( WinEDA_DrawPanel* panel, ...@@ -608,15 +653,20 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
break; break;
*NetNbItems += 1; *NetNbItems += 1;
if( erc == OK ) // 1 marqueur par pin maxi if( erc == OK )
{ {
erc = DiagErc[ref_elect_type][jj]; erc = DiagErc[ref_elect_type][jj];
if( erc != OK ) if( erc != OK )
{ {
if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 ) if( g_NetObjectslist[NetItemTst]->m_FlagOfConnection == 0 )
{ {
Diagnose( panel, g_NetObjectslist[NetItemRef], g_NetObjectslist[NetItemTst], 0, erc ); Diagnose( panel,
g_NetObjectslist[NetItemTst]->m_FlagOfConnection = NOCONNECT_SYMBOL_PRESENT; 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, ...@@ -628,11 +678,10 @@ static void TestOthersItems( WinEDA_DrawPanel* panel,
/********************************************************/ /********************************************************/
static bool WriteDiagnosticERC( const wxString& FullFileName ) static bool WriteDiagnosticERC( const wxString& FullFileName )
{
/*********************************************************/ /*********************************************************/
/* Create the Diagnostic file (<xxx>.erc file) /* Create the Diagnostic file (<xxx>.erc file)
*/ */
{
SCH_ITEM* DrawStruct; SCH_ITEM* DrawStruct;
MARKER_SCH* Marker; MARKER_SCH* Marker;
char Line[1024]; char Line[1024];
...@@ -650,7 +699,9 @@ static bool WriteDiagnosticERC( const wxString& FullFileName ) ...@@ -650,7 +699,9 @@ static bool WriteDiagnosticERC( const wxString& FullFileName )
EDA_SheetList SheetList; 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 ) if( Sheet->Last() == g_RootSheet )
{ {
...@@ -691,8 +742,8 @@ static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b ) ...@@ -691,8 +742,8 @@ static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b )
int at = a->m_Type; int at = a->m_Type;
int bt = b->m_Type; int bt = b->m_Type;
if( (at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER) if( ( at == NET_HIERLABEL || at == NET_HIERBUSLABELMEMBER )
&&(bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER) ) && ( bt == NET_SHEETLABEL || bt == NET_SHEETBUSLABELMEMBER ) )
{ {
if( a->m_SheetList == b->m_SheetListInclude ) if( a->m_SheetList == b->m_SheetListInclude )
{ {
...@@ -704,44 +755,46 @@ static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b ) ...@@ -704,44 +755,46 @@ static bool IsLabelsConnected( NETLIST_OBJECT* a, NETLIST_OBJECT* b )
/***********************************************************************/ /***********************************************************************/
void TestLabel( WinEDA_DrawPanel* panel, void TestLabel( WinEDA_DrawPanel* panel,
unsigned NetItemRef, unsigned NetItemRef,
unsigned StartNet ) unsigned StartNet )
{
/***********************************************************************/ /***********************************************************************/
/* Routine to perform erc on a sheetLabel that is connected to a corresponding
/* Routine controlant qu'un sheetLabel est bien connecte a un Glabel de la * sub sheet Glabel
* sous-feuille correspondante
*/ */
{
unsigned NetItemTst; unsigned NetItemTst;
int erc = 1; int erc = 1;
NetItemTst = StartNet; NetItemTst = StartNet;
/* Examen de la liste des Labels connectees a NetItemRef */ /* Review the list of labels connected to NetItemRef. */
for( ; ; NetItemTst++ ) for( ; ; NetItemTst++ )
{ {
if( NetItemTst == NetItemRef ) if( NetItemTst == NetItemRef )
continue; continue;
/* Est - on toujours dans le meme net ? */ /* Is always in the same net? */
if( ( NetItemTst == g_NetObjectslist.size() ) 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 ) if( erc )
{ {
/* GLabel ou SheetLabel orphelin */ /* Glabel or SheetLabel orphaned. */
Diagnose( panel, g_NetObjectslist[NetItemRef], NULL, -1, WAR ); Diagnose( panel, g_NetObjectslist[NetItemRef], NULL, -1, WAR );
} }
return; return;
} }
if( IsLabelsConnected( g_NetObjectslist[NetItemRef], g_NetObjectslist[NetItemTst] ) ) if( IsLabelsConnected( g_NetObjectslist[NetItemRef],
g_NetObjectslist[NetItemTst] ) )
erc = 0; erc = 0;
//same thing, different order. //same thing, different order.
if( IsLabelsConnected( g_NetObjectslist[NetItemTst], g_NetObjectslist[NetItemRef] ) ) if( IsLabelsConnected( g_NetObjectslist[NetItemTst],
g_NetObjectslist[NetItemRef] ) )
erc = 0; erc = 0;
} }
} }
...@@ -38,13 +38,13 @@ enum errortype ...@@ -38,13 +38,13 @@ enum errortype
/// DRC error codes: /// DRC error codes:
#define ERCE_UNSPECIFIED 0 #define ERCE_UNSPECIFIED 0
#define ERCE_DUPLICATE_SHEET_NAME 1 //duplicate sheet names within a given sheet #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_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_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_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_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_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_NOCONNECT_CONNECTED 7 // a no connect symbol is connected to more than 1 pin
#endif // _ERC_H #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