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,8 +143,10 @@ 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
......
......@@ -22,19 +22,15 @@
static void ShowNewEdgeModule( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
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();
......@@ -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,14 +271,7 @@ 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,
EDGE_MODULE* FOOTPRINT_EDIT_FRAME::Begin_Edge_Module( EDGE_MODULE* Edge,
wxDC* DC,
int type_edge )
{
......@@ -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();
......
This diff is collapsed.
......@@ -39,7 +39,7 @@ void PCB_EDIT_FRAME::InstallModuleOptionsFrame( MODULE* Module, wxDC* DC )
{
if( m_ModuleEditFrame == NULL )
{
m_ModuleEditFrame = new WinEDA_ModuleEditFrame( this,
m_ModuleEditFrame = new FOOTPRINT_EDIT_FRAME( this,
_( "Module Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
......@@ -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,10 +20,7 @@
*/
/* 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,
void FOOTPRINT_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
EDA_ITEM* aItem )
{
if( aHotKey == 0 )
......@@ -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;
......
This diff is collapsed.
......@@ -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,16 +131,18 @@ 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 );
DrawPanel->MoveCursorToCrossHair();
......@@ -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);
......
This diff is collapsed.
......@@ -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,8 +108,10 @@ 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;
case ID_MODEDIT_DELETE_TOOL:
......@@ -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,13 +357,13 @@ 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" ),
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" ),
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,15 +13,7 @@
#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,
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{
......@@ -47,15 +39,7 @@ 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,
void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint )
{
......@@ -64,14 +48,7 @@ void WinEDA_ModuleEditFrame::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
}
/********************************************************************************/
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 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,
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:
......
This diff is collapsed.
......@@ -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 );
}
......@@ -127,8 +127,8 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
* 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,7 +144,7 @@ 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
*/
......@@ -154,7 +154,7 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
{ // 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,16 +20,7 @@ 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,
void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC,
int aPrintMaskLayer,
bool aPrintMirrorMode,
void * aData)
......@@ -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