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
Show 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 )
...
@@ -210,22 +210,20 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
Activate
();
Activate
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
m_controls
->
SetSnapping
(
true
);
controls
->
SetSnapping
(
true
);
m_controls
->
ShowCursor
(
true
);
controls
->
ShowCursor
(
true
);
m_controls
->
SetAutoPan
(
true
);
controls
->
SetAutoPan
(
true
);
PCB_BASE_FRAME
*
frame
=
getEditFrame
<
PCB_BASE_FRAME
>
();
m_frame
->
DisplayToolMsg
(
_
(
"Select reference point"
)
);
frame
->
DisplayToolMsg
(
_
(
"Select reference point"
)
);
bool
cancelled
=
false
;
bool
cancelled
=
false
;
VECTOR2I
cursorPos
=
getViewControls
()
->
GetCursorPosition
();
VECTOR2I
cursorPos
=
m_controls
->
GetCursorPosition
();
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
{
if
(
evt
->
IsMotion
()
)
if
(
evt
->
IsMotion
()
)
{
{
cursorPos
=
getViewControls
()
->
GetCursorPosition
();
cursorPos
=
m_controls
->
GetCursorPosition
();
}
}
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
{
...
@@ -243,7 +241,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
...
@@ -243,7 +241,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
PCB_IO
io
(
CTL_FOR_CLIPBOARD
);
PCB_IO
io
(
CTL_FOR_CLIPBOARD
);
// Create a temporary module that contains selected items to ease serialization
// 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
)
for
(
int
i
=
0
;
i
<
selection
.
Size
();
++
i
)
{
{
...
@@ -257,7 +255,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
...
@@ -257,7 +255,7 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
}
}
// Set the new relative internal local coordinates of copied items
// 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
moveVector
=
module
.
GetPosition
()
+
editedModule
->
GetPosition
()
-
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
);
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
);
module
.
MoveAnchorPosition
(
moveVector
);
module
.
MoveAnchorPosition
(
moveVector
);
...
@@ -267,10 +265,10 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
...
@@ -267,10 +265,10 @@ int MODULE_TOOLS::CopyItems( TOOL_EVENT& aEvent )
m_toolMgr
->
SaveClipboard
(
data
);
m_toolMgr
->
SaveClipboard
(
data
);
}
}
frame
->
DisplayToolMsg
(
wxString
::
Format
(
_
(
"Copied %d item(s)"
),
selection
.
Size
()
)
);
m_
frame
->
DisplayToolMsg
(
wxString
::
Format
(
_
(
"Copied %d item(s)"
),
selection
.
Size
()
)
);
controls
->
SetSnapping
(
false
);
m_
controls
->
SetSnapping
(
false
);
controls
->
ShowCursor
(
false
);
m_
controls
->
ShowCursor
(
false
);
controls
->
SetAutoPan
(
false
);
m_
controls
->
SetAutoPan
(
false
);
setTransitions
();
setTransitions
();
...
@@ -282,7 +280,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
...
@@ -282,7 +280,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
{
{
// Parse clipboard
// Parse clipboard
PCB_IO
io
(
CTL_FOR_CLIPBOARD
);
PCB_IO
io
(
CTL_FOR_CLIPBOARD
);
MODULE
*
currentModule
=
getModel
<
BOARD
>
()
->
m_Modules
;
MODULE
*
currentModule
=
m_board
->
m_Modules
;
MODULE
*
pastedModule
=
NULL
;
MODULE
*
pastedModule
=
NULL
;
try
try
...
@@ -300,31 +298,27 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
...
@@ -300,31 +298,27 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
}
}
// Placement tool part
// Placement tool part
KIGFX
::
VIEW
*
view
=
getView
();
VECTOR2I
cursorPos
=
m_controls
->
GetCursorPosition
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
BOARD
*
board
=
getModel
<
BOARD
>
();
PCB_EDIT_FRAME
*
frame
=
getEditFrame
<
PCB_EDIT_FRAME
>
();
VECTOR2I
cursorPos
=
getViewControls
()
->
GetCursorPosition
();
// Add a VIEW_GROUP that serves as a preview for the new item
// Add a VIEW_GROUP that serves as a preview for the new item
KIGFX
::
VIEW_GROUP
preview
(
view
);
KIGFX
::
VIEW_GROUP
preview
(
m_
view
);
pastedModule
->
SetParent
(
board
);
pastedModule
->
SetParent
(
m_
board
);
pastedModule
->
SetPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
pastedModule
->
SetPosition
(
wxPoint
(
cursorPos
.
x
,
cursorPos
.
y
)
);
pastedModule
->
RunOnChildren
(
boost
::
bind
(
&
KIGFX
::
VIEW_GROUP
::
Add
,
boost
::
ref
(
preview
),
_1
)
);
pastedModule
->
RunOnChildren
(
boost
::
bind
(
&
KIGFX
::
VIEW_GROUP
::
Add
,
boost
::
ref
(
preview
),
_1
)
);
preview
.
Add
(
pastedModule
);
preview
.
Add
(
pastedModule
);
view
->
Add
(
&
preview
);
m_
view
->
Add
(
&
preview
);
m_toolMgr
->
RunAction
(
COMMON_ACTIONS
::
selectionClear
);
m_toolMgr
->
RunAction
(
COMMON_ACTIONS
::
selectionClear
);
controls
->
ShowCursor
(
true
);
m_
controls
->
ShowCursor
(
true
);
controls
->
SetSnapping
(
true
);
m_
controls
->
SetSnapping
(
true
);
controls
->
SetAutoPan
(
true
);
m_
controls
->
SetAutoPan
(
true
);
Activate
();
Activate
();
// Main loop: keep receiving events
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
{
cursorPos
=
controls
->
GetCursorPosition
();
cursorPos
=
m_
controls
->
GetCursorPosition
();
if
(
evt
->
IsMotion
()
)
if
(
evt
->
IsMotion
()
)
{
{
...
@@ -336,7 +330,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
...
@@ -336,7 +330,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
{
{
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
rotate
)
)
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
);
preview
.
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
}
}
else
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
flip
)
)
else
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
flip
)
)
...
@@ -353,10 +347,10 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
...
@@ -353,10 +347,10 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
{
frame
->
OnModify
();
m_
frame
->
OnModify
();
frame
->
SaveCopyInUndoList
(
currentModule
,
UR_MODEDIT
);
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
();
currentModule
->
SetLastEditTime
();
// MODULE::RunOnChildren is infeasible here: we need to create copies of items, do not
// 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 )
...
@@ -368,7 +362,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
currentModule
->
Add
(
clone
);
currentModule
->
Add
(
clone
);
clone
->
SetLocalCoord
();
clone
->
SetLocalCoord
();
view
->
Add
(
clone
);
m_
view
->
Add
(
clone
);
}
}
for
(
BOARD_ITEM
*
drawing
=
pastedModule
->
GraphicalItems
();
for
(
BOARD_ITEM
*
drawing
=
pastedModule
->
GraphicalItems
();
...
@@ -393,7 +387,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
...
@@ -393,7 +387,7 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
edge
->
SetLocalCoord
();
edge
->
SetLocalCoord
();
}
}
view
->
Add
(
clone
);
m_
view
->
Add
(
clone
);
}
}
preview
.
Clear
();
preview
.
Clear
();
...
@@ -403,10 +397,10 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
...
@@ -403,10 +397,10 @@ int MODULE_TOOLS::PasteItems( TOOL_EVENT& aEvent )
}
}
delete
pastedModule
;
delete
pastedModule
;
controls
->
ShowCursor
(
false
);
m_
controls
->
ShowCursor
(
false
);
controls
->
SetSnapping
(
false
);
m_
controls
->
SetSnapping
(
false
);
controls
->
SetAutoPan
(
false
);
m_
controls
->
SetAutoPan
(
false
);
view
->
Remove
(
&
preview
);
m_
view
->
Remove
(
&
preview
);
setTransitions
();
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