Created a common interface for edit frames.
This commit is contained in:
parent
eee2779f6b
commit
b0f3e79e54
|
@ -30,7 +30,7 @@
|
|||
#define WXPCB_STRUCT_H_
|
||||
|
||||
|
||||
#include <wxBasePcbFrame.h>
|
||||
#include <pcb_base_edit_frame.h>
|
||||
#include <config_params.h>
|
||||
#include <class_macros_record.h>
|
||||
#include <class_undoredo_container.h>
|
||||
|
@ -73,7 +73,7 @@ namespace PCB { struct IFACE; } // KIFACE_I is in pcbnew.cpp
|
|||
*
|
||||
* See also class PCB_BASE_FRAME(): Basic class for Pcbnew and GerbView.
|
||||
*/
|
||||
class PCB_EDIT_FRAME : public PCB_BASE_FRAME
|
||||
class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
|
||||
{
|
||||
friend class PCB::IFACE;
|
||||
friend class PCB_LAYER_WIDGET;
|
||||
|
@ -659,22 +659,22 @@ public:
|
|||
bool aRebuildRatsnet = true );
|
||||
|
||||
/**
|
||||
* Function GetBoardFromRedoList
|
||||
* Function RestoreCopyFromRedoList
|
||||
* 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& aEvent );
|
||||
void RestoreCopyFromRedoList( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Function GetBoardFromUndoList
|
||||
* Function RestoreCopyFromUndoList
|
||||
* 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& aEvent );
|
||||
void RestoreCopyFromUndoList( wxCommandEvent& aEvent );
|
||||
|
||||
/* Block operations: */
|
||||
|
||||
|
|
|
@ -630,7 +630,7 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
|
||||
void PCB_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( GetScreen()->GetUndoCommandCount() <= 0 )
|
||||
return;
|
||||
|
@ -653,7 +653,7 @@ void PCB_EDIT_FRAME::GetBoardFromUndoList( wxCommandEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::GetBoardFromRedoList( wxCommandEvent& aEvent )
|
||||
void PCB_EDIT_FRAME::RestoreCopyFromRedoList( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( GetScreen()->GetRedoCommandCount() == 0 )
|
||||
return;
|
||||
|
|
|
@ -418,41 +418,7 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
|
|||
|
||||
// Item found
|
||||
SetCurItem( item );
|
||||
|
||||
switch( item->Type() )
|
||||
{
|
||||
case PCB_PAD_T:
|
||||
InstallPadOptionsFrame( (D_PAD*) item );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
break;
|
||||
|
||||
case PCB_MODULE_T:
|
||||
{
|
||||
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) item );
|
||||
int ret = dialog.ShowModal();
|
||||
GetScreen()->GetCurItem()->ClearFlags();
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
|
||||
if( ret > 0 )
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
case PCB_MODULE_TEXT_T:
|
||||
InstallTextModOptionsFrame( (TEXTE_MODULE*) item, DC );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
break;
|
||||
|
||||
case PCB_MODULE_EDGE_T :
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) item );
|
||||
m_canvas->Refresh();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
OnEditItemRequest( DC, item );
|
||||
break; // end case 0
|
||||
|
||||
case ID_PCB_ADD_LINE_BUTT:
|
||||
|
@ -471,3 +437,41 @@ void FOOTPRINT_EDIT_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem )
|
||||
{
|
||||
switch( aItem->Type() )
|
||||
{
|
||||
case PCB_PAD_T:
|
||||
InstallPadOptionsFrame( (D_PAD*) aItem );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
break;
|
||||
|
||||
case PCB_MODULE_T:
|
||||
{
|
||||
DIALOG_MODULE_MODULE_EDITOR dialog( this, (MODULE*) aItem );
|
||||
int ret = dialog.ShowModal();
|
||||
GetScreen()->GetCurItem()->ClearFlags();
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
|
||||
if( ret > 0 )
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
case PCB_MODULE_TEXT_T:
|
||||
InstallTextModOptionsFrame( (TEXTE_MODULE*) aItem, aDC );
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
break;
|
||||
|
||||
case PCB_MODULE_EDGE_T :
|
||||
m_canvas->MoveCursorToCrossHair();
|
||||
InstallFootprintBodyItemPropertiesDlg( (EDGE_MODULE*) aItem );
|
||||
m_canvas->Refresh();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLi
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& aEvent )
|
||||
void FOOTPRINT_EDIT_FRAME::RestoreCopyFromRedoList( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( GetScreen()->GetRedoCommandCount() <= 0 )
|
||||
return;
|
||||
|
@ -107,7 +107,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& aEvent )
|
||||
void FOOTPRINT_EDIT_FRAME::RestoreCopyFromUndoList( wxCommandEvent& aEvent )
|
||||
{
|
||||
if( GetScreen()->GetUndoCommandCount() <= 0 )
|
||||
return;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#define MODULE_EDITOR_FRAME_H_
|
||||
|
||||
#include <wxBasePcbFrame.h>
|
||||
#include <pcb_base_edit_frame.h>
|
||||
#include <io_mgr.h>
|
||||
|
||||
|
||||
|
@ -38,7 +39,7 @@ class FP_LIB_TABLE;
|
|||
namespace PCB { struct IFACE; } // A KIFACE_I coded in pcbnew.c
|
||||
|
||||
|
||||
class FOOTPRINT_EDIT_FRAME : public PCB_BASE_FRAME
|
||||
class FOOTPRINT_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
|
||||
{
|
||||
friend struct PCB::IFACE;
|
||||
|
||||
|
@ -148,6 +149,9 @@ public:
|
|||
void OnUpdateReplaceModuleInBoard( wxUpdateUIEvent& aEvent );
|
||||
void OnUpdateSelectCurrentLib( wxUpdateUIEvent& aEvent );
|
||||
|
||||
///> @copydoc PCB_BASE_EDIT_FRAME::OnEditItemRequest()
|
||||
void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem );
|
||||
|
||||
/**
|
||||
* Function LoadModuleFromBoard
|
||||
* called from the main toolbar to load a footprint from board mainly to edit it.
|
||||
|
@ -244,6 +248,22 @@ public:
|
|||
UNDO_REDO_T aTypeCommand,
|
||||
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
||||
|
||||
/**
|
||||
* Function RestoreCopyFromUndoList
|
||||
* 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 RestoreCopyFromUndoList( wxCommandEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Function RestoreCopyFromRedoList
|
||||
* 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 RestoreCopyFromRedoList( wxCommandEvent& aEvent );
|
||||
|
||||
/// Return the current library nickname.
|
||||
const wxString GetCurrentLib() const;
|
||||
|
||||
|
@ -413,22 +433,6 @@ protected:
|
|||
|
||||
PCB_LAYER_WIDGET* m_Layers;
|
||||
|
||||
/**
|
||||
* 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& aEvent );
|
||||
|
||||
/**
|
||||
* Function 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& aEvent );
|
||||
|
||||
/**
|
||||
* Function UpdateTitle
|
||||
* updates window title according to getLibNickName().
|
||||
|
|
|
@ -99,8 +99,8 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
EVT_TOOL( ID_MODEDIT_INSERT_MODULE_IN_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_UPDATE_MODULE_IN_BOARD, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( ID_MODEDIT_EDIT_MODULE_PROPERTIES, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( wxID_UNDO, FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList )
|
||||
EVT_TOOL( wxID_REDO, FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList )
|
||||
EVT_TOOL( wxID_UNDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromUndoList )
|
||||
EVT_TOOL( wxID_REDO, FOOTPRINT_EDIT_FRAME::RestoreCopyFromRedoList )
|
||||
|
||||
// Vertical tool bar button click event handler.
|
||||
EVT_TOOL( ID_NO_TOOL_SELECTED, FOOTPRINT_EDIT_FRAME::OnVerticalToolbar )
|
||||
|
@ -160,7 +160,7 @@ END_EVENT_TABLE()
|
|||
#define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" )
|
||||
|
||||
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
PCB_BASE_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
|
||||
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
KICAD_DEFAULT_DRAWFRAME_STYLE, GetFootprintEditorFrameName() )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 CERN
|
||||
* @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
|
||||
|
||||
#include <wxBasePcbFrame.h>
|
||||
|
||||
/**
|
||||
* 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,
|
||||
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
|
||||
long aStyle, const wxString& aFrameName ) :
|
||||
PCB_BASE_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
|
||||
{}
|
||||
|
||||
virtual ~PCB_BASE_EDIT_FRAME() {};
|
||||
|
||||
/**
|
||||
* Function OnEditItemRequest
|
||||
* 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
|
||||
*/
|
||||
virtual void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) = 0;
|
||||
|
||||
/**
|
||||
* Function RestoreCopyFromRedoList
|
||||
* Redo the last edition:
|
||||
* - Save the current data in Undo list
|
||||
* - Get an old version of the data from Redo list
|
||||
*/
|
||||
virtual void RestoreCopyFromRedoList( wxCommandEvent& aEvent ) = 0;
|
||||
|
||||
/**
|
||||
* Function RestoreCopyFromUndoList
|
||||
* Undo the last edition:
|
||||
* - Save the current board in Redo list
|
||||
* - Get an old version of the data from Undo list
|
||||
*/
|
||||
virtual void RestoreCopyFromUndoList( wxCommandEvent& aEvent ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -187,8 +187,8 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
EVT_TOOL( wxID_CUT, PCB_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( wxID_COPY, PCB_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( wxID_PASTE, PCB_EDIT_FRAME::Process_Special_Functions )
|
||||
EVT_TOOL( wxID_UNDO, PCB_EDIT_FRAME::GetBoardFromUndoList )
|
||||
EVT_TOOL( wxID_REDO, PCB_EDIT_FRAME::GetBoardFromRedoList )
|
||||
EVT_TOOL( wxID_UNDO, PCB_EDIT_FRAME::RestoreCopyFromUndoList )
|
||||
EVT_TOOL( wxID_REDO, PCB_EDIT_FRAME::RestoreCopyFromRedoList )
|
||||
EVT_TOOL( wxID_PRINT, PCB_EDIT_FRAME::ToPrinter )
|
||||
EVT_TOOL( ID_GEN_PLOT_SVG, PCB_EDIT_FRAME::SVG_Print )
|
||||
EVT_TOOL( ID_GEN_PLOT, PCB_EDIT_FRAME::Process_Special_Functions )
|
||||
|
@ -304,7 +304,7 @@ END_EVENT_TABLE()
|
|||
#define PCB_EDIT_FRAME_NAME wxT( "PcbFrame" )
|
||||
|
||||
PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
PCB_BASE_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition,
|
||||
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB, wxT( "Pcbnew" ), wxDefaultPosition,
|
||||
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PCB_EDIT_FRAME_NAME )
|
||||
{
|
||||
m_FrameName = PCB_EDIT_FRAME_NAME;
|
||||
|
|
|
@ -189,7 +189,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
|
|||
{
|
||||
// Modifications have to be rollbacked, so restore the previous state of items
|
||||
wxCommandEvent dummy;
|
||||
editFrame->GetBoardFromUndoList( dummy );
|
||||
editFrame->RestoreCopyFromUndoList( dummy );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -309,7 +309,7 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
|
|||
if( modified ) // Restore the last change
|
||||
{
|
||||
wxCommandEvent dummy;
|
||||
editFrame->GetBoardFromUndoList( dummy );
|
||||
editFrame->RestoreCopyFromUndoList( dummy );
|
||||
|
||||
updatePoints();
|
||||
modified = false;
|
||||
|
|
Loading…
Reference in New Issue