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
433e17a5
Commit
433e17a5
authored
Jul 09, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for "locked" property for modules (GAL).
parent
c1eda6b8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
14 deletions
+72
-14
edit_tool.cpp
pcbnew/tools/edit_tool.cpp
+6
-3
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+54
-5
selection_tool.h
pcbnew/tools/selection_tool.h
+12
-6
No files found.
pcbnew/tools/edit_tool.cpp
View file @
433e17a5
...
@@ -158,6 +158,9 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
...
@@ -158,6 +158,9 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
}
}
else
// Prepare to start dragging
else
// Prepare to start dragging
{
{
if
(
m_selectionTool
->
CheckLock
()
)
break
;
// Save items, so changes can be undone
// Save items, so changes can be undone
editFrame
->
OnModify
();
editFrame
->
OnModify
();
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_CHANGED
);
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_CHANGED
);
...
@@ -298,7 +301,7 @@ int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
...
@@ -298,7 +301,7 @@ int EDIT_TOOL::Rotate( TOOL_EVENT& aEvent )
// Shall the selection be cleared at the end?
// Shall the selection be cleared at the end?
bool
unselect
=
selection
.
Empty
();
bool
unselect
=
selection
.
Empty
();
if
(
!
makeSelection
(
selection
)
)
if
(
!
makeSelection
(
selection
)
||
m_selectionTool
->
CheckLock
()
)
{
{
setTransitions
();
setTransitions
();
...
@@ -352,7 +355,7 @@ int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
...
@@ -352,7 +355,7 @@ int EDIT_TOOL::Flip( TOOL_EVENT& aEvent )
// Shall the selection be cleared at the end?
// Shall the selection be cleared at the end?
bool
unselect
=
selection
.
Empty
();
bool
unselect
=
selection
.
Empty
();
if
(
!
makeSelection
(
selection
)
)
if
(
!
makeSelection
(
selection
)
||
m_selectionTool
->
CheckLock
()
)
{
{
setTransitions
();
setTransitions
();
...
@@ -402,7 +405,7 @@ int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
...
@@ -402,7 +405,7 @@ int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
{
{
const
SELECTION
&
selection
=
m_selectionTool
->
GetSelection
();
const
SELECTION
&
selection
=
m_selectionTool
->
GetSelection
();
if
(
!
makeSelection
(
selection
)
)
if
(
!
makeSelection
(
selection
)
||
m_selectionTool
->
CheckLock
()
)
{
{
setTransitions
();
setTransitions
();
...
...
pcbnew/tools/selection_tool.cpp
View file @
433e17a5
...
@@ -25,9 +25,7 @@
...
@@ -25,9 +25,7 @@
#include <boost/foreach.hpp>
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <boost/bind.hpp>
#include <cassert>
#include <class_draw_panel_gal.h>
#include <class_board.h>
#include <class_board.h>
#include <class_board_item.h>
#include <class_board_item.h>
#include <class_track.h>
#include <class_track.h>
...
@@ -35,6 +33,9 @@
...
@@ -35,6 +33,9 @@
#include <wxPcbStruct.h>
#include <wxPcbStruct.h>
#include <collectors.h>
#include <collectors.h>
#include <confirm.h>
#include <class_draw_panel_gal.h>
#include <view/view_controls.h>
#include <view/view_controls.h>
#include <view/view_group.h>
#include <view/view_group.h>
#include <painter.h>
#include <painter.h>
...
@@ -52,7 +53,8 @@ SELECTION_TOOL::SELECTION_TOOL() :
...
@@ -52,7 +53,8 @@ SELECTION_TOOL::SELECTION_TOOL() :
SelectedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.selected"
),
SelectedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.selected"
),
DeselectedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.deselected"
),
DeselectedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.deselected"
),
ClearedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.cleared"
),
ClearedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.cleared"
),
m_frame
(
NULL
),
m_additive
(
false
),
m_multiple
(
false
),
m_editModules
(
false
)
m_frame
(
NULL
),
m_additive
(
false
),
m_multiple
(
false
),
m_editModules
(
false
),
m_locked
(
true
)
{
{
m_selArea
=
new
SELECTION_AREA
;
m_selArea
=
new
SELECTION_AREA
;
m_selection
.
group
=
new
KIGFX
::
VIEW_GROUP
;
m_selection
.
group
=
new
KIGFX
::
VIEW_GROUP
;
...
@@ -77,6 +79,7 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
...
@@ -77,6 +79,7 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
clearSelection
();
clearSelection
();
m_frame
=
getEditFrame
<
PCB_BASE_FRAME
>
();
m_frame
=
getEditFrame
<
PCB_BASE_FRAME
>
();
m_locked
=
true
;
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW
getView
()
->
Remove
(
m_selection
.
group
);
getView
()
->
Remove
(
m_selection
.
group
);
...
@@ -384,6 +387,48 @@ void SELECTION_TOOL::setTransitions()
...
@@ -384,6 +387,48 @@ void SELECTION_TOOL::setTransitions()
}
}
bool
SELECTION_TOOL
::
CheckLock
()
{
if
(
!
m_locked
)
return
false
;
bool
containsLocked
=
false
;
// Check if the selection contains locked items
for
(
int
i
=
0
;
i
<
m_selection
.
Size
();
++
i
)
{
BOARD_ITEM
*
item
=
m_selection
.
Item
<
BOARD_ITEM
>
(
i
);
switch
(
item
->
Type
()
)
{
case
PCB_MODULE_T
:
if
(
static_cast
<
MODULE
*>
(
item
)
->
IsLocked
()
)
containsLocked
=
true
;
break
;
case
PCB_MODULE_EDGE_T
:
case
PCB_MODULE_TEXT_T
:
if
(
static_cast
<
MODULE
*>
(
item
->
GetParent
()
)
->
IsLocked
()
)
containsLocked
=
true
;
break
;
default
:
// suppress warnings
break
;
}
}
if
(
containsLocked
&&
!
IsOK
(
m_frame
,
_
(
"Selection contains locked items. Do you want to continue?"
)
)
)
{
return
true
;
}
m_locked
=
false
;
return
false
;
}
int
SELECTION_TOOL
::
SingleSelection
(
TOOL_EVENT
&
aEvent
)
int
SELECTION_TOOL
::
SingleSelection
(
TOOL_EVENT
&
aEvent
)
{
{
selectSingle
(
getView
()
->
ToWorld
(
getViewControls
()
->
GetMousePosition
()
)
);
selectSingle
(
getView
()
->
ToWorld
(
getViewControls
()
->
GetMousePosition
()
)
);
...
@@ -419,7 +464,8 @@ void SELECTION_TOOL::clearSelection()
...
@@ -419,7 +464,8 @@ void SELECTION_TOOL::clearSelection()
}
}
m_selection
.
clear
();
m_selection
.
clear
();
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
NULL
);
m_frame
->
SetCurItem
(
NULL
);
m_locked
=
true
;
// Inform other potentially interested tools
// Inform other potentially interested tools
TOOL_EVENT
clearEvent
(
ClearedEvent
);
TOOL_EVENT
clearEvent
(
ClearedEvent
);
...
@@ -650,7 +696,10 @@ void SELECTION_TOOL::deselect( BOARD_ITEM* aItem )
...
@@ -650,7 +696,10 @@ void SELECTION_TOOL::deselect( BOARD_ITEM* aItem )
m_selection
.
items
.
RemovePicker
(
itemIdx
);
m_selection
.
items
.
RemovePicker
(
itemIdx
);
if
(
m_selection
.
Empty
()
)
if
(
m_selection
.
Empty
()
)
{
m_frame
->
SetCurItem
(
NULL
);
m_frame
->
SetCurItem
(
NULL
);
m_locked
=
true
;
}
// Inform other potentially interested tools
// Inform other potentially interested tools
TOOL_EVENT
deselected
(
DeselectedEvent
);
TOOL_EVENT
deselected
(
DeselectedEvent
);
...
...
pcbnew/tools/selection_tool.h
View file @
433e17a5
...
@@ -148,6 +148,15 @@ public:
...
@@ -148,6 +148,15 @@ public:
m_editModules
=
aEnabled
;
m_editModules
=
aEnabled
;
}
}
///> Checks if the user has agreed to modify locked items for the given selection.
bool
CheckLock
();
///> Select single item event handler.
int
SingleSelection
(
TOOL_EVENT
&
aEvent
);
///> Clear current selection event handler.
int
ClearSelection
(
TOOL_EVENT
&
aEvent
);
///> Event sent after an item is selected.
///> Event sent after an item is selected.
const
TOOL_EVENT
SelectedEvent
;
const
TOOL_EVENT
SelectedEvent
;
...
@@ -157,12 +166,6 @@ public:
...
@@ -157,12 +166,6 @@ public:
///> Event sent after selection is cleared.
///> Event sent after selection is cleared.
const
TOOL_EVENT
ClearedEvent
;
const
TOOL_EVENT
ClearedEvent
;
///> Select single item event handler.
int
SingleSelection
(
TOOL_EVENT
&
aEvent
);
///> Clear current selection event handler.
int
ClearSelection
(
TOOL_EVENT
&
aEvent
);
private
:
private
:
/**
/**
* Function selectSingle()
* Function selectSingle()
...
@@ -313,6 +316,9 @@ private:
...
@@ -313,6 +316,9 @@ private:
/// Edit module mode flag.
/// Edit module mode flag.
bool
m_editModules
;
bool
m_editModules
;
/// Can other tools modify locked items.
bool
m_locked
;
/// Conditions for specific context menu entries.
/// Conditions for specific context menu entries.
std
::
deque
<
SELECTION_CONDITION
>
m_menuConditions
;
std
::
deque
<
SELECTION_CONDITION
>
m_menuConditions
;
};
};
...
...
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