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
8f054a60
Commit
8f054a60
authored
Jan 07, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed snapping and ratsnest update for EDIT_TOOL.
parent
84412ce1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
3 deletions
+49
-3
edit_tool.cpp
pcbnew/tools/edit_tool.cpp
+47
-3
edit_tool.h
pcbnew/tools/edit_tool.h
+2
-0
No files found.
pcbnew/tools/edit_tool.cpp
View file @
8f054a60
...
...
@@ -28,8 +28,10 @@
#include <wxPcbStruct.h>
#include <tool/tool_manager.h>
#include <view/view_controls.h>
#include <ratsnest_data.h>
#include <confirm.h>
#include <cassert>
#include <boost/foreach.hpp>
#include "common_actions.h"
#include "selection_tool.h"
...
...
@@ -88,6 +90,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
controls
->
ShowCursor
(
true
);
controls
->
SetSnapping
(
true
);
controls
->
SetAutoPan
(
true
);
controls
->
ForceCursorPosition
(
false
);
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
...
...
@@ -115,6 +118,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
else
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
remove
)
)
{
Remove
(
aEvent
);
break
;
}
}
...
...
@@ -124,12 +128,15 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
if
(
m_dragging
)
{
// Drag items to the current cursor position
VECTOR2D
movement
=
(
evt
->
Position
()
-
dragPosition
);
VECTOR2D
movement
=
(
getView
()
->
ToWorld
(
controls
->
GetCursorPosition
()
)
-
dragPosition
);
for
(
unsigned
int
i
=
0
;
i
<
selection
.
items
.
GetCount
();
++
i
)
{
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
selection
.
items
.
GetPickedItem
(
i
)
);
item
->
Move
(
wxPoint
(
movement
.
x
,
movement
.
y
)
);
}
updateRatsnest
(
true
);
}
else
{
...
...
@@ -141,7 +148,7 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
}
selection
.
group
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
dragPosition
=
evt
->
Position
(
);
dragPosition
=
getView
()
->
ToWorld
(
controls
->
GetCursorPosition
()
);
}
else
if
(
evt
->
IsMouseUp
(
BUT_LEFT
)
||
evt
->
IsClick
(
BUT_LEFT
)
)
...
...
@@ -162,6 +169,10 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
selection
.
group
->
ItemsViewUpdate
(
m_updateFlag
);
}
RN_DATA
*
ratsnest
=
getModel
<
BOARD
>
(
PCB_T
)
->
GetRatsnest
();
ratsnest
->
ClearSimple
();
ratsnest
->
Recalculate
();
controls
->
ShowCursor
(
false
);
controls
->
SetSnapping
(
false
);
controls
->
SetAutoPan
(
false
);
...
...
@@ -195,6 +206,7 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
}
setTransitions
();
updateRatsnest
(
true
);
return
0
;
}
...
...
@@ -225,6 +237,7 @@ int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
selection
.
group
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
setTransitions
();
updateRatsnest
(
true
);
return
0
;
}
...
...
@@ -255,6 +268,7 @@ int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
selection
.
group
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
setTransitions
();
updateRatsnest
(
true
);
return
0
;
}
...
...
@@ -284,10 +298,11 @@ int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
// Rebuild list of pads and nets if necessary
BOARD
*
board
=
getModel
<
BOARD
>
(
PCB_T
);
if
(
!
(
board
->
GetStatus
()
&
NET_CODES_OK
)
)
if
(
!
(
board
->
m_Status_Pcb
&
NET_CODES_OK
)
)
board
->
BuildListOfNets
();
setTransitions
();
board
->
GetRatsnest
()
->
Recalculate
();
return
0
;
}
...
...
@@ -349,3 +364,32 @@ void EDIT_TOOL::setTransitions()
Go
(
&
EDIT_TOOL
::
Remove
,
COMMON_ACTIONS
::
remove
.
MakeEvent
()
);
Go
(
&
EDIT_TOOL
::
Properties
,
COMMON_ACTIONS
::
properties
.
MakeEvent
()
);
}
void
EDIT_TOOL
::
updateRatsnest
(
bool
aRedraw
)
{
const
SELECTION_TOOL
::
SELECTION
&
selection
=
m_selectionTool
->
GetSelection
();
RN_DATA
*
ratsnest
=
getModel
<
BOARD
>
(
PCB_T
)
->
GetRatsnest
();
ratsnest
->
ClearSimple
();
for
(
unsigned
int
i
=
0
;
i
<
selection
.
items
.
GetCount
();
++
i
)
{
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
selection
.
items
.
GetPickedItem
(
i
)
);
if
(
item
->
Type
()
==
PCB_PAD_T
||
item
->
Type
()
==
PCB_TRACE_T
||
item
->
Type
()
==
PCB_VIA_T
||
item
->
Type
()
==
PCB_ZONE_AREA_T
)
{
ratsnest
->
Update
(
static_cast
<
BOARD_CONNECTED_ITEM
*>
(
item
)
);
if
(
aRedraw
)
ratsnest
->
AddSimple
(
static_cast
<
BOARD_CONNECTED_ITEM
*>
(
item
)
);
}
else
if
(
item
->
Type
()
==
PCB_MODULE_T
)
{
ratsnest
->
Update
(
static_cast
<
MODULE
*>
(
item
)
);
if
(
aRedraw
)
ratsnest
->
AddSimple
(
static_cast
<
MODULE
*>
(
item
)
);
}
}
}
pcbnew/tools/edit_tool.h
View file @
8f054a60
...
...
@@ -113,6 +113,8 @@ private:
if
(
m_updateFlag
<
aFlag
)
m_updateFlag
=
aFlag
;
}
void
updateRatsnest
(
bool
aRedraw
);
};
#endif
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