2014-07-09 11:50:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 CERN
|
2023-03-30 11:49:23 +00:00
|
|
|
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
2014-07-09 11:50:27 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BASE_EDIT_FRAME_H
|
|
|
|
#define BASE_EDIT_FRAME_H
|
|
|
|
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
class APPEARANCE_CONTROLS;
|
2016-05-13 15:31:54 +00:00
|
|
|
class BOARD_ITEM_CONTAINER;
|
2020-06-27 22:48:34 +00:00
|
|
|
class PANEL_SELECTION_FILTER;
|
2023-03-30 11:49:23 +00:00
|
|
|
class PCB_TEXTBOX;
|
|
|
|
class PCB_TEXT;
|
|
|
|
class PCB_SHAPE;
|
2016-05-13 15:31:54 +00:00
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
/**
|
|
|
|
* Common, abstract interface for edit frames.
|
|
|
|
*/
|
|
|
|
class PCB_BASE_EDIT_FRAME : public PCB_BASE_FRAME
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PCB_BASE_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
|
2020-12-25 16:58:57 +00:00
|
|
|
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
|
|
|
|
long aStyle, const wxString& aFrameName );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2018-08-03 16:53:38 +00:00
|
|
|
virtual ~PCB_BASE_EDIT_FRAME();
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2020-08-19 10:31:20 +00:00
|
|
|
bool TryBefore( wxEvent& aEvent ) override;
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
void doCloseWindow() override;
|
2020-08-09 15:13:42 +00:00
|
|
|
|
2015-09-28 08:46:00 +00:00
|
|
|
/**
|
2017-08-26 12:04:56 +00:00
|
|
|
* If a library name is given, creates a new footprint library in the project folder
|
|
|
|
* with the given name. If no library name is given it prompts user for a library path,
|
|
|
|
* then creates a new footprint library at that location.
|
|
|
|
* If library exists, user is warned about that, and is given a chance
|
2015-09-28 08:46:00 +00:00
|
|
|
* to abort the new creation, and in that case existing library is first deleted.
|
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aProposedName is the initial path and filename shown in the file chooser dialog.
|
|
|
|
* @return The newly created library path if library was successfully created, else
|
|
|
|
* wxEmptyString because user aborted or error.
|
2015-09-28 08:46:00 +00:00
|
|
|
*/
|
2020-08-07 19:22:15 +00:00
|
|
|
wxString CreateNewLibrary( const wxString& aLibName = wxEmptyString,
|
|
|
|
const wxString& aProposedName = wxEmptyString );
|
2018-10-03 21:44:17 +00:00
|
|
|
|
2021-06-18 10:38:08 +00:00
|
|
|
wxString CreateNewProjectLibrary( const wxString& aLibName = wxEmptyString,
|
|
|
|
const wxString& aProposedName = wxEmptyString );
|
|
|
|
|
2018-10-03 21:44:17 +00:00
|
|
|
/**
|
|
|
|
* Add an existing library to either the global or project library table.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
2018-10-03 21:44:17 +00:00
|
|
|
* @param aFileName the library to add; a file open dialog will be displayed if empty.
|
2021-01-27 22:15:38 +00:00
|
|
|
* @return true if successfully added.
|
2018-10-03 21:44:17 +00:00
|
|
|
*/
|
2021-01-29 01:08:36 +00:00
|
|
|
bool AddLibrary( const wxString& aLibName = wxEmptyString, FP_LIB_TABLE* aTable = nullptr );
|
2015-09-28 08:46:00 +00:00
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Install the corresponding dialog editor for the given item.
|
|
|
|
*
|
|
|
|
* @param aDC the current device context.
|
|
|
|
* @param aItem a pointer to the BOARD_ITEM to edit.
|
2014-07-09 11:50:27 +00:00
|
|
|
*/
|
2023-09-27 15:36:49 +00:00
|
|
|
virtual void OnEditItemRequest( BOARD_ITEM* aItem ) {};
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2016-05-25 09:52:43 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Create a new entry in undo list of commands.
|
|
|
|
*
|
|
|
|
* Add a picker to handle \a aItemToCopy.
|
|
|
|
*
|
|
|
|
* @param aItemToCopy the board item modified by the command to undo.
|
|
|
|
* @param aTypeCommand command type (see enum UNDO_REDO).
|
2016-05-25 09:52:43 +00:00
|
|
|
*/
|
2021-02-12 19:26:48 +00:00
|
|
|
void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand ) override;
|
2016-05-25 09:52:43 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Create 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.
|
2021-02-15 14:02:41 +00:00
|
|
|
* @param aCommandType command type (see enum UNDO_REDO).
|
2016-05-25 09:52:43 +00:00
|
|
|
*/
|
2021-02-15 14:02:41 +00:00
|
|
|
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aCommandType ) override;
|
2019-05-14 19:21:10 +00:00
|
|
|
|
2022-02-25 13:05:25 +00:00
|
|
|
/**
|
|
|
|
* As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
|
|
|
|
*/
|
|
|
|
void AppendCopyToUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
|
|
|
UNDO_REDO aCommandType ) override;
|
|
|
|
|
2014-07-09 11:50:27 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Redo the last edit:
|
2016-05-25 09:52:43 +00:00
|
|
|
* - Save the current board in Undo list
|
|
|
|
* - Get an old version of the board from Redo list
|
2014-07-09 11:50:27 +00:00
|
|
|
*/
|
2016-05-25 09:52:43 +00:00
|
|
|
void RestoreCopyFromRedoList( wxCommandEvent& aEvent );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Undo the last edit:
|
2014-07-09 11:50:27 +00:00
|
|
|
* - Save the current board in Redo list
|
2016-05-25 09:52:43 +00:00
|
|
|
* - Get an old version of the board from Undo list
|
2014-07-09 11:50:27 +00:00
|
|
|
*/
|
2016-05-25 09:52:43 +00:00
|
|
|
void RestoreCopyFromUndoList( wxCommandEvent& aEvent );
|
2014-07-09 11:50:27 +00:00
|
|
|
|
2019-05-26 15:36:40 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Perform an undo of the last edit **without** logging a corresponding redo. Used to cancel
|
2019-05-26 15:36:40 +00:00
|
|
|
* an in-progress operation.
|
|
|
|
*/
|
|
|
|
void RollbackFromUndo();
|
|
|
|
|
2016-05-25 09:52:43 +00:00
|
|
|
/**
|
|
|
|
* Used in undo or redo command.
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
|
|
|
* Put data pointed by List in the previous state, i.e. the state memorized by \a aList.
|
|
|
|
*
|
|
|
|
* @param aList a PICKED_ITEMS_LIST pointer to the list of items to undo/redo.
|
2016-05-25 09:52:43 +00:00
|
|
|
*/
|
2021-02-15 14:02:41 +00:00
|
|
|
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList );
|
2015-02-12 03:22:24 +00:00
|
|
|
|
2015-08-04 21:08:13 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Check if the undo and redo operations are currently blocked.
|
2015-08-04 21:08:13 +00:00
|
|
|
*/
|
|
|
|
bool UndoRedoBlocked() const
|
|
|
|
{
|
|
|
|
return m_undoRedoBlocked;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Enable/disable undo and redo operations.
|
2015-08-04 21:08:13 +00:00
|
|
|
*/
|
|
|
|
void UndoRedoBlock( bool aBlock = true )
|
|
|
|
{
|
|
|
|
m_undoRedoBlocked = aBlock;
|
|
|
|
}
|
|
|
|
|
2019-11-23 22:43:54 +00:00
|
|
|
/**
|
|
|
|
* Override this function in the PCB_BASE_EDIT_FRAME to refill the layer widget
|
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* @param aVisible true if the grid must be shown.
|
2019-11-23 22:43:54 +00:00
|
|
|
*/
|
|
|
|
void SetGridVisibility( bool aVisible ) override;
|
|
|
|
|
2020-10-17 19:52:51 +00:00
|
|
|
void SetObjectVisible( GAL_LAYER_ID aLayer, bool aVisible = true );
|
|
|
|
|
2016-05-25 09:52:43 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return the angle used for rotate operations.
|
2016-05-25 09:52:43 +00:00
|
|
|
*/
|
2022-01-20 09:43:40 +00:00
|
|
|
virtual EDA_ANGLE GetRotationAngle() const;
|
2016-05-25 09:52:43 +00:00
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Set the angle used for rotate operations.
|
2016-05-25 09:52:43 +00:00
|
|
|
*/
|
2022-01-20 09:43:40 +00:00
|
|
|
//void SetRotationAngle( EDA_ANGLE aRotationAngle );
|
2016-05-25 09:52:43 +00:00
|
|
|
|
2022-02-08 19:29:54 +00:00
|
|
|
void ShowBitmapPropertiesDialog( BOARD_ITEM* aBitmap );
|
2023-03-30 11:49:23 +00:00
|
|
|
void ShowTextPropertiesDialog( PCB_TEXT* aText );
|
|
|
|
int ShowTextBoxPropertiesDialog( PCB_TEXTBOX* aTextBox );
|
|
|
|
void ShowGraphicItemPropertiesDialog( PCB_SHAPE* aShape );
|
2018-06-11 15:03:16 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< @copydoc EDA_DRAW_FRAME::UseGalCanvas()
|
2019-05-30 12:25:08 +00:00
|
|
|
void ActivateGalCanvas() override;
|
2015-08-07 17:15:36 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< @copydoc PCB_BASE_FRAME::SetBoard()
|
2021-11-25 16:19:03 +00:00
|
|
|
virtual void SetBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter = nullptr ) override;
|
2015-08-15 14:00:34 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
COLOR_SETTINGS* GetColorSettings( bool aForceRefresh = false ) const override;
|
2020-05-06 01:45:48 +00:00
|
|
|
|
2020-07-13 11:21:40 +00:00
|
|
|
/* full undo redo management : */
|
|
|
|
|
|
|
|
// use EDA_BASE_FRAME::ClearUndoRedoList()
|
|
|
|
// use EDA_BASE_FRAME::PushCommandToUndoList( PICKED_ITEMS_LIST* aItem )
|
|
|
|
// use EDA_BASE_FRAME::PushCommandToRedoList( PICKED_ITEMS_LIST* aItem )
|
|
|
|
|
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Free the undo or redo list from List element.
|
|
|
|
*
|
|
|
|
* Wrappers are deleted. Data pointed by wrappers are deleted if not in use in schematic
|
|
|
|
* i.e. when they are copy of a schematic item or they are no more in use (DELETED).
|
|
|
|
* Items are removed from the beginning of the list so this function can be called to
|
|
|
|
* remove old commands.
|
|
|
|
*
|
|
|
|
* @param whichList the #UNDO_REDO_CONTAINER to clear.
|
|
|
|
* @param aItemCount the count of items to remove. < 0 for all items.
|
2020-07-13 11:21:40 +00:00
|
|
|
*/
|
2020-07-13 13:50:35 +00:00
|
|
|
void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
|
2020-07-13 11:21:40 +00:00
|
|
|
|
2022-11-11 17:09:25 +00:00
|
|
|
void ClearListAndDeleteItems( PICKED_ITEMS_LIST* aList );
|
|
|
|
|
2020-09-25 01:26:23 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Return the absolute path to the design rules file for the currently-loaded board.
|
|
|
|
*
|
|
|
|
* @note There is no guarantee that this file actually exists and can be opened! It only
|
|
|
|
* makes sense from PcbNew but is needed in #PCB_BASE_EDIT_FRAME::SetBoard.
|
2020-09-25 01:26:23 +00:00
|
|
|
*/
|
|
|
|
wxString GetDesignRulesPath();
|
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
APPEARANCE_CONTROLS* GetAppearancePanel() { return m_appearancePanel; }
|
2021-01-29 01:08:36 +00:00
|
|
|
|
2023-06-21 01:57:20 +00:00
|
|
|
void ToggleProperties() override;
|
2023-02-16 03:16:49 +00:00
|
|
|
|
2023-05-24 22:46:48 +00:00
|
|
|
void GetContextualTextVars( BOARD_ITEM* aSourceItem, const wxString& aCrossRef,
|
|
|
|
wxArrayString* aTokens );
|
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
protected:
|
2021-01-29 01:08:36 +00:00
|
|
|
/**
|
|
|
|
* Prompts a user to select global or project library tables
|
|
|
|
*
|
|
|
|
* @return Pointer to library table selected or nullptr if none selected/canceled
|
|
|
|
*/
|
|
|
|
FP_LIB_TABLE* selectLibTable( bool aOptional = false );
|
2021-03-26 01:24:12 +00:00
|
|
|
|
2021-06-18 10:38:08 +00:00
|
|
|
/**
|
|
|
|
* Create a new library in the given table (presumed to be either the global or project
|
|
|
|
* library table).
|
|
|
|
*/
|
|
|
|
wxString createNewLibrary( const wxString& aLibName, const wxString& aProposedName,
|
|
|
|
FP_LIB_TABLE* aTable );
|
|
|
|
|
2021-03-26 01:24:12 +00:00
|
|
|
void handleActivateEvent( wxActivateEvent& aEvent ) override;
|
2021-04-05 22:29:12 +00:00
|
|
|
|
2022-02-25 13:05:25 +00:00
|
|
|
void saveCopyInUndoList( PICKED_ITEMS_LIST* commandToUndo, const PICKED_ITEMS_LIST& aItemsList,
|
|
|
|
UNDO_REDO aCommandType );
|
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
void unitsChangeRefresh() override;
|
|
|
|
|
2022-11-06 00:34:13 +00:00
|
|
|
virtual void onDarkModeToggle();
|
|
|
|
|
2021-04-05 22:29:12 +00:00
|
|
|
protected:
|
|
|
|
bool m_undoRedoBlocked;
|
|
|
|
|
|
|
|
PANEL_SELECTION_FILTER* m_selectionFilterPanel;
|
|
|
|
APPEARANCE_CONTROLS* m_appearancePanel;
|
2020-02-04 08:40:25 +00:00
|
|
|
|
2022-11-06 00:34:13 +00:00
|
|
|
wxAuiNotebook* m_tabbedPanel; /// Panel with Layers and Object Inspector tabs
|
|
|
|
|
|
|
|
bool m_darkMode;
|
2014-07-09 11:50:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|