Commit 0d57d670 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Add user write permission tests to PCBNew and other minor fixes.

* Check user write permissions before saving project, board, and footprint
  library files.
* Append read only to file name and path in title bar when the user
  does not have write privileges.
* Rename class WinEDA_ModuleEditFrame to FOOTPRINT_EDIT_FRAME.
* Lot's of Doxygen comment and coding style policy fixes.
parent 5fd409f8
......@@ -22,7 +22,7 @@
/* Forward declarations of classes. */
class WinEDA_CvpcbFrame;
class PCB_EDIT_FRAME;
class WinEDA_ModuleEditFrame;
class FOOTPRINT_EDIT_FRAME;
class BOARD;
class TEXTE_PCB;
class MODULE;
......@@ -61,7 +61,7 @@ public:
wxRealPoint m_UserGridSize;
EDA_3D_FRAME* m_Draw3DFrame;
WinEDA_ModuleEditFrame* m_ModuleEditFrame;
FOOTPRINT_EDIT_FRAME* m_ModuleEditFrame;
protected:
BOARD* m_Pcb;
......@@ -172,7 +172,6 @@ public:
*/
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide();
/**
* Function CursorGoto
* positions the cursor at a given coordinate and reframes the drawing if
......@@ -182,7 +181,6 @@ public:
*/
void CursorGoto( const wxPoint& aPos );
void place_marqueur( wxDC* DC,
const wxPoint& pos,
char* pt_bitmap,
......@@ -208,8 +206,14 @@ public:
bool aOverwrite,
bool aDisplayDialog );
void Archive_Modules( const wxString& LibName,
bool NewModulesOnly );
/**
* Function Archive_Modules
* Save in the library:
* All new modules (ie modules not found in this lib) (if NewModulesOnly == true)
* all modules (if NewModulesOnly == false)
*/
void Archive_Modules( const wxString& LibName, bool NewModulesOnly );
MODULE* GetModuleByName();
/**
......@@ -276,15 +280,17 @@ public:
wxDC* DC );
void AddPad( MODULE* Module, bool draw );
/**
* Function DeletePad
* Delete the pad aPad.
* Refresh the modified screen area
* Refresh modified parameters of the parent module (bounding box, last date)
* @param aPad = the pad to delete
* @param aQuery = true to promt for confirmation, false to delete silently
* @param aQuery = true to prompt for confirmation, false to delete silently
*/
void DeletePad( D_PAD* aPad, bool aQuery = true );
void StartMovePad( D_PAD* Pad, wxDC* DC );
void RotatePad( D_PAD* Pad, wxDC* DC );
void PlacePad( D_PAD* Pad, wxDC* DC );
......
......@@ -19,7 +19,6 @@
/* Forward declarations of classes. */
class PCB_SCREEN;
class WinEDA_ModuleEditFrame;
class BOARD;
class TEXTE_PCB;
class MODULE;
......@@ -106,7 +105,7 @@ protected:
* here and we do not want to do that.
* </p>
*/
void syncLayerWidget( );
void syncLayerWidget();
virtual void unitsChangeRefresh();
......@@ -141,6 +140,10 @@ public:
*/
void ToPrinter( wxCommandEvent& event );
/**
* Function SVG_Print
* shows the print SVG file dialog.
*/
void SVG_Print( wxCommandEvent& event );
// User interface update command event handlers.
......@@ -204,7 +207,7 @@ public:
virtual void SetGridColor(int aColor);
// Configurations:
void InstallConfigFrame( );
void InstallConfigFrame();
void Process_Config( wxCommandEvent& event );
PARAM_CFG_ARRAY& GetProjectFileParameters();
......@@ -341,13 +344,14 @@ public:
void ReCreateMenuBar();
LAYER_BOX_SELECTOR* ReCreateLayerBox( EDA_TOOLBAR* parent );
/** Virtual Function OnModify()
* Must be called after a board change
* in order to set the "modify" flag of the current screen
* and prepare, if needed the refresh of the 3D frame showing the footprint
* do not forget to call the basic OnModify function to update auxiliary info
/**
* Function OnModify
* must be called after a board change to set the modified flag.
* <p>
* Reloads the 3D view if required and calls the base PCB_BASE_FRAME::OnModify function
* to update auxiliary information.
*/
virtual void OnModify( );
virtual void OnModify();
/**
* Function IsElementVisible
......@@ -375,7 +379,7 @@ public:
* Function SetVisibleAlls
* Set the status of all visible element categories and layers to VISIBLE
*/
void SetVisibleAlls( );
void SetVisibleAlls();
/**
* Function ReFillLayerWidget
......@@ -384,12 +388,16 @@ public:
*/
void ReFillLayerWidget();
/**
* Function Show3D_Frame
* displays the 3D view of current printed circuit board.
*/
void Show3D_Frame( wxCommandEvent& event );
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
/**
* Function ShowDesignRulesEditor
* Display the Design Rules Editor.
* displays the Design Rules Editor.
*/
void ShowDesignRulesEditor( wxCommandEvent& event );
......@@ -484,7 +492,7 @@ public:
virtual int ReturnBlockCommand( int aKey );
/**
* Function HandleBlockPlace( )
* Function HandleBlockPlace()
* Called after HandleBlockEnd, when a block command needs to be
* executed after the block is moved to its new place
* (bloc move, drag, copy .. )
......@@ -493,7 +501,7 @@ public:
virtual void HandleBlockPlace( wxDC* DC );
/**
* Function HandleBlockEnd( )
* Function HandleBlockEnd()
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
......@@ -567,11 +575,16 @@ public:
void ToPostProcess( wxCommandEvent& event );
void OnFileHistory( wxCommandEvent& event );
/**
* Function Files_io
* is the command event handler for read and write file commands.
*/
void Files_io( wxCommandEvent& event );
/**
* Function LoadOnePcbFile
* Load a Kicad board (.brd) file.
* loads a Kicad board (.brd) from \a aFileName.
*
* @param aFileName - File name including path. If empty, a file dialog will
* be displayed.
......@@ -595,7 +608,16 @@ public:
*/
int ReadPcbFile( LINE_READER* aReader, bool Append );
bool SavePcbFile( const wxString& FileName );
/**
* Function SavePcbFile
* writes the board data structures to \a a aFileName
*
* @param aFileName The file name to write or wxEmptyString to prompt user for
* file name.
* @return True if file was saved successfully.
*/
bool SavePcbFile( const wxString& aFileName );
int SavePcbFormatAscii( FILE* File );
bool WriteGeneralDescrPcb( FILE* File );
......@@ -643,7 +665,7 @@ public:
* @param aFullFileName = the full filename of the file to create
* @param aScale = the general scaling factor. 1.0 to export in inches
* @param aExport3DFiles = true to copy 3D shapes in the subir a3D_Subdir
* @param a3D_Subdir = sub directory where 3D sahpes files are copied
* @param a3D_Subdir = sub directory where 3D shapes files are copied
* used only when aExport3DFiles == true
* @return true if Ok.
*/
......@@ -761,11 +783,15 @@ public:
// Track and via edition:
void Via_Edit_Control( wxCommandEvent& event );
/* Return true if a microvia can be put on board
/**
* Function IsMicroViaAcceptable
* return true if a microvia can be placed on the board.
* <p>
* A microvia is a small via restricted to 2 near neighbor layers
* because its is hole is made by laser which can penetrate only one layer
* It is mainly used to connect BGA to the first inner layer
* And it is allowed from an external layer to the first inner layer
* </p>
*/
bool IsMicroViaAcceptable( void );
......@@ -1158,6 +1184,17 @@ public:
*/
virtual void SetLanguage( wxCommandEvent& event );
/**
* Function UpdateTitle
* sets the main window title bar text.
* <p>
* If file name defined by PCB_SCREEN::m_FileName is not set, the title is set to the
* application name appended with no file. Otherwise, the title is set to the full path
* and file name and read only is appended to the title if the user does not have write
* access to the file.
*/
void UpdateTitle();
DECLARE_EVENT_TABLE()
};
......
......@@ -36,11 +36,7 @@ static void RotateMarkedItems( MODULE* module, wxPoint offset );
static void DeleteMarkedItems( MODULE* module );
/* Return the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to
* the key (ALT, SHIFT ALT ..) pressed when dragging mouse and left or
* middle button pressed
*/
int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key )
int FOOTPRINT_EDIT_FRAME::ReturnBlockCommand( int key )
{
int cmd;
......@@ -83,17 +79,7 @@ int WinEDA_ModuleEditFrame::ReturnBlockCommand( int key )
}
/**
* Function HandleBlockEnd( )
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/
bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
bool FOOTPRINT_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
{
int itemsCount = 0;
bool nextcmd = false;
......@@ -121,8 +107,8 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
itemsCount = MarkItemsInBloc( currentModule,
GetScreen()->m_BlockLocate );
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
{
nextcmd = true;
......@@ -147,8 +133,10 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_DELETE: /* Delete */
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
SaveCopyInUndoList( currentModule, UR_MODEDIT );
DeleteMarkedItems( currentModule );
break;
......@@ -158,8 +146,10 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_ROTATE:
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
SaveCopyInUndoList( currentModule, UR_MODEDIT );
RotateMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break;
......@@ -168,8 +158,10 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
case BLOCK_MIRROR_Y:
case BLOCK_FLIP: /* mirror */
itemsCount = MarkItemsInBloc( currentModule, GetScreen()->m_BlockLocate );
if( itemsCount )
SaveCopyInUndoList( currentModule, UR_MODEDIT );
MirrorMarkedItems( currentModule, GetScreen()->m_BlockLocate.Centre() );
break;
......@@ -202,15 +194,7 @@ bool WinEDA_ModuleEditFrame::HandleBlockEnd( wxDC* DC )
}
/******************************************************/
void WinEDA_ModuleEditFrame::HandleBlockPlace( wxDC* DC )
/******************************************************/
/* Routine to handle the BLOCK PLACE command
* Last routine for block operation for:
* - block move & drag
* - block copy & paste
*/
void FOOTPRINT_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
{
MODULE* currentModule = GetBoard()->m_Modules;
......@@ -326,6 +310,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
{
if( pad->m_Selected == 0 )
continue;
pad->Draw( aPanel, aDC, g_XorMode, move_offset );
}
}
......@@ -434,15 +419,18 @@ void MoveMarkedItems( MODULE* module, wxPoint offset )
return;
D_PAD* pad = module->m_Pads;
for( ; pad != NULL; pad = pad->Next() )
{
if( pad->m_Selected == 0 )
continue;
pad->SetPosition( pad->GetPosition() + offset );
pad->m_Pos0 += offset;
}
item = module->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
......@@ -485,20 +473,26 @@ void DeleteMarkedItems( MODULE* module )
return;
pad = module->m_Pads;
for( ; pad != NULL; pad = next_pad )
{
next_pad = pad->Next();
if( pad->m_Selected == 0 )
continue;
pad->DeleteStructure();
}
item = module->m_Drawings;
for( ; item != NULL; item = next_item )
{
next_item = item->Next();
if( item->m_Selected == 0 )
continue;
item->DeleteStructure();
}
}
......@@ -515,10 +509,12 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
return;
D_PAD* pad = module->m_Pads;
for( ; pad != NULL; pad = pad->Next() )
{
if( pad->m_Selected == 0 )
continue;
SETMIRROR( pad->GetPosition().x );
pad->m_Pos0.x = pad->GetPosition().x;
NEGATE( pad->m_Offset.x );
......@@ -528,6 +524,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
}
item = module->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
......@@ -536,7 +533,8 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
switch( item->Type() )
{
case TYPE_EDGE_MODULE:
{ EDGE_MODULE * edge = (EDGE_MODULE*) item;
{
EDGE_MODULE * edge = (EDGE_MODULE*) item;
SETMIRROR( edge->m_Start.x );
edge->m_Start0.x = edge->m_Start.x;
SETMIRROR( edge->m_End.x );
......@@ -547,8 +545,7 @@ void MirrorMarkedItems( MODULE* module, wxPoint offset )
case TYPE_TEXTE_MODULE:
SETMIRROR( ( (TEXTE_MODULE*) item )->GetPosition().x );
( (TEXTE_MODULE*) item )->m_Pos0.x =
( (TEXTE_MODULE*) item )->GetPosition().x;
( (TEXTE_MODULE*) item )->m_Pos0.x = ( (TEXTE_MODULE*) item )->GetPosition().x;
break;
default:
......@@ -572,10 +569,12 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
return;
D_PAD* pad = module->m_Pads;
for( ; pad != NULL; pad = pad->Next() )
{
if( pad->m_Selected == 0 )
continue;
ROTATE( pad->GetPosition() );
pad->m_Pos0 = pad->GetPosition();
pad->m_Orient += 900;
......@@ -583,6 +582,7 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
}
item = module->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
if( item->m_Selected == 0 )
......@@ -592,16 +592,14 @@ void RotateMarkedItems( MODULE* module, wxPoint offset )
{
case TYPE_EDGE_MODULE:
ROTATE( ( (EDGE_MODULE*) item )->m_Start );
( (EDGE_MODULE*) item )->m_Start0 =
( (EDGE_MODULE*) item )->m_Start;
( (EDGE_MODULE*) item )->m_Start0 = ( (EDGE_MODULE*) item )->m_Start;
ROTATE( ( (EDGE_MODULE*) item )->m_End );
( (EDGE_MODULE*) item )->m_End0 = ( (EDGE_MODULE*) item )->m_End;
break;
case TYPE_TEXTE_MODULE:
ROTATE( ( (TEXTE_MODULE*) item )->GetPosition() );
( (TEXTE_MODULE*) item )->m_Pos0 =
( (TEXTE_MODULE*) item )->GetPosition();
( (TEXTE_MODULE*) item )->m_Pos0 = ( (TEXTE_MODULE*) item )->GetPosition();
( (TEXTE_MODULE*) item )->m_Orient += 900;
break;
......@@ -622,10 +620,12 @@ void ClearMarkItems( MODULE* module )
return;
item = module->m_Drawings;
for( ; item != NULL; item = item->Next() )
item->m_Flags = item->m_Selected = 0;
item = module->m_Pads;
for( ; item != NULL; item = item->Next() )
item->m_Flags = item->m_Selected = 0;
}
......@@ -645,10 +645,12 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
return 0;
pad = module->m_Pads;
for( ; pad != NULL; pad = pad->Next() )
{
pad->m_Selected = 0;
pos = pad->GetPosition();
if( Rect.Contains( pos ) )
{
pad->m_Selected = IS_SELECTED;
......@@ -657,6 +659,7 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
}
item = module->m_Drawings;
for( ; item != NULL; item = item->Next() )
{
item->m_Selected = 0;
......@@ -669,15 +672,18 @@ int MarkItemsInBloc( MODULE* module, EDA_RECT& Rect )
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
break;
case TYPE_TEXTE_MODULE:
pos = ( (TEXTE_MODULE*) item )->GetPosition();
if( Rect.Contains( pos ) )
{
item->m_Selected = IS_SELECTED;
ItemsCount++;
}
break;
default:
......
......@@ -24,22 +24,19 @@
FOOTPRINT_LIBRARY::FOOTPRINT_LIBRARY( FILE * aFile, FILTER_READER * aReader )
{
wxASSERT( m_reader || m_file );
wxASSERT( aFile != NULL );
m_file = aFile;
m_reader = aReader;
m_LineNum = 0;
}
/* function IsLibrary
* Read the library file Header
* return > 0 if this file is a footprint lib
* (currentlu return 1 but could be a value > 1 for future file formats
*/
int FOOTPRINT_LIBRARY::IsLibrary( )
{
char *line;
char buffer[1024];
if( m_reader )
{
m_reader->ReadLine();
......@@ -52,6 +49,7 @@ int FOOTPRINT_LIBRARY::IsLibrary( )
}
StrPurge( line );
if( strnicmp( line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) == 0 )
return 1;
......@@ -59,11 +57,6 @@ int FOOTPRINT_LIBRARY::IsLibrary( )
}
/*
* function RebuildIndex
* Read the full library file and build the list od footprints found
* and do not use the $INDEX ... $EndINDEX section
*/
bool FOOTPRINT_LIBRARY::RebuildIndex()
{
m_List.Clear();
......@@ -76,6 +69,7 @@ bool FOOTPRINT_LIBRARY::RebuildIndex()
{
char * line = m_reader->Line();
StrPurge( line );
if( strnicmp( line, "$MODULE", 7 ) == 0 )
{
sscanf( line + 7, " %s", name );
......@@ -86,6 +80,7 @@ bool FOOTPRINT_LIBRARY::RebuildIndex()
else
{
char line[1024];
while( GetLine( m_file, line, &m_LineNum ) )
{
if( strnicmp( line, "$MODULE", 7 ) == 0 )
......@@ -99,29 +94,30 @@ bool FOOTPRINT_LIBRARY::RebuildIndex()
return true;
}
/* function ReadSectionIndex
* Read the $INDEX ... $EndINDEX section
* list of footprints is stored in m_List
*/
bool FOOTPRINT_LIBRARY::ReadSectionIndex()
{
// Some broken INDEX sections have more than one section
// So we must read the next line after $EndINDEX tag,
// to see if this is not a new $INDEX tag.
bool exit = false;
if( m_reader )
{
while( m_reader->ReadLine() )
{
char * line = m_reader->Line();
StrPurge( line );
if( strnicmp( line, "$INDEX", 6 ) == 0 )
{
exit = false;
while( m_reader->ReadLine() )
{
StrPurge( line );
m_List.Add( FROM_UTF8( line ) );
if( strnicmp( line, "$EndINDEX", 9 ) == 0 )
{
exit = true;
......@@ -136,15 +132,18 @@ bool FOOTPRINT_LIBRARY::ReadSectionIndex()
else
{
char line[1024];
while( GetLine( m_file, line, &m_LineNum ) )
{
if( strnicmp( line, "$INDEX", 6 ) == 0 )
{
exit = false;
while( GetLine( m_file, line, &m_LineNum ) )
{
StrPurge( line );
m_List.Add( FROM_UTF8( line ) );
if( strnicmp( line, "$EndINDEX", 9 ) == 0 )
{
exit = true;
......@@ -153,16 +152,16 @@ bool FOOTPRINT_LIBRARY::ReadSectionIndex()
}
}
else if( exit )
{
break;
}
}
}
return true;
}
/* Function WriteHeader
* Write the library header
*/
bool FOOTPRINT_LIBRARY::WriteHeader()
{
char line[256];
......@@ -171,34 +170,28 @@ bool FOOTPRINT_LIBRARY::WriteHeader()
return true;
}
/* Function WriteSectionIndex
* Write the $INDEX ... $EndINDEX section.
* This section is filled by names in m_List
*/
bool FOOTPRINT_LIBRARY::WriteSectionIndex()
{
fputs( "$INDEX\n", m_file );
for( unsigned ii = 0; ii < m_List.GetCount(); ii++ )
{
fprintf( m_file, "%s\n", TO_UTF8( m_List[ii] ) );
}
fputs( "$EndINDEX\n", m_file );
return true;
}
/* Function WriteEndOfFile
* Write the last line section.
*/
bool FOOTPRINT_LIBRARY::WriteEndOfFile()
{
fputs( "$EndLIBRARY\n", m_file );
return true;
}
/*
* Function FindInList
* Search for aName int m_List and return true if found
*/
bool FOOTPRINT_LIBRARY::FindInList( const wxString & aName )
{
for( unsigned ii = 0; ii < m_List.GetCount(); ii++ )
......@@ -210,11 +203,7 @@ bool FOOTPRINT_LIBRARY::FindInList( const wxString & aName )
return false;
}
/**
* Function RemoveFromList
* Search for aName int m_List and remove it
* @return true if found and removed
*/
bool FOOTPRINT_LIBRARY::RemoveFromList( const wxString & aName )
{
for( unsigned ii = 0; ii < m_List.GetCount(); ii++ )
......@@ -229,10 +218,7 @@ bool FOOTPRINT_LIBRARY::RemoveFromList( const wxString & aName )
return false;
}
/**
* Function SortList
* Sort m_List in alphabetic order
*/
void FOOTPRINT_LIBRARY::SortList()
{
m_List.Sort();
......
......@@ -14,7 +14,7 @@ public:
int m_LineNum; // the line count
private:
FILTER_READER * m_reader; // FILTER_READER to read file. id NULL, use m_file
FILTER_READER * m_reader; // FILTER_READER to read file. If NULL, use m_file
FILE * m_file; // footprint file to read/write.
public:
......@@ -23,7 +23,7 @@ public:
* @param aFile = a FILE * pointer used for write operations,
* and read operations when aReader = NULL
* @param aReader = a FILTER_READER pointer used for read operations
* If NULL, a direct aFILE read is used
* If NULL, a direct aFile read is used
*/
FOOTPRINT_LIBRARY( FILE * aFile, FILTER_READER * aReader = NULL );
......@@ -39,7 +39,7 @@ public:
/**
* function RebuildIndex
* Read the full library file and build the list od footprints found
* Read the full library file and build the list of footprints found
* Do not use the $INDEX ... $EndINDEX section
*/
bool RebuildIndex();
......
......@@ -143,7 +143,9 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
ii--;
}
else
{
timestampzone = item->m_TimeStamp;
}
}
if( m_Collector->GetCount() <= 1 )
......@@ -152,7 +154,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode )
SetCurItem( item );
}
// If the count is 2, and first item is a pad or moduletext, and the 2nd item is its
// If the count is 2, and first item is a pad or module text, and the 2nd item is its
// parent module:
else if( m_Collector->GetCount() == 2
&& ( (*m_Collector)[0]->Type() == TYPE_PAD || (*m_Collector)[0]->Type() ==
......@@ -259,7 +261,7 @@ void PCB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
}
GetScreen()->SetFileName( tmpFileName );
SetTitle( GetScreen()->GetFileName() );
UpdateTitle();
}
oldpos = GetScreen()->GetCrossHairPosition();
......
......@@ -17,7 +17,7 @@
#include "dialog_edit_module_for_Modedit.h"
DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( WinEDA_ModuleEditFrame* aParent,
DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME* aParent,
MODULE* aModule ) :
DIALOG_MODULE_MODULE_EDITOR_BASE( aParent )
{
......
......@@ -17,7 +17,7 @@ class DIALOG_MODULE_MODULE_EDITOR : public DIALOG_MODULE_MODULE_EDITOR_BASE
{
private:
WinEDA_ModuleEditFrame* m_Parent;
FOOTPRINT_EDIT_FRAME* m_Parent;
MODULE* m_CurrentModule;
TEXTE_MODULE* m_ReferenceCopy;
TEXTE_MODULE* m_ValueCopy;
......@@ -30,7 +30,7 @@ private:
public:
// Constructor and destructor
DIALOG_MODULE_MODULE_EDITOR( WinEDA_ModuleEditFrame* aParent, MODULE* aModule );
DIALOG_MODULE_MODULE_EDITOR( FOOTPRINT_EDIT_FRAME* aParent, MODULE* aModule );
~DIALOG_MODULE_MODULE_EDITOR();
private:
......
......@@ -25,7 +25,7 @@ void PCB_EDIT_FRAME::OnConfigurePcbOptions( wxCommandEvent& aEvent )
}
void WinEDA_ModuleEditFrame::InstallOptionsFrame( const wxPoint& pos )
void FOOTPRINT_EDIT_FRAME::InstallOptionsFrame( const wxPoint& pos )
{
DIALOG_GRAPHIC_ITEMS_OPTIONS dlg( this );
dlg.ShowModal();
......
......@@ -56,7 +56,7 @@ private:
/*************************************************************/
void WinEDA_ModuleEditFrame::ToPrinter( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
/*************************************************************/
/* Virtual function:
* Display the print dialog
......
......@@ -20,21 +20,17 @@
static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool erase );
bool erase );
static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC );
static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase );
static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase );
int ArcValue = 900;
static wxPoint MoveVector; // Move vector for move edge
static wxPoint CursorInitialPosition; // Mouse cursor inital position for
// move command
static wxPoint CursorInitialPosition; // Mouse cursor initial position for move command
/* Function to initialise the move function params of a graphic item type
* DRAWSEGMENT
*/
void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
void FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
{
if( Edge == NULL )
return;
......@@ -49,10 +45,7 @@ void WinEDA_ModuleEditFrame::Start_Move_EdgeMod( EDGE_MODULE* Edge, wxDC* DC )
}
/*
* Function to place a graphic item type EDGE_MODULE currently moved
*/
void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge )
void FOOTPRINT_EDIT_FRAME::Place_EdgeMod( EDGE_MODULE* Edge )
{
if( Edge == NULL )
return;
......@@ -75,7 +68,8 @@ void WinEDA_ModuleEditFrame::Place_EdgeMod( EDGE_MODULE* Edge )
/* Redraw the current moved graphic item when mouse is moving
* Use this function to show an existing outline, in move command
*/
static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase )
static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase )
{
BASE_SCREEN* screen = aPanel->GetScreen();
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem();
......@@ -102,7 +96,7 @@ static void ShowCurrentOutlineWhileMoving( EDA_DRAW_PANEL* aPanel, wxDC* aDC, co
* Use this function to show a new outline, in begin command
*/
static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase )
bool aErase )
{
BASE_SCREEN* screen = aPanel->GetScreen();
EDGE_MODULE* Edge = (EDGE_MODULE*) screen->GetCurItem();
......@@ -129,14 +123,7 @@ static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
}
/**
* Function Edit_Edge_Width
* changes the width of module perimeter lines, EDGE_MODULEs.
* param ModuleSegmentWidth (global) = new width
* @param aEdge = edge to edit, or NULL. If aEdge == NULL change
* the width of all footprint's edges
*/
void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* aEdge )
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge )
{
MODULE* Module = GetBoard()->m_Modules;
......@@ -161,12 +148,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Width( EDGE_MODULE* aEdge )
}
/* Change the EDGE_MODULE Edge layer, (The new layer will be asked)
* if Edge == NULL change the layer of the entire footprint edges
* @param Edge = edge to edit, or NULL
* @param DC = current Device Context
*/
void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* Edge )
{
MODULE* Module = GetBoard()->m_Modules;
int new_layer = SILKSCREEN_N_FRONT;
......@@ -176,9 +158,7 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
/* Ask for the new layer */
new_layer = SelectLayer( new_layer,
FIRST_COPPER_LAYER,
LAST_NO_COPPER_LAYER );
new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, LAST_NO_COPPER_LAYER );
if( new_layer < 0 )
return;
......@@ -196,15 +176,19 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
if( Edge == NULL )
{
Edge = (EDGE_MODULE*) (BOARD_ITEM*) Module->m_Drawings;
for( ; Edge != NULL; Edge = Edge->Next() )
{
if( Edge->Type() != TYPE_EDGE_MODULE )
continue;
Edge->SetLayer( new_layer );
}
}
else
{
Edge->SetLayer( new_layer );
}
OnModify();
Module->Set_Rectangle_Encadrement();
......@@ -212,23 +196,16 @@ void WinEDA_ModuleEditFrame::Edit_Edge_Layer( EDGE_MODULE* Edge )
}
/**
* Function Enter_Edge_Width
* Edition of width of module outlines
* Ask for a new width.
* Change the width of EDGE_MODULE aEdge if aEdge != NULL
* @param aEdge = edge to edit, or NULL
* changes g_ModuleSegmentWidth (global) = new width
*/
void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* aEdge )
void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge )
{
wxString buffer;
buffer = ReturnStringFromValue( g_UserUnit, g_ModuleSegmentWidth,
GetScreen()->GetInternalUnits() );
wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer );
if( dlg.ShowModal() != wxID_OK )
return; // cancelled by user
return; // canceled by user
buffer = dlg.GetValue( );
g_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer,
......@@ -244,19 +221,14 @@ void WinEDA_ModuleEditFrame::Enter_Edge_Width( EDGE_MODULE* aEdge )
}
/**
* Function Delete_Edge_Module
* delete EDGE_MODULE Edge
* @param Edge = edge to delete
*/
void WinEDA_ModuleEditFrame::Delete_Edge_Module( EDGE_MODULE* Edge )
void FOOTPRINT_EDIT_FRAME::Delete_Edge_Module( EDGE_MODULE* Edge )
{
if( Edge == NULL )
return;
if( Edge->Type() != TYPE_EDGE_MODULE )
{
DisplayError( this,
wxT( "StructType error: TYPE_EDGE_MODULE expected" ) );
DisplayError( this, wxT( "StructType error: TYPE_EDGE_MODULE expected" ) );
return;
}
......@@ -299,16 +271,9 @@ static void Abort_Move_ModuleOutline( EDA_DRAW_PANEL* Panel, wxDC* DC )
}
/* Create a new edge item (line, arc ..).
* @param Edge = if NULL: create new edge else terminate edge and create a
* new edge
* @param DC = current Device Context
* @param type_edge = S_SEGMENT,S_ARC ..
* @return the new created edge.
*/
EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
wxDC* DC,
int type_edge )
EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
wxDC* DC,
int type_edge )
{
MODULE* module = GetBoard()->m_Modules;
int angle = 0;
......@@ -339,16 +304,17 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
if( module->GetLayer() == LAYER_N_FRONT )
Edge->SetLayer( SILKSCREEN_N_FRONT );
if( module->GetLayer() == LAYER_N_BACK )
Edge->SetLayer( SILKSCREEN_N_BACK );
/* Initialise the starting point of the new segment or arc */
/* Initialize the starting point of the new segment or arc */
Edge->m_Start = GetScreen()->GetCrossHairPosition();
/* Initialise the ending point of the new segment or arc */
/* Initialize the ending point of the new segment or arc */
Edge->m_End = Edge->m_Start;
/* Initialise the relative coordinates */
/* Initialize the relative coordinates */
Edge->m_Start0 = Edge->m_Start - module->m_Pos;
RotatePoint( &Edge->m_Start0, -module->m_Orient );
......@@ -360,7 +326,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
/* Segment creation in progress.
* The ending coordinate is updated by the function
* ShowNewEdgeModule() called on move mouse event
* during the segment craetion
* during the segment creation
*/
else
{
......@@ -373,8 +339,7 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
EDGE_MODULE* newedge = new EDGE_MODULE( module );
newedge->Copy( Edge );
// insert _after_ Edge, which is the same as inserting _before_
// Edge->Next()
// insert _after_ Edge, which is the same as inserting before Edge->Next()
module->m_Drawings.Insert( newedge, Edge->Next() );
Edge->m_Flags = 0;
......@@ -398,25 +363,28 @@ EDGE_MODULE* WinEDA_ModuleEditFrame::Begin_Edge_Module( EDGE_MODULE* Edge,
}
}
else
{
wxMessageBox( wxT( "Begin_Edge() error" ) );
}
}
return Edge;
}
/* Terminate a move or create edge function
*/
void WinEDA_ModuleEditFrame::End_Edge_Module( EDGE_MODULE* Edge )
void FOOTPRINT_EDIT_FRAME::End_Edge_Module( EDGE_MODULE* Edge )
{
MODULE* Module = GetBoard()->m_Modules;
if( Edge )
{
Edge->m_Flags = 0;
/* If last segment length is 0: remove it */
if( Edge->m_Start == Edge->m_End )
Edge->DeleteStructure();
}
Module->Set_Rectangle_Encadrement();
Module->m_LastEdit_Time = time( NULL );
OnModify();
......
......@@ -158,11 +158,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_OPEN_MODULE_EDITOR:
if( m_ModuleEditFrame == NULL )
{
m_ModuleEditFrame =
new WinEDA_ModuleEditFrame( this,
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
m_ModuleEditFrame = new FOOTPRINT_EDIT_FRAME( this,
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
m_ModuleEditFrame->Show( true );
m_ModuleEditFrame->Zoom_Automatique( false );
}
......@@ -170,6 +169,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
if( m_ModuleEditFrame->IsIconized() )
m_ModuleEditFrame->Iconize( false );
m_ModuleEditFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on
......@@ -273,12 +273,14 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
{
int type = GetCurItem()->Type();
if( type == TYPE_TRACK || type == TYPE_VIA )
{
BOARD_CONNECTED_ITEM*item = (BOARD_CONNECTED_ITEM*) GetCurItem();
DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( this, item->GetNet() );
dlg.ShowModal();
}
}
DrawPanel->MoveCursorToCrossHair();
break;
......@@ -314,6 +316,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_PLACE_MICROVIA:
if( !IsMicroViaAcceptable() )
break;
case ID_POPUP_PCB_PLACE_VIA:
DrawPanel->MoveCursorToCrossHair();
if( GetCurItem()->m_Flags & IS_DRAGGED )
......@@ -325,6 +328,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
int v_type = GetBoard()->GetBoardDesignSettings()->m_CurrentViaType;
if( id == ID_POPUP_PCB_PLACE_MICROVIA )
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = VIA_MICROVIA; // place micro via and switch layer
Other_Layer_Route( (TRACK*) GetCurItem(), &dc );
GetBoard()->GetBoardDesignSettings()->m_CurrentViaType = v_type;
......@@ -336,6 +340,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DELETE_TRACKSEG:
if( GetCurItem() == NULL )
break;
DrawPanel->MoveCursorToCrossHair();
SetCurItem( Delete_Segment( &dc, (TRACK*) GetCurItem() ) );
OnModify();
......@@ -386,8 +391,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_DELETE_ZONE:
DrawPanel->MoveCursorToCrossHair();
if( GetCurItem() == NULL )
break;
{
SEGZONE* zsegm = (SEGZONE*) GetCurItem();
int netcode = zsegm->GetNet();
......@@ -476,8 +483,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
* and start move the new corner
*/
zone_cont->Draw( DrawPanel, &dc, GR_XOR );
zone_cont->m_Poly->InsertCorner( zone_cont->m_CornerSelection,
pos.x, pos.y );
zone_cont->m_Poly->InsertCorner( zone_cont->m_CornerSelection, pos.x, pos.y );
zone_cont->m_CornerSelection++;
zone_cont->Draw( DrawPanel, &dc, GR_XOR );
DrawPanel->m_AutoPAN_Request = true;
......@@ -519,6 +525,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_REMOVE_FILLED_AREAS_IN_ALL_ZONES: // Remove all zones :
GetBoard()->m_Zone.DeleteAll(); // remove zone segments used to fill zones.
for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
{
// Remove filled areas in zone
......@@ -526,9 +533,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
zone_container->m_FilledPolysList.clear();
}
SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
SetCurItem( NULL ); // CurItem might be deleted by this command, clear the pointer
test_connexions( NULL );
Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links */
Tst_Ratsnest( NULL, 0 ); // Recalculate the active ratsnest, i.e. the unconnected links
OnModify();
GetBoard()->DisplayInfo( this );
DrawPanel->Refresh();
......@@ -556,12 +563,15 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
{
g_Drag_Pistes_On = false;
break;
}
module = (MODULE*) GetCurItem();
if( module->IsLocked() )
{
wxString msg;
......@@ -570,6 +580,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
GetScreen()->SetCrossHairPosition( ((MODULE*) GetCurItem())->m_Pos );
DrawPanel->MoveCursorToCrossHair();
StartMove_Module( (MODULE*) GetCurItem(), &dc );
......@@ -578,8 +589,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: /* get module by name and move it */
SetCurItem( GetModuleByName() );
module = (MODULE*) GetCurItem();
if( module == NULL )
break;
if( module->IsLocked() )
{
wxString msg;
......@@ -588,6 +601,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
DrawPanel->MoveCursorToCrossHair();
StartMove_Module( module, &dc );
break;
......@@ -601,7 +615,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break;
module = (MODULE*) GetCurItem();
if( module->IsLocked() )
{
wxString msg;
......@@ -610,10 +626,12 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
if( Delete_Module( (MODULE*) GetCurItem(), &dc, true ) )
{
SetCurItem( NULL );
}
break;
case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
......@@ -625,7 +643,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break;
module = (MODULE*) GetCurItem();
if( module->IsLocked() )
{
wxString msg;
......@@ -634,8 +654,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */
SaveCopyInUndoList(GetCurItem(), UR_ROTATED, ((MODULE*)GetCurItem())->m_Pos);
Rotate_Module( &dc, (MODULE*) GetCurItem(), 900, true );
break;
......@@ -648,7 +670,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break;
module = (MODULE*) GetCurItem();
if( module->IsLocked() )
{
wxString msg;
......@@ -657,8 +681,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple rotation, no other edition in progress */
SaveCopyInUndoList(GetCurItem(), UR_ROTATED_CLOCKWISE, ((MODULE*)GetCurItem())->m_Pos);
Rotate_Module( &dc, (MODULE*) GetCurItem(), -900, true );
break;
......@@ -668,9 +694,12 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break;
module = (MODULE*) GetCurItem();
if( module->IsLocked() )
{
wxString msg;
......@@ -679,8 +708,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
if( !(GetCurItem()->m_Flags & IS_MOVED) ) /* This is a simple flip, no other edition in progress */
SaveCopyInUndoList(GetCurItem(), UR_FLIPPED, ((MODULE*)GetCurItem())->m_Pos);
Change_Side_Module( (MODULE*) GetCurItem(), &dc );
break;
......@@ -689,16 +720,20 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
// If the current Item is a pad, text module ...: Get its parent
if( GetCurItem()->Type() != TYPE_MODULE )
SetCurItem( GetCurItem()->GetParent() );
if( !GetCurItem() || GetCurItem()->Type() != TYPE_MODULE )
break;
InstallModuleOptionsFrame( (MODULE*) GetCurItem(), &dc );
DrawPanel->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_DRAG_PAD_REQUEST:
module = (MODULE*) GetCurItem()->GetParent();
if( !module || module->Type() != TYPE_MODULE )
break;
if( module->IsLocked() )
{
wxString msg;
......@@ -707,6 +742,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
g_Drag_Pistes_On = true;
DrawPanel->MoveCursorToCrossHair();
StartMovePad( (D_PAD*) GetCurItem(), &dc );
......@@ -714,8 +750,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_MOVE_PAD_REQUEST:
module = (MODULE*) GetCurItem()->GetParent();
if( !module || module->Type() != TYPE_MODULE )
break;
if( module->IsLocked() )
{
wxString msg;
......@@ -724,6 +762,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
DisplayInfoMessage( this, msg );
break;
}
g_Drag_Pistes_On = false;
DrawPanel->MoveCursorToCrossHair();
StartMovePad( (D_PAD*) GetCurItem(), &dc );
......@@ -785,8 +824,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_SELECT_LAYER:
itmp = SelectLayer( getActiveLayer(), -1, -1 );
if( itmp >= 0 )
setActiveLayer( itmp );
DrawPanel->MoveCursorToCrossHair();
break;
......@@ -796,15 +837,19 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_SELECT_NO_CU_LAYER:
itmp = SelectLayer( getActiveLayer(), FIRST_NO_COPPER_LAYER, -1 );
if( itmp >= 0 )
setActiveLayer( itmp );
DrawPanel->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_SELECT_CU_LAYER:
itmp = SelectLayer( getActiveLayer(), -1, LAST_COPPER_LAYER );
if( itmp >= 0 )
setActiveLayer( itmp );
break;
case ID_POPUP_PCB_SELECT_LAYER_PAIR:
......@@ -814,8 +859,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_TOOLBARH_PCB_SELECT_LAYER:
setActiveLayer( (size_t) m_SelLayerBox->GetLayerSelection());
if( DisplayOpt.ContrastModeDisplay )
DrawPanel->Refresh( true );
break;
case ID_POPUP_PCB_EDIT_TEXTEPCB:
......@@ -873,12 +920,14 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_GETINFO_MARKER:
if( GetCurItem() && GetCurItem()->Type() == TYPE_MARKER_PCB )
( (MARKER_PCB*) GetCurItem() )->DisplayMarkerInfo( this );
DrawPanel->MoveCursorToCrossHair();
break;
case ID_POPUP_PCB_DELETE_DRAWING_LAYER:
if( GetCurItem()->m_Flags != 0 )
break;
Delete_Drawings_All_Layer( GetCurItem()->GetLayer() );
SetCurItem( NULL );
DrawPanel->MoveCursorToCrossHair();
......@@ -897,50 +946,53 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
DrawPanel->MoveCursorToCrossHair();
if( GetCurItem() && (GetCurItem()->IsNew()) )
{
End_Edge( (DRAWSEGMENT*) GetCurItem(), &dc );
SetCurItem( NULL );
}
break;
case ID_POPUP_PCB_STOP_CURRENT_EDGE_ZONE:
DrawPanel->MoveCursorToCrossHair();
if( GetCurItem() && (GetCurItem()->IsNew()) )
{
if( End_Zone( &dc ) )
SetCurItem( NULL );
}
DrawPanel->m_AutoPAN_Request = false;
break;
case ID_POPUP_PCB_DELETE_ZONE_LAST_CREATED_CORNER:
DrawPanel->MoveCursorToCrossHair();
if( GetCurItem() && (GetCurItem()->IsNew()) )
{
if( Delete_LastCreatedCorner( &dc ) == 0 ) // No more segment in outline,
SetCurItem( NULL );
}
break;
case ID_POPUP_PCB_MOVE_TRACK_SEGMENT:
DrawPanel->MoveCursorToCrossHair();
Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(),
&dc, id );
Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id );
break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT:
case ID_POPUP_PCB_MOVE_TRACK_NODE:
DrawPanel->MoveCursorToCrossHair();
Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(),
&dc, id );
Start_MoveOneNodeOrSegment( (TRACK*) GetScreen()->GetCurItem(), &dc, id );
break;
case ID_POPUP_PCB_DRAG_TRACK_SEGMENT_KEEP_SLOPE:
DrawPanel->MoveCursorToCrossHair();
Start_DragTrackSegmentAndKeepSlope( (TRACK*) GetScreen()->GetCurItem(),
&dc );
Start_DragTrackSegmentAndKeepSlope( (TRACK*) GetScreen()->GetCurItem(), &dc );
break;
case ID_POPUP_PCB_BREAK_TRACK:
......@@ -950,11 +1002,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
wxPoint pos = GetScreen()->GetCrossHairPosition();
track->Draw( DrawPanel, &dc, GR_XOR );
PICKED_ITEMS_LIST itemsListPicker;
TRACK* newtrack = CreateLockPoint( GetBoard(), pos, track, &itemsListPicker);
SaveCopyInUndoList(itemsListPicker,UR_UNSPECIFIED);
TRACK* newtrack = CreateLockPoint( GetBoard(), pos, track, &itemsListPicker );
SaveCopyInUndoList( itemsListPicker, UR_UNSPECIFIED );
track->Draw( DrawPanel, &dc, GR_XOR );
newtrack->Draw( DrawPanel, &dc, GR_XOR );
/* compute the new rastnest, because connectivity could change */
/* compute the new ratsnest, because connectivity could change */
test_1_net_connexion( &dc, track->GetNet() );
}
break;
......@@ -997,11 +1049,9 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
default:
wxString msg;
msg.Printf(
wxT( "PCB_EDIT_FRAME::Process_Special_Functions() id %d error" ),
DrawStruct->Type() );
msg.Printf( wxT( "PCB_EDIT_FRAME::Process_Special_Functions() id %d error" ),
DrawStruct->Type() );
DisplayError( this, msg );
break;
}
......@@ -1023,9 +1073,8 @@ static void Process_Move_Item( PCB_EDIT_FRAME* frame, EDA_ITEM* DrawStruct, wxDC
default:
wxString msg;
msg.Printf(
wxT( "PCB_EDIT_FRAME::Move_Item Error: Bad DrawType %d" ),
DrawStruct->Type() );
msg.Printf( wxT( "PCB_EDIT_FRAME::Move_Item Error: Bad DrawType %d" ),
DrawStruct->Type() );
DisplayError( frame, msg );
break;
}
......@@ -1089,6 +1138,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
case TYPE_MARKER_PCB:
if( Item == GetCurItem() )
SetCurItem( NULL );
( (MARKER_PCB*) Item )->Draw( DrawPanel, DC, GR_XOR );
// delete the marker, and free memory. Don't use undo stack.
......@@ -1105,8 +1155,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
default:
{
wxString Line;
Line.Printf( wxT( "Remove: item type %d unknown." ),
Item->Type() );
Line.Printf( wxT( "Remove: item type %d unknown." ), Item->Type() );
DisplayError( this, Line );
}
break;
......@@ -1179,6 +1228,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, int layer )
if( DisplayOpt.ContrastModeDisplay )
DrawPanel->Refresh();
}
// if the via was allowed by DRC, then the layer swap has already
// been done by Other_Layer_Route(). if via not allowed, then
// return now so assignment to setActiveLayer() below doesn't happen.
......
......@@ -39,10 +39,10 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
{
if( m_ModuleEditFrame == NULL )
{
m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this,
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
m_ModuleEditFrame = new FOOTPRINT_EDIT_FRAME( this,
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
}
m_ModuleEditFrame->Load_Module_From_BOARD( Module );
......@@ -57,7 +57,7 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
/*
* Position anchor under the cursor.
*/
void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
void FOOTPRINT_EDIT_FRAME::Place_Ancre( MODULE* pt_mod )
{
wxPoint moveVector;
EDA_ITEM* PtStruct;
......@@ -112,7 +112,7 @@ void WinEDA_ModuleEditFrame::Place_Ancre( MODULE* pt_mod )
}
void WinEDA_ModuleEditFrame::RemoveStruct( EDA_ITEM* Item )
void FOOTPRINT_EDIT_FRAME::RemoveStruct( EDA_ITEM* Item )
{
if( Item == NULL )
return;
......@@ -151,8 +151,7 @@ void WinEDA_ModuleEditFrame::RemoveStruct( EDA_ITEM* Item )
default:
{
wxString Line;
Line.Printf( wxT( " Remove: draw item type %d unknown." ),
Item->Type() );
Line.Printf( wxT( " Remove: draw item type %d unknown." ), Item->Type() );
DisplayError( this, Line );
}
break;
......
......@@ -34,8 +34,6 @@ void PCB_EDIT_FRAME::OnFileHistory( wxCommandEvent& event )
}
/* Handle the read/write file commands
*/
void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
{
int id = event.GetId();
......@@ -78,6 +76,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
else
{
msg = _( "OK to load recovery file " ) + fn.GetFullPath();
if( !IsOK( this, msg ) )
break;
}
......@@ -85,7 +84,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
LoadOnePcbFile( fn.GetFullPath(), false );
fn.SetExt( PcbFileExtension );
GetScreen()->SetFileName( fn.GetFullPath() );
SetTitle( GetScreen()->GetFileName() );
UpdateTitle();
break;
}
......@@ -98,7 +97,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
GetScreen()->GetFileName().Printf( wxT( "%s%cnoname%s" ),
GetChars( wxGetCwd() ), DIR_SEP,
GetChars( PcbFileExtension ) );
SetTitle( GetScreen()->GetFileName() );
UpdateTitle();
ReCreateLayerBox( NULL );
break;
......@@ -116,19 +115,6 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
}
/**
* Function LoadOnePcbFile
* Load a Kicad board (.brd) file.
*
* @param aFileName - File name including path. If empty, a file dialog will
* be displayed.
* @param aAppend - Append board file aFileName to the currently loaded file if true.
* Default = false.
* @param aForceFileDialog - Display the file open dialog even if aFullFileName is
* valid if true; Default = false.
*
* @return False if file load fails or is cancelled by the user, otherwise true.
*/
bool PCB_EDIT_FRAME::LoadOnePcbFile( const wxString& aFileName, bool aAppend,
bool aForceFileDialog )
{
......@@ -183,6 +169,7 @@ the changes?" ) ) )
*/
source = wxFopen( GetScreen()->GetFileName(), wxT( "rt" ) );
if( source == NULL )
{
msg.Printf( _( "File <%s> not found" ), GetChars( GetScreen()->GetFileName() ) );
......@@ -196,6 +183,7 @@ the changes?" ) ) )
/* Read header and TEST if it is a PCB file format */
reader.ReadLine();
if( strncmp( reader.Line(), "PCBNEW-BOARD", 12 ) != 0 )
{
DisplayError( this, wxT( "Unknown file type" ) );
......@@ -204,6 +192,7 @@ the changes?" ) ) )
int ver;
sscanf( reader.Line() , "PCBNEW-BOARD Version %d date", &ver );
if ( ver > g_CurrentVersionPCB )
{
DisplayInfoMessage( this, _( "This file was created by a more recent \
......@@ -220,7 +209,9 @@ this file again." ) );
wxSetWorkingDirectory( wxPathOnly( GetScreen()->GetFileName() ) );
if( aAppend )
{
ReadPcbFile( &reader, true );
}
else
{
// Update the option toolbar
......@@ -252,7 +243,7 @@ this file again." ) );
GetScreen()->GetFileName().Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
SetTitle( GetScreen()->GetFileName() );
UpdateTitle();
UpdateFileHistory( GetScreen()->GetFileName() );
/* Rebuild the new pad list (for drc and ratsnet control ...) */
......@@ -309,9 +300,7 @@ this file again." ) );
}
/* Write the board file
*/
bool PCB_EDIT_FRAME::SavePcbFile( const wxString& FileName )
bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName )
{
wxFileName backupFileName;
wxFileName pcbFileName;
......@@ -322,7 +311,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& FileName )
bool saveok = true;
FILE* dest;
if( FileName == wxEmptyString )
if( aFileName == wxEmptyString )
{
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString,
GetScreen()->GetFileName(), PcbFileWildcard,
......@@ -334,7 +323,9 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& FileName )
GetScreen()->SetFileName( dlg.GetPath() );
}
else
GetScreen()->SetFileName( FileName );
{
GetScreen()->SetFileName( aFileName );
}
/* If changes are made, update the board date */
if( GetScreen()->IsModify() )
......@@ -344,6 +335,9 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& FileName )
pcbFileName = GetScreen()->GetFileName();
if( !IsWritable( pcbFileName ) )
return false;
/* Get the backup file name */
backupFileName = pcbFileName;
backupFileName.SetExt( BACKUP_FILE_EXT );
......@@ -356,10 +350,11 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& FileName )
/* rename the "old" file" from xxx.brd to xxx.000 */
if( backupFileName.FileExists() ) /* Remove the old file xxx.000 (if exists) */
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( pcbFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
msg = _( "Warning: unable to create backup file " ) + backupFileName.GetFullPath();
DisplayError( this, msg, 15 );
DisplayError( this, msg );
saveok = false;
}
}
......@@ -382,7 +377,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& FileName )
if( dest )
{
GetScreen()->SetFileName( pcbFileName.GetFullPath() );
SetTitle( GetScreen()->GetFileName() );
UpdateTitle();
SavePcbFormatAscii( dest );
fclose( dest );
......@@ -400,6 +395,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& FileName )
lowerTxt = _( "Wrote board file: " );
else
lowerTxt = _( "Failed to create " );
lowerTxt += pcbFileName.GetFullPath();
ClearMsgPanel();
......
......@@ -20,11 +20,8 @@
*/
/* Hot keys. Some commands are relative to the item under the mouse cursor
* Commands are case insensitive
*/
void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem )
void FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem )
{
if( aHotKey == 0 )
return;
......@@ -35,7 +32,8 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aP
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
/* Convert lower to upper case (the usual toupper function has problem with non ascii codes like function keys */
/* Convert lower to upper case (the usual toupper function has problem with non ascii
* codes like function keys */
if( (aHotKey >= 'a') && (aHotKey <= 'z') )
aHotKey += 'A' - 'a';
......@@ -90,8 +88,7 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aP
case HK_REDO:
if( ItemFree && !blockActive )
{
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED,
HK_Descr->m_IdMenuEvent );
wxCommandEvent event( wxEVT_COMMAND_TOOL_CLICKED, HK_Descr->m_IdMenuEvent );
wxPostEvent( this, event );
}
break;
......@@ -120,7 +117,7 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aP
}
bool WinEDA_ModuleEditFrame::OnHotkeyEditItem( int aIdCommand )
bool FOOTPRINT_EDIT_FRAME::OnHotkeyEditItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
......@@ -136,7 +133,7 @@ bool WinEDA_ModuleEditFrame::OnHotkeyEditItem( int aIdCommand )
SetCurItem( item );
int evt_type = 0; //Used to post a wxCommandEvent on demand
int evt_type = 0; // Used to post a wxCommandEvent on demand
switch( item->Type() )
{
......@@ -172,7 +169,7 @@ bool WinEDA_ModuleEditFrame::OnHotkeyEditItem( int aIdCommand )
}
bool WinEDA_ModuleEditFrame::OnHotkeyDeleteItem( int aIdCommand )
bool FOOTPRINT_EDIT_FRAME::OnHotkeyDeleteItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
......@@ -188,7 +185,7 @@ bool WinEDA_ModuleEditFrame::OnHotkeyDeleteItem( int aIdCommand )
SetCurItem( item );
int evt_type = 0; //Used to post a wxCommandEvent on demand
int evt_type = 0; // Used to post a wxCommandEvent on demand
switch( item->Type() )
{
......@@ -224,7 +221,7 @@ bool WinEDA_ModuleEditFrame::OnHotkeyDeleteItem( int aIdCommand )
}
bool WinEDA_ModuleEditFrame::OnHotkeyMoveItem( int aIdCommand )
bool FOOTPRINT_EDIT_FRAME::OnHotkeyMoveItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
......@@ -240,7 +237,7 @@ bool WinEDA_ModuleEditFrame::OnHotkeyMoveItem( int aIdCommand )
SetCurItem( item );
int evt_type = 0; //Used to post a wxCommandEvent on demand
int evt_type = 0; // Used to post a wxCommandEvent on demand
switch( item->Type() )
{
......@@ -276,7 +273,7 @@ bool WinEDA_ModuleEditFrame::OnHotkeyMoveItem( int aIdCommand )
}
bool WinEDA_ModuleEditFrame::OnHotkeyRotateItem( int aIdCommand )
bool FOOTPRINT_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand )
{
BOARD_ITEM* item = GetCurItem();
bool itemCurrentlyEdited = item && item->m_Flags;
......
......@@ -72,12 +72,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
/**
* Function Clear_Pcb
* delete all and reinitialize the current board
* @param aQuery = true to prompt user for confirmation, false to initialize silently
*/
bool WinEDA_ModuleEditFrame::Clear_Pcb( bool aQuery )
bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
{
if( GetBoard() == NULL )
return FALSE;
......
......@@ -32,20 +32,10 @@
const wxString ModExportFileExtension( wxT( "emp" ) );
static const wxString ModExportFileWildcard(
_( "Kicad foot print export files (*.emp)|*.emp" ) );
static const wxString ModExportFileWildcard( _( "Kicad foot print export files (*.emp)|*.emp" ) );
/*
* Function Import_Module
* Read a file containing only one footprint.
* Used to import (after exporting) a footprint
* Exported files have the standard ext .emp
* This is the same format as .mod files but restricted to only one footprint
* The import function can also read gpcb footprint file, in Newlib format
* (One footprint per file, Newlib files have no special ext.)
*/
MODULE* WinEDA_ModuleEditFrame::Import_Module( )
MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
{
char* Line;
FILE* file;
......@@ -85,17 +75,19 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( )
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading );
}
// Switch the locale to standard C (needed to print floating point numbers
// like 1.3)
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard();
/* Read header and test file type */
reader.ReadLine();
Line = reader.Line();
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
{
if( strnicmp( Line, "Element", 7 ) == 0 )
{
Footprint_Is_GPCB_Format = true;
}
else
{
DisplayError( this, _( "Not a module file" ) );
......@@ -123,6 +115,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( )
{
module->ReadDescr( &reader );
}
SetLocaleTo_Default(); // revert to the current locale
/* Insert footprint in list*/
......@@ -138,19 +131,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( )
}
/**
* Function Export_Module
* Create a file containing only one footprint.
* Used to export a footprint
* Exported files have the standard ext .emp
* This is the same format as .mod files but restricted to only one footprint
* So Create a new lib (which will contains one module) and export a footprint
* is basically the same thing
* @param aModule = the module to export
* @param aCreateSysLib : true = use default lib path to create lib
* false = use current path or last used path to export the footprint
*/
void WinEDA_ModuleEditFrame::Export_Module( MODULE* aModule, bool aCreateSysLib )
void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule, bool aCreateSysLib )
{
wxFileName fn;
FILE* file;
......@@ -192,8 +173,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* aModule, bool aCreateSysLib
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, fn.GetPath() );
}
// Switch the locale to standard C (needed to read/write floating point numbers
// like 1.3)
// Switch the locale to standard C (needed to read/write floating point numbers like 1.3)
SetLocaleTo_C_standard();
FOOTPRINT_LIBRARY libexport( file );
......@@ -208,13 +188,12 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* aModule, bool aCreateSysLib
SetLocaleTo_Default(); // revert to the current locale
msg.Printf( _( "Module exported in file <%s>" ),
GetChars( fn.GetFullPath() ) );
msg.Printf( _( "Module exported in file <%s>" ), GetChars( fn.GetFullPath() ) );
DisplayInfoMessage( this, msg );
}
void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname )
void FOOTPRINT_EDIT_FRAME::Delete_Module_In_Library( const wxString& aLibname )
{
wxFileName newFileName;
wxFileName oldFileName;
......@@ -223,27 +202,24 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
FILE* out_file, * lib_module;
wxString CmpName, msg;
CmpName = Select_1_Module_From_List( this,
aLibname,
wxEmptyString,
wxEmptyString );
CmpName = Select_1_Module_From_List( this, aLibname, wxEmptyString, wxEmptyString );
if( CmpName == wxEmptyString )
return;
/* Confirmation */
msg.Printf( _( "Ok to delete module %s in library %s" ),
GetChars( CmpName ), GetChars( aLibname ) );
GetChars( CmpName ), GetChars( aLibname ) );
if( !IsOK( this, msg ) )
return;
oldFileName = aLibname;
if( ( lib_module = wxFopen( oldFileName.GetFullPath(),
wxT( "rt" ) ) ) == NULL )
if( ( lib_module = wxFopen( oldFileName.GetFullPath(), wxT( "rt" ) ) ) == NULL )
{
wxString msg;
msg.Printf( _( "Library %s not found" ), GetChars(oldFileName.GetFullPath()) );
msg.Printf( _( "Library %s not found" ), GetChars(oldFileName.GetFullPath() ) );
DisplayError( this, msg );
return;
}
......@@ -264,6 +240,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
/* Read module names. */
input_lib.RebuildIndex();
bool found = input_lib.FindInList( CmpName );
if( !found )
{
fclose( lib_module );
......@@ -291,22 +268,25 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
output_lib.m_List = input_lib.m_List;
output_lib.WriteHeader();
output_lib.RemoveFromList(CmpName);
output_lib.RemoveFromList( CmpName );
output_lib.SortList();
output_lib.WriteSectionIndex();
/* Copy modules. */
rewind( lib_module );
LineNum = input_lib.m_LineNum;
bool copylines = false;
while( GetLine( lib_module, Line, &LineNum ) )
{
StrPurge( Line );
if( strnicmp( Line, "$MODULE", 7 ) == 0 )
{
copylines = true;
sscanf( Line + 7, " %s", Name );
msg = FROM_UTF8( Name );
if( msg.CmpNoCase( CmpName ) == 0 )
{
/* Delete old module (i.e. do not copy description to out_file). */
......@@ -319,6 +299,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
continue;
}
}
if( copylines )
fprintf( out_file, "%s\n", Line );
}
......@@ -335,8 +316,7 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
if( backupFileName.FileExists() )
wxRemoveFile( backupFileName.GetFullPath() );
if( !wxRenameFile( oldFileName.GetFullPath(),
backupFileName.GetFullPath() ) )
if( !wxRenameFile( oldFileName.GetFullPath(), backupFileName.GetFullPath() ) )
{
DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) );
return;
......@@ -350,17 +330,11 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const wxString& aLibname
}
msg.Printf( _( "Component %s deleted in library %s" ), GetChars( CmpName ),
GetChars( oldFileName.GetFullPath() ) );
GetChars( oldFileName.GetFullPath() ) );
SetStatusText( msg );
}
/**
* Function Archive_Modules
* Save in the library:
* All new modules (ie modules not found in this lib) (if NewModulesOnly == true)
* all modules (if NewModulesOnly == false)
*/
void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOnly )
{
int ii, NbModules = 0;
......@@ -374,6 +348,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
}
path = wxGetApp().ReturnLastVisitedLibraryPath();
if( LibName.IsEmpty() )
{
wxFileDialog dlg( this, _( "Library" ), path,
......@@ -393,8 +368,8 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
if( !NewModulesOnly && file_exists )
{
wxString msg;
msg.Printf( _( "File %s exists, OK to replace ?" ),
GetChars( fileName ) );
msg.Printf( _( "File %s exists, OK to replace ?" ), GetChars( fileName ) );
if( !IsOK( this, msg ) )
return;
}
......@@ -405,12 +380,14 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
if( !NewModulesOnly || !file_exists )
{
FILE* lib_module;
if( ( lib_module = wxFopen( fileName, wxT( "w+t" ) ) ) == NULL )
{
wxString msg = _( "Unable to create " ) + fileName;
DisplayError( this, msg );
return;
}
FOOTPRINT_LIBRARY new_lib( lib_module );
new_lib.WriteHeader();
new_lib.WriteSectionIndex();
......@@ -420,6 +397,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
/* Calculate the number of modules. */
Module = (MODULE*) GetBoard()->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() )
NbModules++;
......@@ -427,6 +405,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
DisplayActivity( 0, wxEmptyString );
Module = (MODULE*) GetBoard()->m_Modules;
for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() )
{
if( Save_Module_In_Library( fileName, Module,
......@@ -434,6 +413,7 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
false ) == 0 )
break;
DisplayActivity( (int) ( ii * step ), wxEmptyString );
/* Check for request to stop backup (ESCAPE key actuated) */
if( DrawPanel->m_AbortRequest )
break;
......@@ -441,17 +421,6 @@ void PCB_BASE_FRAME::Archive_Modules( const wxString& LibName, bool NewModulesOn
}
/**
* Function Save_Module_In_Library
* Save in an existing library a given footprint
* @param aLibName = name of the library to use
* @param aModule = the given footprint
* @param aOverwrite = true to overwrite an existing footprint, false to abort
* an existing footprint is found
* @param aDisplayDialog = true to display a dialog to enter or confirm the
* footprint name
* @return : true if OK, false if abort
*/
bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
MODULE* aModule,
bool aOverwrite,
......@@ -470,26 +439,35 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
aModule->DisplayInfo( this );
if( !wxFileExists( aLibName ) )
newFileName = aLibName;
if( !newFileName.FileExists( aLibName ) )
{
msg.Printf( _( "Library %s not found" ), GetChars( aLibName ) );
msg.Printf( _( "Library %s not found." ), GetChars( aLibName ) );
DisplayError( this, msg );
return false;
}
if( !IsWritable( newFileName ) )
return false;
/* Ask for the footprint name in lib */
Name_Cmp = aModule->m_LibRef;
if( aDisplayDialog )
{
wxTextEntryDialog dlg( this, _( "Name:" ), _( "Save module" ), Name_Cmp );
if( dlg.ShowModal() != wxID_OK )
return false; // cancelled by user
Name_Cmp = dlg.GetValue();
Name_Cmp.Trim( true );
Name_Cmp.Trim( false );
if( Name_Cmp.IsEmpty() )
return false;
aModule->m_LibRef = Name_Cmp;
}
......@@ -513,8 +491,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
if( ! input_lib.IsLibrary() )
{
fclose( lib_module );
msg.Printf( _( "File %s is not a eeschema library" ),
GetChars( aLibName ) );
msg.Printf( _( "File %s is not a eeschema library" ), GetChars( aLibName ) );
DisplayError( this, msg );
return false;
}
......@@ -522,6 +499,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
/* Read footprints in lib: - search for an existing footprint */
input_lib.RebuildIndex();
bool module_exists = input_lib.FindInList( Name_Cmp );
if( module_exists )
{
// an existing footprint is found in current lib
......@@ -531,6 +509,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
msg << LineNum;
SetStatusText( msg );
}
if( !aOverwrite ) // Do not save the given footprint: an old one exists
{
fclose( lib_module );
......@@ -540,7 +519,6 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
/* Creates the new library */
newFileName = aLibName;
newFileName.SetExt( FILETMP_EXT );
if( ( dest = wxFopen( newFileName.GetFullPath(), wxT( "w+t" ) ) ) == NULL )
......@@ -553,12 +531,12 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
wxBeginBusyCursor();
// Switch the locale to standard C (needed to print floating point numbers
// like 1.3)
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard();
FOOTPRINT_LIBRARY output_lib( dest );
output_lib.m_List = input_lib.m_List;
if( ! module_exists )
output_lib.m_List.Add( Name_Cmp );
......@@ -573,6 +551,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
// Copy footprints, until the old footprint to delete
bool skip_header = true;
while( GetLine( lib_module, Line, &LineNum ) )
{
StrPurge( Line );
......@@ -592,6 +571,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
{
sscanf( Line + 7, " %s", Name );
msg = FROM_UTF8( Name );
if( msg.CmpNoCase( Name_Cmp ) == 0 )
{
/* skip old footprint descr (delete from the lib) */
......@@ -604,6 +584,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
continue;
}
}
fprintf( dest, "%s\n", Line );
}
......@@ -649,16 +630,6 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibName,
}
/**
* Function Create_1_Module
* Creates a new module or footprint : A new module contains 2 texts :
* First = REFERENCE
* Second = VALUE: "VAL**"
* the new module is added to the board module list
* @param aModuleName = name of the new footprint
* (will the component reference in board)
* @return a pointer to the new module
*/
MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
{
MODULE* Module;
......@@ -671,21 +642,23 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
if( moduleName.IsEmpty() )
{
wxTextEntryDialog dlg( this, _( "Module Reference:" ),
_( "Module Creation" ), moduleName );
_( "Module Creation" ), moduleName );
if( dlg.ShowModal() != wxID_OK )
return NULL; //Aborted by user
moduleName = dlg.GetValue();
}
moduleName.Trim( true );
moduleName.Trim( false );
if( moduleName.IsEmpty( ) )
{
DisplayInfoMessage( this, _( "No reference, aborted" ) );
return NULL;
}
// Creates the new module and add it to the head of the linked list of
// modules
// Creates the new module and add it to the head of the linked list of modules
Module = new MODULE( GetBoard() );
GetBoard()->Add( Module );
......@@ -715,8 +688,10 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
}
void WinEDA_ModuleEditFrame::Select_Active_Library()
void FOOTPRINT_EDIT_FRAME::Select_Active_Library()
{
wxString msg;
if( g_LibName_List.GetCount() == 0 )
return;
......@@ -725,29 +700,44 @@ void WinEDA_ModuleEditFrame::Select_Active_Library()
if( dlg.ShowModal() != wxID_OK )
return;
m_CurrentLib = dlg.GetTextSelection();
wxFileName fileName = wxFileName( wxEmptyString, dlg.GetTextSelection(), ModuleFileExtension );
fileName = wxGetApp().FindLibraryPath( fileName );
UpdateTitle();
if( fileName.IsOk() && fileName.FileExists() )
{
m_CurrentLib = dlg.GetTextSelection();
}
else
{
msg.Printf( _( "The footprint library <%s> could not be found in any of the search paths." ),
GetChars( dlg.GetTextSelection() ) );
DisplayError( this, msg );
m_CurrentLib.Empty();
}
return;
UpdateTitle();
}
int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
int FOOTPRINT_EDIT_FRAME::Create_Librairie( const wxString& aLibName )
{
FILE* lib_module;
wxString msg;
wxFileName fileName = aLibName;
if( wxFileExists( LibName ) )
if( fileName.FileExists() )
{
msg = _( "Library exists " ) + LibName;
msg.Printf( _( "Library <%s> already exists." ), GetChars( fileName.GetFullPath() ) );
DisplayError( this, msg );
return 0;
}
if( ( lib_module = wxFopen( LibName, wxT( "wt" ) ) ) == NULL )
if( !IsWritable( fileName ) )
return 0;
if( ( lib_module = wxFopen( fileName.GetFullPath(), wxT( "wt" ) ) ) == NULL )
{
msg = _( "Unable to create " ) + LibName;
msg = _( "Unable to create " ) + fileName.GetFullPath();
DisplayError( this, msg );
return -1;
}
......
......@@ -24,13 +24,8 @@ static void DisplayCmpDoc( wxString& Name );
static FOOTPRINT_LIST MList;
/**
* Function Load_Module_From_BOARD
* load in Modedit a footfrint from the main board
* @param Module = the module to load. If NULL, a module reference will we asked to user
* @return true if a module isloaded, false otherwise.
*/
bool WinEDA_ModuleEditFrame::Load_Module_From_BOARD( MODULE* Module )
bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* Module )
{
MODULE* NewModule;
PCB_BASE_FRAME* parent = (PCB_BASE_FRAME*) GetParent();
......@@ -109,8 +104,8 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
{
AllowWildSeach = false;
keys = ModuleName.AfterFirst( '=' );
ModuleName = Select_1_Module_From_List( this, library, wxEmptyString,
keys );
ModuleName = Select_1_Module_From_List( this, library, wxEmptyString, keys );
if( ModuleName.IsEmpty() ) /* Cancel command */
{
DrawPanel->MoveCursorToCrossHair();
......@@ -121,8 +116,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
|| ( ModuleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
{
AllowWildSeach = false;
ModuleName = Select_1_Module_From_List( this, library, ModuleName,
wxEmptyString );
ModuleName = Select_1_Module_From_List( this, library, ModuleName, wxEmptyString );
if( ModuleName.IsEmpty() )
{
DrawPanel->MoveCursorToCrossHair();
......@@ -137,15 +131,17 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
AllowWildSeach = false;
wxString wildname = wxChar( '*' ) + ModuleName + wxChar( '*' );
ModuleName = wildname;
ModuleName = Select_1_Module_From_List( this, library, ModuleName,
wxEmptyString );
ModuleName = Select_1_Module_From_List( this, library, ModuleName, wxEmptyString );
if( ModuleName.IsEmpty() )
{
DrawPanel->MoveCursorToCrossHair();
return NULL; /* Cancel command. */
}
else
{
module = Get_Librairie_Module( library, ModuleName, true );
}
}
GetScreen()->SetCrossHairPosition( curspos );
......@@ -168,6 +164,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& library, wxDC*
* rebuild only the pad and list of nets ( faster)
*/
// GetBoard()->m_Pcb->m_NetInfo->BuildListOfNets();
RecalculateAllTracksNetcode();
......@@ -208,8 +205,7 @@ MODULE* PCB_BASE_FRAME::Get_Librairie_Module( const wxString& aLibraryFullFilena
if( one_lib )
fn = aLibraryFullFilename;
else
fn = wxFileName( wxEmptyString, g_LibName_List[ii],
ModuleFileExtension );
fn = wxFileName( wxEmptyString, g_LibName_List[ii], ModuleFileExtension );
tmp = wxGetApp().FindLibraryPath( fn );
......@@ -219,9 +215,9 @@ MODULE* PCB_BASE_FRAME::Get_Librairie_Module( const wxString& aLibraryFullFilena
{
msg.Printf( _( "PCB footprint library file <%s> not found in search paths." ),
GetChars( fn.GetFullName() ) );
wxMessageBox( msg, _( "Library Load Error" ),
wxOK | wxICON_ERROR, this );
wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
}
continue;
}
......@@ -231,8 +227,7 @@ MODULE* PCB_BASE_FRAME::Get_Librairie_Module( const wxString& aLibraryFullFilena
{
msg.Printf( _( "Could not open PCB footprint library file <%s>." ),
GetChars( tmp ) );
wxMessageBox( msg, _( "Library Load Error" ),
wxOK | wxICON_ERROR, this );
wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
continue;
}
......@@ -249,8 +244,7 @@ MODULE* PCB_BASE_FRAME::Get_Librairie_Module( const wxString& aLibraryFullFilena
{
msg.Printf( _( "<%s> is not a valid Kicad PCB footprint library file." ),
GetChars( tmp ) );
wxMessageBox( msg, _( "Library Load Error" ),
wxOK | wxICON_ERROR, this );
wxMessageBox( msg, _( "Library Load Error" ), wxOK | wxICON_ERROR, this );
return NULL;
}
......@@ -312,7 +306,7 @@ MODULE* PCB_BASE_FRAME::Get_Librairie_Module( const wxString& aLibraryFullFilena
* void, list all modules)
* @param aMask = Display filter (wildcard)( Mask = wxEmptyString if not used )
* @param aKeyWord = keyword list, to display a filtered list of module having
* one (or more) of these keyworks in their keywork list
* one (or more) of these keyworks in their keyword list
* ( aKeyWord = wxEmptyString if not used )
*
* @return wxEmptyString if abort or fails, or the selected module name if Ok
......@@ -350,13 +344,16 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
{
wxString& candidate = MList.GetItem(ii).m_Module;
if( WildCompareString( aMask, candidate, false ) )
footprint_names_list.Add( candidate );
}
}
else // Create the full list of modules
{
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
footprint_names_list.Add( MList.GetItem(ii).m_Module );
}
if( footprint_names_list.GetCount() )
{
......@@ -401,16 +398,10 @@ static void DisplayCmpDoc( wxString& Name )
}
/**
* Function Select_1_Module_From_BOARD
* Display the list of modules currently existing on the BOARD
* @return a pointer to a module if this module is selected or NULL otherwise
* @param aPcb = the board from modules can be loaded
*/
MODULE* WinEDA_ModuleEditFrame::Select_1_Module_From_BOARD( BOARD* aPcb )
MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
{
MODULE* Module;
static wxString OldName; /* Save name of last module selectec. */
static wxString OldName; /* Save name of last module selected. */
wxString CmpName, msg;
wxArrayString listnames;
......@@ -432,6 +423,7 @@ MODULE* WinEDA_ModuleEditFrame::Select_1_Module_From_BOARD( BOARD* aPcb )
OldName = CmpName;
Module = aPcb->m_Modules;
for( ; Module != NULL; Module = (MODULE*) Module->Next() )
{
if( CmpName == Module->m_Reference->m_Text )
......
......@@ -13,10 +13,8 @@
#include "protos.h"
#include "pcbnew_id.h"
/**
* @brief (Re)Create the menubar for the module editor frame
*/
void WinEDA_ModuleEditFrame::ReCreateMenuBar()
void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
{
// Create and try to get the current menubar
wxMenuBar* menuBar = GetMenuBar();
......@@ -28,6 +26,7 @@ void WinEDA_ModuleEditFrame::ReCreateMenuBar()
// Delete all existing menus so they can be rebuilt.
// This allows language changes of the menu text on the fly.
menuBar->Freeze();
while( menuBar->GetMenuCount() )
delete menuBar->Remove(0);
......
......@@ -25,7 +25,7 @@
#include "collectors.h"
BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode )
{
BOARD_ITEM* item = GetCurItem();
......@@ -49,19 +49,18 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
scanList = GENERAL_COLLECTOR::ModulesAndTheirItems;
}
m_Collector->Collect( GetBoard(), scanList, GetScreen()->RefPos(
true ), guide );
m_Collector->Collect( GetBoard(), scanList, GetScreen()->RefPos( true ), guide );
/* Remove redundancies: when an item is found, we can remove the
* module from list
*/
/* Remove redundancies: when an item is found, we can remove the module from list */
if( m_Collector->GetCount() > 1 )
{
for( int ii = 0; ii < m_Collector->GetCount(); ii++ )
{
item = (*m_Collector)[ii];
if( item->Type() != TYPE_MODULE )
continue;
m_Collector->Remove( ii );
ii--;
}
......@@ -72,21 +71,20 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
item = (*m_Collector)[0];
SetCurItem( item );
}
else // we can't figure out which item user wants, do popup menu so user
// can choose
else // we can't figure out which item user wants, do popup menu so user can choose
{
wxMenu itemMenu;
/* Give a title to the selection menu. This is also a cancel
* menu item **/
wxMenuItem* item_title =
new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) );
/* Give a title to the selection menu. This is also a cancel menu item **/
wxMenuItem* item_title = new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) );
#ifdef __WINDOWS__
wxFont bold_font( *wxNORMAL_FONT );
bold_font.SetWeight( wxFONTWEIGHT_BOLD );
bold_font.SetStyle( wxFONTSTYLE_ITALIC );
item_title->SetFont( bold_font );
#endif
itemMenu.Append( item_title );
itemMenu.AppendSeparator();
......@@ -117,11 +115,9 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
// item is selected
DrawPanel->MoveCursorToCrossHair();
DrawPanel->m_IgnoreMouseEvents = false;
DrawPanel->m_IgnoreMouseEvents = FALSE;
// The function ProcessItemSelection() has set the current item, return
// it.
// The function ProcessItemSelection() has set the current item, return it.
item = GetCurItem();
}
......@@ -133,17 +129,13 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
return item;
}
/**
* Function LoadModuleFromBoard
* called from the main toolbar
* to load a footprint from board mainly to edit it
*/
void WinEDA_ModuleEditFrame::LoadModuleFromBoard( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event )
{
if( GetScreen()->IsModify() )
if( GetScreen()->IsModify() )
{
if( !IsOK( this,
_( "Current footprint changes will be lost and this operation cannot be undone. Continue ?" ) ) )
_( "Current footprint changes will be lost and this operation cannot be undone. Continue?" ) ) )
return;
}
......@@ -158,7 +150,7 @@ void WinEDA_ModuleEditFrame::LoadModuleFromBoard( wxCommandEvent& event )
}
void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
int id = event.GetId();
wxPoint pos;
......@@ -227,11 +219,12 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_DELETE_PART:
{
wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib,
ModuleFileExtension );
wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension );
wxString full_libraryfilename = wxGetApp().FindLibraryPath( fn );
if( wxFileName::FileExists( full_libraryfilename ) )
Delete_Module_In_Library( full_libraryfilename );
break;
}
......@@ -252,8 +245,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
GetBoard()->m_NetInfo->BuildListOfNets();
redraw = true;
module->SetPosition( wxPoint( 0, 0 ) );
if( GetBoard()->m_Modules )
GetBoard()->m_Modules->m_Flags = 0;
Zoom_Automatique( false );
}
break;
......@@ -286,14 +281,14 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
if( module_in_edit->m_Link ) // this is not a new module ...
{
source_module = mainpcb->m_Modules;
for( ;
source_module != NULL;
source_module = (MODULE*) source_module->Next() )
for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() )
{
if( module_in_edit->m_Link == source_module->m_TimeStamp )
break;
}
}
if( ( source_module == NULL )
&& ( id == ID_MODEDIT_UPDATE_MODULE_IN_BOARD ) ) // source not found
{
......@@ -331,6 +326,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
PICKED_ITEMS_LIST pickList;
pcbframe->Exchange_Module( source_module, newmodule, &pickList );
newmodule->m_TimeStamp = module_in_edit->m_Link;
if( pickList.GetCount() )
pcbframe->SaveCopyInUndoList( pickList, UR_UNSPECIFIED );
}
......@@ -354,22 +350,27 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_MODEDIT_IMPORT_PART:
if( ! Clear_Pcb( true ) )
break; // //this command is aborted
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
GetScreen()->SetCrossHairPosition( wxPoint( 0, 0 ) );
Import_Module( );
Import_Module();
redraw = true;
if( GetBoard()->m_Modules )
GetBoard()->m_Modules->m_Flags = 0;
GetScreen()->ClrModify();
Zoom_Automatique( false );
if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
break;
case ID_MODEDIT_EXPORT_PART:
if( GetBoard()->m_Modules )
Export_Module( GetBoard()->m_Modules, FALSE );
Export_Module( GetBoard()->m_Modules, false );
break;
case ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART:
......@@ -390,6 +391,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
full_libraryfilename = wxGetApp().FindLibraryPath( fn );
}
wxLogDebug( wxT( "Loading module from library " ) + full_libraryfilename );
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
Clear_Pcb( true );
......@@ -407,20 +410,27 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
{
TEXTE_MODULE* ref = GetBoard()->m_Modules->m_Reference;
TEXTE_MODULE* val = GetBoard()->m_Modules->m_Value;
if( val && ref )
{
ref->m_Type = TEXT_is_REFERENCE; // just in case ...
if( ref->m_Text.Length() == 0 )
ref->m_Text = L"Ref**";
val->m_Type = TEXT_is_VALUE; // just in case ...
if( val->m_Text.Length() == 0 )
val->m_Text = L"Val**";
}
}
GetScreen()->ClrModify();
Zoom_Automatique( false );
if( m_Draw3DFrame )
m_Draw3DFrame->NewDisplay();
break;
case ID_MODEDIT_PAD_SETTINGS:
......@@ -434,11 +444,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
if( GetBoard()->m_Modules )
{
SetCurItem( GetBoard()->m_Modules );
DIALOG_MODULE_MODULE_EDITOR dialog( this,
(MODULE*) GetScreen()->
GetCurItem() );
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()-> GetCurItem() );
int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->m_Flags = 0;
if( ret > 0 )
DrawPanel->Refresh();
}
......@@ -464,12 +473,12 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_EDIT_MODULE:
{
DIALOG_MODULE_MODULE_EDITOR dialog( this,
(MODULE*) GetScreen()->GetCurItem() );
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) GetScreen()->GetCurItem() );
int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->m_Flags = 0;
GetScreen()->GetCurItem()->m_Flags = 0;
DrawPanel->MoveCursorToCrossHair();
if( ret > 0 )
DrawPanel->Refresh();
}
......@@ -515,8 +524,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_EDIT_TEXTMODULE:
{
InstallTextModOptionsFrame(
(TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
InstallTextModOptionsFrame( (TEXTE_MODULE*) GetScreen()->GetCurItem(), &dc );
DrawPanel->MoveCursorToCrossHair();
}
break;
......@@ -551,11 +559,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PCB_STOP_CURRENT_DRAWING:
DrawPanel->MoveCursorToCrossHair();
if( (GetScreen()->GetCurItem()->m_Flags & IS_NEW) )
{
End_Edge_Module( (EDGE_MODULE*) GetScreen()->GetCurItem() );
SetCurItem( NULL );
}
break;
case ID_POPUP_PCB_ENTER_EDGE_WIDTH:
......@@ -566,36 +576,37 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
{
edge = (EDGE_MODULE*) GetScreen()->GetCurItem();
}
Enter_Edge_Width( edge );
DrawPanel->MoveCursorToCrossHair();
if( edge )
DrawPanel->Refresh();
}
break;
case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE:
DrawPanel->MoveCursorToCrossHair();
Edit_Edge_Width( (EDGE_MODULE*) GetScreen()->GetCurItem() );
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_POPUP_PCB_EDIT_WIDTH_ALL_EDGE:
DrawPanel->MoveCursorToCrossHair();
Edit_Edge_Width( NULL );
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_POPUP_PCB_EDIT_LAYER_CURRENT_EDGE:
DrawPanel->MoveCursorToCrossHair();
Edit_Edge_Layer( (EDGE_MODULE*) GetScreen()->GetCurItem() );
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_POPUP_PCB_EDIT_LAYER_ALL_EDGE:
DrawPanel->MoveCursorToCrossHair();
Edit_Edge_Layer( NULL );
DrawPanel->Refresh( );
DrawPanel->Refresh();
break;
case ID_POPUP_PCB_DELETE_EDGE:
......@@ -619,11 +630,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_PCB_PAD_SETUP:
{
BOARD_ITEM* item = GetCurItem();
if( item )
{
if( item->Type() != TYPE_PAD )
item = NULL;
}
InstallPadOptionsFrame( (D_PAD*) item );
}
break;
......@@ -634,14 +647,14 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
case ID_POPUP_PLACE_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_MOVE;
DrawPanel->m_AutoPAN_Request = FALSE;
DrawPanel->m_AutoPAN_Request = false;
HandleBlockPlace( &dc );
break;
case ID_POPUP_COPY_BLOCK:
GetScreen()->m_BlockLocate.m_Command = BLOCK_COPY;
GetScreen()->m_BlockLocate.SetMessageBlock( this );
DrawPanel->m_AutoPAN_Request = FALSE;
DrawPanel->m_AutoPAN_Request = false;
HandleBlockPlace( &dc );
break;
......@@ -671,7 +684,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
default:
DisplayError( this,
wxT( "WinEDA_ModuleEditFrame::Process_Special_Functions error" ) );
wxT( "FOOTPRINT_EDIT_FRAME::Process_Special_Functions error" ) );
break;
}
......@@ -680,13 +693,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
}
/* Execute a geometric transform on the current footprint.
* The footprint, after transform is always in reference position and
* orientation:
* position 0,0
* orientation 0, component side.
*/
void WinEDA_ModuleEditFrame::Transform( MODULE* module, int transform )
void FOOTPRINT_EDIT_FRAME::Transform( MODULE* module, int transform )
{
D_PAD* pad = module->m_Pads;
EDA_ITEM* PtStruct = module->m_Drawings;
......@@ -710,10 +717,13 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, int transform )
module->m_Reference->m_Pos0 = module->m_Reference->m_Pos;
module->m_Reference->m_Orient += angle;
if( module->m_Reference->m_Orient >= 1800 )
module->m_Reference->m_Orient -= 1800;
module->m_Value->m_Pos0 = module->m_Value->m_Pos;
module->m_Value->m_Orient += angle;
if( module->m_Value->m_Orient >= 1800 )
module->m_Value->m_Orient -= 1800;
......@@ -742,6 +752,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, int transform )
NEGATE( pad->m_Pos0.y );
NEGATE( pad->m_Offset.y );
NEGATE( pad->m_DeltaSize.y );
if( pad->m_Orient )
pad->m_Orient = 3600 - pad->m_Orient;
}
......@@ -750,6 +761,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, int transform )
textmod = module->m_Reference;
NEGATE( textmod->m_Pos.y );
NEGATE( textmod->m_Pos0.y );
if( textmod->m_Orient )
textmod->m_Orient = 3600 - textmod->m_Orient;
......@@ -757,6 +769,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, int transform )
textmod = module->m_Value;
NEGATE( textmod->m_Pos.y );
NEGATE( textmod->m_Pos0.y );
if( textmod->m_Orient )
textmod->m_Orient = 3600 - textmod->m_Orient;
......@@ -803,7 +816,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, int transform )
}
void WinEDA_ModuleEditFrame::OnVerticalToolbar( wxCommandEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnVerticalToolbar( wxCommandEvent& aEvent )
{
int id = aEvent.GetId();
......@@ -840,7 +853,9 @@ void WinEDA_ModuleEditFrame::OnVerticalToolbar( wxCommandEvent& aEvent )
case ID_MODEDIT_PAD_TOOL:
if( GetBoard()->m_Modules )
{
SetToolID( id, wxCURSOR_PENCIL, _( "Add pad" ) );
}
else
{
SetToolID( id, wxCURSOR_ARROW, _( "Pad settings" ) );
......
......@@ -19,9 +19,8 @@
#include "hotkeys.h"
/* Handle the left click in footprint editor
*/
void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
void FOOTPRINT_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
{
BOARD_ITEM* item = GetCurItem();
......@@ -66,6 +65,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( !wxGetKeyState( WXK_SHIFT ) && !wxGetKeyState( WXK_ALT )
&& !wxGetKeyState( WXK_CONTROL ) )
item = ModeditLocateAndDisplay();
SetCurItem( item );
}
......@@ -83,6 +83,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
if( GetToolId() == ID_MODEDIT_CIRCLE_TOOL )
shape = S_CIRCLE;
if( GetToolId() == ID_MODEDIT_ARC_TOOL )
shape = S_ARC;
......@@ -107,7 +108,9 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
SetCurItem( Begin_Edge_Module( (EDGE_MODULE*) item, DC, 0 ) );
}
else
{
DisplayError( this, wxT( "ProcessCommand error: item flags error" ) );
}
}
break;
......@@ -171,7 +174,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
break;
default:
DisplayError( this, wxT( "WinEDA_ModuleEditFrame::ProcessCommand error" ) );
DisplayError( this, wxT( "FOOTPRINT_EDIT_FRAME::ProcessCommand error" ) );
SetToolID( ID_NO_TOOL_SELECTED, DrawPanel->GetDefaultCursor(), wxEmptyString );
}
......@@ -179,11 +182,7 @@ void WinEDA_ModuleEditFrame::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
}
/* Handle the right click in the footprint editor:
* Create the pull up menu
* After this menu is built, the standard ZOOM menu is added
*/
bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
{
BOARD_ITEM* item = GetCurItem();
wxString msg;
......@@ -358,14 +357,14 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopM
case TYPE_SCREEN:
case TYPE_NOT_INIT:
case TYPE_PCB:
msg.Printf( wxT( "WinEDA_ModuleEditFrame::OnRightClick Error: illegal DrawType %d" ),
item->Type() );
msg.Printf( wxT( "FOOTPRINT_EDIT_FRAME::OnRightClick Error: illegal DrawType %d" ),
item->Type() );
DisplayError( this, msg );
break;
default:
msg.Printf( wxT( "WinEDA_ModuleEditFrame::OnRightClick Error: unknown DrawType %d" ),
item->Type() );
msg.Printf( wxT( "FOOTPRINT_EDIT_FRAME::OnRightClick Error: unknown DrawType %d" ),
item->Type() );
DisplayError( this, msg );
break;
}
......@@ -386,10 +385,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos, wxMenu* PopM
}
/* Handle the double click in the footprint editor:
* If the double clicked item is editable: call the corresponding editor.
*/
void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
{
BOARD_ITEM* item = GetCurItem();
......@@ -420,6 +416,7 @@ void WinEDA_ModuleEditFrame::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
int ret = dialog.ShowModal();
GetScreen()->GetCurItem()->m_Flags = 0;
DrawPanel->MoveCursorToCrossHair();
if( ret > 0 )
DrawPanel->Refresh();
}
......
......@@ -13,17 +13,9 @@
#include "protos.h"
/**
* Function SaveCopyInUndoList.
* Creates a new entry in undo list of commands.
* add a picker to handle aItemToCopy
* @param aItem = the board item modified by the command to undo
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
* @param aTransformPoint = the reference point of the transformation, for commands like move
*/
void WinEDA_ModuleEditFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{
EDA_ITEM* item;
MODULE* CopyItem;
......@@ -47,31 +39,16 @@ void WinEDA_ModuleEditFrame::SaveCopyInUndoList( BOARD_ITEM* aItem,
}
/**
* Function SaveCopyInUndoList (overloaded).
* Creates a new entry in undo list of commands.
* add a list of pickers to handle a list of items
* @param aItemsList = the list of items modified by the command to undo
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
* @param aTransformPoint = the reference point of the transformation, for commands like move
*/
void WinEDA_ModuleEditFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{
// Currently unused in modedit, because the module itself is saved for each change
wxMessageBox( wxT( "SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList..) not yet in use" ) );
}
/********************************************************************************/
void WinEDA_ModuleEditFrame::GetComponentFromRedoList( wxCommandEvent& event )
/********************************************************************************/
/* Redo the last edition:
* - Place the current edited library component in undo list
* - Get old version of the current edited library component
*/
void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event )
{
if( GetScreen()->GetRedoCommandCount() <= 0 )
return;
......@@ -99,14 +76,7 @@ void WinEDA_ModuleEditFrame::GetComponentFromRedoList( wxCommandEvent& event )
}
/***************************************************************************/
void WinEDA_ModuleEditFrame::GetComponentFromUndoList( wxCommandEvent& event )
/***************************************************************************/
/* Undo the last edition:
* - Place the current edited library component in Redo list
* - Get old version of the current edited library component
*/
void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event )
{
if( GetScreen()->GetUndoCommandCount() <= 0 )
return;
......
......@@ -16,7 +16,7 @@
#include "protos.h"
void WinEDA_ModuleEditFrame::OnSelectOptionToolbar( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
......@@ -46,7 +46,7 @@ void WinEDA_ModuleEditFrame::OnSelectOptionToolbar( wxCommandEvent& event )
default:
DisplayError( this,
wxT( "WinEDA_ModuleEditFrame::OnSelectOptionToolbar error" ) );
wxT( "FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar error" ) );
break;
}
}
/*********************************************************/
/* class WinEDA_ModuleEditFrame: public EDA_DRAW_FRAME */
/* Class for the footprint editor */
/*********************************************************/
/*****************************************************/
/* class FOOTPRINT_EDIT_FRAME: public EDA_DRAW_FRAME */
/* Class for the footprint editor */
/*****************************************************/
#ifndef _MODULE_EDITOR_FRAME_H_
#define _MODULE_EDITOR_FRAME_H_
class WinEDA_ModuleEditFrame : public PCB_BASE_FRAME
class FOOTPRINT_EDIT_FRAME : public PCB_BASE_FRAME
{
public:
MODULE* CurrentModule;
public:
WinEDA_ModuleEditFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
FOOTPRINT_EDIT_FRAME( wxWindow* father,
const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~WinEDA_ModuleEditFrame();
~FOOTPRINT_EDIT_FRAME();
void InstallOptionsFrame( const wxPoint& pos );
......@@ -27,24 +27,69 @@ public:
void CloseModuleEditor( wxCommandEvent& Event );
void Process_Special_Functions( wxCommandEvent& event );
/**
* Function RedrawActiveWindoow
* daws the footprint editor BOARD, and others elements : axis, grid ..
*/
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
/**
* Function ReCreateHToolbar
* create the main horizontal toolbar for the footprint editor
*/
void ReCreateHToolbar();
void ReCreateVToolbar();
void ReCreateOptToolbar();
void ReCreateAuxiliaryToolbar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
/**
* Function OnLeftDClick
* handles the double click in the footprint editor:
* If the double clicked item is editable: call the corresponding editor.
*/
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
/**
* Function OnRightClick
* handles the right mouse click in the footprint editor:
* Create the pop up menu
* After this menu is built, the standard ZOOM menu is added
*/
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
/**
* @brief (Re)Create the menubar for the module editor frame
*/
void ReCreateMenuBar();
void ToolOnRightClick( wxCommandEvent& event );
void OnSelectOptionToolbar( wxCommandEvent& event );
/**
* Function OnHotKey
* handle hot key events.
* <p?
* Some commands are relative to the item under the mouse cursor. Commands are
* case insensitive
* </p>
*/
void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem = NULL );
bool OnHotkeyEditItem( int aIdCommand );
bool OnHotkeyDeleteItem( int aIdCommand );
bool OnHotkeyMoveItem( int aIdCommand );
bool OnHotkeyRotateItem( int aIdCommand );
/**
* Function Show3D_Frame
* displays 3D view of the footprint (module) being edited.
*/
void Show3D_Frame( wxCommandEvent& event );
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
void OnVerticalToolbar( wxCommandEvent& aEvent );
......@@ -58,12 +103,12 @@ public:
/**
* Function LoadModuleFromBoard
* called from the main toolbar
* to load a footprint from board mainly to edit it
* called from the main toolbar to load a footprint from board mainly to edit it.
*/
void LoadModuleFromBoard( wxCommandEvent& event );
/** Virtual Function OnModify()
/**
* Virtual Function OnModify()
* Must be called after a footprint change
* in order to set the "modify" flag of the current screen
* and prepare, if needed the refresh of the 3D frame showing the footprint
......@@ -77,7 +122,8 @@ public:
*/
void ToPrinter( wxCommandEvent& event );
/** Virtual function PrintPage
/**
* Virtual function PrintPage
* used to print a page
* Print the page pointed by ActiveScreen, set by the calling print function
* @param aDC = wxDC given by the calling print function
......@@ -93,14 +139,32 @@ public:
/**
* Function Clear_Pcb
* delete all and reinitialize the current board
* @param aQuery = true to prompt user for confirmation, false to
* initialize silently
* @param aQuery = true to prompt user for confirmation, false to initialize silently
*/
bool Clear_Pcb( bool aQuery );
/* handlers for block commands */
virtual int ReturnBlockCommand( int key );
/**
* Function HandleBlockPlace
* handles the BLOCK PLACE command
* Last routine for block operation for:
* - block move & drag
* - block copy & paste
*/
virtual void HandleBlockPlace( wxDC* DC );
/**
* Function HandleBlockEnd( )
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/
virtual bool HandleBlockEnd( wxDC* DC );
BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
......@@ -137,7 +201,20 @@ public:
private:
static wxString m_CurrentLib;
/**
* Function GetComponentFromUndoList
* performs an undo operation on the last edition:
* - Place the current edited library component in Redo list
* - Get old version of the current edited library component
*/
void GetComponentFromUndoList( wxCommandEvent& event );
/**
* Fucntion GetComponentFromRedoList
* performs a redo operation on the the last edition:
* - Place the current edited library component in undo list
* - Get old version of the current edited library component
*/
void GetComponentFromRedoList( wxCommandEvent& event );
/**
......@@ -151,6 +228,11 @@ public:
// Footprint edition
void Place_Ancre( MODULE* module );
void RemoveStruct( EDA_ITEM* Item );
/**
* Function Transform
* performs a geometric transform on the current footprint.
*/
void Transform( MODULE* module, int transform );
// importing / exporting Footprint
......@@ -167,6 +249,7 @@ public:
* false = use current path or last used path to export the footprint
*/
void Export_Module( MODULE* aModule, bool aCreateSysLib );
/**
* Function Import_Module
* Read a file containing only one footprint.
......@@ -178,7 +261,6 @@ public:
*/
MODULE* Import_Module( );
/**
* Function Load_Module_From_BOARD
* load in Modedit a footfrint from the main board
......@@ -205,10 +287,39 @@ public:
* the width of all footprint's edges
*/
void Edit_Edge_Width( EDGE_MODULE* aEdge );
/**
* Function Edit_Edge_Layer
* changes the EDGE_MODULE Edge layer, (The new layer will be asked)
* if Edge == NULL change the layer of the entire footprint edges
* @param Edge = edge to edit, or NULL
*/
void Edit_Edge_Layer( EDGE_MODULE* Edge );
/**
* Function Delete_Edge_Module
* deletes EDGE_MODULE Edge
* @param Edge = edge to delete
*/
void Delete_Edge_Module( EDGE_MODULE* Edge );
/**
* Function Begin_Edge_Module
* creates a new edge item (line, arc ..).
* @param Edge = if NULL: create new edge else terminate edge and create a
* new edge
* @param DC = current Device Context
* @param type_edge = S_SEGMENT,S_ARC ..
* @return the new created edge.
*/
EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, int type_edge );
/**
* Function End_Edge_Module
* terminates a move or create edge function
*/
void End_Edge_Module( EDGE_MODULE* Edge );
/**
* Function Enter_Edge_Width
* Edition of width of module outlines
......@@ -218,7 +329,11 @@ public:
* changes ModuleSegmentWidth (global) = new width
*/
void Enter_Edge_Width( EDGE_MODULE* aEdge );
/* Function to initialise the move function params of a graphic item type DRAWSEGMENT */
void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
/* Function to place a graphic item type EDGE_MODULE currently moved */
void Place_EdgeMod( EDGE_MODULE* drawitem );
// handlers for libraries:
......
......@@ -19,106 +19,100 @@
#include "3d_viewer.h"
static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the
// footprint editor
static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the footprint editor
// Design setting for the module editor:
static BOARD_DESIGN_SETTINGS s_ModuleEditorDesignSetting;
wxString WinEDA_ModuleEditFrame::m_CurrentLib = wxEmptyString;
wxString FOOTPRINT_EDIT_FRAME::m_CurrentLib = wxEmptyString;
/********************************/
/* class WinEDA_ModuleEditFrame */
/********************************/
BEGIN_EVENT_TABLE( WinEDA_ModuleEditFrame, PCB_BASE_FRAME )
/******************************/
/* class FOOTPRINT_EDIT_FRAME */
/******************************/
BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU_RANGE( ID_POPUP_PCB_ITEM_SELECTION_START, ID_POPUP_PCB_ITEM_SELECTION_END,
PCB_BASE_FRAME::ProcessItemSelection )
EVT_CLOSE( WinEDA_ModuleEditFrame::OnCloseWindow )
EVT_MENU( wxID_EXIT, WinEDA_ModuleEditFrame::CloseModuleEditor )
EVT_CLOSE( FOOTPRINT_EDIT_FRAME::OnCloseWindow )
EVT_MENU( wxID_EXIT, FOOTPRINT_EDIT_FRAME::CloseModuleEditor )
EVT_SIZE( WinEDA_ModuleEditFrame::OnSize )
EVT_SIZE( FOOTPRINT_EDIT_FRAME::OnSize )
EVT_COMBOBOX( ID_ON_ZOOM_SELECT, WinEDA_ModuleEditFrame::OnSelectZoom )
EVT_COMBOBOX( ID_ON_GRID_SELECT, WinEDA_ModuleEditFrame::OnSelectGrid )
EVT_COMBOBOX( ID_ON_ZOOM_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectZoom )
EVT_COMBOBOX( ID_ON_GRID_SELECT, FOOTPRINT_EDIT_FRAME::OnSelectGrid )
EVT_TOOL( ID_MODEDIT_SELECT_CURRENT_LIB, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_DELETE_PART, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_NEW_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_IMPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EXPORT_PART, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SELECT_CURRENT_LIB, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SAVE_LIBMODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_NEW_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_LOAD_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_IMPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SHEET_SET, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, WinEDA_ModuleEditFrame::ToPrinter )
EVT_TOOL( ID_MODEDIT_LOAD_MODULE, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_CHECK, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_PAD_SETTINGS, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, WinEDA_ModuleEditFrame::LoadModuleFromBoard )
EVT_TOOL( ID_MODEDIT_INSERT_MODULE_IN_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, WinEDA_ModuleEditFrame::GetComponentFromUndoList )
EVT_TOOL( wxID_REDO, WinEDA_ModuleEditFrame::GetComponentFromRedoList )
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SHEET_SET, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_PRINT, FOOTPRINT_EDIT_FRAME::ToPrinter )
EVT_TOOL( ID_MODEDIT_LOAD_MODULE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_CHECK, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_PAD_SETTINGS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard )
EVT_TOOL( ID_MODEDIT_INSERT_MODULE_IN_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( wxID_UNDO, FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList )
EVT_TOOL( wxID_REDO, FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList )
// Vertical tool bar button click event handler.
EVT_TOOL( ID_NO_TOOL_SELECTED, WinEDA_ModuleEditFrame::OnVerticalToolbar )
EVT_TOOL( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
EVT_TOOL_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_PLACE_GRID_COORD,
WinEDA_ModuleEditFrame::OnVerticalToolbar )
FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
// Options Toolbar
EVT_TOOL( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
WinEDA_ModuleEditFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
WinEDA_ModuleEditFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
WinEDA_ModuleEditFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
WinEDA_ModuleEditFrame::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_PADS_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, FOOTPRINT_EDIT_FRAME::OnSelectOptionToolbar )
// popup commands
EVT_MENU_RANGE( ID_POPUP_PCB_START_RANGE, ID_POPUP_PCB_END_RANGE,
WinEDA_ModuleEditFrame::Process_Special_Functions )
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
WinEDA_ModuleEditFrame::Process_Special_Functions )
FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
// Module transformations
EVT_MENU( ID_MODEDIT_MODULE_ROTATE, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_MENU( ID_MODEDIT_MODULE_MIRROR, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_MENU( ID_MODEDIT_MODULE_ROTATE, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MODEDIT_MODULE_MIRROR, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_MENU( ID_PCB_PAD_SETUP, WinEDA_ModuleEditFrame::Process_Special_Functions )
EVT_MENU( ID_PCB_DRAWINGS_WIDTHS_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_PAD_SETUP, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_PCB_USER_GRID_SETUP, PCB_EDIT_FRAME::Process_Special_Functions )
// Menu 3D Frame
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, WinEDA_ModuleEditFrame::Show3D_Frame )
EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, FOOTPRINT_EDIT_FRAME::Show3D_Frame )
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, WinEDA_ModuleEditFrame::OnUpdateLibSelected )
EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, WinEDA_ModuleEditFrame::OnUpdateModuleSelected )
EVT_UPDATE_UI( ID_MODEDIT_DELETE_PART, FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected )
EVT_UPDATE_UI( ID_MODEDIT_EXPORT_PART, FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
EVT_UPDATE_UI( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
WinEDA_ModuleEditFrame::OnUpdateModuleSelected )
EVT_UPDATE_UI( ID_MODEDIT_SAVE_LIBMODULE,
WinEDA_ModuleEditFrame::OnUpdateLibAndModuleSelected )
FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected )
EVT_UPDATE_UI( ID_MODEDIT_SAVE_LIBMODULE, FOOTPRINT_EDIT_FRAME::OnUpdateLibAndModuleSelected )
EVT_UPDATE_UI( ID_MODEDIT_LOAD_MODULE_FROM_BOARD,
WinEDA_ModuleEditFrame::OnUpdateLoadModuleFromBoard )
FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard )
EVT_UPDATE_UI( ID_MODEDIT_INSERT_MODULE_IN_BOARD,
WinEDA_ModuleEditFrame::OnUpdateInsertModuleInBoard )
FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard )
EVT_UPDATE_UI( ID_MODEDIT_UPDATE_MODULE_IN_BOARD,
WinEDA_ModuleEditFrame::OnUpdateReplaceModuleInBoard )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, WinEDA_ModuleEditFrame::OnUpdateVerticalToolbar )
FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard )
EVT_UPDATE_UI( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar )
EVT_UPDATE_UI_RANGE( ID_MODEDIT_PAD_TOOL, ID_MODEDIT_PLACE_GRID_COORD,
WinEDA_ModuleEditFrame::OnUpdateVerticalToolbar )
FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar )
END_EVENT_TABLE()
WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( wxWindow* father,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style ) :
PCB_BASE_FRAME( father, MODULE_EDITOR_FRAME, wxEmptyString, pos, size, style )
{
m_FrameName = wxT( "ModEditFrame" );
......@@ -196,7 +190,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
}
WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
{
/* g_ModuleEditor_Pcb and its corresponding PCB_SCREEN are not deleted
* here, because if we reopen the Footprint editor, we expect to find
......@@ -211,7 +205,7 @@ WinEDA_ModuleEditFrame::~WinEDA_ModuleEditFrame()
}
void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
void FOOTPRINT_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
if( GetScreen()->IsModify() )
{
......@@ -226,13 +220,13 @@ void WinEDA_ModuleEditFrame::OnCloseWindow( wxCloseEvent& Event )
}
void WinEDA_ModuleEditFrame::CloseModuleEditor( wxCommandEvent& Event )
void FOOTPRINT_EDIT_FRAME::CloseModuleEditor( wxCommandEvent& Event )
{
Close();
}
void WinEDA_ModuleEditFrame::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( GetBoard()->m_Modules != NULL );
......@@ -241,25 +235,25 @@ void WinEDA_ModuleEditFrame::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
}
void WinEDA_ModuleEditFrame::OnUpdateLibSelected( wxUpdateUIEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnUpdateLibSelected( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( m_CurrentLib != wxEmptyString );
}
void WinEDA_ModuleEditFrame::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnUpdateModuleSelected( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( GetBoard()->m_Modules != NULL );
}
void WinEDA_ModuleEditFrame::OnUpdateLibAndModuleSelected( wxUpdateUIEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnUpdateLibAndModuleSelected( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( ( m_CurrentLib != wxEmptyString ) && ( GetBoard()->m_Modules != NULL ) );
}
void WinEDA_ModuleEditFrame::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent )
{
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
......@@ -267,7 +261,7 @@ void WinEDA_ModuleEditFrame::OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEven
}
void WinEDA_ModuleEditFrame::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent )
{
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
......@@ -294,7 +288,7 @@ void WinEDA_ModuleEditFrame::OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEven
}
void WinEDA_ModuleEditFrame::OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent )
void FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent )
{
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) GetParent();
......@@ -320,10 +314,7 @@ void WinEDA_ModuleEditFrame::OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEve
}
/**
* Display 3D frame of footprint (module) being edited.
*/
void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
{
......@@ -331,6 +322,7 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
// This should work on any platform.
if( m_Draw3DFrame->IsIconized() )
m_Draw3DFrame->Iconize( false );
m_Draw3DFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on any platform.
......@@ -345,7 +337,7 @@ void WinEDA_ModuleEditFrame::Show3D_Frame( wxCommandEvent& event )
}
void WinEDA_ModuleEditFrame::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
void FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey )
{
wxRealPoint gridSize;
wxPoint oldpos;
......@@ -420,14 +412,7 @@ void WinEDA_ModuleEditFrame::GeneralControl( wxDC* aDC, const wxPoint& aPosition
}
/**
* Function OnModify() (virtual)
* Must be called after a change
* in order to set the "modify" flag of the current screen
* and prepare, if needed the refresh of the 3D frame showing the footprint
* do not forget to call the basic OnModify function to update auxiliary info
*/
void WinEDA_ModuleEditFrame::OnModify()
void FOOTPRINT_EDIT_FRAME::OnModify()
{
PCB_BASE_FRAME::OnModify();
......@@ -436,10 +421,31 @@ void WinEDA_ModuleEditFrame::OnModify()
}
void WinEDA_ModuleEditFrame::UpdateTitle()
void FOOTPRINT_EDIT_FRAME::UpdateTitle()
{
wxString title = _( "Module Editor " );
if( m_CurrentLib.IsEmpty() )
SetTitle( _( "Module Editor (no active library)" ) );
{
title += _( "(no active library)" );
}
else
SetTitle( _( "Module Editor (active library: " ) + m_CurrentLib + wxT( ")" ) );
{
wxFileName fileName = wxFileName( wxEmptyString, m_CurrentLib, ModuleFileExtension );
fileName = wxGetApp().FindLibraryPath( fileName );
if( !fileName.IsOk() || !fileName.FileExists() )
{
title += _( "(no active library)" );
}
else
{
title = _( "Module Editor (active library: " ) + fileName.GetFullPath() + wxT( ")" );
if( !fileName.IsFileWritable() )
title += _( " [Read Only]" );
}
}
SetTitle( title );
}
......@@ -38,6 +38,7 @@
#include "pcbstruct.h" // enum PCB_VISIBLE
#include "collectors.h"
#include "bitmaps.h"
#include "build_version.h"
#include "protos.h"
#include "pcbnew_id.h"
#include "drc_stuff.h"
......@@ -477,9 +478,6 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
}
/**
* Display 3D frame of current printed circuit board.
*/
void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
{
if( m_Draw3DFrame )
......@@ -502,9 +500,6 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
}
/**
* Display the Design Rules Editor.
*/
void PCB_EDIT_FRAME::ShowDesignRulesEditor( wxCommandEvent& event )
{
DIALOG_DESIGN_RULES dR_editor( this );
......@@ -574,54 +569,30 @@ void PCB_EDIT_FRAME::SaveSettings()
}
/**
* Function IsGridVisible() , virtual
* @return true if the grid must be shown
*/
bool PCB_EDIT_FRAME::IsGridVisible()
{
return IsElementVisible( GRID_VISIBLE );
}
/**
* Function SetGridVisibility() , virtual
* It may be overloaded by derived classes
* if you want to store/retrieve the grid visibility in configuration.
* @param aVisible = true if the grid must be shown
*/
void PCB_EDIT_FRAME::SetGridVisibility(bool aVisible)
{
SetElementVisibility( GRID_VISIBLE, aVisible );
}
/**
* Function GetGridColor() , virtual
* @return the color of the grid
*/
int PCB_EDIT_FRAME::GetGridColor()
{
return GetBoard()->GetVisibleElementColor( GRID_VISIBLE );
}
/**
* Function SetGridColor() , virtual
* @param aColor = the new color of the grid
*/
void PCB_EDIT_FRAME::SetGridColor(int aColor)
{
GetBoard()->SetVisibleElementColor( GRID_VISIBLE, aColor );
}
/* Return true if a microvia can be put on board
* A microvia is a small via restricted to 2 near neighbor layers
* because its is hole is made by laser which can penetrate only one layer
* It is mainly used to connect BGA to the first inner layer
* And it is allowed from an external layer to the first inner layer
*/
bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
{
int copperlayercnt = GetBoard()->GetCopperLayerCount( );
......@@ -658,13 +629,6 @@ void PCB_EDIT_FRAME::unitsChangeRefresh()
}
/**
* Function SetElementVisibility
* changes the visibility of an element category
* @param aPCB_VISIBLE is from the enum by the same name
* @param aNewState = The new visibility state of the element category
* @see enum PCB_VISIBLE
*/
void PCB_EDIT_FRAME::SetElementVisibility( int aPCB_VISIBLE, bool aNewState )
{
GetBoard()->SetElementVisibility( aPCB_VISIBLE, aNewState );
......@@ -672,10 +636,6 @@ void PCB_EDIT_FRAME::SetElementVisibility( int aPCB_VISIBLE, bool aNewState )
}
/**
* Function SetVisibleAlls
* Set the status of all visible element categories and layers to VISIBLE
*/
void PCB_EDIT_FRAME::SetVisibleAlls( )
{
GetBoard()->SetVisibleAlls( );
......@@ -685,10 +645,6 @@ void PCB_EDIT_FRAME::SetVisibleAlls( )
}
/**
* Function SetLanguage
* called on a language menu selection
*/
void PCB_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
{
EDA_DRAW_FRAME::SetLanguage( event );
......@@ -731,13 +687,6 @@ void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead )
}
/**
* Function OnModify() (virtual)
* Must be called after a change
* in order to set the "modify" flag of the current screen
* and prepare, if needed the refresh of the 3D frame showing the footprint
* do not forget to call the basic OnModify function to update auxiliary info
*/
void PCB_EDIT_FRAME::OnModify( )
{
PCB_BASE_FRAME::OnModify();
......@@ -747,12 +696,32 @@ void PCB_EDIT_FRAME::OnModify( )
}
/* Prepare the data structures of print management
* And displays the dialog window management of printing sheets
*/
void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
{
DIALOG_SVG_PRINT frame( this );
frame.ShowModal();
}
void PCB_EDIT_FRAME::UpdateTitle()
{
wxString title;
wxFileName fileName = GetScreen()->GetFileName();
if( fileName.IsOk() && fileName.FileExists() )
{
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + fileName.GetFullPath();
if( !fileName.IsFileWritable() )
title += _( " [Read Only]" );
}
else
{
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + _( " [no file]" );
}
SetTitle( title );
}
......@@ -83,7 +83,7 @@ void WinEDA_App::MacOpenFile( const wxString& fileName )
if( !filename.FileExists() )
return;
frame->LoadOnePcbFile( fileName, FALSE );
frame->LoadOnePcbFile( fileName, false );
}
......@@ -96,7 +96,7 @@ bool WinEDA_App::OnInit()
if( m_Checker && m_Checker->IsAnotherRunning() )
{
if( !IsOK( NULL, _( "Pcbnew is already running, Continue?" ) ) )
if( !IsOK( NULL, _( "PCBnew is already running, Continue?" ) ) )
return false;
}
......@@ -112,7 +112,7 @@ bool WinEDA_App::OnInit()
if( fn.GetExt() != PcbFileExtension )
{
wxLogDebug( wxT( "PcbNew file <%s> has the wrong extension. \
wxLogDebug( wxT( "PCBNew file <%s> has the wrong extension. \
Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
fn.SetExt( PcbFileExtension );
}
......@@ -123,12 +123,12 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
g_DrawBgColor = BLACK;
/* Must be called before creating the main frame in order to
* display the real hotkeys in menus or tool tips */
/* Must be called before creating the main frame in order to
* display the real hotkeys in menus or tool tips */
ReadHotkeyConfig( wxT("PcbFrame"), g_Board_Editor_Hokeys_Descr );
frame = new PCB_EDIT_FRAME( NULL, wxT( "PcbNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
frame = new PCB_EDIT_FRAME( NULL, wxT( "PCBNew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );
frame->UpdateTitle();
SetTopWindow( frame );
frame->Show( true );
......@@ -144,17 +144,17 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
/* Load file specified in the command line. */
if( fn.IsOk() )
{
/* Note the first time Pcbnew is called after creating a new project
/* Note the first time PCBnew is called after creating a new project
* the board file may not exists
* So we load settings only
*/
*/
if( fn.FileExists() )
frame->LoadOnePcbFile( fn.GetFullPath() );
else
{ // File does not exists: prepare an empty board
wxSetWorkingDirectory( fn.GetPath() );
frame->GetScreen()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
frame->SetTitle( frame->GetScreen()->GetFileName() );
frame->UpdateTitle();
frame->UpdateFileHistory( frame->GetScreen()->GetFileName() );
frame->OnModify(); // Ready to save the new empty board
g_SaveTime = time( NULL ); // Init the time out to save the board
......
......@@ -20,19 +20,10 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
int aDraw_mode, int aMasklayer,
PRINT_PARAMETERS::DrillShapeOptT aDrillShapeOpt );
/**
* Function PrintPage
* Used to print the board (on printer, or when creating SVF files).
* Print the board, but only layers allowed by aPrintMaskLayer
* @param aDC = the print device context
* @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = true to plot mirrored
* @param aData = a pointer to an optional data (NULL if not used)
*/
void WinEDA_ModuleEditFrame::PrintPage( wxDC* aDC,
int aPrintMaskLayer,
bool aPrintMirrorMode,
void * aData)
void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
int aPrintMaskLayer,
bool aPrintMirrorMode,
void * aData)
{
MODULE* Module;
int drawmode = GR_COPY;
......@@ -42,6 +33,7 @@ void WinEDA_ModuleEditFrame::PrintPage( wxDC* aDC,
PRINT_PARAMETERS * printParameters = (PRINT_PARAMETERS*) aData; // can be null
PRINT_PARAMETERS::DrillShapeOptT drillShapeOpt = PRINT_PARAMETERS::FULL_DRILL_SHAPE;
if( printParameters )
defaultPenSize = printParameters->m_PenDefaultSize;
......@@ -67,9 +59,9 @@ void WinEDA_ModuleEditFrame::PrintPage( wxDC* aDC,
DrawPanel->m_PrintIsMirrored = aPrintMirrorMode;
// The OR mode is used in color mode, but be aware the backgroud *must be
// The OR mode is used in color mode, but be aware the background *must be
// BLACK. In the print page dialog, we first print in BLACK, and after
// reprint in color, on the black "local" backgroud, in OR mode the black
// reprint in color, on the black "local" background, in OR mode the black
// print is not made before, only a white page is printed
if( GetGRForceBlackPenState() == false )
drawmode = GR_OR;
......@@ -92,6 +84,7 @@ void WinEDA_ModuleEditFrame::PrintPage( wxDC* aDC,
Print_Module( DrawPanel, aDC, Module, drawmode, aPrintMaskLayer, drillShapeOpt );
Module->Move( -offset );
}
D_PAD::m_PadSketchModePenSize = tmp;
DrawPanel->m_PrintIsMirrored = false;
......@@ -166,8 +159,8 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
}
// pads on Silkscreen layer are usually plot in sketch mode:
if( (GetScreen()->m_Active_Layer == SILKSCREEN_N_BACK) ||
(GetScreen()->m_Active_Layer == SILKSCREEN_N_FRONT) )
if( (GetScreen()->m_Active_Layer == SILKSCREEN_N_BACK)
|| (GetScreen()->m_Active_Layer == SILKSCREEN_N_FRONT) )
DisplayOpt.DisplayPadFill = false;
}
......@@ -181,8 +174,8 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
m_DisplayPadNum = DisplayOpt.DisplayPadNum = false;
bool nctmp = GetBoard()->IsElementVisible(NO_CONNECTS_VISIBLE);
GetBoard()->SetElementVisibility(NO_CONNECTS_VISIBLE, false);
bool nctmp = GetBoard()->IsElementVisible( NO_CONNECTS_VISIBLE );
GetBoard()->SetElementVisibility( NO_CONNECTS_VISIBLE, false );
DisplayOpt.DisplayPadIsol = false;
m_DisplayModEdge = DisplayOpt.DisplayModEdge = FILLED;
m_DisplayModText = DisplayOpt.DisplayModText = FILLED;
......@@ -194,15 +187,16 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
DrawPanel->m_PrintIsMirrored = aPrintMirrorMode;
// The OR mode is used in color mode, but be aware the backgroud *must be
// The OR mode is used in color mode, but be aware the background *must be
// BLACK. In the print page dialog, we first print in BLACK, and after
// reprint in color, on the black "local" backgroud, in OR mode the black
// reprint in color, on the black "local" background, in OR mode the black
// print is not made before, only a white page is printed
if( GetGRForceBlackPenState() == false )
drawmode = GR_OR;
/* Print the pcb graphic items (texts, ...) */
GRSetDrawMode( aDC, drawmode );
for( BOARD_ITEM* item = Pcb->m_Drawings; item; item = item->Next() )
{
switch( item->Type() )
......@@ -225,10 +219,12 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
/* Print tracks */
pt_piste = Pcb->m_Track;
for( ; pt_piste != NULL; pt_piste = pt_piste->Next() )
{
if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue;
if( pt_piste->Type() == TYPE_VIA ) /* VIA encountered. */
{
int rayon = pt_piste->m_Width >> 1;
......@@ -241,22 +237,26 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
0, color, color );
}
else
{
pt_piste->Draw( DrawPanel, aDC, drawmode );
}
}
pt_piste = Pcb->m_Zone;
for( ; pt_piste != NULL; pt_piste = pt_piste->Next() )
{
if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue;
pt_piste->Draw( DrawPanel, aDC, drawmode );
}
/* Draw filled areas (i.e. zones) */
for( int ii = 0; ii < Pcb->GetAreaCount(); ii++ )
{
ZONE_CONTAINER* zone = Pcb->GetArea( ii );
if( ( aPrintMaskLayer & ( 1 << zone->GetLayer() ) ) == 0 )
continue;
......@@ -268,10 +268,12 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
Module = (MODULE*) Pcb->m_Modules;
int tmp = D_PAD::m_PadSketchModePenSize;
D_PAD::m_PadSketchModePenSize = defaultPenSize;
for( ; Module != NULL; Module = Module->Next() )
{
Print_Module( DrawPanel, aDC, Module, drawmode, aPrintMaskLayer, drillShapeOpt );
}
D_PAD::m_PadSketchModePenSize = tmp;
/* Print via holes in bg color: Not sure it is good for buried or blind
......@@ -283,23 +285,28 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC,
bool blackpenstate = GetGRForceBlackPenState();
GRForceBlackPen( false );
GRSetDrawMode( aDC, GR_COPY );
for( ; pt_piste != NULL; pt_piste = pt_piste->Next() )
{
if( ( aPrintMaskLayer & pt_piste->ReturnMaskLayer() ) == 0 )
continue;
if( pt_piste->Type() == TYPE_VIA ) /* VIA encountered. */
{
int diameter;
if( drillShapeOpt == PRINT_PARAMETERS::SMALL_DRILL_SHAPE )
diameter = min( SMALL_DRILL, pt_piste->GetDrillValue());
diameter = min( SMALL_DRILL, pt_piste->GetDrillValue() );
else
diameter = pt_piste->GetDrillValue();
GRFilledCircle( &DrawPanel->m_ClipBox, aDC,
pt_piste->m_Start.x, pt_piste->m_Start.y,
diameter/2,
0, color, color );
}
}
GRForceBlackPen( blackpenstate );
}
......@@ -333,8 +340,10 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
{
if( (pt_pad->m_Masque_Layer & aMasklayer ) == 0 )
continue;
// Manage hole according to the print drill option
wxSize drill_tmp = pt_pad->m_Drill;
switch ( aDrillShapeOpt )
{
case PRINT_PARAMETERS::NO_DRILL_SHAPE:
......@@ -348,6 +357,7 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
// Do nothing
break;
}
pt_pad->Draw( aPanel, aDC, aDraw_mode );
pt_pad->m_Drill = drill_tmp;
}
......@@ -355,6 +365,7 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
/* Print footprint graphic shapes */
PtStruct = aModule->m_Drawings;
mlayer = g_TabOneLayerMask[aModule->GetLayer()];
if( aModule->GetLayer() == LAYER_N_BACK )
mlayer = SILKSCREEN_LAYER_BACK;
else if( aModule->GetLayer() == LAYER_N_FRONT )
......@@ -364,6 +375,7 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
{
if( !aModule->m_Reference->m_NoShow )
aModule->m_Reference->Draw( aPanel, aDC, aDraw_mode );
if( !aModule->m_Value->m_NoShow )
aModule->m_Value->Draw( aPanel, aDC, aDraw_mode );
}
......@@ -373,7 +385,7 @@ static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
switch( PtStruct->Type() )
{
case TYPE_TEXTE_MODULE:
if( (mlayer & aMasklayer ) == 0 )
if( ( mlayer & aMasklayer ) == 0 )
break;
TextMod = (TEXTE_MODULE*) PtStruct;
......
......@@ -20,8 +20,7 @@
#endif
/* Create the main horizontal toolbar for the footprint editor */
void WinEDA_ModuleEditFrame::ReCreateHToolbar()
void FOOTPRINT_EDIT_FRAME::ReCreateHToolbar()
{
if( m_HToolBar != NULL )
return;
......@@ -111,13 +110,12 @@ void WinEDA_ModuleEditFrame::ReCreateHToolbar()
wxBitmap( module_check_xpm ),
_( "Check module" ) );
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
m_HToolBar->Realize();
}
void WinEDA_ModuleEditFrame::ReCreateVToolbar()
void FOOTPRINT_EDIT_FRAME::ReCreateVToolbar()
{
if( m_VToolBar )
return;
......@@ -163,7 +161,7 @@ void WinEDA_ModuleEditFrame::ReCreateVToolbar()
}
void WinEDA_ModuleEditFrame::ReCreateOptToolbar()
void FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar()
{
if( m_OptionsToolBar )
return;
......@@ -206,7 +204,7 @@ void WinEDA_ModuleEditFrame::ReCreateOptToolbar()
}
void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
void FOOTPRINT_EDIT_FRAME::ReCreateAuxiliaryToolbar()
{
wxString msg;
......
......@@ -56,7 +56,7 @@ void PCB_EDIT_FRAME::ToolOnRightClick( wxCommandEvent& event )
}
void WinEDA_ModuleEditFrame::ToolOnRightClick( wxCommandEvent& event )
void FOOTPRINT_EDIT_FRAME::ToolOnRightClick( wxCommandEvent& event )
{
wxPoint pos;
int id = event.GetSelection();
......
......@@ -33,9 +33,7 @@ static void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module,
int ox, int oy, int MasqueLayer, int draw_mode );
/* Draw the footprint editor BOARD, and others elements : axis, grid ..
*/
void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
PCB_SCREEN* screen = (PCB_SCREEN*)GetScreen();
......@@ -54,7 +52,7 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
}
#ifdef USE_WX_OVERLAY
if(IsShown())
if( IsShown() )
{
DrawPanel->m_overlay.Reset();
wxDCOverlay overlaydc( DrawPanel->m_overlay, (wxWindowDC*)DC );
......@@ -63,7 +61,7 @@ void WinEDA_ModuleEditFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
#endif
if( DrawPanel->IsMouseCaptured() )
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
/* Redraw the cursor */
DrawPanel->DrawCrossHair( DC );
......@@ -99,7 +97,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
#endif
if( DrawPanel->IsMouseCaptured() )
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, FALSE );
DrawPanel->m_mouseCaptureCallback( DrawPanel, DC, wxDefaultPosition, false );
// Redraw the cursor
DrawPanel->DrawCrossHair( DC );
......@@ -107,8 +105,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
/* Redraw the BOARD items but not cursors, axis or grid */
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC,
int aDrawMode, const wxPoint& offset )
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC, int aDrawMode, const wxPoint& offset )
{
/* The order of drawing is flexible on some systems and not on others. For
* OSes which use OR to draw, the order is not important except for the
......@@ -180,14 +177,14 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC,
if( !IsElementVisible( PCB_VISIBLE(MOD_FR_VISIBLE) ) )
{
if( module->GetLayer() == LAYER_N_FRONT )
display = FALSE;
display = false;
layerMask &= ~LAYER_FRONT;
}
if( !IsElementVisible( PCB_VISIBLE(MOD_BK_VISIBLE) ) )
{
if( module->GetLayer() == LAYER_N_BACK )
display = FALSE;
display = false;
layerMask &= ~LAYER_BACK;
}
......@@ -200,8 +197,7 @@ void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* DC,
if( IsHightLightNetON() )
DrawHighLight( aPanel, DC, GetHightLightNetCode() );
// draw the BOARD's markers last, otherwise the high light will erase
// any marker on a pad
// draw the BOARD's markers last, otherwise the high light will erase any marker on a pad
for( unsigned i=0; i < m_markers.size(); ++i )
{
m_markers[i]->Draw( aPanel, DC, aDrawMode );
......@@ -220,6 +216,7 @@ void BOARD::DrawHighLight( EDA_DRAW_PANEL* aDrawPanel, wxDC* DC, int aNetCode )
// Redraw ZONE_CONTAINERS
BOARD::ZONE_CONTAINERS& zones = m_ZoneDescriptorList;
for( BOARD::ZONE_CONTAINERS::iterator zc = zones.begin(); zc!=zones.end(); ++zc )
{
if( (*zc)->GetNet() == aNetCode )
......@@ -265,7 +262,7 @@ void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module,
frame = (PCB_BASE_FRAME*) panel->GetParent();
tmp = frame->m_DisplayPadFill;
frame->m_DisplayPadFill = FALSE;
frame->m_DisplayPadFill = false;
/* Draw pads. */
for( D_PAD* pad = Module->m_Pads; pad; pad = pad->Next() )
......@@ -278,4 +275,3 @@ void Trace_Pads_Only( EDA_DRAW_PANEL* panel, wxDC* DC, MODULE* Module,
frame->m_DisplayPadFill = tmp;
}
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