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
cf79b4c6
Commit
cf79b4c6
authored
Jul 09, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed redundant accessor calls in MODULE_TOOLS.
parent
ed88c40b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
37 deletions
+31
-37
module_tools.cpp
pcbnew/tools/module_tools.cpp
+31
-37
No files found.
pcbnew/tools/module_tools.cpp
View file @
cf79b4c6
...
...
@@ -210,22 +210,20 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
Activate
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
controls
->
SetSnapping
(
true
);
controls
->
ShowCursor
(
true
);
controls
->
SetAutoPan
(
true
);
m_controls
->
SetSnapping
(
true
);
m_controls
->
ShowCursor
(
true
);
m_controls
->
SetAutoPan
(
true
);
PCB_BASE_FRAME
*
frame
=
getEditFrame
<
PCB_BASE_FRAME
>
();
frame
->
DisplayToolMsg
(
_
(
"Select reference point"
)
);
m_frame
->
DisplayToolMsg
(
_
(
"Select reference point"
)
);
bool
cancelled
=
false
;
VECTOR2I
cursorPos
=
getViewControls
()
->
GetCursorPosition
();
VECTOR2I
cursorPos
=
m_controls
->
GetCursorPosition
();
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
if
(
evt
->
IsMotion
()
)
{
cursorPos
=
getViewControls
()
->
GetCursorPosition
();
cursorPos
=
m_controls
->
GetCursorPosition
();
}
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
...
...
@@ -243,7 +241,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
PCB_IO
io
(
CTL_FOR_CLIPBOARD
);
// Create a temporary module that contains selected items to ease serialization
MODULE
module
(
getModel
<
BOARD
>
()
);
MODULE
module
(
m_board
);
for
(
int
i
=
0
;
i
<
selection
.
Size
();
++
i
)
{
...
...
@@ -257,7 +255,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
}
// Set the new relative internal local coordinates of copied items
MODULE
*
editedModule
=
getModel
<
BOARD
>
()
->
m_Modules
;
MODULE
*
editedModule
=
m_board
->
m_Modules
;
wxPoint
moveVector
=
module
.
GetPosition
()
+
editedModule
->
GetPosition
()
-
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
);
module
.
MoveAnchorPosition
(
moveVector
);
...
...
@@ -267,10 +265,10 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
m_toolMgr
->
SaveClipboard
(
data
);
}
frame
->
DisplayToolMsg
(
wxString
::
Format
(
_
(
"Copied %d item(s)"
),
selection
.
Size
()
)
);
controls
->
SetSnapping
(
false
);
controls
->
ShowCursor
(
false
);
controls
->
SetAutoPan
(
false
);
m_
frame
->
DisplayToolMsg
(
wxString
::
Format
(
_
(
"Copied %d item(s)"
),
selection
.
Size
()
)
);
m_
controls
->
SetSnapping
(
false
);
m_
controls
->
ShowCursor
(
false
);
m_
controls
->
SetAutoPan
(
false
);
setTransitions
();
...
...
@@ -282,7 +280,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
{
// Parse clipboard
PCB_IO
io
(
CTL_FOR_CLIPBOARD
);
MODULE
*
currentModule
=
getModel
<
BOARD
>
()
->
m_Modules
;
MODULE
*
currentModule
=
m_board
->
m_Modules
;
MODULE
*
pastedModule
=
NULL
;
try
...
...
@@ -300,31 +298,27 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
}
// Placement tool part
KIGFX
::
VIEW
*
view
=
getView
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
BOARD
*
board
=
getModel
<
BOARD
>
();
PCB_EDIT_FRAME
*
frame
=
getEditFrame
<
PCB_EDIT_FRAME
>
();
VECTOR2I
cursorPos
=
getViewControls
()
->
GetCursorPosition
();
VECTOR2I
cursorPos
=
m_controls
->
GetCursorPosition
();
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
view
);
pastedModule
->
SetParent
(
board
);
KIGFX
::
VIEW_GROUP
preview
(
m_
view
);
pastedModule
->
SetParent
(
m_
board
);
pastedModule
->
SetPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
pastedModule
->
RunOnChildren
(
boost
::
bind
(
&
KIGFX
::
VIEW_GROUP
::
Add
,
boost
::
ref
(
preview
),
_1
)
);
preview
.
Add
(
pastedModule
);
view
->
Add
(
&
preview
);
m_
view
->
Add
(
&
preview
);
m_toolMgr
->
RunAction
(
COMMON_ACTIONS
::
selectionClear
);
controls
->
ShowCursor
(
true
);
controls
->
SetSnapping
(
true
);
controls
->
SetAutoPan
(
true
);
m_
controls
->
ShowCursor
(
true
);
m_
controls
->
SetSnapping
(
true
);
m_
controls
->
SetAutoPan
(
true
);
Activate
();
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
cursorPos
=
controls
->
GetCursorPosition
();
cursorPos
=
m_
controls
->
GetCursorPosition
();
if
(
evt
->
IsMotion
()
)
{
...
...
@@ -336,7 +330,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
{
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
rotate
)
)
{
pastedModule
->
Rotate
(
pastedModule
->
GetPosition
(),
frame
->
GetRotationAngle
()
);
pastedModule
->
Rotate
(
pastedModule
->
GetPosition
(),
m_
frame
->
GetRotationAngle
()
);
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
else
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
flip
)
)
...
...
@@ -353,10 +347,10 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
frame
->
OnModify
();
frame
->
SaveCopyInUndoList
(
currentModule
,
UR_MODEDIT
);
m_
frame
->
OnModify
();
m_
frame
->
SaveCopyInUndoList
(
currentModule
,
UR_MODEDIT
);
board
->
m_Status_Pcb
=
0
;
// I have no clue why, but it is done in the legacy view
m_
board
->
m_Status_Pcb
=
0
;
// I have no clue why, but it is done in the legacy view
currentModule
->
SetLastEditTime
();
// MODULE::RunOnChildren is infeasible here: we need to create copies of items, do not
...
...
@@ -368,7 +362,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
currentModule
->
Add
(
clone
);
clone
->
SetLocalCoord
();
view
->
Add
(
clone
);
m_
view
->
Add
(
clone
);
}
for
(
BOARD_ITEM
*
drawing
=
pastedModule
->
GraphicalItems
();
...
...
@@ -393,7 +387,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
edge
->
SetLocalCoord
();
}
view
->
Add
(
clone
);
m_
view
->
Add
(
clone
);
}
preview
.
Clear
();
...
...
@@ -403,10 +397,10 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
}
delete
pastedModule
;
controls
->
ShowCursor
(
false
);
controls
->
SetSnapping
(
false
);
controls
->
SetAutoPan
(
false
);
view
->
Remove
(
&
preview
);
m_
controls
->
ShowCursor
(
false
);
m_
controls
->
SetSnapping
(
false
);
m_
controls
->
SetAutoPan
(
false
);
m_
view
->
Remove
(
&
preview
);
setTransitions
();
...
...
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