diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index 3b72d17314..f4ca29a804 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-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 @@ -65,13 +65,6 @@ static const wxChar EnableSvgImport[] = wxT( "EnableSvgImport" ); */ static const wxChar RealtimeConnectivity[] = wxT( "RealtimeConnectivity" ); -/** - * Allow legacy canvas to be shown in GTK3. Legacy canvas is generally pretty - * broken, but this avoids code in an ifdef where it could become broken - * on other platforms - */ -static const wxChar AllowLegacyCanvasInGtk3[] = wxT( "AllowLegacyCanvasInGtk3" ); - } // namespace KEYS @@ -150,7 +143,6 @@ ADVANCED_CFG::ADVANCED_CFG() // Init defaults - this is done in case the config doesn't exist, // then the values will remain as set here. m_enableSvgImport = false; - m_allowLegacyCanvasInGtk3 = false; m_realTimeConnectivity = true; loadFromConfigFile(); @@ -188,9 +180,6 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::EnableSvgImport, &m_enableSvgImport, false ) ); - configParams.push_back( new PARAM_CFG_BOOL( - true, AC_KEYS::AllowLegacyCanvasInGtk3, &m_allowLegacyCanvasInGtk3, false ) ); - configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::RealtimeConnectivity, &m_realTimeConnectivity, false ) ); @@ -200,15 +189,3 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) } -bool ADVANCED_CFG::AllowLegacyCanvas() const -{ - // default is to allow - bool allow = true; - - // on GTK3, check the config -#ifdef __WXGTK3__ - allow = m_allowLegacyCanvasInGtk3; -#endif - - return allow; -} diff --git a/common/origin_viewitem.cpp b/common/origin_viewitem.cpp index bf9430140d..ad56aacaea 100644 --- a/common/origin_viewitem.cpp +++ b/common/origin_viewitem.cpp @@ -59,8 +59,8 @@ const BOX2I ORIGIN_VIEWITEM::ViewBBox() const void ORIGIN_VIEWITEM::ViewDraw( int, VIEW* aView ) const { auto gal = aView->GetGAL(); - // Nothing to do if the target shouldn't be drawn at 0,0 and that's where the target is. This - // mimics the Legacy canvas that doesn't display most targets at 0,0 + + // Nothing to do if the target shouldn't be drawn at 0,0 and that's where the target is. if( !m_drawAtZero && ( m_position.x == 0 ) && ( m_position.y == 0 ) ) return; diff --git a/cvpcb/tools/cvpcb_control.h b/cvpcb/tools/cvpcb_control.h index ec72b2440a..617c450f3b 100644 --- a/cvpcb/tools/cvpcb_control.h +++ b/cvpcb/tools/cvpcb_control.h @@ -62,9 +62,6 @@ private: ///> Grid origin marker. std::unique_ptr m_gridOrigin; - ///> Applies the legacy canvas grid settings for GAL. - void updateGrid(); - KIGFX::VIEW* view() { return m_frame->GetGalCanvas()->GetView(); diff --git a/gerbview/dcode.cpp b/gerbview/dcode.cpp index c7c8e71d16..dbf63e32c2 100644 --- a/gerbview/dcode.cpp +++ b/gerbview/dcode.cpp @@ -452,7 +452,4 @@ static void addHoleToPolygon( SHAPE_POLY_SET* aPolygon, } aPolygon->BooleanSubtract( holeBuffer, SHAPE_POLY_SET::PM_FAST ); - - // Needed for legacy canvas only - aPolygon->Fracture( SHAPE_POLY_SET::PM_FAST ); } diff --git a/include/advanced_config.h b/include/advanced_config.h index 86c532a31e..39c4e47fd9 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -78,21 +78,6 @@ public: */ bool m_realTimeConnectivity; - /** - * Helper to determine if legacy canvas is allowed (according to platform - * and config) - * @return true if legacy canvas should be shown - */ - bool AllowLegacyCanvas() const; - -private: - /* - * These settings are private, as there is extra logic provide by helper - * functions above. - */ - - bool m_allowLegacyCanvasInGtk3; - private: ADVANCED_CFG(); diff --git a/include/basic_gal.h b/include/basic_gal.h index c6fda6841d..11463bfe6d 100644 --- a/include/basic_gal.h +++ b/include/basic_gal.h @@ -42,8 +42,8 @@ class PLOTTER; * (using wxDC functions) in plot functions only for texts. * It is used also to calculate the text bounding boxes * - * The main purpose is to avoid duplicate code to do the same thing in GAL canvas - * legacy canvas, plotter canvas and DRC. + * The main purpose is to avoid duplicate code to do the same thing in GAL canvas, + * print & plotter canvasses and DRC. * * It will be certainly removed when a full GAL canvas using wxDC is implemented * (or at least restricted to plotter and DRC "canvas") diff --git a/pcbnew/array_creator.cpp b/pcbnew/array_creator.cpp index c7cfb27be4..0450a91dcd 100644 --- a/pcbnew/array_creator.cpp +++ b/pcbnew/array_creator.cpp @@ -22,10 +22,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file array_creator.cpp - */ - #include "array_creator.h" #include @@ -52,17 +48,14 @@ static void TransformItem( const ARRAY_OPTIONS& aArrOpts, int aIndex, BOARD_ITEM void ARRAY_CREATOR::Invoke() { - const int numItems = getNumberOfItemsToArray(); - // bail out if no items - if( numItems == 0 ) + if( m_selection.Size() == 0 ) return; - MODULE* const module = getModule(); - const bool isModuleEditor = module != NULL; + MODULE* const module = m_editModules ? m_parent.GetBoard()->m_Modules.GetFirst() : nullptr; - const bool enableArrayNumbering = isModuleEditor; - const wxPoint rotPoint = getRotationCentre(); + const bool enableArrayNumbering = m_editModules; + const wxPoint rotPoint = (wxPoint) m_selection.GetCenter(); std::unique_ptr array_opts; @@ -77,11 +70,11 @@ void ARRAY_CREATOR::Invoke() ARRAY_PAD_NAME_PROVIDER pad_name_provider( module, *array_opts ); - for ( int i = 0; i < numItems; ++i ) + for ( int i = 0; i < m_selection.Size(); ++i ) { - BOARD_ITEM* item = getNthItemToArray( i ); + BOARD_ITEM* item = static_cast( m_selection[ i ] ); - if( item->Type() == PCB_PAD_T && !isModuleEditor ) + if( item->Type() == PCB_PAD_T && !m_editModules ) { // If it is not the module editor, then duplicate the parent module instead item = static_cast( item )->GetParent(); @@ -103,7 +96,7 @@ void ARRAY_CREATOR::Invoke() // Need to create a new item std::unique_ptr new_item; - if( isModuleEditor ) + if( m_editModules ) { // Don't bother incrementing pads: the module won't update // until commit, so we can only do this once @@ -111,7 +104,7 @@ void ARRAY_CREATOR::Invoke() } else { - new_item.reset( getBoard()->Duplicate( item ) ); + new_item.reset( m_parent.GetBoard()->Duplicate( item ) ); // PCB items keep the same numbering @@ -129,9 +122,19 @@ void ARRAY_CREATOR::Invoke() if( new_item ) { - prePushAction( this_item ); + // Because aItem is/can be created from a selected item, and inherits from + // it this state, reset the selected stated of aItem: + this_item->ClearSelected(); + + if( this_item->Type() == PCB_MODULE_T ) + { + static_cast( this_item )->RunOnChildren( [&] ( BOARD_ITEM* item ) + { + item->ClearSelected(); + }); + } + commit.Add( new_item.release() ); - postPushAction( this_item ); } } @@ -163,5 +166,4 @@ void ARRAY_CREATOR::Invoke() } commit.Push( _( "Create an array" ) ); - finalise(); } diff --git a/pcbnew/array_creator.h b/pcbnew/array_creator.h index c02539b2c3..399a57a1ff 100644 --- a/pcbnew/array_creator.h +++ b/pcbnew/array_creator.h @@ -22,93 +22,40 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/** - * @file array_creator.h - */ - -#ifndef PCBNEW_ARRAY_CREATOR_H_ -#define PCBNEW_ARRAY_CREATOR_H_ +#ifndef ARRAY_CREATOR_H_ +#define ARRAY_CREATOR_H_ #include #include #include #include +#include /*! * Class that performs array creation by producing a dialog to gather * parameters and then creating and laying out the items. - * - * This is a template class which needs to be implemented by the relevant - * edit tooling, since the details of how the document is manipulated - * varies between edit modes (e.g. legacy or GAL) */ class ARRAY_CREATOR { public: - ARRAY_CREATOR(PCB_BASE_FRAME& parent): - m_parent( parent ) + ARRAY_CREATOR( PCB_BASE_FRAME& aParent, bool editModules, const SELECTION& aSelection ) : + m_parent( aParent ), + m_editModules( editModules ), + m_selection( aSelection ) {} + virtual ~ARRAY_CREATOR() {} + /*! * Open the dialog, gather parameters and create the array */ void Invoke(); -protected: - virtual ~ARRAY_CREATOR() {} - - PCB_BASE_FRAME& m_parent; - private: - - /*! - * Get the BOARD that is currently being edited. - */ - virtual BOARD* getBoard() const = 0; - - /*! - * If editing a footprint, returns the relevant MODULE, else NULL - */ - virtual MODULE* getModule() const = 0; - - /*! - * @return number of original items to put into an array (eg size of the - * selection) - */ - virtual int getNumberOfItemsToArray() const = 0; - - /*! - * @return the n'th original item to be arrayed - */ - virtual BOARD_ITEM* getNthItemToArray( int n ) const = 0; - - /*! - * @return the rotation centre of all the items to be arrayed, when taken - * together - */ - virtual wxPoint getRotationCentre() const = 0; - - /*! - * Perform any relevant action before pushing a newly created array item - * to the BOARD - */ - virtual void prePushAction( BOARD_ITEM* new_item ) - {} - - /*! - * Perform any actions needed after pushing an item to the BOARD - */ - virtual void postPushAction( BOARD_ITEM* new_item ) - {} - - /*! - * Actions to perform after the array process is complete - */ - virtual void finalise() = 0; + PCB_BASE_FRAME& m_parent; + bool m_editModules; + const SELECTION& m_selection; }; - - - -#endif /* PCBNEW_ARRAY_CREATOR_H_ */ +#endif /* ARRAY_CREATOR_H_ */ diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index cee77099e7..08c07d4fc7 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1131,77 +1131,6 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) } -class GAL_ARRAY_CREATOR: public ARRAY_CREATOR -{ -public: - - GAL_ARRAY_CREATOR( PCB_BASE_FRAME& editFrame, bool editModules, - const SELECTION& selection ): - ARRAY_CREATOR( editFrame ), - m_editModules( editModules ), - m_selection( selection ) - {} - -private: - - int getNumberOfItemsToArray() const override - { - // only handle single items - return m_selection.Size(); - } - - BOARD_ITEM* getNthItemToArray( int n ) const override - { - return static_cast( m_selection[n] ); - } - - BOARD* getBoard() const override - { - return m_parent.GetBoard(); - } - - MODULE* getModule() const override - { - // Remember this is valid and used only in the module editor. - // in board editor, the parent of items is usually the board. - return m_editModules ? m_parent.GetBoard()->m_Modules.GetFirst() : NULL; - } - - wxPoint getRotationCentre() const override - { - const VECTOR2I rp = m_selection.GetCenter(); - return wxPoint( rp.x, rp.y ); - } - - void prePushAction( BOARD_ITEM* aItem ) override - { - // Because aItem is/can be created from a selected item, and inherits from - // it this state, reset the selected stated of aItem: - aItem->ClearSelected(); - - if( aItem->Type() == PCB_MODULE_T ) - { - static_cast( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item ) - { - item->ClearSelected(); - } - ); - } - } - - void postPushAction( BOARD_ITEM* new_item ) override - { - } - - void finalise() override - { - } - - bool m_editModules; - const SELECTION& m_selection; -}; - - int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) { const auto& selection = m_selectionTool->RequestSelection( @@ -1213,7 +1142,7 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) // we have a selection to work on now, so start the tool process PCB_BASE_FRAME* editFrame = getEditFrame(); - GAL_ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection ); + ARRAY_CREATOR array_creator( *editFrame, m_editModules, selection ); array_creator.Invoke(); return 0;