Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
bced8c97
Commit
bced8c97
authored
Dec 13, 2011
by
Guillaume Simard
Committed by
Wayne Stambaugh
Dec 13, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add undo/redo support for Pcbnew auto place, auto move, and auto route features.
parent
b2c11207
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
automove.cpp
pcbnew/automove.cpp
+18
-0
autoplac.cpp
pcbnew/autoplac.cpp
+35
-0
solve.cpp
pcbnew/solve.cpp
+10
-0
No files found.
pcbnew/automove.cpp
View file @
bced8c97
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "class_board.h"
#include "class_board.h"
#include "class_module.h"
#include "class_module.h"
extern
BOARD_ITEM
*
DuplicateStruct
(
BOARD_ITEM
*
aItem
);
typedef
enum
{
typedef
enum
{
FIXE_MODULE
,
FIXE_MODULE
,
...
@@ -184,6 +185,11 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
...
@@ -184,6 +185,11 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
int
pas_grille
=
(
int
)
GetScreen
()
->
GetGridSize
().
x
;
int
pas_grille
=
(
int
)
GetScreen
()
->
GetGridSize
().
x
;
double
surface
;
double
surface
;
// Undo: init list
PICKED_ITEMS_LIST
newList
;
newList
.
m_Status
=
UR_CHANGED
;
ITEM_PICKER
picker
(
NULL
,
UR_CHANGED
);
if
(
GetBoard
()
->
m_Modules
==
NULL
)
if
(
GetBoard
()
->
m_Modules
==
NULL
)
{
{
DisplayError
(
this
,
_
(
"No modules found!"
)
);
DisplayError
(
this
,
_
(
"No modules found!"
)
);
...
@@ -264,6 +270,10 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
...
@@ -264,6 +270,10 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
continue
;
continue
;
}
}
// Undo: add copy of old Module to undo
picker
.
m_Link
=
DuplicateStruct
(
Module
);
picker
.
m_PickedItemType
=
Module
->
Type
();
if
(
current
.
x
>
(
Xsize_allowed
+
start
.
x
)
)
if
(
current
.
x
>
(
Xsize_allowed
+
start
.
x
)
)
{
{
current
.
x
=
start
.
x
;
current
.
x
=
start
.
x
;
...
@@ -278,9 +288,17 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
...
@@ -278,9 +288,17 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb )
PlaceModule
(
Module
,
NULL
,
true
);
PlaceModule
(
Module
,
NULL
,
true
);
// Undo: add new Module to undo
picker
.
m_PickedItem
=
Module
;
newList
.
PushItem
(
picker
);
current
.
x
+=
Module
->
m_BoundaryBox
.
GetWidth
()
+
pas_grille
;
current
.
x
+=
Module
->
m_BoundaryBox
.
GetWidth
()
+
pas_grille
;
}
}
// Undo: commit
if
(
newList
.
GetCount
()
)
SaveCopyInUndoList
(
newList
,
UR_CHANGED
);
DrawPanel
->
Refresh
();
DrawPanel
->
Refresh
();
}
}
...
...
pcbnew/autoplac.cpp
View file @
bced8c97
...
@@ -109,6 +109,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
...
@@ -109,6 +109,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
float
Pas
;
float
Pas
;
int
lay_tmp_TOP
,
lay_tmp_BOTTOM
;
int
lay_tmp_TOP
,
lay_tmp_BOTTOM
;
// Undo: init list
PICKED_ITEMS_LIST
newList
;
newList
.
m_Status
=
UR_CHANGED
;
ITEM_PICKER
picker
(
NULL
,
UR_CHANGED
);
if
(
GetBoard
()
->
m_Modules
==
NULL
)
if
(
GetBoard
()
->
m_Modules
==
NULL
)
return
;
return
;
...
@@ -175,7 +180,14 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
...
@@ -175,7 +180,14 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
{
{
case
PLACE_1_MODULE
:
case
PLACE_1_MODULE
:
if
(
ThisModule
==
Module
)
if
(
ThisModule
==
Module
)
{
// Module will be placed, add to undo.
picker
.
m_PickedItem
=
ThisModule
;
picker
.
m_PickedItemType
=
ThisModule
->
Type
();
newList
.
PushItem
(
picker
);
Module
->
m_ModuleStatus
|=
MODULE_to_PLACE
;
Module
->
m_ModuleStatus
|=
MODULE_to_PLACE
;
}
break
;
break
;
...
@@ -186,7 +198,14 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
...
@@ -186,7 +198,14 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
break
;
break
;
if
(
!
bbbox
.
Contains
(
Module
->
m_Pos
)
)
if
(
!
bbbox
.
Contains
(
Module
->
m_Pos
)
)
{
// Module will be placed, add to undo.
picker
.
m_PickedItem
=
Module
;
picker
.
m_PickedItemType
=
Module
->
Type
();
newList
.
PushItem
(
picker
);
Module
->
m_ModuleStatus
|=
MODULE_to_PLACE
;
Module
->
m_ModuleStatus
|=
MODULE_to_PLACE
;
}
break
;
break
;
...
@@ -196,6 +215,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
...
@@ -196,6 +215,11 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
if
(
Module
->
m_ModuleStatus
&
MODULE_is_LOCKED
)
if
(
Module
->
m_ModuleStatus
&
MODULE_is_LOCKED
)
break
;
break
;
// Module will be placed, add to undo.
picker
.
m_PickedItem
=
Module
;
picker
.
m_PickedItemType
=
Module
->
Type
();
newList
.
PushItem
(
picker
);
Module
->
m_ModuleStatus
|=
MODULE_to_PLACE
;
Module
->
m_ModuleStatus
|=
MODULE_to_PLACE
;
break
;
break
;
...
@@ -207,7 +231,14 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
...
@@ -207,7 +231,14 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
}
}
if
(
!
(
Module
->
m_ModuleStatus
&
MODULE_is_PLACED
)
)
if
(
!
(
Module
->
m_ModuleStatus
&
MODULE_is_PLACED
)
)
{
// Module will be placed, add to undo.
picker
.
m_PickedItem
=
Module
;
picker
.
m_PickedItemType
=
Module
->
Type
();
newList
.
PushItem
(
picker
);
Module
->
m_ModuleStatus
|=
MODULE_to_PLACE
;
Module
->
m_ModuleStatus
|=
MODULE_to_PLACE
;
}
break
;
break
;
}
}
...
@@ -224,6 +255,10 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
...
@@ -224,6 +255,10 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC )
}
}
}
}
// Undo: commit
if
(
newList
.
GetCount
()
)
SaveCopyInUndoList
(
newList
,
UR_CHANGED
);
activ
=
0
;
activ
=
0
;
Pas
=
100.0
;
Pas
=
100.0
;
...
...
pcbnew/solve.cpp
View file @
bced8c97
...
@@ -79,6 +79,8 @@ static RATSNEST_ITEM* pt_cur_ch;
...
@@ -79,6 +79,8 @@ static RATSNEST_ITEM* pt_cur_ch;
static
int
Ncurrent
;
/* measures of progress */
static
int
Ncurrent
;
/* measures of progress */
static
int
s_Clearance
;
// Clearance value used in autorouter
static
int
s_Clearance
;
// Clearance value used in autorouter
static
PICKED_ITEMS_LIST
s_ItemsListPicker
;
#define NOSUCCESS 0
#define NOSUCCESS 0
#define STOP_FROM_ESC -1
#define STOP_FROM_ESC -1
...
@@ -272,6 +274,9 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
...
@@ -272,6 +274,9 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
Ncurrent
=
0
;
Ncurrent
=
0
;
// Prepare the undo command info
s_ItemsListPicker
.
ClearListAndDeleteItems
();
// Should not be necessary, but...
/* go until no more work to do */
/* go until no more work to do */
GetWork
(
&
row_source
,
&
col_source
,
&
current_net_code
,
GetWork
(
&
row_source
,
&
col_source
,
&
current_net_code
,
&
row_target
,
&
col_target
,
&
pt_cur_ch
);
// First net to route.
&
row_target
,
&
col_target
,
&
pt_cur_ch
);
// First net to route.
...
@@ -375,6 +380,9 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
...
@@ -375,6 +380,9 @@ int PCB_EDIT_FRAME::Solve( wxDC* DC, int two_sides )
DrawPanel
->
m_AbortEnable
=
false
;
DrawPanel
->
m_AbortEnable
=
false
;
SaveCopyInUndoList
(
s_ItemsListPicker
,
UR_UNSPECIFIED
);
s_ItemsListPicker
.
ClearItemsList
();
// s_ItemsListPicker is no more owner of picked items
return
SUCCESS
;
return
SUCCESS
;
}
}
...
@@ -1323,6 +1331,8 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
...
@@ -1323,6 +1331,8 @@ static void AddNewTrace( PCB_EDIT_FRAME* pcbframe, wxDC* DC )
while
(
(
track
=
g_CurrentTrackList
.
PopFront
()
)
!=
NULL
)
while
(
(
track
=
g_CurrentTrackList
.
PopFront
()
)
!=
NULL
)
{
{
ITEM_PICKER
picker
(
track
,
UR_NEW
);
s_ItemsListPicker
.
PushItem
(
picker
);
pcbframe
->
GetBoard
()
->
m_Track
.
Insert
(
track
,
insertBeforeMe
);
pcbframe
->
GetBoard
()
->
m_Track
.
Insert
(
track
,
insertBeforeMe
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment