kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #31182
Re: [FEATURE] Add keepout areas in footprints
Le 19/10/2017 à 12:55, Maciej Sumiński a écrit :
> On 10/19/2017 11:31 AM, jp charras wrote:
>> Le 18/10/2017 à 16:57, Oliver Walters a écrit :
>>> JP,
>>>
>>> Fantastic, you have worked your magic! That works much better in pcbnew now, the undo/redo is
>>> working well.
>>>
>>> However, I still see that undo/redo for zone editing is broken in modedit.
>>>
>>> Oliver
>>>
>>
>> Yes, because when an item belonging a footprint is modified, the footprint itself must be stored in
>> undo/redo stack.
>>
>> In other words:
>> commit.Modify( zone );
>> works only for a zone belonging the board.
>>
>> for a zone belonging a footprint,
>> commit.Modify( footprint);
>> must be used.
>>
>> So, verify the zones added to a footprint has this footprint as parent,
>> and save the parent if a zone has a parent MODULE.
>
> I have not checked it yet, but I suppose it should be possible to modify
> the BOARD_COMMIT class to automagically create a copy of a whole
> footprint when used in the footprint editor. This would allow us to
> write more generic code and remove the confusion.
>
> Regards,
> Orson
Hi Orson,
Could you have a look into this patch?
It fixes the issue when a change is committed with a item belonging a footprint.
But I do not have very good knowledge of COMMIT classes.
--
Jean-Pierre CHARRAS
include/commit.h | 6 +++---
pcbnew/board_commit.cpp | 28 ++++++++++++++++++++++++++++
pcbnew/board_commit.h | 4 ++++
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/include/commit.h b/include/commit.h
index d883bba..f2a436a 100644
--- a/include/commit.h
+++ b/include/commit.h
@@ -123,11 +123,11 @@ public:
///> Adds a change of the item aItem of type aChangeType to the change list.
- COMMIT& Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType );
+ virtual COMMIT& Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType );
- COMMIT& Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType );
+ virtual COMMIT& Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType );
- COMMIT& Stage( const PICKED_ITEMS_LIST& aItems, UNDO_REDO_T aModFlag = UR_UNSPECIFIED );
+ virtual COMMIT& Stage( const PICKED_ITEMS_LIST& aItems, UNDO_REDO_T aModFlag = UR_UNSPECIFIED );
///> Executes the changes.
virtual void Push( const wxString& aMessage = wxT( "A commit" ), bool aCreateUndoEntry = true ) = 0;
diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp
index df2a192..0e40700 100644
--- a/pcbnew/board_commit.cpp
+++ b/pcbnew/board_commit.cpp
@@ -56,6 +56,34 @@ BOARD_COMMIT::~BOARD_COMMIT()
}
+COMMIT& BOARD_COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType )
+{
+ // if aItem belongs a footprint, the full footprint will be saved
+ if( aItem && aItem->Type() != PCB_MODULE_T )
+ {
+ EDA_ITEM* item = aItem->GetParent();
+
+ item = dynamic_cast<MODULE*>( item );
+
+ if( item ) // means aItem belongs a footprint
+ aItem = item;
+ }
+
+ return COMMIT::Stage( aItem, aChangeType );
+}
+
+
+COMMIT& BOARD_COMMIT::Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType )
+{
+ return COMMIT::Stage( container, aChangeType );
+}
+
+COMMIT& BOARD_COMMIT::Stage( const PICKED_ITEMS_LIST& aItems, UNDO_REDO_T aModFlag )
+{
+ return COMMIT::Stage( aItems, aModFlag );
+}
+
+
void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry )
{
// Objects potentially interested in changes:
diff --git a/pcbnew/board_commit.h b/pcbnew/board_commit.h
index 197bbfb..ab78a7f 100644
--- a/pcbnew/board_commit.h
+++ b/pcbnew/board_commit.h
@@ -43,6 +43,10 @@ public:
virtual void Push( const wxString& aMessage = wxT( "A commit" ), bool aCreateUndoEntry = true ) override;
virtual void Revert() override;
+ virtual COMMIT& Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType ) override;
+ virtual COMMIT& Stage( std::vector<EDA_ITEM*>& container, CHANGE_TYPE aChangeType ) override;
+ virtual COMMIT& Stage( const PICKED_ITEMS_LIST& aItems, UNDO_REDO_T aModFlag = UR_UNSPECIFIED ) override;
+
private:
TOOL_MANAGER* m_toolMgr;
bool m_editModules;
Follow ups
References