2011-09-26 20:32:56 +00:00
|
|
|
/**
|
|
|
|
* @file module_editor_frame.h
|
|
|
|
* @brief Definition of class FOOTPRINT_EDIT_FRAME.
|
|
|
|
*/
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
#ifndef _MODULE_EDITOR_FRAME_H_
|
|
|
|
#define _MODULE_EDITOR_FRAME_H_
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
class FOOTPRINT_EDIT_FRAME : public PCB_BASE_FRAME
|
2010-08-10 18:34:26 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
MODULE* CurrentModule;
|
|
|
|
|
|
|
|
public:
|
2011-08-26 17:01:17 +00:00
|
|
|
FOOTPRINT_EDIT_FRAME( wxWindow* father,
|
|
|
|
const wxString& title,
|
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
~FOOTPRINT_EDIT_FRAME();
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
void InstallOptionsFrame( const wxPoint& pos );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
void OnCloseWindow( wxCloseEvent& Event );
|
|
|
|
void CloseModuleEditor( wxCommandEvent& Event );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
void Process_Special_Functions( wxCommandEvent& event );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function RedrawActiveWindoow
|
2011-09-26 20:32:56 +00:00
|
|
|
* draws the footprint editor BOARD, and others elements such as axis and grid.
|
2011-08-26 17:01:17 +00:00
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ReCreateHToolbar
|
|
|
|
* create the main horizontal toolbar for the footprint editor
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void ReCreateHToolbar();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
void ReCreateVToolbar();
|
|
|
|
void ReCreateOptToolbar();
|
|
|
|
void ReCreateAuxiliaryToolbar();
|
|
|
|
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnLeftDClick
|
|
|
|
* handles the double click in the footprint editor:
|
|
|
|
* If the double clicked item is editable: call the corresponding editor.
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief (Re)Create the menubar for the module editor frame
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void ReCreateMenuBar();
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
void ToolOnRightClick( wxCommandEvent& event );
|
|
|
|
void OnSelectOptionToolbar( wxCommandEvent& event );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnHotKey
|
|
|
|
* handle hot key events.
|
|
|
|
* <p?
|
|
|
|
* Some commands are relative to the item under the mouse cursor. Commands are
|
|
|
|
* case insensitive
|
|
|
|
* </p>
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
bool OnHotkeyEditItem( int aIdCommand );
|
|
|
|
bool OnHotkeyDeleteItem( int aIdCommand );
|
|
|
|
bool OnHotkeyMoveItem( int aIdCommand );
|
|
|
|
bool OnHotkeyRotateItem( int aIdCommand );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Show3D_Frame
|
|
|
|
* displays 3D view of the footprint (module) being edited.
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void Show3D_Frame( wxCommandEvent& event );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
|
|
|
|
void OnVerticalToolbar( wxCommandEvent& aEvent );
|
2011-02-21 13:54:29 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateLibSelected( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateModuleSelected( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateLibAndModuleSelected( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateLoadModuleFromBoard( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateInsertModuleInBoard( wxUpdateUIEvent& aEvent );
|
|
|
|
void OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function LoadModuleFromBoard
|
2011-08-26 17:01:17 +00:00
|
|
|
* called from the main toolbar to load a footprint from board mainly to edit it.
|
2010-08-10 18:34:26 +00:00
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void LoadModuleFromBoard( wxCommandEvent& event );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
/**
|
|
|
|
* Virtual Function OnModify()
|
2010-08-10 18:34:26 +00:00
|
|
|
* 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
|
|
|
|
* do not forget to call the basic OnModify function to update auxiliary info
|
|
|
|
*/
|
|
|
|
virtual void OnModify( );
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function ToPrinter
|
2010-08-10 18:34:26 +00:00
|
|
|
* Install the print dialog
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void ToPrinter( wxCommandEvent& event );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
/**
|
|
|
|
* Virtual function PrintPage
|
2010-08-10 18:34:26 +00:00
|
|
|
* 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
|
2010-12-29 17:47:32 +00:00
|
|
|
* @param aPrintMaskLayer = not used here
|
2010-08-10 18:34:26 +00:00
|
|
|
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
|
|
|
|
* @param aData = a pointer on an auxiliary data (NULL if not used)
|
|
|
|
*/
|
2011-02-21 13:54:29 +00:00
|
|
|
virtual void PrintPage( wxDC* aDC, int aPrintMaskLayer, bool aPrintMirrorMode,
|
|
|
|
void * aData = NULL);
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
// BOARD handling
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
2010-11-12 16:59:16 +00:00
|
|
|
* Function Clear_Pcb
|
2010-08-10 18:34:26 +00:00
|
|
|
* delete all and reinitialize the current board
|
2011-08-26 17:01:17 +00:00
|
|
|
* @param aQuery = true to prompt user for confirmation, false to initialize silently
|
2010-08-10 18:34:26 +00:00
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
bool Clear_Pcb( bool aQuery );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
/* handlers for block commands */
|
2011-09-26 20:32:56 +00:00
|
|
|
virtual int ReturnBlockCommand( int key );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function HandleBlockPlace
|
|
|
|
* handles the BLOCK PLACE command
|
|
|
|
* Last routine for block operation for:
|
|
|
|
* - block move & drag
|
|
|
|
* - block copy & paste
|
|
|
|
*/
|
2010-08-10 18:34:26 +00:00
|
|
|
virtual void HandleBlockPlace( wxDC* DC );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2010-11-13 11:02:24 +00:00
|
|
|
virtual bool HandleBlockEnd( wxDC* DC );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
/* Undo and redo functions */
|
|
|
|
public:
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SaveCopyInUndoList.
|
2010-08-10 18:34:26 +00:00
|
|
|
* 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
|
2011-04-05 14:46:51 +00:00
|
|
|
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
|
2010-08-10 18:34:26 +00:00
|
|
|
* @param aTransformPoint = the reference point of the transformation, for
|
|
|
|
* commands like move
|
|
|
|
*/
|
|
|
|
virtual void SaveCopyInUndoList( BOARD_ITEM* aItem,
|
2011-04-05 14:46:51 +00:00
|
|
|
UNDO_REDO_T aTypeCommand,
|
|
|
|
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function SaveCopyInUndoList (overloaded).
|
2010-08-10 18:34:26 +00:00
|
|
|
* 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
|
2011-04-05 14:46:51 +00:00
|
|
|
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
|
2010-08-10 18:34:26 +00:00
|
|
|
* @param aTransformPoint = the reference point of the transformation, for
|
|
|
|
* commands like move
|
|
|
|
*/
|
|
|
|
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
|
2011-04-05 14:46:51 +00:00
|
|
|
UNDO_REDO_T aTypeCommand,
|
|
|
|
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
private:
|
2011-08-08 15:44:43 +00:00
|
|
|
static wxString m_CurrentLib;
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void GetComponentFromUndoList( wxCommandEvent& event );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void GetComponentFromRedoList( wxCommandEvent& event );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-08-08 15:44:43 +00:00
|
|
|
/**
|
|
|
|
* Function UpdateTitle
|
|
|
|
* updates window title according to m_CurrentLib.
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void UpdateTitle();
|
2011-08-08 15:44:43 +00:00
|
|
|
|
2010-08-10 18:34:26 +00:00
|
|
|
public:
|
|
|
|
|
|
|
|
// Footprint edition
|
2011-09-26 20:32:56 +00:00
|
|
|
void Place_Ancre( MODULE* module );
|
|
|
|
void RemoveStruct( EDA_ITEM* Item );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Transform
|
|
|
|
* performs a geometric transform on the current footprint.
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void Transform( MODULE* module, int transform );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
// importing / exporting Footprint
|
2010-12-29 17:47:32 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void Export_Module( MODULE* aModule, bool aCreateSysLib );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-08-10 18:34:26 +00:00
|
|
|
/**
|
|
|
|
* 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* Import_Module( );
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function Load_Module_From_BOARD
|
2011-09-26 20:32:56 +00:00
|
|
|
* load in Modedit a footprint from the main board
|
2010-08-10 18:34:26 +00:00
|
|
|
* @param Module = the module to load. If NULL, a module reference will we asked to user
|
|
|
|
* @return true if a module isloaded, false otherwise.
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
bool Load_Module_From_BOARD( MODULE* Module );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function Select_1_Module_From_BOARD
|
2010-08-10 18:34:26 +00:00
|
|
|
* 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
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
MODULE* Select_1_Module_From_BOARD( BOARD* aPcb );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
// functions to edit footprint edges
|
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function Edit_Edge_Width
|
2010-08-10 18:34:26 +00:00
|
|
|
* 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
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void Edit_Edge_Width( EDGE_MODULE* aEdge );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void Edit_Edge_Layer( EDGE_MODULE* Edge );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function Delete_Edge_Module
|
|
|
|
* deletes EDGE_MODULE Edge
|
|
|
|
* @param Edge = edge to delete
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void Delete_Edge_Module( EDGE_MODULE* Edge );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2010-08-10 18:34:26 +00:00
|
|
|
EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, int type_edge );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function End_Edge_Module
|
|
|
|
* terminates a move or create edge function
|
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void End_Edge_Module( EDGE_MODULE* Edge );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2010-11-12 15:17:10 +00:00
|
|
|
/**
|
|
|
|
* Function Enter_Edge_Width
|
2010-12-29 17:47:32 +00:00
|
|
|
* Edition of width of module outlines
|
2010-08-10 18:34:26 +00:00
|
|
|
* Ask for a new width.
|
|
|
|
* Change the width of EDGE_MODULE Edge if aEdge != NULL
|
|
|
|
* @param aEdge = edge to edit, or NULL
|
2010-12-29 17:47:32 +00:00
|
|
|
* changes ModuleSegmentWidth (global) = new width
|
2010-08-10 18:34:26 +00:00
|
|
|
*/
|
2011-09-26 20:32:56 +00:00
|
|
|
void Enter_Edge_Width( EDGE_MODULE* aEdge );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
/* Function to initialize the move function params of a graphic item type DRAWSEGMENT */
|
|
|
|
void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
|
2011-08-26 17:01:17 +00:00
|
|
|
|
|
|
|
/* Function to place a graphic item type EDGE_MODULE currently moved */
|
2011-09-26 20:32:56 +00:00
|
|
|
void Place_EdgeMod( EDGE_MODULE* drawitem );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
|
|
|
// handlers for libraries:
|
2011-09-26 20:32:56 +00:00
|
|
|
void Delete_Module_In_Library( const wxString& libname );
|
|
|
|
|
|
|
|
int CreateLibrary( const wxString& LibName );
|
2010-08-10 18:34:26 +00:00
|
|
|
|
2011-09-26 20:32:56 +00:00
|
|
|
void Select_Active_Library();
|
|
|
|
|
|
|
|
wxString GetCurrentLib() const { return m_CurrentLib; };
|
2011-08-08 15:44:43 +00:00
|
|
|
|
2010-08-10 18:34:26 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // #define _MODULE_EDITOR_FRAME_H_
|