/***********************************************************/ /* wxPcbStruct.h */ /***********************************************************/ #ifndef WXPCB_STRUCT_H #define WXPCB_STRUCT_H #include "wxstruct.h" #include "base_struct.h" #include "param_config.h" #include "class_layerchoicebox.h" #ifndef PCB_INTERNAL_UNIT #define PCB_INTERNAL_UNIT 10000 #endif /* Forward declarations of classes. */ class PCB_SCREEN; class WinEDA_Toolbar; class WinEDA_ModuleEditFrame; class BOARD; class TEXTE_PCB; class MODULE; class TRACK; class SEGZONE; class SEGVIA; class D_PAD; class TEXTE_MODULE; class MIREPCB; class DIMENSION; class EDGE_MODULE; class WinEDA3D_DrawFrame; class DRC; class ZONE_CONTAINER; class DRAWSEGMENT; class GENERAL_COLLECTOR; class GENERAL_COLLECTORS_GUIDE; class PCB_LAYER_WIDGET; /** * @info see also class WinEDA_BasePcbFrame: Basic class for pcbnew and gerbview. */ /*****************************************************/ /* class WinEDA_PcbFrame: the main frame for Pcbnew */ /*****************************************************/ class WinEDA_PcbFrame : public WinEDA_BasePcbFrame { friend class PCB_LAYER_WIDGET; protected: PCB_LAYER_WIDGET* m_Layers; DRC* m_drc; ///< the DRC controller, see drc.cpp PARAM_CFG_ARRAY m_projectFileParams; ///< List of PCBNew project file settings. PARAM_CFG_ARRAY m_configSettings; ///< List of PCBNew configuration settings. wxString m_lastNetListRead; ///< Last net list read with relative path. // we'll use lower case function names for private member functions. void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu ); void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu ); void createPopUpMenuForFpTexts( TEXTE_MODULE* aText, wxMenu* aPopMenu ); void createPopUpMenuForFpPads( D_PAD* aPad, wxMenu* aPopMenu ); void createPopupMenuForTracks( TRACK* aTrack, wxMenu* aPopMenu ); void createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ); void createPopUpBlockMenu( wxMenu* menu ); void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu ); /** * Function setActiveLayer * will change the currently active layer to \a aLayer and also * update the PCB_LAYER_WIDGET. */ void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true ) { ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer; if( doLayerWidgetUpdate ) syncLayerWidget(); } /** * Function getActiveLayer * returns the active layer */ int getActiveLayer() { return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer; } /** * Function syncLayerWidget * updates the currently "selected" layer within the PCB_LAYER_WIDGET. * The currently active layer is defined by the return value of getActiveLayer(). *
* This function cannot be inline without including layer_widget.h in
* here and we do not want to do that.
*/
void syncLayerWidget( );
/**
* Function syncLayerBox
* updates the currently "selected" layer within m_SelLayerBox
* The currently active layer, as defined by the return value of
* getActiveLayer(). And updates the colored icon in the toolbar.
*/
void syncLayerBox();
public:
WinEDALayerChoiceBox* m_SelLayerBox; // a combo box to display and
// select active layer
WinEDAChoiceBox* m_SelTrackWidthBox; // a combo box to display and
// select current track width
WinEDAChoiceBox* m_SelViaSizeBox; // a combo box to display and
// select current via diameter
wxTextCtrl* m_ClearanceBox; // a text ctrl to display the
// current tracks and vias
// clearance
wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the
// current NetClass
bool m_TrackAndViasSizesList_Changed;
bool m_show_microwave_tools;
bool m_show_layer_manager_tools;
public:
WinEDA_PcbFrame( wxWindow* father, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
~WinEDA_PcbFrame();
void OnQuit( wxCommandEvent & WXUNUSED(event) );
/**
* Function ToPlotter
* Open a dialog frame to create plot and drill files
* relative to the current board
*/
void ToPlotter( wxCommandEvent& event );
/**
* Function ToPrinter
* Install the print dialog
*/
void ToPrinter( wxCommandEvent& event );
/** 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
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
int aPrintMask, bool aPrintMirrorMode,
void * aData = NULL );
void GetKicadAbout( wxCommandEvent& event );
/**
* Function IsGridVisible() , virtual
* @return true if the grid must be shown
*/
virtual bool IsGridVisible();
/**
* 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
*/
virtual void SetGridVisibility(bool aVisible);
/**
* Function GetGridColor() , virtual
* @return the color of the grid
*/
virtual int GetGridColor();
/**
* Function SetGridColor() , virtual
* @param aColor = the new color of the grid
*/
virtual void SetGridColor(int aColor);
// Configurations:
void InstallConfigFrame( const wxPoint& pos );
void Process_Config( wxCommandEvent& event );
PARAM_CFG_ARRAY& GetProjectFileParameters();
void SaveProjectSettings();
/**
* Load the project file configuration settings.
*
* @param aProjectFileName = The project filename.
* if not found use kicad.pro and initialize default values
* @return always returns true.
*/
bool LoadProjectSettings( const wxString& aProjectFileName );
/**
* Get the list of application specific settings.
*
* @return - Reference to the list of applications settings.
*/
PARAM_CFG_ARRAY& GetConfigurationSettings();
/**
* Load applications settings specific to PCBNew.
*
* This overrides the base class WinEDA_BasePcbFrame::LoadSettings() to
* handle settings specific common to the PCB layout application. It
* calls down to the base class to load settings common to all PCB type
* drawing frames. Please put your application settings for PCBNew here
* to avoid having application settings loaded all over the place.
*/
virtual void LoadSettings();
/**
* Save applications settings common to PCBNew.
*
* This overrides the base class WinEDA_BasePcbFrame::SaveSettings() to
* save settings specific to the PCB layout application main window. It
* calls down to the base class to save settings common to all PCB type
* drawing frames. Please put your application settings for PCBNew here
* to avoid having application settings saved all over the place.
*/
virtual void SaveSettings();
/**
* Get the last net list read with the net list dialog box.
*
* @return - Absolute path and file name of the last net list file successfully read.
*/
wxString GetLastNetListRead();
/**
* Set the last net list successfully read by the net list dialog box.
*
* Note: the file path is converted to a path relative to the project file path. If
* the path cannot be made relative, than m_lastNetListRead is set to and empty
* string. This could happen when the net list file is on a different drive than
* the project file. The advantage of relative paths is that is more likely to
* work when opening the same project from both Windows and Linux.
*
* @param aNetListFile - The last net list file with full path successfully read.
*/
void SetLastNetListRead( const wxString& aNetListFile );
/**
* Function OnHotKey.
* ** Commands are case insensitive **
* Some commands are relatives to the item under the mouse cursor
* @param aDC = current device context
* @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
* @param aItem = NULL or pointer on a EDA_BaseStruct under the mouse cursor
*/
void OnHotKey( wxDC* aDC,
int aHotkeyCode,
EDA_BaseStruct* aItem );
/**
* Function OnHotkeyDeleteItem
* Delete the item found under the mouse cursor
* Depending on the current active tool::
* Tool track
* if a track is in progress: Delete the last segment
* else delete the entire track
* Tool module (footprint):
* Delete the module.
* @param aDC = current device context
* @return true if an item was deleted
*/
bool OnHotkeyDeleteItem( wxDC* aDC );
bool OnHotkeyEditItem( int aIdCommand );
/**
* Function OnHotkeyMoveItem
* Moves or drag the item (footprint, track, text .. ) found under the mouse cursor
* Only a footprint or a track can be dragged
* @param aIdCommand = the hotkey command id
* @return true if an item was moved
*/
bool OnHotkeyMoveItem( int aIdCommand );
/**
* Function OnHotkeyRotateItem
* Rotate the item (text or footprint) found under the mouse cursor
* @param aIdCommand = the hotkey command id
* @return true if an item was moved
*/
bool OnHotkeyRotateItem( int aIdCommand );
void OnCloseWindow( wxCloseEvent& Event );
void Process_Special_Functions( wxCommandEvent& event );
void Tracks_and_Vias_Size_Event( wxCommandEvent& event );
void ProcessMuWaveFunctions( wxCommandEvent& event );
void MuWaveCommand( wxDC* DC, const wxPoint& MousePos );
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void ReCreateHToolbar();
void ReCreateAuxiliaryToolbar();
void ReCreateVToolbar();
void ReCreateMicrowaveVToolbar();
void ReCreateOptToolbar();
void ReCreateMenuBar();
WinEDALayerChoiceBox* ReCreateLayerBox( WinEDA_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
*/
virtual void OnModify( );
/**
* Function IsElementVisible
* tests whether a given element category is visible. Keep this as an
* inline function.
* @param aPCB_VISIBLE is from the enum by the same name
* @return bool - true if the element is visible.
* @see enum PCB_VISIBLE
*/
bool IsElementVisible( int aPCB_VISIBLE )
{
return GetBoard()->IsElementVisible( aPCB_VISIBLE );
}
/**
* 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 SetElementVisibility( int aPCB_VISIBLE, bool aNewState );
/**
* Function SetVisibleAlls
* Set the status of all visible element categories and layers to VISIBLE
*/
void SetVisibleAlls( );
/**
* Function ReFillLayerWidget
* changes out all the layers in m_Layers and may be called upon
* loading a new BOARD.
*/
void ReFillLayerWidget();
void Show3D_Frame( wxCommandEvent& event );
void GeneralControle( wxDC* DC, wxPoint Mouse );
/**
* Function ShowDesignRulesEditor
* Display the Design Rules Editor.
*/
void ShowDesignRulesEditor( wxCommandEvent& event );
/* toolbars update UI functions: */
void PrepareLayerIndicator();
/**
* Function AuxiliaryToolBar_Update_UI
* update the displayed values on auxiliary horizontal toolbar
* (track width, via sizes, clearance ...
*/
void AuxiliaryToolBar_Update_UI();
/**
* Function AuxiliaryToolBar_DesignRules_Update_UI
* update the displayed values: track width, via sizes, clearance
* used when a new netclass is selected
*/
void AuxiliaryToolBar_DesignRules_Update_UI();
/* mouse functions events: */
void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
/**
* Function OnRightClick
* populates a popup menu with the choices appropriate for the current
*context.
* The caller will add the ZOOM menu choices afterward.
* @param aMousePos The current mouse position
* @param aPopMenu The menu to add to.
*/
bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu );
void OnSelectOptionToolbar( wxCommandEvent& event );
void ToolOnRightClick( wxCommandEvent& event );
/**
* Function SaveCopyInUndoList.
* Creates a new entry in undo list of commands.
* add a picker to handle aItemToCopy
* @param aItemToCopy = the board item modified by the command to undo
* @param aTypeCommand = command type (see enum UndoRedoOpType)
* @param aTransformPoint = the reference point of the transformation, for
*commands like move
*/
virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint =
wxPoint( 0, 0 ) );
/**
* 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 UndoRedoOpType)
* @param aTransformPoint = the reference point of the transformation, for
*commands like move
*/
virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
UndoRedoOpType aTypeCommand,
const wxPoint& aTransformPoint =
wxPoint( 0, 0 ) );
/**
* Function PutDataInPreviousState()
* Used in undo or redo command.
* Put data pointed by List in the previous state, i.e. the state memorized
* by List
* @param aList = a PICKED_ITEMS_LIST pointer to the list of items to
* undo/redo
* @param aRedoCommand = a bool: true for redo, false for undo
* @param aRebuildRatsnet = a bool: true to rebuild ratsnet (normal use),
* false
* to just retrieve last state (used in abort commands that do not need to
* rebuild ratsnest)
*/
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
bool aRedoCommand,
bool aRebuildRatsnet = true );
/**
* Function GetBoardFromRedoList
* Redo the last edition:
* - Save the current board in Undo list
* - Get an old version of the board from Redo list
* @return none
*/
void GetBoardFromRedoList( wxCommandEvent& event );
/**
* Function GetBoardFromUndoList
* Undo the last edition:
* - Save the current board in Redo list
* - Get an old version of the board from Undo list
* @return none
*/
void GetBoardFromUndoList( wxCommandEvent& event );
/* Block operations: */
int ReturnBlockCommand( int key );
void HandleBlockPlace( wxDC* DC );
int HandleBlockEnd( wxDC* DC );
/**
* Function Block_SelectItems
* Uses GetScreen()->m_BlockLocate
* select items within the selected block.
* selected items are put in the pick list
* @param none
*/
void Block_SelectItems();
/**
* Function Block_Delete
* deletes all items within the selected block.
* @param none
*/
void Block_Delete();
/**
* Function Block_Rotate
* Rotate all items within the selected block.
* The rotation center is the center of the block
* @param none
*/
void Block_Rotate();
/**
* Function Block_Flip
* Flip items within the selected block.
* The flip center is the center of the block
* @param none
*/
void Block_Flip();
/**
* Function Block_Move
* move all items within the selected block.
* New location is determined by the current offset from the selected
*block's original location.
* @param none
*/
void Block_Move();
/**
* Function Block_Mirror_X
* mirrors all items within the currently selected block in the X axis.
* @param none
*/
void Block_Mirror_X();
/**
* Function Block_Duplicate
* Duplicate all items within the selected block.
* New location is determined by the current offset from the selected
* block's original location.
* @param none
*/
void Block_Duplicate();
void SetToolbars();
void Process_Settings( wxCommandEvent& event );
void OnConfigurePcbOptions( wxCommandEvent& aEvent );
void InstallDisplayOptionsDialog( wxCommandEvent& aEvent );
void InstallPcbGlobalDeleteFrame( const wxPoint& pos );
void GenModulesPosition( wxCommandEvent& event );
void GenModuleReport( wxCommandEvent& event );
void InstallDrillFrame( wxCommandEvent& event );
void ToPostProcess( wxCommandEvent& event );
void OnFileHistory( wxCommandEvent& event );
void 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 LoadOnePcbFile( const wxString& aFileName, bool aAppend = false,
bool aForceFileDialog = false );
/**
* Function ReadPcbFile
* reads a board file