/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008-2011 Wayne Stambaugh
* EVT_CLOSE( LIB_EDIT_FRAME::OnCloseWindow )
*/
void CloseWindow( wxCommandEvent& event )
{
// Generate a wxCloseEvent
Close( false );
}
/**
* Function OnModify
* Must be called after a schematic change
* in order to set the "modify" flag of the current screen
*/
void OnModify()
{
GetScreen()->SetModify();
}
LIB_COMPONENT* GetComponent( void ) { return m_component; }
CMP_LIBRARY* GetLibrary( void ) { return m_library; }
wxString& GetAliasName( void ) { return m_aliasName; }
int GetUnit( void ) { return m_unit; }
void SetUnit( int unit )
{
wxASSERT( unit >= 1 );
m_unit = unit;
}
int GetConvert( void ) { return m_convert; }
void SetConvert( int convert )
{
wxASSERT( convert >= 0 );
m_convert = convert;
}
LIB_ITEM* GetLastDrawItem( void ) { return m_lastDrawItem; }
void SetLastDrawItem( LIB_ITEM* drawItem )
{
m_lastDrawItem = drawItem;
}
LIB_ITEM* GetDrawItem( void ) { return m_drawItem; }
void SetDrawItem( LIB_ITEM* drawItem );
bool GetShowDeMorgan( void ) { return m_showDeMorgan; }
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
FILL_T GetFillStyle( void ) { return m_drawFillStyle; }
/**
* Function TempCopyComponent
* create a temporary copy of the current edited component
* Used to prepare an Undo ant/or abort command before editing the component
*/
void TempCopyComponent();
/**
* Function RestoreComponent
* Restore the current edited component from its temporary copy.
* Used to abort a command
*/
void RestoreComponent();
/**
* Function GetTempCopyComponent
* @return the temporary copy of the current component.
*/
LIB_COMPONENT* GetTempCopyComponent() { return m_tempCopyComponent; }
/**
* Function ClearTempCopyComponent
* delete temporary copy of the current component and clear pointer
*/
void ClearTempCopyComponent();
bool IsEditingDrawItem() { return m_drawItem && m_drawItem->InEditMode(); }
private:
/**
* Function OnActivate
* is called when the frame is activated. Tests if the current library exists.
* The library list can be changed by the schematic editor after reloading a new schematic
* and the current m_library can point a non existent lib.
*/
virtual void OnActivate( wxActivateEvent& event );
// General:
/**
* Function SaveOnePartInMemory
* updates the current component being edited in the active library.
*
* Any changes are updated in memory only and NOT to a file. The old component is
* deleted from the library and/or any aliases before the edited component is updated
* in the library.
*/
void SaveOnePartInMemory();
/**
* Function SelectActiveLibrary
* sets the current active library to \a aLibrary.
*
* @param aLibrary A pointer to the CMP_LIBRARY object to select. If NULL, then display
* list of available libraries to select from.
*/
void SelectActiveLibrary( CMP_LIBRARY* aLibrary = NULL );
/**
* Function OnSaveActiveLibrary
* it the command event handler to save the changes to the current library.
*
* A backup file of the current library is saved with the .bak extension before the
* changes made to the library are saved.
*/
void OnSaveActiveLibrary( wxCommandEvent& event );
/**
* Function SaveActiveLibrary
* saves the changes to the current library.
*
* A backup file of the current library is saved with the .bak extension before the
* changes made to the library are saved.
* @param newFile Ask for a new file name to save the library.
* @return True if the library was successfully saved.
*/
bool SaveActiveLibrary( bool newFile );
/**
* Function LoadComponentFromCurrentLib
* loads a component from the current active library.
* @param aLibEntry The component to load from \a aLibrary (can be an alias)
* @return true if \a aLibEntry loaded correctly.
*/
bool LoadComponentFromCurrentLib( LIB_ALIAS* aLibEntry );
/**
* Function LoadOneLibraryPartAux
* loads a copy of \a aLibEntry from \a aLibrary into memory.
*
* @param aLibEntry A pointer to the LIB_ALIAS object to load.
* @param aLibrary A pointer to the CMP_LIBRARY object to load \a aLibEntry from.
* @return True if a copy of \a aLibEntry was successfully loaded from \a aLibrary.
*/
bool LoadOneLibraryPartAux( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary );
/**
* Function DisplayCmpDoc
* displays the documentation of the selected component.
*/
void DisplayCmpDoc();
/**
* Function OnRotateItem
* rotates the current item.
*/
void OnRotateItem( wxCommandEvent& aEvent );
/**
* Function deleteItem
* deletes the currently selected draw item.
* @param aDC The device context to draw upon when removing item.
*/
void deleteItem( wxDC* aDC );
// General editing
public:
void SaveCopyInUndoList( EDA_ITEM* ItemToCopy, int flag_type_command = 0 );
private:
void GetComponentFromUndoList( wxCommandEvent& event );
void GetComponentFromRedoList( wxCommandEvent& event );
// Editing pins
void CreatePin( wxDC* DC );
void StartMovePin( wxDC* DC );
/**
* Function CreateImagePins
* adds copies of \a aPin for \a aUnit in components with multiple parts and
* \a aConvert for components that have multiple body styles.
*
* @param aPin The pin to copy.
* @param aUnit The unit to add a copy of \a aPin to.
* @param aConvert The alternate body style to add a copy of \a aPin to.
* @param aDeMorgan Flag to indicate if \a aPin should be created for the
* alternate body style.
*/
void CreateImagePins( LIB_PIN* aPin, int aUnit, int aConvert, bool aDeMorgan );
/**
* Function PlaceAnchor
* places an anchor reference coordinate for the current component.
*
* All object coordinates are offset to the current cursor position.
*
* The symbol file format is similar to the standard component library file format, but * there is only one symbol. Invisible pins are not saved. */ void SaveOneSymbol(); void EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ); void EditSymbolText( wxDC* DC, LIB_ITEM* DrawItem ); LIB_ITEM* LocateItemUsingCursor( const wxPoint& aPosition, const KICAD_T aFilterList[] = LIB_COLLECTOR::AllItems ); void EditField( LIB_FIELD* Field ); public: /** * Function LoadComponentAndSelectLib * selects the current active library. * * @param aLibrary The CMP_LIBRARY to select * @param aLibEntry The component to load from aLibrary (can be an alias). * @return true if \a aLibEntry was loaded from \a aLibrary. */ bool LoadComponentAndSelectLib( LIB_ALIAS* aLibEntry, CMP_LIBRARY* aLibrary ); /* Block commands: */ /** * Function BlockCommand * returns the block command (BLOCK_MOVE, BLOCK_COPY...) corresponding to * the \a aKey (ALT, SHIFT ALT ..) */ virtual int BlockCommand( int aKey ); /** * Function HandleBlockPlace * handles the block place command. */ virtual void HandleBlockPlace( wxDC* DC ); /** * Function HandleBlockEnd * performs a block end command. * @return If command finished (zoom, delete ...) false is returned otherwise true * is returned indicating more processing is required. */ virtual bool HandleBlockEnd( wxDC* DC ); /** * Function PlacePin * Place at cursor location the pin currently moved (i.e. pin pointed by m_drawItem) * (and the linked pins, if any) */ void PlacePin(); /** * Function GlobalSetPins * @param aMasterPin is the "template" pin * @param aId is a param to select what should be mofified: * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNAMESIZE_ITEM: * Change pins text name size * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINNUMSIZE_ITEM: * Change pins text num size * - aId = ID_POPUP_LIBEDIT_PIN_GLOBAL_CHANGE_PINSIZE_ITEM: * Change pins length. * * If aMasterPin is selected ( .m_flag == IS_SELECTED ), * only the other selected pins are modified */ void GlobalSetPins( LIB_PIN* aMasterPin, int aId ); // Automatic placement of pins void RepeatPinItem( wxDC* DC, LIB_PIN* Pin ); /** * Function CreatePNGorJPEGFile * creates an image (screenshot) of the current component in PNG or JPEG format. * @param aFileName = the full filename * @param aFmt_jpeg = true to use JPEG file format, false to use PNG file format */ void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg ); /** * Virtual function PrintPage * used to print a page * @param aDC = wxDC given by the calling print function * @param aPrintMask = not used here * @param aPrintMirrorMode = not used here (Set when printing in mirror mode) * @param aData = a pointer on an auxiliary data (not always used, NULL if not used) */ virtual void PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData = NULL ); /** * Function SVG_PlotComponent * Creates the SVG print file for the current edited component. * @param aFullFileName = the full filename */ void SVG_PlotComponent( const wxString& aFullFileName ); DECLARE_EVENT_TABLE() }; #endif // LIBEDITFRM_H_