Implement undo for Page Settings in PlEditor, Eeschema and PCBNew.

Fixes: lp:1820059
* https://bugs.launchpad.net/kicad/+bug/1820059
This commit is contained in:
Jeff Young 2019-05-26 16:36:40 +01:00
parent 248089c934
commit 6936effaa7
60 changed files with 822 additions and 892 deletions

View File

@ -36,7 +36,6 @@ set( GAL_SRCS
newstroke_font.cpp newstroke_font.cpp
painter.cpp painter.cpp
text_utils.cpp text_utils.cpp
page_layout/ws_view_item.cpp
gal/color4d.cpp gal/color4d.cpp
gal/gal_display_options.cpp gal/gal_display_options.cpp
gal/graphics_abstraction_layer.cpp gal/graphics_abstraction_layer.cpp
@ -241,6 +240,8 @@ set( COMMON_PAGE_LAYOUT_SRCS
page_layout/ws_data_model_io.cpp page_layout/ws_data_model_io.cpp
page_layout/page_layout_default_description.cpp page_layout/page_layout_default_description.cpp
page_layout/ws_draw_item.cpp page_layout/ws_draw_item.cpp
page_layout/ws_proxy_undo_item.cpp
page_layout/ws_proxy_view_item.cpp
page_layout/page_layout_reader_keywords.cpp page_layout/page_layout_reader_keywords.cpp
page_layout/page_layout_reader.cpp page_layout/page_layout_reader.cpp
) )

View File

@ -22,7 +22,6 @@
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <macros.h> // arrayDim()
#include <common.h> #include <common.h>
#include <project.h> #include <project.h>
#include <confirm.h> #include <confirm.h>
@ -34,7 +33,7 @@
#include <ws_data_model.h> #include <ws_data_model.h>
#include <base_screen.h> #include <base_screen.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <tool/tool_manager.h>
#include <wx/valgen.h> #include <wx/valgen.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
@ -45,6 +44,7 @@
#include <ws_painter.h> #include <ws_painter.h>
#include <dialog_page_settings.h> #include <dialog_page_settings.h>
#include <tool/actions.h>
#define MAX_PAGE_EXAMPLE_SIZE 200 #define MAX_PAGE_EXAMPLE_SIZE 200
@ -75,44 +75,6 @@ static const wxString pageFmts[] =
// to be recognized in code // to be recognized in code
}; };
void EDA_DRAW_FRAME::Process_PageSettings( wxCommandEvent& event )
{
FRAME_T smallSizeFrames[] =
{
FRAME_PCB, FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_VIEWER,
FRAME_PCB_MODULE_VIEWER_MODAL, FRAME_PCB_FOOTPRINT_WIZARD,
FRAME_PCB_FOOTPRINT_PREVIEW,
FRAME_CVPCB_DISPLAY
};
// Fix the max page size: it is MAX_PAGE_SIZE_EDITORS
// or MAX_PAGE_SIZE_PCBNEW for Pcbnew draw frames, due to the small internal
// units that do not allow too large draw areas
wxSize maxPageSize( MAX_PAGE_SIZE_EDITORS_MILS, MAX_PAGE_SIZE_EDITORS_MILS );
for( unsigned ii = 0; ii < arrayDim( smallSizeFrames ); ii++ )
{
if( IsType( smallSizeFrames[ii] ) )
{
maxPageSize.x = maxPageSize.y = MAX_PAGE_SIZE_PCBNEW_MILS;
break;
}
}
DIALOG_PAGES_SETTINGS dlg( this, maxPageSize );
dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
if( dlg.ShowModal() == wxID_OK )
{
#ifdef EESCHEMA
RedrawScreen( wxPoint( 0, 0 ), false );
#else
GetCanvas()->Refresh();
#endif
}
}
DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent, wxSize aMaxUserSizeMils ) : DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent, wxSize aMaxUserSizeMils ) :
DIALOG_PAGES_SETTINGS_BASE( parent ), DIALOG_PAGES_SETTINGS_BASE( parent ),
m_initialized( false ), m_initialized( false ),
@ -157,10 +119,10 @@ void DIALOG_PAGES_SETTINGS::initDialog()
// The first shows translated strings, the second contains not translated strings // The first shows translated strings, the second contains not translated strings
m_paperSizeComboBox->Clear(); m_paperSizeComboBox->Clear();
for( unsigned ii = 0; ii < arrayDim(pageFmts); ii++ ) for( const wxString& pageFmt : pageFmts )
{ {
m_pageFmt.Add( pageFmts[ii] ); m_pageFmt.Add( pageFmt );
m_paperSizeComboBox->Append( wxGetTranslation( pageFmts[ii] ) ); m_paperSizeComboBox->Append( wxGetTranslation( pageFmt ) );
} }
// initialize the page layout descr filename // initialize the page layout descr filename

View File

@ -321,12 +321,6 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
} }
void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
{
wxFAIL_MSG( "Obsolete! Should go through EDITOR_CONTROL." );
}
bool EDA_DRAW_FRAME::GetToolToggled( int aToolId ) bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
{ {
// Checks all the toolbars and returns true if the given tool id is toggled. // Checks all the toolbars and returns true if the given tool id is toggled.
@ -338,26 +332,6 @@ bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
} }
void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
{
wxFAIL_MSG( "Obsolete! Should go through EDITOR_CONTROL." );
}
void EDA_DRAW_FRAME::OnUpdateUndo( wxUpdateUIEvent& aEvent )
{
if( GetScreen() )
aEvent.Enable( GetScreen()->GetUndoCommandCount() > 0 );
}
void EDA_DRAW_FRAME::OnUpdateRedo( wxUpdateUIEvent& aEvent )
{
if( GetScreen() )
aEvent.Enable( GetScreen()->GetRedoCommandCount() > 0 );
}
void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ) void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{ {
// No need to update the grid select box if it doesn't exist or the grid setting change // No need to update the grid select box if it doesn't exist or the grid setting change
@ -508,13 +482,6 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
} }
wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
return aPosition;
}
void EDA_DRAW_FRAME::SetNextGrid() void EDA_DRAW_FRAME::SetNextGrid()
{ {
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." ); wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );

View File

@ -347,20 +347,6 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
} }
void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
{
SetGridVisibility( !IsGridVisible() );
if( IsGalCanvasActive() )
{
GetGalCanvas()->GetGAL()->SetGridVisibility( IsGridVisible() );
GetGalCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
}
m_canvas->Refresh();
}
bool EDA_DRAW_FRAME::GetToolToggled( int aToolId ) bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
{ {
// Checks all the toolbars and returns true if the given tool id is toggled. // Checks all the toolbars and returns true if the given tool id is toggled.
@ -372,19 +358,6 @@ bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
} }
void EDA_DRAW_FRAME::OnToggleCrossHairStyle( wxCommandEvent& aEvent )
{
INSTALL_UNBUFFERED_DC( dc, m_canvas );
m_canvas->CrossHairOff( &dc );
auto& galOpts = GetGalDisplayOptions();
galOpts.m_fullscreenCursor = !galOpts.m_fullscreenCursor;
galOpts.NotifyChanged();
m_canvas->CrossHairOn( &dc );
}
void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ) void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
{ {
// No need to update the grid select box if it doesn't exist or the grid setting change // No need to update the grid select box if it doesn't exist or the grid setting change
@ -408,12 +381,6 @@ void EDA_DRAW_FRAME::OnUpdateSelectGrid( wxUpdateUIEvent& aEvent )
} }
void EDA_DRAW_FRAME::OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent )
{
aEvent.Check( GetGalDisplayOptions().m_fullscreenCursor );
}
void EDA_DRAW_FRAME::ReCreateAuxiliaryToolbar() void EDA_DRAW_FRAME::ReCreateAuxiliaryToolbar()
{ {
} }
@ -620,17 +587,6 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
} }
wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
{
wxPoint pos = aPosition;
if( m_currentScreen != NULL && m_snapToGrid )
pos = GetNearestGridPosition( aPosition );
return pos;
}
void EDA_DRAW_FRAME::SetNextGrid() void EDA_DRAW_FRAME::SetNextGrid()
{ {
BASE_SCREEN * screen = GetScreen(); BASE_SCREEN * screen = GetScreen();
@ -1559,6 +1515,7 @@ bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{ {
// JEY TODO: OBSOLETE
if( IsGalCanvasActive() ) if( IsGalCanvasActive() )
return; return;
@ -1739,18 +1696,6 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
} }
void EDA_DRAW_FRAME::SetNextZoom()
{
GetScreen()->SetNextZoom();
}
void EDA_DRAW_FRAME::SetPrevZoom()
{
GetScreen()->SetPreviousZoom();
}
void EDA_DRAW_FRAME::SetPresetZoom( int aIndex ) void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
{ {
BASE_SCREEN* screen = GetScreen(); BASE_SCREEN* screen = GetScreen();

View File

@ -748,7 +748,7 @@ void WS_DATA_MODEL::SetPageLayout( const wxString& aFullFileName, bool Append )
{ {
#if 0 #if 0
if( !fullFileName.IsEmpty() ) if( !fullFileName.IsEmpty() )
wxLogMessage( wxT("Page layout file <%s> not found"), fullFileName.GetData() ); wxLogMessage( wxT( "Page layout file <%s> not found" ), fullFileName.GetData() );
#endif #endif
SetDefaultLayout(); SetDefaultLayout();
return; return;

View File

@ -549,7 +549,7 @@ void WS_DATA_ITEM_TEXT::SyncDrawItems( WS_DRAW_ITEM_LIST* aCollector, KIGFX::VIE
int pensize = GetPenSizeUi(); int pensize = GetPenSizeUi();
bool multilines = false; bool multilines = false;
if( WS_DATA_MODEL::GetTheInstance().m_SpecialMode ) if( WS_DATA_MODEL::GetTheInstance().m_EditMode )
m_FullText = m_TextBase; m_FullText = m_TextBase;
else else
{ {

View File

@ -25,23 +25,23 @@
/* /*
* the class WS_DATA_ITEM (and derived ) defines * The WS_DATA_ITEM_* classes define the basic shapes of a page layout (frame references
* a basic shape of a page layout ( frame references and title block ) * and title block). The list of these items is stored in a WS_DATA_MODEL instance.
* The list of these items is stored in a WS_DATA_MODEL instance.
* *
* These items cannot be drawn or plotetd "as is". They must be converted to WS_DRAW_*
* types. When building the draw list:
* - the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST
* - coordinates are converted to draw/plot coordinates.
* - texts are expanded if they contain format symbols.
* - items with m_RepeatCount > 1 are created m_RepeatCount times.
* *
* These items cannot be drawn or plot "as this". they should be converted * The WS_DATA_MODEL is created only once.
* to a "draw list". When building the draw list: * The WS_DRAW_ITEM_*s are created and maintained by the PlEditor, but are created each time
* the WS_DATA_MODEL is used to create a WS_DRAW_ITEM_LIST * they're needed for drawing by the clients (Eeschema, Pcbnew, etc.)
* coordinates are converted to draw/plot coordinates.
* texts are expanded if they contain format symbols.
* Items with m_RepeatCount > 1 are created m_RepeatCount times
* *
* the WS_DATA_MODEL is created only once. * The WS_DATA_MODEL instance is created from a S expression which describes the page
* the WS_DRAW_ITEM_LIST is created each time the page layout is plot/drawn * layout (can be the default page layout or a custom file). This format is also used
* * for undo/redo storage (wrapped in a WS_PROXY_UNDO_ITEM).
* the WS_DATA_MODEL instance is created from a S expression which
* describes the page layout (can be the default page layout or a custom file).
*/ */
#include <fctsys.h> #include <fctsys.h>
@ -63,7 +63,7 @@ WS_DATA_MODEL::WS_DATA_MODEL() :
m_DefaultLineWidth( 0.0 ), m_DefaultLineWidth( 0.0 ),
m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE ), m_DefaultTextSize( TB_DEFAULT_TEXTSIZE, TB_DEFAULT_TEXTSIZE ),
m_DefaultTextThickness( 0.0 ), m_DefaultTextThickness( 0.0 ),
m_SpecialMode( false ) m_EditMode( false )
{ {
m_allowVoidList = false; m_allowVoidList = false;
m_leftMargin = 10.0; // the left page margin in mm m_leftMargin = 10.0; // the left page margin in mm
@ -158,7 +158,7 @@ WS_DATA_ITEM* WS_DATA_MODEL::GetItem( unsigned aIdx ) const
if( aIdx < m_list.size() ) if( aIdx < m_list.size() )
return m_list[aIdx]; return m_list[aIdx];
else else
return NULL; return nullptr;
} }

View File

@ -0,0 +1,92 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2019 Kicad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
#include <ws_proxy_undo_item.h>
#include <ws_data_model.h>
#include <draw_frame.h>
#include <macros.h>
using namespace KIGFX;
WS_PROXY_UNDO_ITEM::WS_PROXY_UNDO_ITEM( const EDA_DRAW_FRAME* aFrame ) :
EDA_ITEM( aFrame ? WS_PROXY_UNDO_ITEM_PLUS_T : WS_PROXY_UNDO_ITEM_T ),
m_selectedDataItem( INT_MAX ),
m_selectedDrawItem( INT_MAX )
{
if( aFrame )
{
m_pageInfo = aFrame->GetPageSettings();
m_titleBlock = aFrame->GetTitleBlock();
}
WS_DATA_MODEL& model = WS_DATA_MODEL::GetTheInstance();
model.SaveInString( m_layoutSerialization );
for( int ii = 0; ii < model.GetItems().size(); ++ii )
{
WS_DATA_ITEM* dataItem = model.GetItem( ii );
for( int jj = 0; jj < dataItem->GetDrawItems().size(); ++jj )
{
WS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ jj ];
if( drawItem->IsSelected() )
{
m_selectedDataItem = ii;
m_selectedDrawItem = jj;
break;
}
}
}
}
void WS_PROXY_UNDO_ITEM::Restore( EDA_DRAW_FRAME* aFrame, KIGFX::VIEW* aView )
{
if( Type() == WS_PROXY_UNDO_ITEM_PLUS_T )
{
aFrame->SetPageSettings( m_pageInfo );
aFrame->SetTitleBlock( m_titleBlock );
}
WS_DATA_MODEL::GetTheInstance().SetPageLayout( TO_UTF8( m_layoutSerialization ) );
if( aView )
{
aView->Clear();
for( int ii = 0; ii < WS_DATA_MODEL::GetTheInstance().GetItems().size(); ++ii )
{
WS_DATA_ITEM* dataItem = WS_DATA_MODEL::GetTheInstance().GetItem( ii );
dataItem->SyncDrawItems( nullptr, aView );
if( ii == m_selectedDataItem && m_selectedDrawItem < dataItem->GetDrawItems().size() )
{
WS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ m_selectedDrawItem ];
drawItem->SetSelected();
}
}
}
}

View File

@ -22,12 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/** #include <ws_proxy_view_item.h>
* @file worksheet_viewitem.cpp
* @brief Class that handles properties and drawing of worksheet layout.
*/
#include <ws_view_item.h>
#include <ws_draw_item.h> #include <ws_draw_item.h>
#include <ws_data_item.h> #include <ws_data_item.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
@ -39,26 +34,31 @@
using namespace KIGFX; using namespace KIGFX;
WS_VIEW_ITEM::WS_VIEW_ITEM( int aMils2IUscalefactor, WS_PROXY_VIEW_ITEM::WS_PROXY_VIEW_ITEM( int aMils2IUscalefactor, const PAGE_INFO* aPageInfo,
const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ) : const TITLE_BLOCK* aTitleBlock ) :
EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type EDA_ITEM( NOT_USED ), // this item is never added to a BOARD so it needs no type
m_mils2IUscalefactor( aMils2IUscalefactor ), m_mils2IUscalefactor( aMils2IUscalefactor ),
m_titleBlock( aTitleBlock ), m_pageInfo( aPageInfo ), m_sheetNumber( 1 ), m_sheetCount( 1 ) {} m_titleBlock( aTitleBlock ),
m_pageInfo( aPageInfo ),
m_sheetNumber( 1 ),
m_sheetCount( 1 )
{
}
void WS_VIEW_ITEM::SetPageInfo( const PAGE_INFO* aPageInfo ) void WS_PROXY_VIEW_ITEM::SetPageInfo( const PAGE_INFO* aPageInfo )
{ {
m_pageInfo = aPageInfo; m_pageInfo = aPageInfo;
} }
void WS_VIEW_ITEM::SetTitleBlock( const TITLE_BLOCK* aTitleBlock ) void WS_PROXY_VIEW_ITEM::SetTitleBlock( const TITLE_BLOCK* aTitleBlock )
{ {
m_titleBlock = aTitleBlock; m_titleBlock = aTitleBlock;
} }
const BOX2I WS_VIEW_ITEM::ViewBBox() const const BOX2I WS_PROXY_VIEW_ITEM::ViewBBox() const
{ {
BOX2I bbox; BOX2I bbox;
@ -77,7 +77,7 @@ const BOX2I WS_VIEW_ITEM::ViewBBox() const
} }
void WS_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const void WS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
{ {
auto gal = aView->GetGAL(); auto gal = aView->GetGAL();
auto settings = aView->GetPainter()->GetSettings(); auto settings = aView->GetPainter()->GetSettings();
@ -127,7 +127,7 @@ void WS_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
} }
void WS_VIEW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const void WS_PROXY_VIEW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
{ {
aCount = 1; aCount = 1;
aLayers[0] = LAYER_WORKSHEET; aLayers[0] = LAYER_WORKSHEET;

View File

@ -503,7 +503,7 @@ wxMenuItem* ACTION_MENU::appendCopy( const wxMenuItem* aSource )
// our predefined checked alternate bitmap // our predefined checked alternate bitmap
const wxBitmap& src_bitmap = aSource->GetBitmap(); const wxBitmap& src_bitmap = aSource->GetBitmap();
if( src_bitmap.GetHeight() > 1 ) // a null bitmap has a 0 size if( src_bitmap.IsOk() && src_bitmap.GetHeight() > 1 ) // a null bitmap has a 0 size
AddBitmapToMenuItem( newItem, src_bitmap ); AddBitmapToMenuItem( newItem, src_bitmap );
if( aSource->IsSubMenu() ) if( aSource->IsSubMenu() )

View File

@ -24,12 +24,17 @@ TOOL_ACTION ACTIONS::saveAs( "common.Control.saveAs",
_( "Save As..." ), _( "Save current document to another location" ), _( "Save As..." ), _( "Save current document to another location" ),
save_as_xpm ); save_as_xpm );
TOOL_ACTION ACTIONS::saveCopyAs( "common.Control.saveCopyAs",
AS_GLOBAL, 0,
_( "Save Copy As..." ), _( "Save a copy of the current document to another location" ),
save_as_xpm );
TOOL_ACTION ACTIONS::saveAll( "common.Control.saveAll", TOOL_ACTION ACTIONS::saveAll( "common.Control.saveAll",
AS_GLOBAL, 0, AS_GLOBAL, 0,
_( "Save All" ), _( "Save all changes" ), _( "Save All" ), _( "Save all changes" ),
save_xpm ); save_xpm );
TOOL_ACTION ACTIONS::pageSetup( "common.Control.pageSetup", TOOL_ACTION ACTIONS::pageSettings( "common.Control.pageSettings",
AS_GLOBAL, 0, AS_GLOBAL, 0,
_( "Page Settings..." ), _( "Settings for paper size and frame references" ), _( "Page Settings..." ), _( "Settings for paper size and frame references" ),
sheetset_xpm ); sheetset_xpm );

View File

@ -43,7 +43,7 @@ static const int HOTKEY_MIN_WIDTH = 100;
*/ */
enum ID_WHKL_MENU_IDS enum ID_WHKL_MENU_IDS
{ {
ID_EDIT = 2001, ID_EDIT_HOTKEY = 2001,
ID_RESET, ID_RESET,
ID_DEFAULT, ID_DEFAULT,
ID_RESET_ALL, ID_RESET_ALL,
@ -426,7 +426,7 @@ void WIDGET_HOTKEY_LIST::OnContextMenu( wxTreeListEvent& aEvent )
// Some actions only apply if the row is hotkey data // Some actions only apply if the row is hotkey data
if( hkdata ) if( hkdata )
{ {
menu.Append( ID_EDIT, _( "Edit..." ) ); menu.Append( ID_EDIT_HOTKEY, _( "Edit..." ) );
menu.Append( ID_RESET, _( "Undo Changes" ) ); menu.Append( ID_RESET, _( "Undo Changes" ) );
menu.Append( ID_DEFAULT, _( "Restore Default" ) ); menu.Append( ID_DEFAULT, _( "Restore Default" ) );
menu.Append( wxID_SEPARATOR ); menu.Append( wxID_SEPARATOR );
@ -443,7 +443,7 @@ void WIDGET_HOTKEY_LIST::OnMenu( wxCommandEvent& aEvent )
{ {
switch( aEvent.GetId() ) switch( aEvent.GetId() )
{ {
case ID_EDIT: case ID_EDIT_HOTKEY:
EditItem( m_context_menu_item ); EditItem( m_context_menu_item );
break; break;

View File

@ -94,7 +94,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddItem( ACTIONS::saveAs, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::saveAs, EE_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::saveAll, modifiedDocumentCondition ); fileMenu->AddItem( ACTIONS::saveAll, modifiedDocumentCondition );
fileMenu->AppendSeparator(); fileMenu->AddSeparator();
fileMenu->AddItem( ID_APPEND_PROJECT, _( "Append Schematic Sheet Content..." ), fileMenu->AddItem( ID_APPEND_PROJECT, _( "Append Schematic Sheet Content..." ),
_( "Append schematic sheet content from another project to the current sheet" ), _( "Append schematic sheet content from another project to the current sheet" ),
@ -133,7 +133,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways ); fileMenu->AddMenu( submenuExport, EE_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::pageSetup, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::pageSettings, EE_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::print, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::print, EE_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::plot, EE_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::plot, EE_CONDITIONS::ShowAlways );

View File

@ -25,7 +25,7 @@
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>
#include <sch_draw_panel.h> #include <sch_draw_panel.h>

View File

@ -23,7 +23,7 @@
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <gal/graphics_abstraction_layer.h> #include <gal/graphics_abstraction_layer.h>

View File

@ -28,7 +28,7 @@
#include <view/view_group.h> #include <view/view_group.h>
#include <view/view_rtree.h> #include <view/view_rtree.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
#include <class_libentry.h> #include <class_libentry.h>
#include <sch_sheet.h> #include <sch_sheet.h>
@ -52,9 +52,9 @@ SCH_VIEW::SCH_VIEW( bool aIsDynamic, SCH_BASE_FRAME* aFrame ) :
// is acceptable for Pcbnew and Gerbview, but too large for Eeschema due to // is acceptable for Pcbnew and Gerbview, but too large for Eeschema due to
// very different internal units. // very different internal units.
// So we have to use a smaller value. // So we have to use a smaller value.
// A full size = 3 * MAX_PAGE_SIZE_EDITORS_MILS size allows a wide margin // A full size = 3 * MAX_PAGE_SIZE_MILS size allows a wide margin
// around the worksheet. // around the worksheet.
double max_size = MAX_PAGE_SIZE_EDITORS_MILS * IU_PER_MILS * 3.0; double max_size = MAX_PAGE_SIZE_MILS * IU_PER_MILS * 3.0;
m_boundary.SetOrigin( -max_size/4, -max_size/4 ); m_boundary.SetOrigin( -max_size/4, -max_size/4 );
m_boundary.SetSize( max_size, max_size ); m_boundary.SetSize( max_size, max_size );
@ -85,7 +85,7 @@ void SCH_VIEW::DisplaySheet( SCH_SCREEN *aScreen )
for( auto item = aScreen->GetDrawItems(); item; item = item->Next() ) for( auto item = aScreen->GetDrawItems(); item; item = item->Next() )
Add( item ); Add( item );
m_worksheet.reset( new KIGFX::WS_VIEW_ITEM( 1, &aScreen->GetPageSettings(), m_worksheet.reset( new KIGFX::WS_PROXY_VIEW_ITEM( 1, &aScreen->GetPageSettings(),
&aScreen->GetTitleBlock() ) ); &aScreen->GetTitleBlock() ) );
m_worksheet->SetSheetNumber( aScreen->m_ScreenNumber ); m_worksheet->SetSheetNumber( aScreen->m_ScreenNumber );
m_worksheet->SetSheetCount( aScreen->m_NumberOfScreens ); m_worksheet->SetSheetCount( aScreen->m_NumberOfScreens );

View File

@ -29,7 +29,7 @@
#include <math/box2.h> #include <math/box2.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
class SCH_SHEET; class SCH_SHEET;
@ -61,7 +61,7 @@ static const LAYER_NUM SCH_LAYER_ORDER[] =
namespace KIGFX namespace KIGFX
{ {
class VIEW_GROUP; class VIEW_GROUP;
class WS_VIEW_ITEM; class WS_PROXY_VIEW_ITEM;
namespace PREVIEW namespace PREVIEW
{ {
@ -105,7 +105,7 @@ public:
private: private:
SCH_BASE_FRAME* m_frame; // The frame using this view. Can be null. Used mainly SCH_BASE_FRAME* m_frame; // The frame using this view. Can be null. Used mainly
// to know the sheet path name when drawing the page layout // to know the sheet path name when drawing the page layout
std::unique_ptr<WS_VIEW_ITEM> m_worksheet; std::unique_ptr<WS_PROXY_VIEW_ITEM> m_worksheet;
std::unique_ptr<KIGFX::PREVIEW::SELECTION_AREA> m_selectionArea; std::unique_ptr<KIGFX::PREVIEW::SELECTION_AREA> m_selectionArea;
std::unique_ptr<KIGFX::VIEW_GROUP> m_preview; std::unique_ptr<KIGFX::VIEW_GROUP> m_preview;
std::vector<EDA_ITEM *> m_ownedItems; std::vector<EDA_ITEM *> m_ownedItems;

View File

@ -37,6 +37,8 @@
#include <sch_bitmap.h> #include <sch_bitmap.h>
#include <sch_view.h> #include <sch_view.h>
#include <tools/ee_selection_tool.h> #include <tools/ee_selection_tool.h>
#include <ws_proxy_undo_item.h>
#include <tool/actions.h>
/* Functions to undo and redo edit commands. /* Functions to undo and redo edit commands.
* commands to undo are stored in CurrentScreen->m_UndoList * commands to undo are stored in CurrentScreen->m_UndoList
@ -106,9 +108,9 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
bool aAppend, bool aAppend,
const wxPoint& aTransformPoint ) const wxPoint& aTransformPoint )
{ {
PICKED_ITEMS_LIST* commandToUndo = NULL; PICKED_ITEMS_LIST* commandToUndo = nullptr;
if( aItem == NULL ) if( !aItem )
return; return;
// Connectivity may change // Connectivity may change
@ -162,11 +164,11 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO_T aTypeCommand, UNDO_REDO_T aTypeCommand,
bool aAppend, bool aAppend,
const wxPoint& aTransformPoint ) const wxPoint& aTransformPoint )
{ {
PICKED_ITEMS_LIST* commandToUndo = NULL; PICKED_ITEMS_LIST* commandToUndo = nullptr;
if( !aItemsList.GetCount() ) if( !aItemsList.GetCount() )
return; return;
@ -195,11 +197,14 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
// Verify list, and creates data if needed // Verify list, and creates data if needed
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ ) for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
{ {
SCH_ITEM* item = (SCH_ITEM*) commandToUndo->GetPickedItem( ii ); SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( commandToUndo->GetPickedItem( ii ) );
wxASSERT( item );
// Common items implemented in EDA_DRAW_FRAME will not be SCH_ITEMs.
if( !sch_item )
continue;
// Connectivity may change // Connectivity may change
item->SetConnectivityDirty(); sch_item->SetConnectivityDirty();
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii ); UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
@ -211,14 +216,14 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
switch( command ) switch( command )
{ {
case UR_CHANGED: /* Create a copy of item */ case UR_CHANGED:
/* If needed, create a copy of item, and put in undo list /* If needed, create a copy of item, and put in undo list
* in the picker, as link * in the picker, as link
* If this link is not null, the copy is already done * If this link is not null, the copy is already done
*/ */
if( commandToUndo->GetPickedItemLink( ii ) == NULL ) if( commandToUndo->GetPickedItemLink( ii ) == nullptr )
commandToUndo->SetPickedItemLink( item->Duplicate( true ), ii ); commandToUndo->SetPickedItemLink( sch_item->Duplicate( true ), ii );
wxASSERT( commandToUndo->GetPickedItemLink( ii ) ); wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
break; break;
@ -230,6 +235,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
case UR_NEW: case UR_NEW:
case UR_DELETED: case UR_DELETED:
case UR_EXCHANGE_T: case UR_EXCHANGE_T:
case UR_PAGESETTINGS:
break; break;
default: default:
@ -255,36 +261,44 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand ) void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand )
{ {
SCH_ITEM* item;
SCH_ITEM* alt_item;
// Undo in the reverse order of list creation: (this can allow stacked changes like the // Undo in the reverse order of list creation: (this can allow stacked changes like the
// same item can be changed and deleted in the same complex command). // same item can be changed and deleted in the same complex command).
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- ) for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
{ {
UNDO_REDO_T status = aList->GetPickedItemStatus((unsigned) ii ); UNDO_REDO_T status = aList->GetPickedItemStatus((unsigned) ii );
item = (SCH_ITEM*) aList->GetPickedItem( (unsigned) ii ); EDA_ITEM* eda_item = aList->GetPickedItem( (unsigned) ii );
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( (unsigned) ii );
item->SetFlags( aList->GetPickerFlags( (unsigned) ii ) ); eda_item->SetFlags( aList->GetPickerFlags( (unsigned) ii ) );
item->ClearEditFlags(); eda_item->ClearEditFlags();
item->ClearTempFlags(); eda_item->ClearTempFlags();
if( status == UR_NEW ) if( status == UR_NEW )
{ {
// new items are deleted on undo // new items are deleted on undo
RemoveFromScreen( item ); RemoveFromScreen( eda_item );
aList->SetPickedItemStatus( UR_DELETED, (unsigned) ii ); aList->SetPickedItemStatus( UR_DELETED, (unsigned) ii );
} }
else if (status == UR_DELETED ) else if( status == UR_DELETED )
{ {
// deleted items are re-inserted on undo // deleted items are re-inserted on undo
AddToScreen( item ); AddToScreen( eda_item );
aList->SetPickedItemStatus( UR_NEW, (unsigned) ii ); aList->SetPickedItemStatus( UR_NEW, (unsigned) ii );
} }
else else if( status == UR_PAGESETTINGS )
{
// swap current settings with stored settings
WS_PROXY_UNDO_ITEM alt_item( this );
WS_PROXY_UNDO_ITEM* item = (WS_PROXY_UNDO_ITEM*) eda_item;
item->Restore( this );
*item = alt_item;
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
}
else if( dynamic_cast<SCH_ITEM*>( eda_item ) )
{ {
// everthing else is modified in place // everthing else is modified in place
SCH_ITEM* item = (SCH_ITEM*) eda_item;
SCH_ITEM* alt_item = (SCH_ITEM*) aList->GetPickedItemLink( (unsigned) ii );
RemoveFromScreen( item ); RemoveFromScreen( item );
switch( status ) switch( status )
@ -318,8 +332,8 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
break; break;
case UR_EXCHANGE_T: case UR_EXCHANGE_T:
alt_item->SetNext( NULL ); alt_item->SetNext( nullptr );
alt_item->SetBack( NULL ); alt_item->SetBack( nullptr );
aList->SetPickedItem( alt_item, (unsigned) ii ); aList->SetPickedItem( alt_item, (unsigned) ii );
aList->SetPickedItemLink( item, (unsigned) ii ); aList->SetPickedItemLink( item, (unsigned) ii );
item = alt_item; item = alt_item;

View File

@ -57,7 +57,7 @@ void SCH_EDIT_FRAME::ReCreateHToolbar()
m_mainToolBar->Add( ACTIONS::saveAll ); m_mainToolBar->Add( ACTIONS::saveAll );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->Add( ACTIONS::pageSetup ); m_mainToolBar->Add( ACTIONS::pageSettings );
m_mainToolBar->Add( ACTIONS::print ); m_mainToolBar->Add( ACTIONS::print );
m_mainToolBar->Add( ACTIONS::plot ); m_mainToolBar->Add( ACTIONS::plot );

View File

@ -46,6 +46,8 @@
#include <confirm.h> #include <confirm.h>
#include <sch_painter.h> #include <sch_painter.h>
#include <status_popup.h> #include <status_popup.h>
#include <ws_proxy_undo_item.h>
#include <dialogs/dialog_page_settings.h>
TOOL_ACTION EE_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview", TOOL_ACTION EE_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview",
AS_GLOBAL, 0, "", "" ); AS_GLOBAL, 0, "", "" );
@ -155,8 +157,21 @@ int SCH_EDITOR_CONTROL::SaveAll( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent ) int SCH_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent )
{ {
wxCommandEvent dummy; PICKED_ITEMS_LIST undoCmd;
m_frame->Process_PageSettings( dummy ); WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
undoCmd.PushItem( wrapper );
m_frame->SaveCopyInUndoList( undoCmd, UR_PAGESETTINGS );
DIALOG_PAGES_SETTINGS dlg( m_frame, wxSize( MAX_PAGE_SIZE_MILS, MAX_PAGE_SIZE_MILS ) );
dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
if( dlg.ShowModal() == wxID_OK )
m_toolMgr->RunAction( ACTIONS::zoomFitScreen );
else
m_frame->RollbackSchematicFromUndo();
return 0; return 0;
} }
@ -1094,7 +1109,7 @@ void SCH_EDITOR_CONTROL::setTransitions()
Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::PageSetup, ACTIONS::pageSetup.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::PageSetup, ACTIONS::pageSettings.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() ); Go( &SCH_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );

View File

@ -21,7 +21,7 @@
#include <view/view.h> #include <view/view.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <gerbview_painter.h> #include <gerbview_painter.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <colors_design_settings.h> #include <colors_design_settings.h>
#include <gerbview_frame.h> #include <gerbview_frame.h>
@ -179,7 +179,7 @@ void GERBVIEW_DRAW_PANEL_GAL::setDefaultLayerDeps()
} }
void GERBVIEW_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WS_VIEW_ITEM* aWorksheet ) void GERBVIEW_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
{ {
m_worksheet.reset( aWorksheet ); m_worksheet.reset( aWorksheet );
m_view->Add( m_worksheet.get() ); m_view->Add( m_worksheet.get() );

View File

@ -21,11 +21,11 @@
#define GERBVIEW_DRAW_PANEL_GAL_H_ #define GERBVIEW_DRAW_PANEL_GAL_H_
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
namespace KIGFX namespace KIGFX
{ {
class WS_VIEW_ITEM; class WS_PROXY_VIEW_ITEM;
} }
class COLORS_DESIGN_SETTINGS; class COLORS_DESIGN_SETTINGS;
@ -69,14 +69,14 @@ public:
* @param aWorksheet is the worksheet to be used. * @param aWorksheet is the worksheet to be used.
* The object is then owned by GERBVIEW_DRAW_PANEL_GAL. * The object is then owned by GERBVIEW_DRAW_PANEL_GAL.
*/ */
void SetWorksheet( KIGFX::WS_VIEW_ITEM* aWorksheet ); void SetWorksheet( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet );
protected: protected:
///> Sets rendering targets & dependencies for layers. ///> Sets rendering targets & dependencies for layers.
void setDefaultLayerDeps(); void setDefaultLayerDeps();
///> Currently used worksheet ///> Currently used worksheet
std::unique_ptr<KIGFX::WS_VIEW_ITEM> m_worksheet; std::unique_ptr<KIGFX::WS_PROXY_VIEW_ITEM> m_worksheet;
}; };

View File

@ -960,7 +960,7 @@ void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
// Prepare worksheet template // Prepare worksheet template
auto worksheet = auto worksheet =
new KIGFX::WS_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(), &GetTitleBlock() ); new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS, &GetPageSettings(), &GetTitleBlock() );
if( screen != NULL ) if( screen != NULL )
{ {

View File

@ -182,7 +182,8 @@ enum KICAD_T
WSG_BITMAP_T, WSG_BITMAP_T,
// serialized layout used in undo/redo commands // serialized layout used in undo/redo commands
TYPE_PL_EDITOR_LAYOUT, WS_PROXY_UNDO_ITEM_T, // serialized layout used in undo/redo commands
WS_PROXY_UNDO_ITEM_PLUS_T, // serialized layout plus page and title block settings
/* /*
* FOR PROJECT::_ELEMs * FOR PROJECT::_ELEMs

View File

@ -482,7 +482,6 @@ public:
inline double GetZoomLevelCoeff() const { return m_zoomLevelCoeff; } inline double GetZoomLevelCoeff() const { return m_zoomLevelCoeff; }
void EraseMsgBox(); void EraseMsgBox();
void Process_PageSettings( wxCommandEvent& event );
virtual void ReCreateHToolbar() = 0; virtual void ReCreateHToolbar() = 0;
virtual void ReCreateVToolbar() = 0; virtual void ReCreateVToolbar() = 0;
@ -567,16 +566,6 @@ public:
m_gridColor = aColor; m_gridColor = aColor;
} }
/**
* Return the nearest grid position to \a aPosition if a screen is defined and snap to
* grid is enabled. Otherwise, the original positions is returned.
*
* @see m_snapToGrid and m_BaseScreen members.
* @param aPosition The position to test.
* @return The wxPoint of the appropriate cursor position.
*/
wxPoint GetGridPosition( const wxPoint& aPosition ) const;
/** /**
* Change the grid size settings to the next one available. * Change the grid size settings to the next one available.
*/ */
@ -617,16 +606,9 @@ public:
*/ */
virtual void OnSelectZoom( wxCommandEvent& event ); virtual void OnSelectZoom( wxCommandEvent& event );
// Command event handlers shared by all applications derived from EDA_DRAW_FRAME.
void OnToggleGridState( wxCommandEvent& aEvent );
void OnToggleCrossHairStyle( wxCommandEvent& aEvent );
// Update user interface event handlers shared by all applications derived from // Update user interface event handlers shared by all applications derived from
// EDA_DRAW_FRAME. // EDA_DRAW_FRAME.
void OnUpdateUndo( wxUpdateUIEvent& aEvent );
void OnUpdateRedo( wxUpdateUIEvent& aEvent );
void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent ); void OnUpdateSelectGrid( wxUpdateUIEvent& aEvent );
void OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent );
/** /**
* Perform application specific control using \a aDC at \a aPosition in logical units. * Perform application specific control using \a aDC at \a aPosition in logical units.
@ -653,11 +635,6 @@ public:
virtual void OnZoom( wxCommandEvent& event ); virtual void OnZoom( wxCommandEvent& event );
/**
* Change the zoom to the next one available.
*/
void SetNextZoom();
/** /**
* Change the zoom to the next one available redraws the screen * Change the zoom to the next one available redraws the screen
* and warp the mouse pointer on request. * and warp the mouse pointer on request.
@ -667,11 +644,6 @@ public:
*/ */
void SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer ); void SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer );
/**
* Change the zoom to the previous one available.
*/
void SetPrevZoom();
/** /**
* Change the zoom to the previous one available redraws the screen * Change the zoom to the previous one available redraws the screen
* and warp the mouse pointer on request. * and warp the mouse pointer on request.

View File

@ -121,7 +121,6 @@ enum main_id
ID_GEN_EXPORT_FILE, ID_GEN_EXPORT_FILE,
ID_GEN_IMPORT_FILE, ID_GEN_IMPORT_FILE,
ID_EXIT,
ID_OPTIONS_SETUP, ID_OPTIONS_SETUP,
// id for toolbars // id for toolbars
@ -130,7 +129,7 @@ enum main_id
ID_OPT_TOOLBAR, ID_OPT_TOOLBAR,
ID_AUX_TOOLBAR, ID_AUX_TOOLBAR,
ID_EDIT, ID_EDIT_HOTKEY,
ID_NO_TOOL_SELECTED, ID_NO_TOOL_SELECTED,
ID_ZOOM_SELECTION, ID_ZOOM_SELECTION,
ID_SEL_BG_COLOR, ID_SEL_BG_COLOR,
@ -165,8 +164,6 @@ enum main_id
ID_KICAD_SELECT_ICONS_IN_MENUS, ID_KICAD_SELECT_ICONS_IN_MENUS,
ID_KICAD_SELECT_ICON_OPTIONS_END, ID_KICAD_SELECT_ICON_OPTIONS_END,
ID_SET_REPEAT_OPTION,
// Popup Menu (mouse Right button) (id consecutifs) // Popup Menu (mouse Right button) (id consecutifs)
ID_POPUP_GENERAL_START_RANGE, // first number ID_POPUP_GENERAL_START_RANGE, // first number
@ -174,8 +171,6 @@ enum main_id
ID_POPUP_CLOSE_CURRENT_TOOL, ID_POPUP_CLOSE_CURRENT_TOOL,
ID_POPUP_GENERAL_END_RANGE, // last number ID_POPUP_GENERAL_END_RANGE, // last number
ID_POPUP_ENTER_MENU,
ID_ON_ZOOM_SELECT, ID_ON_ZOOM_SELECT,
ID_POPUP_ZOOM_START_RANGE, // first zoom id ID_POPUP_ZOOM_START_RANGE, // first zoom id
ID_POPUP_CANCEL, ID_POPUP_CANCEL,
@ -231,7 +226,6 @@ enum main_id
ID_GRID_SETTINGS, ID_GRID_SETTINGS,
ID_SHEET_SET,
ID_COMPONENT_BUTT, ID_COMPONENT_BUTT,
ID_ZOOM_BEGIN, ID_ZOOM_BEGIN,

View File

@ -36,9 +36,9 @@
#include <base_units.h> // for IU_PER_MILS #include <base_units.h> // for IU_PER_MILS
/// Min and max page sizes for clamping, in mils. /// Min and max page sizes for clamping, in mils.
#define MIN_PAGE_SIZE 4000 #define MIN_PAGE_SIZE 4000
#define MAX_PAGE_SIZE_PCBNEW_MILS 48000 #define MAX_PAGE_SIZE_PCBNEW_MILS 48000
#define MAX_PAGE_SIZE_EDITORS_MILS 120000 #define MAX_PAGE_SIZE_MILS 120000
/** /**

View File

@ -57,10 +57,6 @@ public:
PCB_SCREEN* Next() const { return static_cast<PCB_SCREEN*>( Pnext ); } PCB_SCREEN* Next() const { return static_cast<PCB_SCREEN*>( Pnext ); }
void SetNextZoom();
void SetPreviousZoom();
void SetLastZoom();
virtual int MilsToIuScalar() override; virtual int MilsToIuScalar() override;
/** /**

View File

@ -49,8 +49,9 @@ public:
static TOOL_ACTION open; static TOOL_ACTION open;
static TOOL_ACTION save; static TOOL_ACTION save;
static TOOL_ACTION saveAs; static TOOL_ACTION saveAs;
static TOOL_ACTION saveCopyAs;
static TOOL_ACTION saveAll; static TOOL_ACTION saveAll;
static TOOL_ACTION pageSetup; static TOOL_ACTION pageSettings;
static TOOL_ACTION print; static TOOL_ACTION print;
static TOOL_ACTION plot; static TOOL_ACTION plot;
static TOOL_ACTION quit; static TOOL_ACTION quit;

View File

@ -74,7 +74,8 @@ enum UNDO_REDO_T {
UR_EXCHANGE_T, ///< Use for changing the schematic text type where swapping UR_EXCHANGE_T, ///< Use for changing the schematic text type where swapping
///< data structure is insufficient to restore the change. ///< data structure is insufficient to restore the change.
UR_DRILLORIGIN, // origin changed (like UR_CHANGED, contains the origin and a copy) UR_DRILLORIGIN, // origin changed (like UR_CHANGED, contains the origin and a copy)
UR_GRIDORIGIN // origin changed (like UR_CHANGED, contains the origin and a copy) UR_GRIDORIGIN, // origin changed (like UR_CHANGED, contains the origin and a copy)
UR_PAGESETTINGS // page settings or title block changes
}; };

View File

@ -55,7 +55,7 @@ public:
double m_DefaultLineWidth; // Used when object line width is 0 double m_DefaultLineWidth; // Used when object line width is 0
DSIZE m_DefaultTextSize; // Used when object text size is 0 DSIZE m_DefaultTextSize; // Used when object text size is 0
double m_DefaultTextThickness; // Used when object text stroke width is 0 double m_DefaultTextThickness; // Used when object text stroke width is 0
bool m_SpecialMode; // Used in page layout editor to toggle variable substition bool m_EditMode; // Used in page layout editor to toggle variable substition
public: public:
WS_DATA_MODEL(); WS_DATA_MODEL();

View File

@ -0,0 +1,62 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2019 Kicad Developers, see AUTHORS.txt for contributors.
*
* 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 WS_PROXY_UNDO_ITEM_H
#define WS_PROXY_UNDO_ITEM_H
#include <base_struct.h>
#include <title_block.h>
#include <page_info.h>
class WS_PROXY_UNDO_ITEM : public EDA_ITEM
{
public:
explicit WS_PROXY_UNDO_ITEM( const EDA_DRAW_FRAME* aFrame );
/*
* Restores the saved worksheet layout to the global worksheet record, and the saved
* page info and title blocks to the given frame. The WS_DRAW_ITEMs are rehydrated
* and installed in aView if it is not null (ie: if we're in the PageLayout Editor).
*/
void Restore( EDA_DRAW_FRAME* aFrame, KIGFX::VIEW* aView = nullptr );
#if defined(DEBUG)
/// @copydoc EDA_ITEM::Show()
void Show( int x, std::ostream& st ) const override { }
#endif
wxString GetClass() const override
{
return wxT( "WS_PROXY_UNDO_ITEM" );
}
protected:
TITLE_BLOCK m_titleBlock;
PAGE_INFO m_pageInfo;
wxString m_layoutSerialization;
int m_selectedDataItem;
int m_selectedDrawItem;
};
#endif /* WS_PROXY_UNDO_ITEM_H */

View File

@ -22,8 +22,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#ifndef WS_VIEW_ITEM_H #ifndef WS_PROXY_VIEW_ITEM_H
#define WS_VIEW_ITEM_H #define WS_PROXY_VIEW_ITEM_H
#include <base_struct.h> #include <base_struct.h>
@ -41,10 +41,10 @@ namespace KIGFX
class VIEW; class VIEW;
class GAL; class GAL;
class WS_VIEW_ITEM : public EDA_ITEM class WS_PROXY_VIEW_ITEM : public EDA_ITEM
{ {
public: public:
WS_VIEW_ITEM( int aScaleFactor, const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock ); WS_PROXY_VIEW_ITEM( int aScaleFactor, const PAGE_INFO* aPageInfo, const TITLE_BLOCK* aTitleBlock );
/** /**
* Function SetFileName() * Function SetFileName()
@ -117,9 +117,7 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
/// @copydoc EDA_ITEM::Show() /// @copydoc EDA_ITEM::Show()
void Show( int x, std::ostream& st ) const override void Show( int x, std::ostream& st ) const override { }
{
}
#endif #endif
/** Get class name /** Get class name
@ -127,7 +125,7 @@ public:
*/ */
virtual wxString GetClass() const override virtual wxString GetClass() const override
{ {
return wxT( "WS_VIEW_ITEM" ); return wxT( "WS_PROXY_VIEW_ITEM" );
} }
protected: protected:
@ -155,4 +153,4 @@ protected:
}; };
} }
#endif /* WS_VIEW_ITEM_H */ #endif /* WS_PROXY_VIEW_ITEM_H */

View File

@ -21,7 +21,6 @@ set( PL_EDITOR_SRCS
pl_editor_screen.cpp pl_editor_screen.cpp
pl_editor_layout.cpp pl_editor_layout.cpp
files.cpp files.cpp
../common/page_layout/ws_data_model_io.cpp
pl_editor_frame.cpp pl_editor_frame.cpp
pl_editor_undo_redo.cpp pl_editor_undo_redo.cpp
properties_frame.cpp properties_frame.cpp

View File

@ -81,7 +81,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
fileMenu->AddItem( ACTIONS::saveAs, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::saveAs, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator(); fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::pageSetup, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::pageSettings, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways ); fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();

View File

@ -22,7 +22,7 @@
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pl_actions.h> #include <tools/pl_actions.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <ws_data_model.h> #include <ws_data_model.h>
#include <ws_painter.h> #include <ws_painter.h>
#include <colors_design_settings.h> #include <colors_design_settings.h>

View File

@ -21,7 +21,7 @@
#define PL_DRAW_PANEL_GAL_H #define PL_DRAW_PANEL_GAL_H
#include <class_draw_panel_gal.h> #include <class_draw_panel_gal.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <ws_painter.h> #include <ws_painter.h>
@ -49,7 +49,7 @@ protected:
void setDefaultLayerDeps(); void setDefaultLayerDeps();
///> Currently used worksheet ///> Currently used worksheet
std::unique_ptr<KIGFX::WS_VIEW_ITEM> m_worksheet; std::unique_ptr<KIGFX::WS_PROXY_VIEW_ITEM> m_worksheet;
}; };

View File

@ -50,7 +50,6 @@
#include <tools/pl_edit_tool.h> #include <tools/pl_edit_tool.h>
#include <tools/pl_point_editor.h> #include <tools/pl_point_editor.h>
#include <tools/pl_picker_tool.h> #include <tools/pl_picker_tool.h>
#include <dialog_page_settings.h>
#include <invoke_pl_editor_dialog.h> #include <invoke_pl_editor_dialog.h>
#include <tools/pl_editor_control.h> #include <tools/pl_editor_control.h>
@ -64,14 +63,13 @@ BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Special_Functions ) EVT_MENU( ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Special_Functions ) EVT_MENU( wxID_PREFERENCES, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_TOOL( ID_SHEET_SET, PL_EDITOR_FRAME::Process_Special_Functions )
EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) EVT_TOOL( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode ) EVT_TOOL( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode )
EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner) EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner)
EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions) EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::Process_Special_Functions)
EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode ) EVT_UPDATE_UI( ID_SHOW_REAL_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode )
EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode ) EVT_UPDATE_UI( ID_SHOW_PL_EDITOR_MODE, PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayEditMode )
END_EVENT_TABLE() END_EVENT_TABLE()
@ -92,7 +90,7 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
m_hotkeysDescrList = PlEditorHotkeysDescr; m_hotkeysDescrList = PlEditorHotkeysDescr;
m_originSelectChoice = 0; m_originSelectChoice = 0;
SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK) SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
WS_DATA_MODEL::GetTheInstance().m_SpecialMode = true; WS_DATA_MODEL::GetTheInstance().m_EditMode = true;
SetShowPageLimits( true ); SetShowPageLimits( true );
m_AboutTitle = "PlEditor"; m_AboutTitle = "PlEditor";
@ -289,18 +287,6 @@ void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
} }
break; break;
case ID_SHEET_SET:
{
DIALOG_PAGES_SETTINGS dlg( this, wxSize( MAX_PAGE_SIZE_EDITORS_MILS,
MAX_PAGE_SIZE_EDITORS_MILS ) );
dlg.SetWksFileName( GetCurrFileName() );
dlg.EnableWksFileNamePicker( false );
if( dlg.ShowModal() == wxID_OK )
m_toolManager->RunAction( ACTIONS::zoomFitScreen );
}
break;
default: default:
wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) ); wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) );
break; break;
@ -321,7 +307,7 @@ void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event )
void PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode( wxCommandEvent& event ) void PL_EDITOR_FRAME::OnSelectTitleBlockDisplayMode( wxCommandEvent& event )
{ {
WS_DATA_MODEL::GetTheInstance().m_SpecialMode = (event.GetId() == ID_SHOW_PL_EDITOR_MODE); WS_DATA_MODEL::GetTheInstance().m_EditMode = (event.GetId() == ID_SHOW_PL_EDITOR_MODE);
HardRedraw(); HardRedraw();
} }
@ -373,13 +359,13 @@ void PL_EDITOR_FRAME::ToPrinter( bool doPreview )
void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event ) void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event )
{ {
event.Check( WS_DATA_MODEL::GetTheInstance().m_SpecialMode == false ); event.Check( WS_DATA_MODEL::GetTheInstance().m_EditMode == false );
} }
void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event ) void PL_EDITOR_FRAME::OnUpdateTitleBlockDisplayEditMode( wxUpdateUIEvent& event )
{ {
event.Check( WS_DATA_MODEL::GetTheInstance().m_SpecialMode == true ); event.Check( WS_DATA_MODEL::GetTheInstance().m_EditMode == true );
} }

View File

@ -88,8 +88,7 @@ public:
/** /**
* Function InsertPageLayoutDescrFile * Function InsertPageLayoutDescrFile
* Loads a .kicad_wks page layout descr file, and add items * Loads a .kicad_wks page layout descr file, and add items to the current layout list
* to the current layout list
* @param aFullFileName = the filename. * @param aFullFileName = the filename.
*/ */
bool InsertPageLayoutDescrFile( const wxString& aFullFileName ); bool InsertPageLayoutDescrFile( const wxString& aFullFileName );
@ -109,9 +108,7 @@ public:
/** /**
* Function GetZoomLevelIndicator * Function GetZoomLevelIndicator
* returns a human readable value which can be displayed as zoom * returns a human readable value which can be displayed in dialogs.
* level indicator in dialogs.
* Virtual from the base class
*/ */
const wxString GetZoomLevelIndicator() const override; const wxString GetZoomLevelIndicator() const override;
@ -142,14 +139,12 @@ public:
void UpdateStatusBar() override; void UpdateStatusBar() override;
/** /**
* Must be called to initialize parameters when a new page layout * Must be called to initialize parameters when a new page layout description is loaded
* description is loaded
*/ */
void OnNewPageLayout(); void OnNewPageLayout();
/** /**
* creates or updates the right vertical toolbar. * creates or updates the right vertical toolbar.
* @note This is currently not used.
*/ */
void ReCreateVToolbar() override; void ReCreateVToolbar() override;
@ -170,11 +165,9 @@ public:
const BOX2I GetDocumentExtents() const override; const BOX2I GetDocumentExtents() const override;
/** /**
* Page layout editor can show the title block using a page number * Page layout editor can show the title block using a page number 1 or another number.
* 1 or another number. * This is because some items can be shown (or not) only on page 1 (a feature which
* This is because some items can be shown (or not) only on page 1 * looks like word processing option "page 1 differs from other pages").
* (a feature which look like word processing option
* "page 1 differs from other pages".
* @return true if the page 1 is selected, and false if not * @return true if the page 1 is selected, and false if not
*/ */
bool GetPageNumberOption() const bool GetPageNumberOption() const
@ -183,8 +176,7 @@ public:
} }
/** /**
* Displays the short filename (if exists) loaded file * Displays the short filename (if exists) loaded file on the caption of the main window
* on the caption of the main window
*/ */
void UpdateTitleAndInfo(); void UpdateTitleAndInfo();
@ -205,23 +197,22 @@ public:
void Process_Special_Functions( wxCommandEvent& event ); void Process_Special_Functions( wxCommandEvent& event );
/** /**
* called when the user select one of the 4 page corner as corner * called when the user select one of the 4 page corner as corner reference (or the
* reference (or the left top paper corner) * left top paper corner)
*/ */
void OnSelectCoordOriginCorner( wxCommandEvent& event ); void OnSelectCoordOriginCorner( wxCommandEvent& event );
/** /**
* Toggle the display mode between the normal mode and the editor mode: * Toggle the display mode between the normal mode and the editor mode:
* In normal mode, title block texts are shown like they will be * In normal mode, title block texts are shown like they will be shown in other kicad
* shown in other kicad applications: the format symbols in texts * applications: the format symbols in texts are replaced by the actual text.
* are replaced by the actual text. * In editor mode, the format symbols in texts are not replaced by the actual text,
* In editor mode, the format symbols in texts are not replaced * and therefore format symbols are displayed.
* by the actual text, and therefore format symbols are displayed.
*/ */
void OnSelectTitleBlockDisplayMode( wxCommandEvent& event ); void OnSelectTitleBlockDisplayMode( wxCommandEvent& event );
void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event ); void OnUpdateTitleBlockDisplayNormalMode( wxUpdateUIEvent& event );
void OnUpdateTitleBlockDisplaySpecialMode( wxUpdateUIEvent& event ); void OnUpdateTitleBlockDisplayEditMode( wxUpdateUIEvent& event );
///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription() ///> @copydoc EDA_DRAW_FRAME::GetHotKeyDescription()
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override; EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
@ -286,8 +277,7 @@ public:
WS_DATA_ITEM* AddPageLayoutItem( int aType ); WS_DATA_ITEM* AddPageLayoutItem( int aType );
/** /**
* Must be called after a change * Must be called after a change in order to set the "modify" flag
* in order to set the "modify" flag of the current screen
*/ */
void OnModify() void OnModify()
{ {
@ -295,10 +285,10 @@ public:
} }
/** /**
* Save a copy of the description (in a S expr string) * Save a copy of the description (in a S expr string) for Undo/redo commands.
* for Undo/redo commands * Optionally save the pageInfo and titleBlock as well.
*/ */
void SaveCopyInUndoList(); void SaveCopyInUndoList( bool aSavePageSettingsAndTitleBlock = false );
/** Redo the last edit: /** Redo the last edit:
* - Place the current edited layout in undo list * - Place the current edited layout in undo list
@ -313,8 +303,8 @@ public:
void GetLayoutFromUndoList(); void GetLayoutFromUndoList();
/** /**
* Remove the last command in Undo List. * Apply the last command in Undo List without stacking a Redo. Used to clean the
* Used to clean the Undo stack after a cancel command * Undo stack after cancelling a command.
*/ */
void RollbackFromUndo(); void RollbackFromUndo();

View File

@ -52,11 +52,9 @@ public:
PL_EDITOR_LAYOUT(); PL_EDITOR_LAYOUT();
~PL_EDITOR_LAYOUT(); ~PL_EDITOR_LAYOUT();
const PAGE_INFO& GetPageSettings() const { return m_paper; } PAGE_INFO& GetPageSettings() { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) const PAGE_INFO& GetPageSettings() const { return m_paper; }
{ void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
m_paper = aPageSettings;
}
const wxPoint& GetAuxOrigin() const const wxPoint& GetAuxOrigin() const
{ {
@ -64,21 +62,15 @@ public:
return zero; return zero;
} }
const TITLE_BLOCK& GetTitleBlock() const TITLE_BLOCK& GetTitleBlock() { return m_titles; }
{ const TITLE_BLOCK& GetTitleBlock() const { return m_titles; }
return m_titles; void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
}
WS_DRAW_ITEM_LIST& GetDrawItems() WS_DRAW_ITEM_LIST& GetDrawItems()
{ {
return m_drawItemList; return m_drawItemList;
} }
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
{
m_titles = aTitleBlock;
}
/** /**
* Function ComputeBoundingBox * Function ComputeBoundingBox
* calculates the bounding box containing all Gerber items. * calculates the bounding box containing all Gerber items.

View File

@ -32,99 +32,16 @@
#include <pl_editor_frame.h> #include <pl_editor_frame.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pl_selection_tool.h> #include <tools/pl_selection_tool.h>
#include <ws_proxy_undo_item.h>
#include <tool/actions.h>
/* Note: the Undo/redo commands use a "brute" method: void PL_EDITOR_FRAME::SaveCopyInUndoList( bool aSavePageSettingsAndTitleBlock )
* the full page layout is converted to a S expression, and saved as string.
* When a previous version is needed, the old string is parsed,
* and the description replaces the current desc, just like reading a new file
*
* This is not optimal from the memory point of view, but:
* - the descriptions are never very long (max few thousand of bytes)
* - this is very easy to code
*/
// A helper class used in undo/redo commad:
class PL_ITEM_LAYOUT: public EDA_ITEM
{ {
wxString m_serialization; PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
int m_selectedDataItem; WS_PROXY_UNDO_ITEM* copyItem = new WS_PROXY_UNDO_ITEM( this );
int m_selectedDrawItem; ITEM_PICKER wrapper( copyItem, UR_LIBEDIT );
public: lastcmd->PushItem( wrapper );
PL_ITEM_LAYOUT() :
EDA_ITEM( TYPE_PL_EDITOR_LAYOUT ),
m_selectedDataItem( INT_MAX ),
m_selectedDrawItem( INT_MAX )
{
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
pglayout.SaveInString( m_serialization );
for( size_t ii = 0; ii < pglayout.GetItems().size(); ++ii )
{
WS_DATA_ITEM* dataItem = pglayout.GetItem( ii );
for( size_t jj = 0; jj < dataItem->GetDrawItems().size(); ++jj )
{
WS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ jj ];
if( drawItem->IsSelected() )
{
m_selectedDataItem = ii;
m_selectedDrawItem = jj;
break;
}
}
}
}
void RestoreLayout( PL_EDITOR_FRAME* aFrame )
{
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
PL_SELECTION_TOOL* selTool = aFrame->GetToolManager()->GetTool<PL_SELECTION_TOOL>();
KIGFX::VIEW* view = aFrame->GetGalCanvas()->GetView();
pglayout.SetPageLayout( TO_UTF8( m_serialization ) );
selTool->ClearSelection();
view->Clear();
for( size_t ii = 0; ii < pglayout.GetItems().size(); ++ii )
{
WS_DATA_ITEM* dataItem = pglayout.GetItem( ii );
dataItem->SyncDrawItems( nullptr, view );
if( ii == m_selectedDataItem && m_selectedDrawItem < dataItem->GetDrawItems().size() )
{
WS_DRAW_ITEM_BASE* drawItem = dataItem->GetDrawItems()[ m_selectedDrawItem ];
drawItem->SetSelected();
}
}
selTool->RebuildSelection();
}
// Required to keep compiler happy on debug builds.
#if defined(DEBUG)
virtual void Show( int nestLevel, std::ostream& os ) const override {}
#endif
/** Get class name
* @return string "PL_ITEM_LAYOUT"
*/
virtual wxString GetClass() const override
{
return wxT( "PL_ITEM_LAYOUT" );
}
};
void PL_EDITOR_FRAME::SaveCopyInUndoList()
{
PL_ITEM_LAYOUT* copyItem = new PL_ITEM_LAYOUT; // constructor stores current layout
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST();
ITEM_PICKER wrapper( copyItem, UR_LIBEDIT );
lastcmd->PushItem(wrapper);
GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->PushCommandToUndoList( lastcmd );
// Clear redo list, because after new save there is no redo to do. // Clear redo list, because after new save there is no redo to do.
@ -138,25 +55,34 @@ void PL_EDITOR_FRAME::SaveCopyInUndoList()
*/ */
void PL_EDITOR_FRAME::GetLayoutFromRedoList() void PL_EDITOR_FRAME::GetLayoutFromRedoList()
{ {
PL_SELECTION_TOOL* selTool = GetToolManager()->GetTool<PL_SELECTION_TOOL>();
if ( GetScreen()->GetRedoCommandCount() <= 0 ) if ( GetScreen()->GetRedoCommandCount() <= 0 )
return; return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER redoWrapper = GetScreen()->PopCommandFromRedoList()->PopItem();
PL_ITEM_LAYOUT* copyItem = new PL_ITEM_LAYOUT; // constructor stores current layout WS_PROXY_UNDO_ITEM* redoItem = static_cast<WS_PROXY_UNDO_ITEM*>( redoWrapper.GetItem() );
bool pageSettingsAndTitleBlock = redoItem->Type() == WS_PROXY_UNDO_ITEM_PLUS_T;
ITEM_PICKER wrapper( copyItem, UR_LIBEDIT ); PICKED_ITEMS_LIST* undoCmd = new PICKED_ITEMS_LIST();
lastcmd->PushItem( wrapper ); undoCmd->PushItem( new WS_PROXY_UNDO_ITEM( pageSettingsAndTitleBlock ? this : nullptr ) );
GetScreen()->PushCommandToUndoList( lastcmd ); GetScreen()->PushCommandToUndoList( undoCmd );
lastcmd = GetScreen()->PopCommandFromRedoList(); selTool->ClearSelection();
redoItem->Restore( this, GetGalCanvas()->GetView() );
selTool->RebuildSelection();
wrapper = lastcmd->PopItem(); delete redoItem;
copyItem = static_cast<PL_ITEM_LAYOUT*>( wrapper.GetItem() );
copyItem->RestoreLayout( this ); if( pageSettingsAndTitleBlock )
delete copyItem; {
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
HardRedraw(); // items based off of corners will need re-calculating
}
else
GetCanvas()->Refresh();
GetCanvas()->Refresh();
OnModify(); OnModify();
} }
@ -167,41 +93,63 @@ void PL_EDITOR_FRAME::GetLayoutFromRedoList()
*/ */
void PL_EDITOR_FRAME::GetLayoutFromUndoList() void PL_EDITOR_FRAME::GetLayoutFromUndoList()
{ {
PL_SELECTION_TOOL* selTool = GetToolManager()->GetTool<PL_SELECTION_TOOL>();
if ( GetScreen()->GetUndoCommandCount() <= 0 ) if ( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
PICKED_ITEMS_LIST* lastcmd = new PICKED_ITEMS_LIST(); ITEM_PICKER undoWrapper = GetScreen()->PopCommandFromUndoList()->PopItem();
PL_ITEM_LAYOUT* copyItem = new PL_ITEM_LAYOUT; // constructor stores current layout WS_PROXY_UNDO_ITEM* undoItem = static_cast<WS_PROXY_UNDO_ITEM*>( undoWrapper.GetItem() );
bool pageSettingsAndTitleBlock = undoItem->Type() == WS_PROXY_UNDO_ITEM_PLUS_T;
ITEM_PICKER wrapper( copyItem, UR_LIBEDIT ); PICKED_ITEMS_LIST* redoCmd = new PICKED_ITEMS_LIST();
lastcmd->PushItem( wrapper );
GetScreen()->PushCommandToRedoList( lastcmd );
lastcmd = GetScreen()->PopCommandFromUndoList(); redoCmd->PushItem( new WS_PROXY_UNDO_ITEM( pageSettingsAndTitleBlock ? this : nullptr ) );
GetScreen()->PushCommandToRedoList( redoCmd );
wrapper = lastcmd->PopItem(); selTool->ClearSelection();
copyItem = static_cast<PL_ITEM_LAYOUT*>( wrapper.GetItem() ); undoItem->Restore( this, GetGalCanvas()->GetView() );
copyItem->RestoreLayout( this ); selTool->RebuildSelection();
delete copyItem;
delete undoItem;
if( pageSettingsAndTitleBlock )
{
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
HardRedraw(); // items based off of corners will need re-calculating
}
else
GetCanvas()->Refresh();
GetCanvas()->Refresh();
OnModify(); OnModify();
} }
/* Remove the last command in Undo List. /* Remove the last command in Undo List.
* Used to clean the uUndo stack after a cancel command * Used to clean the uUndo stack after a cancel command
*/ */
void PL_EDITOR_FRAME::RollbackFromUndo() void PL_EDITOR_FRAME::RollbackFromUndo()
{ {
PL_SELECTION_TOOL* selTool = GetToolManager()->GetTool<PL_SELECTION_TOOL>();
if ( GetScreen()->GetUndoCommandCount() <= 0 ) if ( GetScreen()->GetUndoCommandCount() <= 0 )
return; return;
PICKED_ITEMS_LIST* lastcmd = GetScreen()->PopCommandFromUndoList(); ITEM_PICKER undoWrapper = GetScreen()->PopCommandFromUndoList()->PopItem();
WS_PROXY_UNDO_ITEM* undoItem = static_cast<WS_PROXY_UNDO_ITEM*>( undoWrapper.GetItem() );
bool pageSettingsAndTitleBlock = undoItem->Type() == WS_PROXY_UNDO_ITEM_PLUS_T;
ITEM_PICKER wrapper = lastcmd->PopItem(); selTool->ClearSelection();
PL_ITEM_LAYOUT* copyItem = static_cast<PL_ITEM_LAYOUT*>( wrapper.GetItem() ); undoItem->Restore( this, GetGalCanvas()->GetView() );
copyItem->RestoreLayout( this ); selTool->RebuildSelection();
delete copyItem;
GetCanvas()->Refresh(); delete undoItem;
if( pageSettingsAndTitleBlock )
{
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
HardRedraw(); // items based off of corners will need re-calculating
}
else
GetCanvas()->Refresh();
} }

View File

@ -44,7 +44,7 @@ void PL_EDITOR_FRAME::ReCreateHToolbar()
m_mainToolBar->Add( ACTIONS::save ); m_mainToolBar->Add( ACTIONS::save );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->Add( ACTIONS::pageSetup ); m_mainToolBar->Add( ACTIONS::pageSettings );
m_mainToolBar->Add( ACTIONS::print ); m_mainToolBar->Add( ACTIONS::print );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );

View File

@ -35,6 +35,7 @@
#include <properties_frame.h> #include <properties_frame.h>
#include <pl_editor_id.h> #include <pl_editor_id.h>
TOOL_ACTION PL_ACTIONS::refreshPreview( "plEditor.EditorControl.refreshPreview", TOOL_ACTION PL_ACTIONS::refreshPreview( "plEditor.EditorControl.refreshPreview",
AS_GLOBAL, 0, "", "" ); AS_GLOBAL, 0, "", "" );
@ -92,8 +93,22 @@ int PL_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
int PL_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent ) int PL_EDITOR_CONTROL::PageSetup( const TOOL_EVENT& aEvent )
{ {
wxCommandEvent evt( wxEVT_NULL, ID_SHEET_SET ); m_frame->SaveCopyInUndoList( true );
m_frame->Process_Special_Functions( evt );
DIALOG_PAGES_SETTINGS dlg( m_frame, wxSize( MAX_PAGE_SIZE_MILS, MAX_PAGE_SIZE_MILS ) );
dlg.SetWksFileName( m_frame->GetCurrFileName() );
dlg.EnableWksFileNamePicker( false );
if( dlg.ShowModal() != wxID_OK )
{
// Nothing to roll back but we have to at least pop the stack
m_frame->RollbackFromUndo();
}
else
{
m_toolMgr->RunAction( ACTIONS::zoomFitScreen );
m_frame->HardRedraw();
}
return 0; return 0;
} }
@ -165,7 +180,7 @@ void PL_EDITOR_CONTROL::setTransitions()
Go( &PL_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() ); Go( &PL_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() ); Go( &PL_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
Go( &PL_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() ); Go( &PL_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
Go( &PL_EDITOR_CONTROL::PageSetup, ACTIONS::pageSetup.MakeEvent() ); Go( &PL_EDITOR_CONTROL::PageSetup, ACTIONS::pageSettings.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() ); Go( &PL_EDITOR_CONTROL::Print, ACTIONS::print.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() ); Go( &PL_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
Go( &PL_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() ); Go( &PL_EDITOR_CONTROL::Quit, ACTIONS::quit.MakeEvent() );

View File

@ -44,7 +44,7 @@
#include <base_units.h> #include <base_units.h>
#include <ratsnest_data.h> #include <ratsnest_data.h>
#include <ratsnest_viewitem.h> #include <ratsnest_viewitem.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <collectors.h> #include <collectors.h>

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2010-2016 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr * Copyright (C) 2010-2016 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018 CERN * Copyright (C) 2018 CERN
* Author: Maciej Suminski <maciej.suminski@cern.ch> * Author: Maciej Suminski <maciej.suminski@cern.ch>
* *
@ -28,20 +28,16 @@
#include <kiface_i.h> #include <kiface_i.h>
#include <class_drawpanel.h> #include <class_drawpanel.h>
#include <confirm.h> #include <confirm.h>
#include <pcb_edit_frame.h>
#include <footprint_edit_frame.h>
#include <base_units.h> #include <base_units.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <pcbplot.h> #include <pcbplot.h>
#include <class_board.h> #include <class_board.h>
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <tools/pcbnew_control.h>
#include <dialog_print_generic.h> #include <dialog_print_generic.h>
#include <pcbnew_printout.h> #include <pcbnew_printout.h>
class DIALOG_PRINT_PCBNEW : public DIALOG_PRINT_GENERIC class DIALOG_PRINT_PCBNEW : public DIALOG_PRINT_GENERIC
{ {
public: public:
@ -329,24 +325,20 @@ void DIALOG_PRINT_PCBNEW::saveSettings()
} }
void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) int PCBNEW_CONTROL::Print( const TOOL_EVENT& aEvent )
{ {
// Selection affects the original item visibility // Selection affects the origin item visibility
GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
PCBNEW_PRINTOUT_SETTINGS settings( m_frame->GetPageSettings() );
DIALOG_PRINT_PCBNEW dlg( (PCB_BASE_EDIT_FRAME*) m_frame, &settings );
if( m_editModules )
dlg.ForcePrintBorder( false );
PCBNEW_PRINTOUT_SETTINGS settings( GetPageSettings() );
DIALOG_PRINT_PCBNEW dlg( this, &settings );
dlg.ShowModal(); dlg.ShowModal();
return 0;
} }
void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
{
// Selection affects the original item visibility
GetToolManager()->RunAction( PCB_ACTIONS::selectionClear, true );
PCBNEW_PRINTOUT_SETTINGS settings( GetPageSettings() );
DIALOG_PRINT_PCBNEW dlg( this, &settings );
dlg.ForcePrintBorder( false );
dlg.ShowModal();
}

View File

@ -1061,3 +1061,9 @@ void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
wxYield(); wxYield();
saveCanvasImageToFile( dlg.GetPath() ); saveCanvasImageToFile( dlg.GetPath() );
} }
void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
{
GetToolManager()->RunAction( ACTIONS::print );
}

View File

@ -280,10 +280,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_EXIT:
Close( true );
break;
case ID_OPEN_MODULE_VIEWER: case ID_OPEN_MODULE_VIEWER:
{ {
FOOTPRINT_VIEWER_FRAME* viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false ); FOOTPRINT_VIEWER_FRAME* viewer = (FOOTPRINT_VIEWER_FRAME*) Kiway().Player( FRAME_PCB_MODULE_VIEWER, false );
@ -578,9 +574,6 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
AddLibrary(); AddLibrary();
break; break;
case ID_MODEDIT_SHEET_SET:
break;
case ID_MODEDIT_EDIT_MODULE: case ID_MODEDIT_EDIT_MODULE:
LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() ); LoadModuleFromLibrary( m_treePane->GetLibTree()->GetSelectedLibId() );
break; break;

View File

@ -42,20 +42,9 @@
#include "pcbnew_id.h" #include "pcbnew_id.h"
// Build the files menu. Because some commands are available only if
// Pcbnew is run outside a project (run alone), aIsOutsideProject is false
// when Pcbnew is run from Kicad manager, and true is run as stand alone app.
static void prepareFilesMenu( wxMenu* aParentMenu, bool aIsOutsideProject );
// Build the export submenu (inside files menu)
static void prepareExportMenu( wxMenu* aParentMenu );
// Build the place submenu // Build the place submenu
static void preparePlaceMenu( CONDITIONAL_MENU* aPlaceMenu, SELECTION_TOOL* aSelectionTool ); static void preparePlaceMenu( CONDITIONAL_MENU* aPlaceMenu, SELECTION_TOOL* aSelectionTool );
// Build the edit submenu
static void prepareEditMenu( PCB_EDIT_FRAME * aFrame, CONDITIONAL_MENU* aEditMenu, SELECTION_TOOL* aSelectionTool );
// Build the route menu // Build the route menu
static void prepareRouteMenu( wxMenu* aParentMenu ); static void prepareRouteMenu( wxMenu* aParentMenu );
@ -81,16 +70,229 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
wxMenuBar* menuBar = new wxMenuBar(); wxMenuBar* menuBar = new wxMenuBar();
wxString text; wxString text;
auto modifiedDocumentCondition = [ this ] ( const SELECTION& sel ) {
return GetScreen()->IsModify();
};
// Recreate all menus: // Recreate all menus:
// Create File Menu //----- Edit menu -----------------------------------------------------------
wxMenu* filesMenu = new wxMenu; CONDITIONAL_MENU* fileMenu = new CONDITIONAL_MENU( false, selTool );
prepareFilesMenu( filesMenu, Kiface().IsSingle() ); static ACTION_MENU* openRecentMenu;
if( Kiface().IsSingle() ) // not when under a project mgr
{
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history)
if( openRecentMenu )
Kiface().GetFileHistory().RemoveMenu( openRecentMenu );
openRecentMenu = new ACTION_MENU();
openRecentMenu->SetTool( selTool );
openRecentMenu->SetTitle( _( "Open Recent" ) );
openRecentMenu->SetIcon( recent_xpm );
Kiface().GetFileHistory().UseMenu( openRecentMenu );
Kiface().GetFileHistory().AddFilesToMenu( openRecentMenu );
fileMenu->AddItem( ACTIONS::doNew, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::open, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddMenu( openRecentMenu, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator();
}
fileMenu->AddItem( ACTIONS::save, modifiedDocumentCondition );
// Save as menu:
// under a project mgr we do not want to modify the board filename
// to keep consistency with the project mgr which expects files names same as prj name
// for main files
if( Kiface().IsSingle() )
fileMenu->AddItem( ACTIONS::saveAs, SELECTION_CONDITIONS::ShowAlways );
else
fileMenu->AddItem( ACTIONS::saveCopyAs, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator();
fileMenu->AddItem( ID_MENU_RECOVER_BOARD_AUTOSAVE,
_( "Resc&ue" ),
_( "Clear board and get last rescue file automatically saved by Pcbnew" ),
rescue_xpm, SELECTION_CONDITIONS::ShowAlways );
if( Kiface().IsSingle() ) // not when under a project mgr
{
fileMenu->AddItem( ID_APPEND_FILE,
_( "&Append Board..." ),
_( "Append another board to currently loaded board" ),
add_board_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ID_IMPORT_NON_KICAD_BOARD,
_( "Import Non-KiCad Board File..." ),
_( "Import board file from other applications" ),
import_brd_file_xpm, SELECTION_CONDITIONS::ShowAlways );
}
fileMenu->AddItem( ID_MENU_READ_BOARD_BACKUP_FILE,
_( "Revert to Last Backup" ),
_( "Clear board and get previous backup version of board" ),
undo_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator();
//----- Import submenu ------------------------------------------------------
ACTION_MENU* submenuImport = new ACTION_MENU();
submenuImport->SetTool( selTool );
submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( import_xpm );
submenuImport->Add( _( "Netlist..." ), _( "Read netlist and update board connectivity" ),
ID_GET_NETLIST, netlist_xpm );
submenuImport->Add( _( "Specctra Session..." ), _( "Import routed Specctra session (*.ses) file" ),
ID_GEN_IMPORT_SPECCTRA_SESSION, import_xpm );
submenuImport->Add( _( "Graphics..." ), _( "Import 2D drawing file" ),
ID_GEN_IMPORT_GRAPHICS_FILE, import_vector_xpm );
fileMenu->AddMenu( submenuImport, SELECTION_CONDITIONS::ShowAlways );
//----- Export submenu ------------------------------------------------------
ACTION_MENU* submenuExport = new ACTION_MENU();
submenuExport->SetTool( selTool );
submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( export_xpm );
submenuExport->Add( _( "Specctra DSN..." ), _( "Export Specctra DSN routing info" ),
ID_GEN_EXPORT_SPECCTRA, export_dsn_xpm );
submenuExport->Add( _( "GenCAD..." ), _( "Export GenCAD 3D board representation" ),
ID_GEN_EXPORT_FILE_GENCADFORMAT, export_xpm );
submenuExport->Add( _( "VRML..." ), _( "Export VRML 3D board representation" ),
ID_GEN_EXPORT_FILE_VRML, export3d_xpm );
submenuExport->Add( _( "IDFv3..." ), _( "Export IDF 3D board representation" ),
ID_GEN_EXPORT_FILE_IDF3, export_idf_xpm );
submenuExport->Add( _( "STEP..." ), _( "Export STEP 3D board representation" ),
ID_GEN_EXPORT_FILE_STEP, export_step_xpm );
submenuExport->Add( _( "SVG..." ), _( "Export SVG board representation" ),
ID_GEN_PLOT_SVG, plot_svg_xpm );
submenuExport->Add( _( "Footprint Association (.cmp) File..." ),
_( "Export footprint association file (*.cmp) for schematic back annotation" ),
ID_PCB_GEN_CMP_FILE, create_cmp_file_xpm );
submenuExport->Add( _( "Hyperlynx..." ), "",
ID_GEN_EXPORT_FILE_HYPERLYNX, export_step_xpm );
fileMenu->AddMenu( submenuExport, SELECTION_CONDITIONS::ShowAlways );
//----- Fabrication Outputs submenu -----------------------------------------
ACTION_MENU* submenuFabOutputs = new ACTION_MENU();
submenuFabOutputs->SetTool( selTool );
submenuFabOutputs->SetTitle( _( "Fabrication Outputs" ) );
submenuFabOutputs->SetIcon( fabrication_xpm );
submenuFabOutputs->Add( _( "&Gerbers (.gbr)..." ),
_( "Generate Gerbers for fabrication" ),
ID_GEN_PLOT_GERBER, post_compo_xpm );
submenuFabOutputs->Add( _( "&Drill Files (.drl)..." ),
_( "Generate Excellon drill file(s)" ),
ID_PCB_GEN_DRILL_FILE, post_drill_xpm );
submenuFabOutputs->Add( _( "Footprint &Positions (.pos)..." ),
_( "Generate footprint position file for pick and place" ),
ID_PCB_GEN_POS_MODULES_FILE, post_compo_xpm );
submenuFabOutputs->Add( _( "&Footprint Report (.rpt)..." ),
_( "Create report of all footprints from current board" ),
ID_GEN_EXPORT_FILE_MODULE_REPORT, tools_xpm );
submenuFabOutputs->Add( _( "IPC-D-356 Netlist File..." ),
_( "Generate IPC-D-356 netlist file" ),
ID_PCB_GEN_D356_FILE, netlist_xpm );
submenuFabOutputs->Add( _( "&BOM..." ),
_( "Create bill of materials from current schematic" ),
ID_PCB_GEN_BOM_FILE_FROM_BOARD, bom_xpm );
fileMenu->AddMenu( submenuFabOutputs, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator();
fileMenu->AddItem( ID_BOARD_SETUP_DIALOG,
_( "&Board Setup..." ),
_( "Edit board setup including layers, design rules and various defaults" ),
options_board_xpm, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::pageSettings, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::print, SELECTION_CONDITIONS::ShowAlways );
fileMenu->AddItem( ACTIONS::plot, SELECTION_CONDITIONS::ShowAlways );
//----- archive submenu -----------------------------------------------------
ACTION_MENU* submenuArchive = new ACTION_MENU();
submenuArchive->SetTool( selTool );
submenuArchive->SetTitle( _( "Archive Footprints" ) );
submenuArchive->SetIcon( library_archive_xpm );
submenuArchive->Add( _( "&Archive Footprints in Existing Library..." ),
_( "Archive all footprints to existing library in footprint Lib table"
"(does not remove other footprints in this library)" ),
ID_MENU_ARCHIVE_MODULES_IN_LIBRARY, library_archive_xpm );
submenuArchive->Add( _( "&Create New Library and Archive Footprints..." ),
_( "Archive all footprints to a new library\n"
"(if the library already exists it will be replaced)" ),
ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, library_archive_as_xpm );
fileMenu->AddSeparator();
fileMenu->AddMenu( submenuArchive, SELECTION_CONDITIONS::ShowAlways );
// Quit
fileMenu->AddSeparator();
fileMenu->AddItem( ACTIONS::quit, SELECTION_CONDITIONS::ShowAlways );
//----- Edit menu ----------------------------------------------------------- //----- Edit menu -----------------------------------------------------------
CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool ); CONDITIONAL_MENU* editMenu = new CONDITIONAL_MENU( false, selTool );
prepareEditMenu( this, editMenu, selTool );
auto enableUndoCondition = [ this ] ( const SELECTION& sel ) {
return GetScreen() && GetScreen()->GetUndoCommandCount() > 0;
};
auto enableRedoCondition = [ this ] ( const SELECTION& sel ) {
return GetScreen() && GetScreen()->GetRedoCommandCount() > 0;
};
auto noActiveToolCondition = [ this ] ( const SELECTION& aSelection ) {
return GetToolId() == ID_NO_TOOL_SELECTED;
};
editMenu->AddItem( ACTIONS::undo, enableUndoCondition );
editMenu->AddItem( ACTIONS::redo, enableRedoCondition );
editMenu->AddSeparator();
editMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty );
editMenu->AddItem( ACTIONS::paste, noActiveToolCondition );
editMenu->AddSeparator();
editMenu->AddItem( PCB_ACTIONS::deleteTool, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddSeparator();
editMenu->AddItem( ACTIONS::find, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddSeparator();
editMenu->AddItem( ID_PCB_EDIT_TRACKS_AND_VIAS,
_( "Edit Track && Via Properties..." ), "",
width_track_via_xpm, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( ID_MENU_PCB_EDIT_TEXT_AND_GRAPHICS,
_( "Edit Text && Graphic Properties..." ), "",
reset_text_xpm, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( PCB_ACTIONS::exchangeFootprints, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( ID_MENU_PCB_SWAP_LAYERS,
_( "Swap Layers..." ),
_( "Move tracks or drawings from a layer to another layer" ),
swap_layer_xpm, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddSeparator();
editMenu->AddItem( PCB_ACTIONS::zoneFillAll, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( PCB_ACTIONS::zoneUnfillAll, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddSeparator();
editMenu->AddItem( ID_PCB_GLOBAL_DELETE,
_( "Global Deletions..." ),
_( "Delete tracks, footprints and graphic items from board" ),
general_deletions_xpm, SELECTION_CONDITIONS::ShowAlways );
editMenu->AddItem( ID_MENU_PCB_CLEAN,
_( "Cleanup Tracks and Vias..." ),
_( "Clean stubs, vias, delete break points or unconnected tracks" ),
delete_xpm, SELECTION_CONDITIONS::ShowAlways );
//----- View menu ----------------------------------------------------------- //----- View menu -----------------------------------------------------------
CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool ); CONDITIONAL_MENU* viewMenu = new CONDITIONAL_MENU( false, selTool );
@ -149,17 +351,17 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
viewMenu->AddCheckItem( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR, viewMenu->AddCheckItem( ID_TB_OPTIONS_SHOW_MANAGE_LAYERS_VERTICAL_TOOLBAR,
_( "Show La&yers Manager" ), HELP_SHOW_HIDE_LAYERMANAGER, _( "Show La&yers Manager" ), HELP_SHOW_HIDE_LAYERMANAGER,
layers_manager_xpm, layersPaletteShownCondition ); layers_manager_xpm, layersPaletteShownCondition );
viewMenu->AddCheckItem( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE, viewMenu->AddCheckItem( ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR_MICROWAVE,
_( "Show Microwa&ve Toolbar" ), HELP_SHOW_HIDE_MICROWAVE_TOOLS, _( "Show Microwa&ve Toolbar" ), HELP_SHOW_HIDE_MICROWAVE_TOOLS,
mw_toolbar_xpm, microwaveToolbarShownCondition ); mw_toolbar_xpm, microwaveToolbarShownCondition );
viewMenu->AddItem( ID_OPEN_MODULE_VIEWER, viewMenu->AddItem( ID_OPEN_MODULE_VIEWER,
_( "Footprint &Library Browser" ), _( "Browse footprint libraries" ), _( "Footprint &Library Browser" ), _( "Browse footprint libraries" ),
modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways ); modview_icon_xpm, SELECTION_CONDITIONS::ShowAlways );
text = AddHotkeyName( _( "&3D Viewer" ), g_Board_Editor_Hotkeys_Descr, HK_3D_VIEWER ); text = AddHotkeyName( _( "&3D Viewer" ), g_Board_Editor_Hotkeys_Descr, HK_3D_VIEWER );
viewMenu->AddItem( ID_MENU_PCB_SHOW_3D_FRAME, viewMenu->AddItem( ID_MENU_PCB_SHOW_3D_FRAME,
text, _( "Show board in 3D viewer" ), text, _( "Show board in 3D viewer" ),
three_d_xpm, SELECTION_CONDITIONS::ShowAlways ); three_d_xpm, SELECTION_CONDITIONS::ShowAlways );
viewMenu->AddSeparator(); viewMenu->AddSeparator();
viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways ); viewMenu->AddItem( ACTIONS::zoomInCenter, SELECTION_CONDITIONS::ShowAlways );
@ -245,7 +447,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
preparePreferencesMenu( this, configmenu ); preparePreferencesMenu( this, configmenu );
//------ Append all menus to the menuBar ------------------------------------ //------ Append all menus to the menuBar ------------------------------------
menuBar->Append( filesMenu, _( "&File" ) ); menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) ); menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) ); menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( placeMenu, _( "&Place" ) ); menuBar->Append( placeMenu, _( "&Place" ) );
@ -266,61 +468,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
} }
void prepareEditMenu( PCB_EDIT_FRAME * aFrame, CONDITIONAL_MENU* aEditMenu, SELECTION_TOOL* aSelectionTool )
{
auto enableUndoCondition = [ aFrame ] ( const SELECTION& sel ) {
return aFrame->GetScreen() && aFrame->GetScreen()->GetUndoCommandCount() > 0;
};
auto enableRedoCondition = [ aFrame ] ( const SELECTION& sel ) {
return aFrame->GetScreen() && aFrame->GetScreen()->GetRedoCommandCount() > 0;
};
auto noActiveToolCondition = [ aFrame ] ( const SELECTION& aSelection ) {
return aFrame->GetToolId() == ID_NO_TOOL_SELECTED;
};
aEditMenu->AddItem( ACTIONS::undo, enableUndoCondition );
aEditMenu->AddItem( ACTIONS::redo, enableRedoCondition );
aEditMenu->AddSeparator();
aEditMenu->AddItem( ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty );
aEditMenu->AddItem( ACTIONS::copy, SELECTION_CONDITIONS::NotEmpty );
aEditMenu->AddItem( ACTIONS::paste, noActiveToolCondition );
aEditMenu->AddSeparator();
aEditMenu->AddItem( PCB_ACTIONS::deleteTool, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddSeparator();
aEditMenu->AddItem( ACTIONS::find, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddSeparator();
aEditMenu->AddItem( ID_PCB_EDIT_TRACKS_AND_VIAS,
_( "Edit &Track && Via Properties..." ), "",
width_track_via_xpm, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddItem( ID_MENU_PCB_EDIT_TEXT_AND_GRAPHICS,
_( "Edit Text && &Graphic Properties..." ), "",
reset_text_xpm, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddItem( PCB_ACTIONS::exchangeFootprints, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddItem( ID_MENU_PCB_SWAP_LAYERS,
_( "&Swap Layers..." ),
_( "Move tracks or drawings from a layer to another layer" ),
swap_layer_xpm, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddSeparator();
aEditMenu->AddItem( PCB_ACTIONS::zoneFillAll, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddItem( PCB_ACTIONS::zoneUnfillAll, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddSeparator();
aEditMenu->AddItem( ID_PCB_GLOBAL_DELETE,
_( "Glo&bal Deletions..." ),
_( "Delete tracks, footprints and graphic items from board" ),
general_deletions_xpm, SELECTION_CONDITIONS::ShowAlways );
aEditMenu->AddItem( ID_MENU_PCB_CLEAN,
_( "C&leanup Tracks and Vias..." ),
_( "Clean stubs, vias, delete break points or unconnected tracks" ),
delete_xpm, SELECTION_CONDITIONS::ShowAlways );
}
// Build the preferences menu // Build the preferences menu
void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu ) void preparePreferencesMenu( PCB_EDIT_FRAME* aFrame, wxMenu* aParentMenu )
{ {
@ -547,263 +694,3 @@ void prepareToolsMenu( wxMenu* aParentMenu )
submenuActionPluginsMenu->AppendSeparator(); submenuActionPluginsMenu->AppendSeparator();
#endif #endif
} }
// Build the files menu.
void prepareFilesMenu( wxMenu* aParentMenu, bool aIsOutsideProject )
{
wxString text;
// Some commands are available only if Pcbnew is run outside a project (run alone).
// aIsOutsideProject is false when Pcbnew is run from Kicad manager.
FILE_HISTORY& fhist = Kiface().GetFileHistory();
// Load Recent submenu
static wxMenu* openRecentMenu;
// Add this menu to list menu managed by m_fileHistory
// (the file history will be updated when adding/removing files in history
if( openRecentMenu )
fhist.RemoveMenu( openRecentMenu );
openRecentMenu = new wxMenu();
fhist.UseMenu( openRecentMenu );
fhist.AddFilesToMenu();
if( aIsOutsideProject )
{
text = AddHotkeyName( _( "&New" ), g_Board_Editor_Hotkeys_Descr, HK_NEW );
AddMenuItem( aParentMenu, ID_NEW_BOARD,
text, _( "Create new board" ),
KiBitmap( new_board_xpm ) );
text = AddHotkeyName( _( "&Open..." ), g_Board_Editor_Hotkeys_Descr, HK_OPEN );
AddMenuItem( aParentMenu, ID_LOAD_FILE, text,
_( "Open existing board" ),
KiBitmap( open_brd_file_xpm ) );
AddMenuItem( aParentMenu, openRecentMenu,
-1, _( "Open &Recent" ),
_( "Open recently opened board" ),
KiBitmap( recent_xpm ) );
aParentMenu->AppendSeparator();
}
text = AddHotkeyName( _( "&Save" ), g_Board_Editor_Hotkeys_Descr, HK_SAVE );
AddMenuItem( aParentMenu, ID_SAVE_BOARD, text,
_( "Save current board" ),
KiBitmap( save_xpm ) );
// Save as menu:
// under a project mgr we do not want to modify the board filename
// to keep consistency with the project mgr which expects files names same as prj name
// for main files
// when not under a project mgr, we are free to change filenames, cwd ...
if( Kiface().IsSingle() ) // not when under a project mgr (pcbnew is run as stand alone)
{
text = AddHotkeyName( _( "Sa&ve As..." ), g_Board_Editor_Hotkeys_Descr, HK_SAVEAS );
AddMenuItem( aParentMenu, ID_SAVE_BOARD_AS, text,
_( "Save current board with new name" ),
KiBitmap( save_as_xpm ) );
}
// under a project mgr, we can save a copy of the board,
// but do not change the current board file name
else
{
text = AddHotkeyName( _( "Sa&ve Copy As..." ), g_Board_Editor_Hotkeys_Descr, HK_SAVEAS );
AddMenuItem( aParentMenu, ID_COPY_BOARD_AS, text,
_( "Save copy of the current board" ),
KiBitmap( save_as_xpm ) );
}
aParentMenu->AppendSeparator();
AddMenuItem( aParentMenu, ID_MENU_RECOVER_BOARD_AUTOSAVE,
_( "Resc&ue" ),
_( "Clear board and get last rescue file automatically saved by Pcbnew" ),
KiBitmap( rescue_xpm ) );
if( aIsOutsideProject )
{
AddMenuItem( aParentMenu, ID_APPEND_FILE,
_( "&Append Board..." ),
_( "Append another board to currently loaded board" ),
KiBitmap( add_board_xpm ) );
AddMenuItem( aParentMenu, ID_IMPORT_NON_KICAD_BOARD,
_( "Import Non-KiCad Board File..." ),
_( "Import board file from other applications" ),
KiBitmap( import_brd_file_xpm ) );
}
AddMenuItem( aParentMenu, ID_MENU_READ_BOARD_BACKUP_FILE,
_( "Revert to Las&t Backup" ),
_( "Clear board and get previous backup version of board" ),
KiBitmap( undo_xpm ) );
aParentMenu->AppendSeparator();
//----- Import submenu ------------------------------------------------------
wxMenu* submenuImport = new wxMenu();
AddMenuItem( submenuImport, ID_GET_NETLIST,
_( "&Netlist..." ),
_( "Read netlist and update board connectivity" ),
KiBitmap( netlist_xpm ) );
AddMenuItem( submenuImport, ID_GEN_IMPORT_SPECCTRA_SESSION,
_( "&Specctra Session..." ),
_( "Import routed \"Specctra Session\" (*.ses) file" ),
KiBitmap( import_xpm ) );
AddMenuItem( submenuImport, ID_GEN_IMPORT_GRAPHICS_FILE,
_( "&Graphics..." ),
_( "Import 2D Drawing file to Pcbnew on Drawings layer" ),
KiBitmap( import_vector_xpm ) );
AddMenuItem( aParentMenu, submenuImport,
ID_GEN_IMPORT_FILE, _( "&Import" ),
_( "Import files" ), KiBitmap( import_xpm ) );
//----- Export submenu ------------------------------------------------------
wxMenu* submenuexport = new wxMenu();
prepareExportMenu( submenuexport );
AddMenuItem( aParentMenu, submenuexport,
ID_GEN_EXPORT_FILE, _( "E&xport" ),
_( "Export board" ), KiBitmap( export_xpm ) );
//----- Fabrication Outputs submenu -----------------------------------------
wxMenu* fabricationOutputsMenu = new wxMenu;
AddMenuItem( fabricationOutputsMenu, ID_GEN_PLOT_GERBER,
_( "&Gerbers (.gbr)..." ),
_( "Generate Gerbers for fabrication" ),
KiBitmap( post_compo_xpm ) );
AddMenuItem( fabricationOutputsMenu, ID_PCB_GEN_DRILL_FILE,
_( "&Drill Files (.drl)..." ),
_( "Generate Excellon drill file(s)" ),
KiBitmap( post_drill_xpm ) );
AddMenuItem( fabricationOutputsMenu, ID_PCB_GEN_POS_MODULES_FILE,
_( "Footprint &Positions (.pos)..." ),
_( "Generate footprint position file for pick and place" ),
KiBitmap( post_compo_xpm ) );
AddMenuItem( fabricationOutputsMenu, ID_GEN_EXPORT_FILE_MODULE_REPORT,
_( "&Footprint Report (.rpt)..." ),
_( "Create report of all footprints from current board" ),
KiBitmap( tools_xpm ) );
AddMenuItem( fabricationOutputsMenu, ID_PCB_GEN_D356_FILE,
_( "IPC-D-356 Netlist File..." ),
_( "Generate IPC-D-356 netlist file" ),
KiBitmap( netlist_xpm ) );
AddMenuItem( fabricationOutputsMenu, ID_PCB_GEN_BOM_FILE_FROM_BOARD,
_( "&BOM..." ),
_( "Create bill of materials from current schematic" ),
KiBitmap( bom_xpm ) );
AddMenuItem( aParentMenu, fabricationOutputsMenu,
-1, _( "&Fabrication Outputs" ),
_( "Generate files for fabrication" ),
KiBitmap( fabrication_xpm ) );
aParentMenu->AppendSeparator();
AddMenuItem( aParentMenu, ID_BOARD_SETUP_DIALOG,
_( "&Board Setup..." ),
_( "Edit board setup including layers, design rules and various defaults" ),
KiBitmap( options_board_xpm ) );
aParentMenu->AppendSeparator();
AddMenuItem( aParentMenu, ID_SHEET_SET,
_( "Page S&ettings..." ),
_( "Settings for sheet size and frame references" ),
KiBitmap( sheetset_xpm ) );
text = AddHotkeyName( _( "&Print..." ), g_Board_Editor_Hotkeys_Descr, HK_PRINT );
AddMenuItem( aParentMenu, wxID_PRINT, text,
_( "Print board" ),
KiBitmap( print_button_xpm ) );
AddMenuItem( aParentMenu, ID_GEN_PLOT,
_( "P&lot..." ),
_( "Plot board in HPGL, PostScript or Gerber RS-274X format)" ),
KiBitmap( plot_xpm ) );
aParentMenu->AppendSeparator();
//----- archive submenu -----------------------------------------------------
wxMenu* submenuarchive = new wxMenu();
AddMenuItem( submenuarchive, ID_MENU_ARCHIVE_MODULES_IN_LIBRARY,
_( "&Archive Footprints in Existing Library..." ),
_( "Archive all footprints to existing library in footprint Lib table"
"(does not remove other footprints in this library)" ),
KiBitmap( library_archive_xpm ) );
AddMenuItem( submenuarchive, ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES,
_( "&Create New Library and Archive Footprints..." ),
_( "Archive all footprints to a new library\n"
"(if the library already exists it will be replaced)" ),
KiBitmap( library_archive_as_xpm ) );
AddMenuItem( aParentMenu, submenuarchive,
ID_MENU_ARCHIVE_MODULES,
_( "Arc&hive Footprints" ),
_( "Archive or add all footprints in library file" ),
KiBitmap( library_archive_xpm ) );
aParentMenu->AppendSeparator();
AddMenuItem( aParentMenu, wxID_EXIT, _( "&Exit" ), _( "Close Pcbnew" ), KiBitmap( exit_xpm ) );
}
// Build the import/export submenu (inside files menu)
void prepareExportMenu( wxMenu* aParentMenu )
{
AddMenuItem( aParentMenu, ID_GEN_EXPORT_SPECCTRA,
_( "S&pecctra DSN..." ),
_( "Export current board to \"Specctra DSN\" file" ),
KiBitmap( export_dsn_xpm ) );
AddMenuItem( aParentMenu, ID_GEN_EXPORT_FILE_GENCADFORMAT,
_( "&GenCAD..." ), _( "Export GenCAD format" ),
KiBitmap( export_xpm ) );
AddMenuItem( aParentMenu, ID_GEN_EXPORT_FILE_VRML,
_( "&VRML..." ),
_( "Export VRML board representation" ),
KiBitmap( export3d_xpm ) );
AddMenuItem( aParentMenu, ID_GEN_EXPORT_FILE_IDF3,
_( "I&DFv3..." ), _( "IDFv3 board and symbol export" ),
KiBitmap( export_idf_xpm ) );
AddMenuItem( aParentMenu, ID_GEN_EXPORT_FILE_STEP,
_( "S&TEP..." ), _( "STEP export" ),
KiBitmap( export_step_xpm ) );
AddMenuItem( aParentMenu, ID_GEN_PLOT_SVG,
_( "&SVG..." ),
_( "Export board file in Scalable Vector Graphics format" ),
KiBitmap( plot_svg_xpm ) );
AddMenuItem( aParentMenu, ID_PCB_GEN_CMP_FILE,
_( "&Footprint Association (.cmp) File..." ),
_( "Export footprint association file (*.cmp) for schematic back annotation" ),
KiBitmap( create_cmp_file_xpm ) );
AddMenuItem( aParentMenu, ID_GEN_EXPORT_FILE_HYPERLYNX,
_( "&Hyperlynx..." ), _( "Hyperlynx export" ),
KiBitmap( export_step_xpm ) );
}

View File

@ -120,15 +120,20 @@ public:
*/ */
void RestoreCopyFromUndoList( wxCommandEvent& aEvent ); void RestoreCopyFromUndoList( wxCommandEvent& aEvent );
/**
* Performs an undo of the last edit WITHOUT logging a corresponding redo. Used to cancel
* an in-progress operation.
*/
void RollbackFromUndo();
/** /**
* Function PutDataInPreviousState * Function PutDataInPreviousState
* Used in undo or redo command. * Used in undo or redo command.
* Put data pointed by List in the previous state, i.e. the state memorized by List * 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 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 aRedoCommand = a bool: true for redo, false for undo
* @param aRebuildRatsnet = a bool: true to rebuild ratsnest (normal use), false * @param aRebuildRatsnet = a bool: true to rebuild ratsnest (normal use), false to just
* to just retrieve last state (used in abort commands that do not need to * retrieve last state (used in abort commands that do not need to rebuild ratsnest)
* rebuild ratsnest)
*/ */
void PutDataInPreviousState( PICKED_ITEMS_LIST* aList, void PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
bool aRedoCommand, bool aRedoCommand,

View File

@ -26,7 +26,7 @@
#include <pcb_view.h> #include <pcb_view.h>
#include <view/wx_view_controls.h> #include <view/wx_view_controls.h>
#include <pcb_painter.h> #include <pcb_painter.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <ratsnest_viewitem.h> #include <ratsnest_viewitem.h>
#include <ratsnest_data.h> #include <ratsnest_data.h>
#include <connectivity/connectivity_data.h> #include <connectivity/connectivity_data.h>
@ -197,7 +197,7 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard )
} }
void PCB_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WS_VIEW_ITEM* aWorksheet ) void PCB_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet )
{ {
m_worksheet.reset( aWorksheet ); m_worksheet.reset( aWorksheet );
m_view->Add( m_worksheet.get() ); m_view->Add( m_worksheet.get() );

View File

@ -31,7 +31,7 @@
namespace KIGFX namespace KIGFX
{ {
class WS_VIEW_ITEM; class WS_PROXY_VIEW_ITEM;
class RATSNEST_VIEWITEM; class RATSNEST_VIEWITEM;
class PCB_VIEW; class PCB_VIEW;
} }
@ -59,7 +59,7 @@ public:
* @param aWorksheet is the worksheet to be used. * @param aWorksheet is the worksheet to be used.
* The object is then owned by PCB_DRAW_PANEL_GAL. * The object is then owned by PCB_DRAW_PANEL_GAL.
*/ */
void SetWorksheet( KIGFX::WS_VIEW_ITEM* aWorksheet ); void SetWorksheet( KIGFX::WS_PROXY_VIEW_ITEM* aWorksheet );
/** /**
* Function UseColorScheme * Function UseColorScheme
@ -118,7 +118,7 @@ protected:
void setDefaultLayerDeps(); void setDefaultLayerDeps();
///> Currently used worksheet ///> Currently used worksheet
std::unique_ptr<KIGFX::WS_VIEW_ITEM> m_worksheet; std::unique_ptr<KIGFX::WS_PROXY_VIEW_ITEM> m_worksheet;
///> Ratsnest view item ///> Ratsnest view item
std::unique_ptr<KIGFX::RATSNEST_VIEWITEM> m_ratsnest; std::unique_ptr<KIGFX::RATSNEST_VIEWITEM> m_ratsnest;

View File

@ -55,7 +55,7 @@
#include <class_track.h> #include <class_track.h>
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <ws_view_item.h> #include <ws_proxy_view_item.h>
#include <connectivity/connectivity_data.h> #include <connectivity/connectivity_data.h>
#include <ratsnest_viewitem.h> #include <ratsnest_viewitem.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
@ -121,11 +121,8 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_CLOSE( PCB_EDIT_FRAME::OnCloseWindow ) EVT_CLOSE( PCB_EDIT_FRAME::OnCloseWindow )
EVT_SIZE( PCB_EDIT_FRAME::OnSize ) EVT_SIZE( PCB_EDIT_FRAME::OnSize )
EVT_TOOL( ID_LOAD_FILE, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_MENU_READ_BOARD_BACKUP_FILE, PCB_EDIT_FRAME::Files_io ) EVT_TOOL( ID_MENU_READ_BOARD_BACKUP_FILE, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_MENU_RECOVER_BOARD_AUTOSAVE, PCB_EDIT_FRAME::Files_io ) EVT_TOOL( ID_MENU_RECOVER_BOARD_AUTOSAVE, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_NEW_BOARD, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_SAVE_BOARD, PCB_EDIT_FRAME::Files_io )
EVT_TOOL( ID_OPEN_MODULE_EDITOR, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_OPEN_MODULE_EDITOR, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_OPEN_MODULE_VIEWER, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_OPEN_MODULE_VIEWER, PCB_EDIT_FRAME::Process_Special_Functions )
@ -134,8 +131,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_MENU_PCB_FLIP_VIEW, PCB_EDIT_FRAME::OnFlipPcbView ) EVT_MENU( ID_MENU_PCB_FLIP_VIEW, PCB_EDIT_FRAME::OnFlipPcbView )
EVT_MENU( ID_APPEND_FILE, PCB_EDIT_FRAME::Files_io ) EVT_MENU( ID_APPEND_FILE, PCB_EDIT_FRAME::Files_io )
EVT_MENU( ID_SAVE_BOARD_AS, PCB_EDIT_FRAME::Files_io )
EVT_MENU( ID_COPY_BOARD_AS, PCB_EDIT_FRAME::Files_io )
EVT_MENU( ID_IMPORT_NON_KICAD_BOARD, PCB_EDIT_FRAME::Files_io ) EVT_MENU( ID_IMPORT_NON_KICAD_BOARD, PCB_EDIT_FRAME::Files_io )
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PCB_EDIT_FRAME::OnFileHistory ) EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PCB_EDIT_FRAME::OnFileHistory )
@ -157,8 +152,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
EVT_MENU( ID_MENU_ARCHIVE_MODULES_IN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_ARCHIVE_MODULES_IN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_MENU( ID_MENU_CREATE_LIBRARY_AND_ARCHIVE_MODULES, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_MENU( wxID_EXIT, PCB_EDIT_FRAME::OnQuit )
// menu Config // menu Config
EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_PCB_LIB_TABLE_EDIT, PCB_EDIT_FRAME::Process_Config )
EVT_MENU( ID_PCB_3DSHAPELIB_WIZARD, PCB_EDIT_FRAME::Process_Config ) EVT_MENU( ID_PCB_3DSHAPELIB_WIZARD, PCB_EDIT_FRAME::Process_Config )
@ -197,10 +190,7 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
// Horizontal toolbar // Horizontal toolbar
EVT_TOOL( ID_RUN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_RUN_LIBRARY, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_SHEET_SET, EDA_DRAW_FRAME::Process_PageSettings )
EVT_TOOL( wxID_PRINT, PCB_EDIT_FRAME::ToPrinter )
EVT_TOOL( ID_GEN_PLOT_SVG, PCB_EDIT_FRAME::ExportSVG ) EVT_TOOL( ID_GEN_PLOT_SVG, PCB_EDIT_FRAME::ExportSVG )
EVT_TOOL( ID_GEN_PLOT, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_GET_NETLIST, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_GET_NETLIST, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_DRC_CONTROL, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_DRC_CONTROL, PCB_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::Process_Special_Functions ) EVT_TOOL( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::Process_Special_Functions )
@ -253,7 +243,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
PCB_EDIT_FRAME::Process_Special_Functions ) PCB_EDIT_FRAME::Process_Special_Functions )
// User interface update event handlers. // User interface update event handlers.
EVT_UPDATE_UI( ID_SAVE_BOARD, PCB_EDIT_FRAME::OnUpdateSave )
EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::OnUpdateLayerPair ) EVT_UPDATE_UI( ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR, PCB_EDIT_FRAME::OnUpdateLayerPair )
EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::OnUpdateLayerSelectBox ) EVT_UPDATE_UI( ID_TOOLBARH_PCB_SELECT_LAYER, PCB_EDIT_FRAME::OnUpdateLayerSelectBox )
EVT_UPDATE_UI( ID_TB_OPTIONS_DRC_OFF, PCB_EDIT_FRAME::OnUpdateDrcEnable ) EVT_UPDATE_UI( ID_TB_OPTIONS_DRC_OFF, PCB_EDIT_FRAME::OnUpdateDrcEnable )
@ -487,8 +476,8 @@ void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() ); PCB_DRAW_PANEL_GAL* drawPanel = static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() );
// Prepare worksheet template // Prepare worksheet template
KIGFX::WS_VIEW_ITEM* worksheet; KIGFX::WS_PROXY_VIEW_ITEM* worksheet;
worksheet = new KIGFX::WS_VIEW_ITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(), worksheet = new KIGFX::WS_PROXY_VIEW_ITEM( IU_PER_MILS ,&m_Pcb->GetPageSettings(),
&m_Pcb->GetTitleBlock() ); &m_Pcb->GetTitleBlock() );
worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) ); worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) );
@ -571,12 +560,6 @@ void PCB_EDIT_FRAME::ReFillLayerWidget()
} }
void PCB_EDIT_FRAME::OnQuit( wxCommandEvent& event )
{
Close( false );
}
void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
m_canvas->SetAbortRequest( true ); m_canvas->SetAbortRequest( true );

View File

@ -300,8 +300,6 @@ public:
*/ */
void LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter ); void LoadFootprints( NETLIST& aNetlist, REPORTER& aReporter );
void OnQuit( wxCommandEvent& event );
/** /**
* Reload the Python plugins if they are newer than * Reload the Python plugins if they are newer than
* the already loaded, and load new plugins if any * the already loaded, and load new plugins if any

View File

@ -60,9 +60,7 @@ public:
#if defined(DEBUG) #if defined(DEBUG)
/// @copydoc EDA_ITEM::Show() /// @copydoc EDA_ITEM::Show()
void Show( int x, std::ostream& st ) const override void Show( int x, std::ostream& st ) const override { }
{
}
#endif #endif
/** Get class name /** Get class name

View File

@ -4,7 +4,7 @@
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -250,19 +250,19 @@ void PCB_EDIT_FRAME::ReCreateHToolbar()
// Set up toolbar // Set up toolbar
if( Kiface().IsSingle() ) if( Kiface().IsSingle() )
{ {
ADD_TOOL( ID_NEW_BOARD, new_board_xpm, _( "New board" ) ); m_mainToolBar->Add( ACTIONS::doNew );
ADD_TOOL( ID_LOAD_FILE, open_brd_file_xpm, _( "Open existing board" ) ); m_mainToolBar->Add( ACTIONS::open );
} }
ADD_TOOL( ID_SAVE_BOARD, save_xpm, _( "Save board" ) ); m_mainToolBar->Add( ACTIONS::save );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
ADD_TOOL( ID_BOARD_SETUP_DIALOG, options_board_xpm, _( "Board setup" ) ); ADD_TOOL( ID_BOARD_SETUP_DIALOG, options_board_xpm, _( "Board setup" ) );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
ADD_TOOL( ID_SHEET_SET, sheetset_xpm, _( "Page settings for paper size and texts" ) ); m_mainToolBar->Add( ACTIONS::pageSettings );
ADD_TOOL( wxID_PRINT, print_button_xpm, _( "Print board" ) ); m_mainToolBar->Add( ACTIONS::print );
ADD_TOOL( ID_GEN_PLOT, plot_xpm, _( "Plot (HPGL, PostScript, or GERBER format)" ) ); m_mainToolBar->Add( ACTIONS::plot );
KiScaledSeparator( m_mainToolBar, this ); KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->Add( ACTIONS::undo ); m_mainToolBar->Add( ACTIONS::undo );
@ -782,12 +782,6 @@ bool PCB_EDIT_FRAME::MicrowaveToolbarShown()
} }
void PCB_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( GetScreen()->IsModify() );
}
void PCB_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent ) void PCB_EDIT_FRAME::OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent )
{ {
if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar ) if( aEvent.GetEventObject() == m_drawToolBar || aEvent.GetEventObject() == m_mainToolBar )
@ -807,6 +801,7 @@ void PCB_EDIT_FRAME::SyncMenusAndToolbars()
KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions(); KIGFX::GAL_DISPLAY_OPTIONS& galOpts = GetGalDisplayOptions();
int zoneMode = opts->m_DisplayZonesMode; int zoneMode = opts->m_DisplayZonesMode;
m_mainToolBar->Toggle( ACTIONS::save, GetScreen() && GetScreen()->IsModify() );
m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::undo, GetScreen() && GetScreen()->GetUndoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 ); m_mainToolBar->Toggle( ACTIONS::redo, GetScreen() && GetScreen()->GetRedoCommandCount() > 0 );
m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION ); m_mainToolBar->Toggle( ACTIONS::zoomTool, GetToolId() == ID_ZOOM_SELECTION );

View File

@ -31,7 +31,7 @@
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/tool_event_utils.h> #include <tools/tool_event_utils.h>
#include <wx/progdlg.h> #include <wx/progdlg.h>
#include <ws_proxy_undo_item.h>
#include "edit_tool.h" #include "edit_tool.h"
#include "selection_tool.h" #include "selection_tool.h"
#include "drawing_tool.h" #include "drawing_tool.h"
@ -60,6 +60,7 @@
#include <profile.h> #include <profile.h>
#include <widgets/progress_reporter.h> #include <widgets/progress_reporter.h>
#include <dialogs/dialog_find.h> #include <dialogs/dialog_find.h>
#include <dialogs/dialog_page_settings.h>
using namespace std::placeholders; using namespace std::placeholders;
@ -357,6 +358,71 @@ bool PCB_EDITOR_CONTROL::Init()
} }
int PCB_EDITOR_CONTROL::New( const TOOL_EVENT& aEvent )
{
m_frame->Files_io_from_id( ID_NEW_BOARD );
return 0;
}
int PCB_EDITOR_CONTROL::Open( const TOOL_EVENT& aEvent )
{
m_frame->Files_io_from_id( ID_LOAD_FILE );
return 0;
}
int PCB_EDITOR_CONTROL::Save( const TOOL_EVENT& aEvent )
{
m_frame->Files_io_from_id( ID_SAVE_BOARD );
return 0;
}
int PCB_EDITOR_CONTROL::SaveAs( const TOOL_EVENT& aEvent )
{
m_frame->Files_io_from_id( ID_SAVE_BOARD_AS );
return 0;
}
int PCB_EDITOR_CONTROL::SaveCopyAs( const TOOL_EVENT& aEvent )
{
m_frame->Files_io_from_id( ID_COPY_BOARD_AS );
return 0;
}
int PCB_EDITOR_CONTROL::PageSettings( const TOOL_EVENT& aEvent )
{
PICKED_ITEMS_LIST undoCmd;
WS_PROXY_UNDO_ITEM* undoItem = new WS_PROXY_UNDO_ITEM( m_frame );
ITEM_PICKER wrapper( undoItem, UR_PAGESETTINGS );
undoCmd.PushItem( wrapper );
m_frame->SaveCopyInUndoList( undoCmd, UR_PAGESETTINGS );
DIALOG_PAGES_SETTINGS dlg( m_frame, wxSize( MAX_PAGE_SIZE_PCBNEW_MILS,
MAX_PAGE_SIZE_PCBNEW_MILS ) );
dlg.SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName );
if( dlg.ShowModal() == wxID_OK )
m_toolMgr->RunAction( ACTIONS::zoomFitScreen );
else
m_frame->RollbackFromUndo();
return 0;
}
int PCB_EDITOR_CONTROL::Plot( const TOOL_EVENT& aEvent )
{
wxCommandEvent evt( wxEVT_NULL, ID_GEN_PLOT );
m_frame->ToPlotter( evt );
return 0;
}
int PCB_EDITOR_CONTROL::Find( const TOOL_EVENT& aEvent ) int PCB_EDITOR_CONTROL::Find( const TOOL_EVENT& aEvent )
{ {
DIALOG_FIND dlg( m_frame ); DIALOG_FIND dlg( m_frame );
@ -1279,6 +1345,14 @@ void PCB_EDITOR_CONTROL::calculateSelectionRatsnest()
void PCB_EDITOR_CONTROL::setTransitions() void PCB_EDITOR_CONTROL::setTransitions()
{ {
Go( &PCB_EDITOR_CONTROL::New, ACTIONS::doNew.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::Open, ACTIONS::open.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::Save, ACTIONS::save.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::SaveAs, ACTIONS::saveAs.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::SaveCopyAs, ACTIONS::saveCopyAs.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::PageSettings, ACTIONS::pageSettings.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::Plot, ACTIONS::plot.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::Find, ACTIONS::find.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::Find, ACTIONS::find.MakeEvent() );
// Track & via size control // Track & via size control

View File

@ -51,6 +51,14 @@ public:
/// @copydoc TOOL_INTERACTIVE::Init() /// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override; bool Init() override;
int New( const TOOL_EVENT& aEvent );
int Open( const TOOL_EVENT& aEvent );
int Save( const TOOL_EVENT& aEvent );
int SaveAs( const TOOL_EVENT& aEvent );
int SaveCopyAs( const TOOL_EVENT& aEvent );
int PageSettings( const TOOL_EVENT& aEvent );
int Plot( const TOOL_EVENT& aEvent );
int Find( const TOOL_EVENT& aEvent ); int Find( const TOOL_EVENT& aEvent );
// Track & via size control // Track & via size control

View File

@ -240,6 +240,14 @@ void PCBNEW_CONTROL::Reset( RESET_REASON aReason )
} }
} }
int PCBNEW_CONTROL::Quit( const TOOL_EVENT& aEvent )
{
m_frame->Close( false );
return 0;
}
template<class T> void Flip( T& aValue ) template<class T> void Flip( T& aValue )
{ {
aValue = !aValue; aValue = !aValue;
@ -1006,6 +1014,9 @@ void PCBNEW_CONTROL::updateGrid()
void PCBNEW_CONTROL::setTransitions() void PCBNEW_CONTROL::setTransitions()
{ {
Go( &PCBNEW_CONTROL::Print, ACTIONS::print.MakeEvent() );
Go( &PCBNEW_CONTROL::Quit, ACTIONS::quit.MakeEvent() );
// Display modes // Display modes
Go( &PCBNEW_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() ); Go( &PCBNEW_CONTROL::TrackDisplayMode, PCB_ACTIONS::trackDisplayMode.MakeEvent() );
Go( &PCBNEW_CONTROL::ToggleRatsnest, PCB_ACTIONS::showRatsnest.MakeEvent() ); Go( &PCBNEW_CONTROL::ToggleRatsnest, PCB_ACTIONS::showRatsnest.MakeEvent() );

View File

@ -50,6 +50,9 @@ public:
/// @copydoc TOOL_INTERACTIVE::Reset() /// @copydoc TOOL_INTERACTIVE::Reset()
void Reset( RESET_REASON aReason ) override; void Reset( RESET_REASON aReason ) override;
int Print( const TOOL_EVENT& aEvent );
int Quit( const TOOL_EVENT& aEvent );
// Display modes // Display modes
int ToggleRatsnest( const TOOL_EVENT& aEvent ); int ToggleRatsnest( const TOOL_EVENT& aEvent );
int ZoneDisplayMode( const TOOL_EVENT& aEvent ); int ZoneDisplayMode( const TOOL_EVENT& aEvent );

View File

@ -34,7 +34,6 @@ using namespace std::placeholders;
#include <pcbnew.h> #include <pcbnew.h>
#include <pcb_edit_frame.h> #include <pcb_edit_frame.h>
#include <class_board.h> #include <class_board.h>
#include <class_track.h> #include <class_track.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
@ -45,15 +44,14 @@ using namespace std::placeholders;
#include <class_zone.h> #include <class_zone.h>
#include <class_edge_mod.h> #include <class_edge_mod.h>
#include <origin_viewitem.h> #include <origin_viewitem.h>
#include <connectivity/connectivity_data.h> #include <connectivity/connectivity_data.h>
#include <tool/tool_manager.h>
#include <tool/actions.h>
#include <tools/selection_tool.h> #include <tools/selection_tool.h>
#include <tools/pcbnew_control.h> #include <tools/pcbnew_control.h>
#include <tools/pcb_editor_control.h> #include <tools/pcb_editor_control.h>
#include <tool/tool_manager.h>
#include <view/view.h> #include <view/view.h>
#include <ws_proxy_undo_item.h>
/* Functions to undo and redo edit commands. /* Functions to undo and redo edit commands.
* commands to undo are stored in CurrentScreen->m_UndoList * commands to undo are stored in CurrentScreen->m_UndoList
@ -208,6 +206,8 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis
UNDO_REDO_T aTypeCommand, UNDO_REDO_T aTypeCommand,
const wxPoint& aTransformPoint ) const wxPoint& aTransformPoint )
{ {
static KICAD_T moduleChildren[] = { PCB_MODULE_TEXT_T, PCB_MODULE_EDGE_T, PCB_PAD_T, EOT };
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint; commandToUndo->m_TransformPoint = aTransformPoint;
@ -218,11 +218,10 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ ) for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
{ {
ITEM_PICKER curr_picker = aItemsList.GetItemWrapper(ii); ITEM_PICKER curr_picker = aItemsList.GetItemWrapper(ii);
BOARD_ITEM* item = (BOARD_ITEM*) aItemsList.GetPickedItem( ii ); BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItemsList.GetPickedItem( ii ) );
// For items belonging to modules, we need to save state of the parent module // For items belonging to modules, we need to save state of the parent module
if( item->Type() == PCB_MODULE_TEXT_T || item->Type() == PCB_MODULE_EDGE_T if( item && item->IsType( moduleChildren ) )
|| item->Type() == PCB_PAD_T )
{ {
// Item to be stored in the undo buffer is the parent module // Item to be stored in the undo buffer is the parent module
item = item->GetParent(); item = item->GetParent();
@ -281,7 +280,7 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ ) for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
{ {
BOARD_ITEM* item = (BOARD_ITEM*) commandToUndo->GetPickedItem( ii ); EDA_ITEM* item = aItemsList.GetPickedItem( ii );
UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii ); UNDO_REDO_T command = commandToUndo->GetPickedItemStatus( ii );
if( command == UR_UNSPECIFIED ) if( command == UR_UNSPECIFIED )
@ -315,6 +314,7 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis
case UR_FLIPPED: case UR_FLIPPED:
case UR_NEW: case UR_NEW:
case UR_DELETED: case UR_DELETED:
case UR_PAGESETTINGS:
break; break;
default: default:
@ -420,8 +420,7 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
// Restore changes in reverse order // Restore changes in reverse order
for( int ii = aList->GetCount() - 1; ii >= 0 ; ii-- ) for( int ii = aList->GetCount() - 1; ii >= 0 ; ii-- )
{ {
item = (BOARD_ITEM*) aList->GetPickedItem( ii ); EDA_ITEM* eda_item = aList->GetPickedItem( (unsigned) ii );
wxASSERT( item );
/* Test for existence of item on board. /* Test for existence of item on board.
* It could be deleted, and no more on board: * It could be deleted, and no more on board:
@ -434,7 +433,8 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
if( status != UR_DELETED if( status != UR_DELETED
&& status != UR_DRILLORIGIN // origin markers never on board && status != UR_DRILLORIGIN // origin markers never on board
&& status != UR_GRIDORIGIN ) // origin markers never on board && status != UR_GRIDORIGIN // origin markers never on board
&& status != UR_PAGESETTINGS ) // nor are page settings proxy items
{ {
if( build_item_list ) if( build_item_list )
// Build list of existing items, for integrity test // Build list of existing items, for integrity test
@ -551,12 +551,21 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
} }
break; break;
default: case UR_PAGESETTINGS:
{ {
wxLogDebug( wxT( "PutDataInPreviousState() error (unknown code %X)" ), // swap current settings with stored settings
aList->GetPickedItemStatus( ii ) ); WS_PROXY_UNDO_ITEM alt_item( this );
WS_PROXY_UNDO_ITEM* item = (WS_PROXY_UNDO_ITEM*) eda_item;
item->Restore( this );
*item = alt_item;
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
} }
break; break;
default:
wxLogDebug( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
aList->GetPickedItemStatus( ii ) );
break;
} }
} }
@ -601,3 +610,15 @@ void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount
delete curr_cmd; // Delete command delete curr_cmd; // Delete command
} }
} }
void PCB_BASE_EDIT_FRAME::RollbackFromUndo()
{
PICKED_ITEMS_LIST* undo = GetScreen()->PopCommandFromUndoList();
PutDataInPreviousState( undo, false );
undo->ClearListAndDeleteItems();
delete undo;
GetCanvas()->Refresh();
}