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
ac489ece
Commit
ac489ece
authored
Oct 14, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Plain Diff
Merged 'development'
parents
75bb8470
4b6c6a5c
Changes
27
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
303 additions
and
327 deletions
+303
-327
CMakeLists.txt
common/CMakeLists.txt
+1
-1
view.cpp
common/view/view.cpp
+7
-5
view_group.cpp
common/view/view_group.cpp
+33
-11
worksheet_viewitem.cpp
common/worksheet_viewitem.cpp
+13
-13
definitions.h
include/gal/definitions.h
+3
-5
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+1
-1
layers_id_colors_and_visibility.h
include/layers_id_colors_and_visibility.h
+0
-1
view.h
include/view/view.h
+1
-1
view_group.h
include/view/view_group.h
+22
-2
worksheet_viewitem.h
include/worksheet_viewitem.h
+6
-7
wxBasePcbFrame.h
include/wxBasePcbFrame.h
+2
-0
basepcbframe.cpp
pcbnew/basepcbframe.cpp
+3
-6
class_dimension.cpp
pcbnew/class_dimension.cpp
+0
-12
class_dimension.h
pcbnew/class_dimension.h
+0
-3
class_module.cpp
pcbnew/class_module.cpp
+0
-7
class_module.h
pcbnew/class_module.h
+0
-3
class_pcb_text.cpp
pcbnew/class_pcb_text.cpp
+0
-11
class_pcb_text.h
pcbnew/class_pcb_text.h
+0
-3
class_text_mod.cpp
pcbnew/class_text_mod.cpp
+1
-4
pcb_painter.cpp
pcbnew/pcb_painter.cpp
+43
-97
pcb_painter.h
pcbnew/pcb_painter.h
+0
-4
pcbframe.cpp
pcbnew/pcbframe.cpp
+3
-2
bright_box.h
pcbnew/tools/bright_box.h
+1
-1
move_tool.cpp
pcbnew/tools/move_tool.cpp
+11
-70
move_tool.h
pcbnew/tools/move_tool.h
+0
-15
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+128
-20
selection_tool.h
pcbnew/tools/selection_tool.h
+24
-22
No files found.
common/CMakeLists.txt
View file @
ac489ece
...
...
@@ -32,7 +32,7 @@ set(GAL_SRCS
# Common part
drawpanel_gal.cpp
painter.cpp
worksheet_item.cpp
worksheet_
view
item.cpp
gal/graphics_abstraction_layer.cpp
gal/stroke_font.cpp
gal/color4d.cpp
...
...
common/view/view.cpp
View file @
ac489ece
...
...
@@ -676,9 +676,9 @@ struct VIEW::unlinkItem
};
struct
VIEW
::
recache
Layer
struct
VIEW
::
recache
Item
{
recache
Layer
(
VIEW
*
aView
,
GAL
*
aGal
,
int
aLayer
,
bool
aImmediately
)
:
recache
Item
(
VIEW
*
aView
,
GAL
*
aGal
,
int
aLayer
,
bool
aImmediately
)
:
view
(
aView
),
gal
(
aGal
),
layer
(
aLayer
),
immediately
(
aImmediately
)
{
}
...
...
@@ -688,9 +688,7 @@ struct VIEW::recacheLayer
// Remove previously cached group
int
prevGroup
=
aItem
->
getGroup
(
layer
);
if
(
prevGroup
>=
0
)
{
gal
->
DeleteGroup
(
prevGroup
);
}
if
(
immediately
)
{
...
...
@@ -882,6 +880,10 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
m_gal
->
SetLayerDepth
(
l
.
renderingOrder
);
// Redraw the item from scratch
int
prevGroup
=
aItem
->
getGroup
(
aLayer
);
if
(
prevGroup
>=
0
)
m_gal
->
DeleteGroup
(
prevGroup
);
int
group
=
m_gal
->
BeginGroup
();
aItem
->
setGroup
(
aLayer
,
group
);
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
aLayer
);
...
...
@@ -966,7 +968,7 @@ void VIEW::RecacheAllItems( bool aImmediately )
{
m_gal
->
SetTarget
(
l
->
target
);
m_gal
->
SetLayerDepth
(
l
->
renderingOrder
);
recache
Layer
visitor
(
this
,
m_gal
,
l
->
id
,
aImmediately
);
recache
Item
visitor
(
this
,
m_gal
,
l
->
id
,
aImmediately
);
l
->
items
->
Query
(
r
,
visitor
);
MarkTargetDirty
(
l
->
target
);
}
...
...
common/view/view_group.cpp
View file @
ac489ece
...
...
@@ -71,16 +71,6 @@ void VIEW_GROUP::Clear()
}
void
VIEW_GROUP
::
FreeItems
()
{
BOOST_FOREACH
(
VIEW_ITEM
*
item
,
m_items
)
{
delete
item
;
}
m_items
.
clear
();
}
unsigned
int
VIEW_GROUP
::
GetSize
()
const
{
return
m_items
.
size
();
...
...
@@ -102,6 +92,8 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal ) const
// Draw all items immediately (without caching)
BOOST_FOREACH
(
VIEW_ITEM
*
item
,
m_items
)
{
aGal
->
PushDepth
();
int
layers
[
VIEW
::
VIEW_MAX_LAYERS
],
layers_count
;
item
->
ViewGetLayers
(
layers
,
layers_count
);
m_view
->
SortLayers
(
layers
,
layers_count
);
...
...
@@ -110,12 +102,14 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal ) const
{
if
(
m_view
->
IsCached
(
layers
[
i
]
)
&&
m_view
->
IsLayerVisible
(
layers
[
i
]
)
)
{
aGal
->
SetLayerDepth
(
m_view
->
GetLayerOrder
(
layers
[
i
]
)
);
aGal
->
AdvanceDepth
(
);
if
(
!
painter
->
Draw
(
item
,
layers
[
i
]
)
)
item
->
ViewDraw
(
layers
[
i
],
aGal
);
// Alternative drawing method
}
}
aGal
->
PopDepth
();
}
}
...
...
@@ -128,6 +122,34 @@ void VIEW_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const
}
void
VIEW_GROUP
::
FreeItems
()
{
BOOST_FOREACH
(
VIEW_ITEM
*
item
,
m_items
)
{
delete
item
;
}
m_items
.
clear
();
}
void
VIEW_GROUP
::
ItemsSetVisibility
(
bool
aVisible
)
{
std
::
set
<
VIEW_ITEM
*>::
const_iterator
it
,
it_end
;
for
(
it
=
m_items
.
begin
(),
it_end
=
m_items
.
end
();
it
!=
it_end
;
++
it
)
(
*
it
)
->
ViewSetVisible
(
aVisible
);
}
void
VIEW_GROUP
::
ItemsViewUpdate
(
VIEW_ITEM
::
ViewUpdateFlags
aFlags
)
{
std
::
set
<
VIEW_ITEM
*>::
const_iterator
it
,
it_end
;
for
(
it
=
m_items
.
begin
(),
it_end
=
m_items
.
end
();
it
!=
it_end
;
++
it
)
(
*
it
)
->
ViewUpdate
(
aFlags
);
}
void
VIEW_GROUP
::
updateBbox
()
{
// Save the used VIEW, as it used nulled during Remove()
...
...
common/worksheet_item.cpp
→
common/worksheet_
view
item.cpp
View file @
ac489ece
...
...
@@ -23,11 +23,11 @@
*/
/**
* @file worksheet_item.cpp
* @file worksheet_
view
item.cpp
* @brief Class that handles properties and drawing of worksheet layout.
*/
#include <worksheet_item.h>
#include <worksheet_
view
item.h>
#include <worksheet_shape_builder.h>
#include <gal/graphics_abstraction_layer.h>
#include <painter.h>
...
...
@@ -36,28 +36,28 @@
using
namespace
KiGfx
;
WORKSHEET_
ITEM
::
WORKSHEET_
ITEM
(
const
std
::
string
&
aFileName
,
const
std
::
string
&
aSheetName
,
WORKSHEET_
VIEWITEM
::
WORKSHEET_VIEW
ITEM
(
const
std
::
string
&
aFileName
,
const
std
::
string
&
aSheetName
,
const
PAGE_INFO
*
aPageInfo
,
const
TITLE_BLOCK
*
aTitleBlock
)
:
EDA_ITEM
(
NOT_USED
),
// this item is never added to a BOARD so it needs no type
m_fileName
(
aFileName
),
m_sheetName
(
aSheetName
),
m_titleBlock
(
aTitleBlock
),
m_pageInfo
(
aPageInfo
),
m_sheetNumber
(
1
),
m_sheetCount
(
1
)
{}
void
WORKSHEET_ITEM
::
SetPageInfo
(
const
PAGE_INFO
*
aPageInfo
)
void
WORKSHEET_
VIEW
ITEM
::
SetPageInfo
(
const
PAGE_INFO
*
aPageInfo
)
{
m_pageInfo
=
aPageInfo
;
ViewUpdate
(
GEOMETRY
);
}
void
WORKSHEET_ITEM
::
SetTitleBlock
(
const
TITLE_BLOCK
*
aTitleBlock
)
void
WORKSHEET_
VIEW
ITEM
::
SetTitleBlock
(
const
TITLE_BLOCK
*
aTitleBlock
)
{
m_titleBlock
=
aTitleBlock
;
ViewUpdate
(
GEOMETRY
);
}
const
BOX2I
WORKSHEET_ITEM
::
ViewBBox
()
const
const
BOX2I
WORKSHEET_
VIEW
ITEM
::
ViewBBox
()
const
{
BOX2I
bbox
;
...
...
@@ -76,7 +76,7 @@ const BOX2I WORKSHEET_ITEM::ViewBBox() const
}
void
WORKSHEET_ITEM
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
void
WORKSHEET_
VIEW
ITEM
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
{
RENDER_SETTINGS
*
settings
=
m_view
->
GetPainter
()
->
GetSettings
();
wxString
fileName
(
m_fileName
.
c_str
(),
wxConvUTF8
);
...
...
@@ -128,14 +128,14 @@ void WORKSHEET_ITEM::ViewDraw( int aLayer, GAL* aGal ) const
}
void
WORKSHEET_ITEM
::
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
void
WORKSHEET_
VIEW
ITEM
::
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
{
aCount
=
1
;
aLayers
[
0
]
=
ITEM_GAL_LAYER
(
WORKSHEET
);
}
void
WORKSHEET_ITEM
::
draw
(
const
WS_DRAW_ITEM_LINE
*
aItem
,
GAL
*
aGal
)
const
void
WORKSHEET_
VIEW
ITEM
::
draw
(
const
WS_DRAW_ITEM_LINE
*
aItem
,
GAL
*
aGal
)
const
{
aGal
->
SetIsStroke
(
true
);
aGal
->
SetIsFill
(
false
);
...
...
@@ -145,7 +145,7 @@ void WORKSHEET_ITEM::draw( const WS_DRAW_ITEM_LINE* aItem, GAL* aGal ) const
}
void
WORKSHEET_ITEM
::
draw
(
const
WS_DRAW_ITEM_RECT
*
aItem
,
GAL
*
aGal
)
const
void
WORKSHEET_
VIEW
ITEM
::
draw
(
const
WS_DRAW_ITEM_RECT
*
aItem
,
GAL
*
aGal
)
const
{
aGal
->
SetIsStroke
(
true
);
aGal
->
SetIsFill
(
false
);
...
...
@@ -155,7 +155,7 @@ void WORKSHEET_ITEM::draw( const WS_DRAW_ITEM_RECT* aItem, GAL* aGal ) const
}
void
WORKSHEET_ITEM
::
draw
(
const
WS_DRAW_ITEM_POLYGON
*
aItem
,
GAL
*
aGal
)
const
void
WORKSHEET_
VIEW
ITEM
::
draw
(
const
WS_DRAW_ITEM_POLYGON
*
aItem
,
GAL
*
aGal
)
const
{
std
::
deque
<
VECTOR2D
>
corners
;
BOOST_FOREACH
(
wxPoint
point
,
aItem
->
m_Corners
)
...
...
@@ -181,7 +181,7 @@ void WORKSHEET_ITEM::draw( const WS_DRAW_ITEM_POLYGON* aItem, GAL* aGal ) const
}
void
WORKSHEET_ITEM
::
draw
(
const
WS_DRAW_ITEM_TEXT
*
aItem
,
GAL
*
aGal
)
const
void
WORKSHEET_
VIEW
ITEM
::
draw
(
const
WS_DRAW_ITEM_TEXT
*
aItem
,
GAL
*
aGal
)
const
{
VECTOR2D
position
(
aItem
->
GetTextPosition
().
x
,
aItem
->
GetTextPosition
().
y
);
...
...
@@ -192,7 +192,7 @@ void WORKSHEET_ITEM::draw( const WS_DRAW_ITEM_TEXT* aItem, GAL* aGal ) const
}
void
WORKSHEET_ITEM
::
drawBorder
(
GAL
*
aGal
)
const
void
WORKSHEET_
VIEW
ITEM
::
drawBorder
(
GAL
*
aGal
)
const
{
VECTOR2D
origin
=
VECTOR2D
(
0.0
,
0.0
);
VECTOR2D
end
=
VECTOR2D
(
m_pageInfo
->
GetWidthMils
()
*
25400
,
...
...
include/gal/definitions.h
View file @
ac489ece
...
...
@@ -38,13 +38,11 @@ namespace KiGfx
*/
enum
RenderTarget
{
TARGET_CACHED
,
///< Main rendering target (cached)
TARGET_CACHED
=
0
,
///< Main rendering target (cached)
TARGET_NONCACHED
,
///< Auxiliary rendering target (noncached)
TARGET_OVERLAY
///< Items that may change while the view stays the same (noncached)
TARGET_OVERLAY
,
///< Items that may change while the view stays the same (noncached)
TARGETS_NUMBER
///< Number of available rendering targets
};
/// Number of available rendering targets
static
const
int
TARGETS_NUMBER
=
3
;
}
#endif
/* DEFINITIONS_H_ */
include/gal/graphics_abstraction_layer.h
View file @
ac489ece
...
...
@@ -798,7 +798,7 @@ public:
*/
inline
void
AdvanceDepth
()
{
layerDepth
-=
std
::
numeric_limits
<
double
>::
epsilon
()
;
layerDepth
-=
0
.
001
;
}
/**
...
...
include/layers_id_colors_and_visibility.h
View file @
ac489ece
...
...
@@ -261,7 +261,6 @@ enum PCB_VISIBLE
PAD_BK_NETNAMES_VISIBLE
,
PADS_NETNAMES_VISIBLE
,
SELECTION
,
WORKSHEET
,
GP_OVERLAY
,
// General purpose overlay
...
...
include/view/view.h
View file @
ac489ece
...
...
@@ -500,7 +500,7 @@ private:
// Function objects that need to access VIEW/VIEW_ITEM private/protected members
struct
clearLayerCache
;
struct
recache
Layer
;
struct
recache
Item
;
struct
drawItem
;
struct
unlinkItem
;
struct
updateItemsColor
;
...
...
include/view/view_group.h
View file @
ac489ece
...
...
@@ -45,6 +45,10 @@ public:
VIEW_GROUP
(
VIEW
*
aView
=
NULL
);
virtual
~
VIEW_GROUP
();
/// Helper typedefs
typedef
std
::
set
<
VIEW_ITEM
*>::
const_iterator
const_iter
;
typedef
std
::
set
<
VIEW_ITEM
*>::
iterator
iter
;
/**
* Function Add()
* Adds an item to the group.
...
...
@@ -71,7 +75,7 @@ public:
* Function Begin()
* Returns iterator to beginning.
*/
inline
std
::
set
<
VIEW_ITEM
*>::
const_iterato
r
Begin
()
const
inline
const_ite
r
Begin
()
const
{
return
m_items
.
begin
();
}
...
...
@@ -80,7 +84,7 @@ public:
* Function End()
* Returns iterator to end.
*/
inline
std
::
set
<
VIEW_ITEM
*>::
const_iterato
r
End
()
const
inline
const_ite
r
End
()
const
{
return
m_items
.
end
();
}
...
...
@@ -147,6 +151,22 @@ public:
return
m_view
;
}
/**
* Function ItemsSetVisibility()
* Sets visibility of items stored in the VIEW_GROUP.
*
* @param aVisible decides if items should be visible or not.
*/
virtual
void
ItemsSetVisibility
(
bool
aVisible
);
/**
* Function ItemsViewUpdate()
* Updates items stored in the VIEW_GROUP.
*
* @param aFlags determines the way in which items will be updated.
*/
virtual
void
ItemsViewUpdate
(
VIEW_ITEM
::
ViewUpdateFlags
aFlags
);
protected
:
/// These functions cannot be used with VIEW_GROUP as they are intended only to work with
/// singular VIEW_ITEMs (there is only one-to-one relation between item/layer combination and
...
...
include/worksheet_item.h
→
include/worksheet_
view
item.h
View file @
ac489ece
...
...
@@ -23,12 +23,12 @@
*/
/**
* @file worksheet_item.h
* @file worksheet_
view
item.h
* @brief Class that handles properties and drawing of worksheet layout.
*/
#ifndef WORKSHEET_ITEM_H
#define WORKSHEET_ITEM_H
#ifndef WORKSHEET_
VIEW
ITEM_H
#define WORKSHEET_
VIEW
ITEM_H
#include <base_struct.h>
...
...
@@ -44,12 +44,11 @@ namespace KiGfx
{
class
GAL
;
class
WORKSHEET_ITEM
:
public
EDA_ITEM
class
WORKSHEET_
VIEW
ITEM
:
public
EDA_ITEM
{
public
:
WORKSHEET_ITEM
(
const
std
::
string
&
aFileName
,
const
std
::
string
&
aSheetName
,
WORKSHEET_
VIEW
ITEM
(
const
std
::
string
&
aFileName
,
const
std
::
string
&
aSheetName
,
const
PAGE_INFO
*
aPageInfo
,
const
TITLE_BLOCK
*
aTitleBlock
);
~
WORKSHEET_ITEM
()
{}
/**
* Function SetFileName()
...
...
@@ -160,4 +159,4 @@ protected:
};
}
#endif
/* WORKSHEET_ITEM_H */
#endif
/* WORKSHEET_
VIEW
ITEM_H */
include/wxBasePcbFrame.h
View file @
ac489ece
...
...
@@ -115,6 +115,8 @@ protected:
MODULE
*
loadFootprint
(
const
FPID
&
aFootprintId
)
throw
(
IO_ERROR
,
PARSE_ERROR
);
///> Rendering order of layers on GAL-based canvas (lower index in the array
///> means that layer is displayed closer to the user, ie. on the top).
static
const
LAYER_NUM
GAL_LAYER_ORDER
[];
public
:
...
...
pcbnew/basepcbframe.cpp
View file @
ac489ece
...
...
@@ -53,7 +53,7 @@
#include <math/vector2d.h>
#include <trigo.h>
#include <pcb_painter.h>
#include <worksheet_item.h>
#include <worksheet_
view
item.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
...
...
@@ -70,11 +70,9 @@ static const wxString DisplayModuleTextEntry( wxT( "DiModTx" ) );
static
const
wxString
FastGrid1Entry
(
wxT
(
"FastGrid1"
)
);
static
const
wxString
FastGrid2Entry
(
wxT
(
"FastGrid2"
)
);
/// Rendering order of layers on GAL-based canvas (lower index in the array
/// means that layer is displayed closer to the user, ie. on the top).
const
LAYER_NUM
PCB_BASE_FRAME
::
GAL_LAYER_ORDER
[]
=
{
ITEM_GAL_LAYER
(
GP_OVERLAY
),
ITEM_GAL_LAYER
(
SELECTION
),
ITEM_GAL_LAYER
(
GP_OVERLAY
),
ITEM_GAL_LAYER
(
PADS_NETNAMES_VISIBLE
),
DRAW_N
,
COMMENT_N
,
ECO1_N
,
ECO2_N
,
EDGE_N
,
UNUSED_LAYER_29
,
UNUSED_LAYER_30
,
UNUSED_LAYER_31
,
...
...
@@ -242,7 +240,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
}
// Add an entry for the worksheet layout
KiGfx
::
WORKSHEET_
ITEM
*
worksheet
=
new
KiGfx
::
WORKSHEET_
ITEM
(
KiGfx
::
WORKSHEET_
VIEWITEM
*
worksheet
=
new
KiGfx
::
WORKSHEET_VIEW
ITEM
(
std
::
string
(
aBoard
->
GetFileName
().
mb_str
()
),
std
::
string
(
GetScreenDesc
().
mb_str
()
),
&
GetPageSettings
(),
&
GetTitleBlock
()
);
...
...
@@ -897,7 +895,6 @@ void PCB_BASE_FRAME::LoadSettings()
view
->
SetRequired
(
SOLDERPASTE_N_BACK
,
ITEM_GAL_LAYER
(
PAD_BK_VISIBLE
)
);
view
->
SetRequired
(
SOLDERMASK_N_BACK
,
ITEM_GAL_LAYER
(
PAD_BK_VISIBLE
)
);
view
->
SetLayerTarget
(
ITEM_GAL_LAYER
(
SELECTION
),
KiGfx
::
TARGET_OVERLAY
);
view
->
SetLayerTarget
(
ITEM_GAL_LAYER
(
GP_OVERLAY
),
KiGfx
::
TARGET_OVERLAY
);
// Apply layer coloring scheme & display options
...
...
pcbnew/class_dimension.cpp
View file @
ac489ece
...
...
@@ -508,18 +508,6 @@ const BOX2I DIMENSION::ViewBBox() const
}
void
DIMENSION
::
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
{
// Layer that simply displays the text
aLayers
[
0
]
=
m_Layer
;
// On the general purpose overlay there is a selection box displayed
aLayers
[
1
]
=
ITEM_GAL_LAYER
(
SELECTION
);
aCount
=
2
;
}
EDA_ITEM
*
DIMENSION
::
Clone
()
const
{
return
new
DIMENSION
(
*
this
);
...
...
pcbnew/class_dimension.h
View file @
ac489ece
...
...
@@ -147,9 +147,6 @@ public:
/// @copydoc VIEW_ITEM::ViewBBox()
virtual
const
BOX2I
ViewBBox
()
const
;
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual
void
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
;
#if defined(DEBUG)
virtual
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
)
const
{
ShowDummy
(
os
);
}
// override
#endif
...
...
pcbnew/class_module.cpp
View file @
ac489ece
...
...
@@ -1024,10 +1024,3 @@ void MODULE::SetOrientation( double newangle )
CalculateBoundingBox
();
}
void
MODULE
::
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
{
aCount
=
2
;
aLayers
[
0
]
=
ITEM_GAL_LAYER
(
SELECTION
);
// Selection box
aLayers
[
1
]
=
m_Layer
;
}
pcbnew/class_module.h
View file @
ac489ece
...
...
@@ -499,9 +499,6 @@ public:
/// Return the initial comments block or NULL if none, without transfer of ownership.
const
wxArrayString
*
GetInitialComments
()
const
{
return
m_initial_comments
;
}
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual
void
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
;
#if defined(DEBUG)
virtual
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
)
const
{
ShowDummy
(
os
);
}
// override
#endif
...
...
pcbnew/class_pcb_text.cpp
View file @
ac489ece
...
...
@@ -224,14 +224,3 @@ const BOX2I TEXTE_PCB::ViewBBox() const
}
}
void
TEXTE_PCB
::
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
{
// Layer that simply displays the text
aLayers
[
0
]
=
m_Layer
;
// On the general purpose overlay there is a selection box displayed
aLayers
[
1
]
=
ITEM_GAL_LAYER
(
SELECTION
);
aCount
=
2
;
}
pcbnew/class_pcb_text.h
View file @
ac489ece
...
...
@@ -134,9 +134,6 @@ public:
/// @copydoc VIEW_ITEM::ViewBBox()
virtual
const
BOX2I
ViewBBox
()
const
;
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual
void
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
;
#if defined(DEBUG)
virtual
void
Show
(
int
nestLevel
,
std
::
ostream
&
os
)
const
{
ShowDummy
(
os
);
}
// override
#endif
...
...
pcbnew/class_text_mod.cpp
View file @
ac489ece
...
...
@@ -472,8 +472,5 @@ void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
break
;
}
// On the general purpose overlay there is a selection box displayed
aLayers
[
1
]
=
ITEM_GAL_LAYER
(
SELECTION
);
aCount
=
2
;
aCount
=
1
;
}
pcbnew/pcb_painter.cpp
View file @
ac489ece
...
...
@@ -76,7 +76,6 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
m_layerColors
[
ITEM_GAL_LAYER
(
PAD_FR_NETNAMES_VISIBLE
)]
=
COLOR4D
(
0.8
,
0.8
,
0.8
,
0.7
);
m_layerColors
[
ITEM_GAL_LAYER
(
PAD_BK_NETNAMES_VISIBLE
)]
=
COLOR4D
(
0.8
,
0.8
,
0.8
,
0.7
);
m_layerColors
[
ITEM_GAL_LAYER
(
WORKSHEET
)]
=
COLOR4D
(
0.5
,
0.0
,
0.0
,
1.0
);
m_layerColors
[
ITEM_GAL_LAYER
(
SELECTION
)]
=
COLOR4D
(
1.0
,
1.0
,
1.0
,
0.5
);
// Netnames for copper layers
for
(
LAYER_NUM
layer
=
FIRST_COPPER_LAYER
;
layer
<=
LAST_COPPER_LAYER
;
++
layer
)
...
...
@@ -227,10 +226,6 @@ bool PCB_PAINTER::Draw( const VIEW_ITEM* aItem, int aLayer )
draw
(
(
DRAWSEGMENT
*
)
aItem
);
break
;
case
PCB_MODULE_T
:
draw
(
(
MODULE
*
)
aItem
,
aLayer
);
break
;
case
PCB_TEXT_T
:
draw
(
(
TEXTE_PCB
*
)
aItem
,
aLayer
);
break
;
...
...
@@ -593,8 +588,6 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
VECTOR2D
deltaPadSize
=
size
-
padSize
;
// = solder[Paste/Mask]Margin or 0
VECTOR2D
delta
=
VECTOR2D
(
aPad
->
GetDelta
().
x
/
2
,
aPad
->
GetDelta
().
y
/
2
);
VECTOR2D
inflate
=
VECTOR2D
(
delta
.
y
*
(
deltaPadSize
.
x
/
size
.
x
),
delta
.
x
*
(
deltaPadSize
.
y
/
size
.
y
)
);
aPad
->
BuildPadPolygon
(
corners
,
wxSize
(
deltaPadSize
.
x
,
deltaPadSize
.
y
),
0.0
);
pointList
.
push_back
(
VECTOR2D
(
corners
[
0
]
)
);
...
...
@@ -699,26 +692,8 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment )
}
void
PCB_PAINTER
::
draw
(
const
MODULE
*
aModule
,
int
aLayer
)
{
// For modules we have to draw a selection box if needed
if
(
aLayer
==
ITEM_GAL_LAYER
(
SELECTION
)
)
{
if
(
aModule
->
IsSelected
()
)
drawSelectionBox
(
aModule
);
}
}
void
PCB_PAINTER
::
draw
(
const
TEXTE_PCB
*
aText
,
int
aLayer
)
{
if
(
aLayer
==
ITEM_GAL_LAYER
(
SELECTION
)
)
{
if
(
aText
->
IsSelected
()
)
drawSelectionBox
(
aText
);
}
else
{
if
(
aText
->
GetText
().
Length
()
==
0
)
return
;
...
...
@@ -730,19 +705,11 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
m_gal
->
SetLineWidth
(
aText
->
GetThickness
()
);
m_gal
->
SetTextAttributes
(
aText
);
m_gal
->
StrokeText
(
std
::
string
(
aText
->
GetText
().
mb_str
()
),
position
,
orientation
);
}
}
void
PCB_PAINTER
::
draw
(
const
TEXTE_MODULE
*
aText
,
int
aLayer
)
{
if
(
aLayer
==
ITEM_GAL_LAYER
(
SELECTION
)
)
{
if
(
aText
->
IsSelected
()
)
drawSelectionBox
(
aText
);
}
else
{
if
(
aText
->
GetLength
()
==
0
)
return
;
...
...
@@ -754,8 +721,6 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
m_gal
->
SetLineWidth
(
aText
->
GetThickness
()
);
m_gal
->
SetTextAttributes
(
aText
);
m_gal
->
StrokeText
(
std
::
string
(
aText
->
GetText
().
mb_str
()
),
position
,
orientation
);
}
}
...
...
@@ -830,15 +795,7 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
void
PCB_PAINTER
::
draw
(
const
DIMENSION
*
aDimension
,
int
aLayer
)
{
if
(
aLayer
==
ITEM_GAL_LAYER
(
SELECTION
)
)
{
if
(
aDimension
->
IsSelected
()
)
drawSelectionBox
(
aDimension
);
}
else
{
int
layer
=
aDimension
->
GetLayer
();
COLOR4D
strokeColor
=
m_pcbSettings
->
GetColor
(
aDimension
,
layer
);
COLOR4D
strokeColor
=
m_pcbSettings
->
GetColor
(
aDimension
,
aLayer
);
m_gal
->
SetStrokeColor
(
strokeColor
);
m_gal
->
SetIsFill
(
false
);
...
...
@@ -864,7 +821,6 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
m_gal
->
SetLineWidth
(
text
.
GetThickness
()
);
m_gal
->
SetTextAttributes
(
&
text
);
m_gal
->
StrokeText
(
std
::
string
(
text
.
GetText
().
mb_str
()
),
position
,
orientation
);
}
}
...
...
@@ -904,14 +860,4 @@ void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
}
void
PCB_PAINTER
::
drawSelectionBox
(
const
VIEW_ITEM
*
aItem
)
const
{
BOX2I
boundingBox
=
aItem
->
ViewBBox
();
m_gal
->
SetIsStroke
(
false
);
m_gal
->
SetIsFill
(
true
);
m_gal
->
SetFillColor
(
m_pcbSettings
->
GetLayerColor
(
ITEM_GAL_LAYER
(
SELECTION
)
)
);
m_gal
->
DrawRectangle
(
boundingBox
.
GetOrigin
(),
boundingBox
.
GetEnd
()
);
}
const
double
PCB_RENDER_SETTINGS
::
MAX_FONT_SIZE
=
100000000
;
pcbnew/pcb_painter.h
View file @
ac489ece
...
...
@@ -146,15 +146,11 @@ protected:
void
draw
(
const
SEGVIA
*
,
int
);
void
draw
(
const
D_PAD
*
,
int
);
void
draw
(
const
DRAWSEGMENT
*
);
void
draw
(
const
MODULE
*
,
int
);
void
draw
(
const
TEXTE_PCB
*
,
int
);
void
draw
(
const
TEXTE_MODULE
*
,
int
);
void
draw
(
const
ZONE_CONTAINER
*
);
void
draw
(
const
DIMENSION
*
,
int
);
void
draw
(
const
PCB_TARGET
*
);
/// Draws a white semitransparent box indicating an item as selected
void
drawSelectionBox
(
const
VIEW_ITEM
*
aItem
)
const
;
};
}
// namespace KiGfx
...
...
pcbnew/pcbframe.cpp
View file @
ac489ece
...
...
@@ -790,7 +790,8 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
LAYER_NUM
layers
[]
=
{
GetNetnameLayer
(
aLayer
),
ITEM_GAL_LAYER
(
VIAS_VISIBLE
),
ITEM_GAL_LAYER
(
VIAS_HOLES_VISIBLE
),
ITEM_GAL_LAYER
(
PADS_VISIBLE
),
ITEM_GAL_LAYER
(
PADS_HOLES_VISIBLE
),
ITEM_GAL_LAYER
(
PADS_NETNAMES_VISIBLE
)
ITEM_GAL_LAYER
(
PADS_HOLES_VISIBLE
),
ITEM_GAL_LAYER
(
PADS_NETNAMES_VISIBLE
),
ITEM_GAL_LAYER
(
GP_OVERLAY
)
};
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
layers
)
/
sizeof
(
LAYER_NUM
);
++
i
)
...
...
@@ -830,7 +831,7 @@ void PCB_EDIT_FRAME::setTopLayer( LAYER_NUM aLayer )
GetNetnameLayer
(
aLayer
),
ITEM_GAL_LAYER
(
VIAS_VISIBLE
),
ITEM_GAL_LAYER
(
VIAS_HOLES_VISIBLE
),
ITEM_GAL_LAYER
(
PADS_VISIBLE
),
ITEM_GAL_LAYER
(
PADS_HOLES_VISIBLE
),
ITEM_GAL_LAYER
(
PADS_NETNAMES_VISIBLE
),
ITEM_GAL_LAYER
(
SELECTION
)
ITEM_GAL_LAYER
(
GP_OVERLAY
)
};
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
layers
)
/
sizeof
(
LAYER_NUM
);
++
i
)
...
...
pcbnew/tools/bright_box.h
View file @
ac489ece
...
...
@@ -52,7 +52,7 @@ public:
}
private
:
static
const
int
BrightBoxLayer
=
ITEM_GAL_LAYER
(
SELECTION
);
static
const
int
BrightBoxLayer
=
ITEM_GAL_LAYER
(
GP_OVERLAY
);
static
const
KiGfx
::
COLOR4D
BrightColor
;
static
const
double
LineWidth
=
100000
.
0
;
...
...
pcbnew/tools/move_tool.cpp
View file @
ac489ece
...
...
@@ -78,15 +78,15 @@ bool MOVE_TOOL::Init()
int
MOVE_TOOL
::
Main
(
TOOL_EVENT
&
aEvent
)
{
const
SELECTION_TOOL
::
SELECTION
&
selection
=
m_selectionTool
->
GetSelection
();
if
(
selection
.
Empty
()
)
return
0
;
// there are no items to operate on
VECTOR2D
dragPosition
;
bool
dragging
=
false
;
bool
restore
=
false
;
// Should items' state be restored when finishing the tool?
VIEW
*
view
=
getView
();
VIEW_CONTROLS
*
controls
=
getViewControls
();
// Add a VIEW_GROUP that will hold all modified items
view
->
Add
(
&
m_items
);
VIEW_CONTROLS
*
controls
=
getViewControls
();
controls
->
ShowCursor
(
true
);
controls
->
SetSnapping
(
true
);
controls
->
SetAutoPan
(
true
);
...
...
@@ -108,12 +108,12 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
rotate
)
)
// got rotation event?
{
m_state
.
Rotate
(
cursorPos
,
900.0
);
m_items
.
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
selection
.
group
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
}
else
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
flip
)
)
// got flip event?
{
m_state
.
Flip
(
cursorPos
);
m_items
.
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
selection
.
group
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
}
}
...
...
@@ -128,98 +128,39 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
else
{
// Prepare to drag
m_selection
=
m_selectionTool
->
GetSelection
();
if
(
m_selection
.
empty
()
)
break
;
// there are no items to operate on
std
::
set
<
BOARD_ITEM
*>::
iterator
it
;
for
(
it
=
m_selection
.
begin
();
it
!=
m_selection
.
end
();
++
it
)
for
(
it
=
selection
.
items
.
begin
();
it
!=
selection
.
items
.
end
();
++
it
)
{
// Save the state of the selected items, in case it has to be restored
m_state
.
Save
(
*
it
);
// Gather all selected items into one VIEW_GROUP
viewGroupAdd
(
*
it
,
&
m_items
);
}
// Hide the original items, they are temporarily shown in VIEW_GROUP on overlay
vgSetVisibility
(
&
m_items
,
false
);
vgUpdate
(
&
m_items
,
VIEW_ITEM
::
APPEARANCE
);
dragging
=
true
;
}
m_items
.
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
selection
.
group
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
dragPosition
=
evt
->
Position
();
}
else
if
(
evt
->
IsMouseUp
(
MB_Left
)
||
evt
->
IsClick
(
MB_Left
)
)
break
;
// Finish
}
// Restore visibility of the original items
vgSetVisibility
(
&
m_items
,
true
);
if
(
restore
)
{
// Modifications has to be rollbacked, so restore the previous state of items
vgUpdate
(
&
m_items
,
VIEW_ITEM
::
APPEARANCE
);
selection
.
group
->
ItemsViewUpdate
(
VIEW_ITEM
::
APPEARANCE
);
m_state
.
RestoreAll
();
}
else
{
// Changes are applied, so update the items
vgUpdate
(
&
m_items
,
m_state
.
GetUpdateFlag
()
);
selection
.
group
->
ItemsViewUpdate
(
m_state
.
GetUpdateFlag
()
);
m_state
.
Apply
();
}
m_items
.
Clear
();
view
->
Remove
(
&
m_items
);
controls
->
ShowCursor
(
false
);
controls
->
SetSnapping
(
false
);
controls
->
SetAutoPan
(
false
);
return
0
;
}
void
MOVE_TOOL
::
viewGroupAdd
(
BOARD_ITEM
*
aItem
,
VIEW_GROUP
*
aGroup
)
{
// Modules are treated in a special way - when they are moved, we have to
// move all the parts that make the module, not the module itself
if
(
aItem
->
Type
()
==
PCB_MODULE_T
)
{
MODULE
*
module
=
static_cast
<
MODULE
*>
(
aItem
);
// Add everything that belongs to the module (besides the module itself)
for
(
D_PAD
*
pad
=
module
->
Pads
().
GetFirst
();
pad
;
pad
=
pad
->
Next
()
)
viewGroupAdd
(
pad
,
&
m_items
);
for
(
BOARD_ITEM
*
drawing
=
module
->
GraphicalItems
().
GetFirst
();
drawing
;
drawing
=
drawing
->
Next
()
)
viewGroupAdd
(
drawing
,
&
m_items
);
viewGroupAdd
(
&
module
->
Reference
(),
&
m_items
);
viewGroupAdd
(
&
module
->
Value
(),
&
m_items
);
}
// Add items to the VIEW_GROUP, so they will be displayed on the overlay
// while dragging
aGroup
->
Add
(
aItem
);
}
void
MOVE_TOOL
::
vgSetVisibility
(
VIEW_GROUP
*
aGroup
,
bool
aVisible
)
const
{
std
::
set
<
VIEW_ITEM
*>::
const_iterator
it
,
it_end
;
for
(
it
=
aGroup
->
Begin
(),
it_end
=
aGroup
->
End
();
it
!=
it_end
;
++
it
)
(
*
it
)
->
ViewSetVisible
(
aVisible
);
}
void
MOVE_TOOL
::
vgUpdate
(
VIEW_GROUP
*
aGroup
,
VIEW_ITEM
::
ViewUpdateFlags
aFlags
)
const
{
std
::
set
<
VIEW_ITEM
*>::
const_iterator
it
,
it_end
;
for
(
it
=
aGroup
->
Begin
(),
it_end
=
aGroup
->
End
();
it
!=
it_end
;
++
it
)
(
*
it
)
->
ViewUpdate
(
aFlags
);
}
pcbnew/tools/move_tool.h
View file @
ac489ece
...
...
@@ -65,26 +65,11 @@ public:
int
Main
(
TOOL_EVENT
&
aEvent
);
private
:
/// Adds an item to the VIEW_GROUP that holds all moved items and displays them on the overlay
void
viewGroupAdd
(
BOARD_ITEM
*
aItem
,
KiGfx
::
VIEW_GROUP
*
aGroup
);
/// Changes visibility settings for items stored in a VIEW_GROUP
void
vgSetVisibility
(
KiGfx
::
VIEW_GROUP
*
aGroup
,
bool
aVisible
)
const
;
/// Updates items stored in a VIEW_GROUP with selected update flag
void
vgUpdate
(
KiGfx
::
VIEW_GROUP
*
aGroup
,
KiGfx
::
VIEW_ITEM
::
ViewUpdateFlags
aFlags
)
const
;
/// Saves the state of items and allows to restore them
ITEM_STATE
m_state
;
/// Selection tool used for obtaining selected items
SELECTION_TOOL
*
m_selectionTool
;
/// Set of selected items (obtained from pcbnew.InteractiveSelection tool)
std
::
set
<
BOARD_ITEM
*>
m_selection
;
/// VIEW_GROUP that helds currently moved items
KiGfx
::
VIEW_GROUP
m_items
;
};
#endif
pcbnew/tools/selection_tool.cpp
View file @
ac489ece
...
...
@@ -36,6 +36,7 @@
#include <wxPcbStruct.h>
#include <collectors.h>
#include <view/view_controls.h>
#include <view/view_group.h>
#include <painter.h>
#include <tool/tool_event.h>
...
...
@@ -53,19 +54,25 @@ SELECTION_TOOL::SELECTION_TOOL() :
TOOL_INTERACTIVE
(
"pcbnew.InteractiveSelection"
),
m_multiple
(
false
)
{
m_selArea
=
new
SELECTION_AREA
;
m_selection
.
group
=
new
KiGfx
::
VIEW_GROUP
;
}
SELECTION_TOOL
::~
SELECTION_TOOL
()
{
if
(
m_selArea
)
delete
m_selArea
;
delete
m_selection
.
group
;
}
void
SELECTION_TOOL
::
Reset
()
{
m_selectedItems
.
clear
();
m_selection
.
group
->
Clear
();
m_selection
.
items
.
clear
();
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW
getView
()
->
Remove
(
m_selection
.
group
);
getView
()
->
Add
(
m_selection
.
group
);
// The tool launches upon reception of action event ("pcbnew.InteractiveSelection")
Go
(
&
SELECTION_TOOL
::
Main
,
COMMON_ACTIONS
::
selectionActivate
.
MakeEvent
()
);
...
...
@@ -75,8 +82,11 @@ void SELECTION_TOOL::Reset()
int
SELECTION_TOOL
::
Main
(
TOOL_EVENT
&
aEvent
)
{
BOARD
*
board
=
getModel
<
BOARD
>
(
PCB_T
);
VIEW
*
view
=
getView
();
assert
(
board
!=
NULL
);
view
->
Add
(
m_selection
.
group
);
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
...
...
@@ -86,7 +96,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
if
(
evt
->
IsCancel
()
)
{
if
(
!
m_select
edItems
.
e
mpty
()
)
// Cancel event deselects items...
if
(
!
m_select
ion
.
E
mpty
()
)
// Cancel event deselects items...
clearSelection
();
else
// ...unless there is nothing selected
break
;
// then exit the tool
...
...
@@ -99,7 +109,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
// drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
if
(
evt
->
IsDrag
(
MB_Left
)
)
{
if
(
m_select
edItems
.
e
mpty
()
||
m_additive
)
if
(
m_select
ion
.
E
mpty
()
||
m_additive
)
{
// If nothings has been selected or user wants to select more
// draw the selection box
...
...
@@ -112,7 +122,6 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{
// Yes -> run the move tool and wait till it finishes
m_toolMgr
->
InvokeTool
(
"pcbnew.InteractiveMove"
);
Wait
();
}
else
{
...
...
@@ -123,6 +132,9 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
}
}
m_selection
.
group
->
Clear
();
view
->
Remove
(
m_selection
.
group
);
return
0
;
}
...
...
@@ -137,9 +149,13 @@ void SELECTION_TOOL::AddMenuItem( const TOOL_ACTION& aAction )
void
SELECTION_TOOL
::
toggleSelection
(
BOARD_ITEM
*
aItem
)
{
if
(
m_select
edItems
.
find
(
aItem
)
!=
m_selectedI
tems
.
end
()
)
if
(
m_select
ion
.
items
.
find
(
aItem
)
!=
m_selection
.
i
tems
.
end
()
)
{
deselectItem
(
aItem
);
// If there is nothing selected, disable the context menu
if
(
m_selection
.
Empty
()
)
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
}
else
{
...
...
@@ -148,19 +164,29 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
// Prevent selection of invisible or inactive items
if
(
selectable
(
aItem
)
)
{
selectItem
(
aItem
);
// Now the context menu should be enabled
SetContextMenu
(
&
m_menu
,
CMENU_BUTTON
);
}
}
}
void
SELECTION_TOOL
::
clearSelection
()
{
BOOST_FOREACH
(
BOARD_ITEM
*
item
,
m_selectedItems
)
VIEW_GROUP
::
const_iter
it
,
it_end
;
for
(
it
=
m_selection
.
group
->
Begin
(),
it_end
=
m_selection
.
group
->
End
();
it
!=
it_end
;
++
it
)
{
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
*
it
);
item
->
ViewSetVisible
(
true
);
item
->
ClearSelected
();
}
m_selectedItems
.
clear
();
m_selection
.
group
->
Clear
();
m_selection
.
items
.
clear
();
// Do not show the context menu when there is nothing selected
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
...
...
@@ -258,9 +284,6 @@ bool SELECTION_TOOL::selectMultiple()
VIEW
*
view
=
getView
();
getViewControls
()
->
SetAutoPan
(
true
);
// These 2 lines remove the blink-in-the-random-place effect
m_selArea
->
SetOrigin
(
VECTOR2I
(
0
,
0
)
);
m_selArea
->
SetEnd
(
VECTOR2I
(
0
,
0
)
);
view
->
Add
(
m_selArea
);
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
...
...
@@ -300,14 +323,11 @@ bool SELECTION_TOOL::selectMultiple()
// Add only those items that are visible and fully within the selection box
if
(
selectable
(
item
)
&&
selectionBox
.
Contains
(
item
->
ViewBBox
()
)
)
{
item
->
SetSelected
();
m_selectedItems
.
insert
(
item
);
}
selectItem
(
item
);
}
// Now the context menu should be enabled
if
(
!
m_select
edItems
.
e
mpty
()
)
if
(
!
m_select
ion
.
E
mpty
()
)
SetContextMenu
(
&
m_menu
,
CMENU_BUTTON
);
break
;
...
...
@@ -377,6 +397,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
}
}
// Removes possible brighten mark
getView
()
->
MarkTargetDirty
(
TARGET_OVERLAY
);
// Restore the original menu
...
...
@@ -450,10 +471,12 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
return
false
;
break
;
case
PCB_MODULE_EDGE_T
:
// These are not selectable, otherwise silkscreen drawings would be easily destroyed
case
PCB_MODULE_EDGE_T
:
// and some other stuff that should be selected
case
NOT_USED
:
case
TYPE_NOT_INIT
:
return
false
;
break
;
default
:
// Suppress warnings
break
;
...
...
@@ -464,13 +487,98 @@ bool SELECTION_TOOL::selectable( const BOARD_ITEM* aItem ) const
}
void
SELECTION_TOOL
::
selectItem
(
BOARD_ITEM
*
aItem
)
{
/// Selecting an item needs a few operations, so they are wrapped in a functor
class
selectBase_
{
SELECTION
&
s
;
public
:
selectBase_
(
SELECTION
&
s_
)
:
s
(
s_
)
{}
void
operator
()(
BOARD_ITEM
*
item
)
{
s
.
group
->
Add
(
item
);
// Hide the original item, so it is shown only on overlay
item
->
ViewSetVisible
(
false
);
item
->
SetSelected
();
}
}
selectBase
(
m_selection
);
// Modules are treated in a special way - when they are moved, we have to
// move all the parts that make the module, not the module itself
if
(
aItem
->
Type
()
==
PCB_MODULE_T
)
{
MODULE
*
module
=
static_cast
<
MODULE
*>
(
aItem
);
// Add everything that belongs to the module (besides the module itself)
for
(
D_PAD
*
pad
=
module
->
Pads
().
GetFirst
();
pad
;
pad
=
pad
->
Next
()
)
selectBase
(
pad
);
for
(
BOARD_ITEM
*
drawing
=
module
->
GraphicalItems
().
GetFirst
();
drawing
;
drawing
=
drawing
->
Next
()
)
selectBase
(
drawing
);
selectBase
(
&
module
->
Reference
()
);
selectBase
(
&
module
->
Value
()
);
}
// Add items to the VIEW_GROUP, so they will be displayed on the overlay
selectBase
(
aItem
);
m_selection
.
items
.
insert
(
aItem
);
}
void
SELECTION_TOOL
::
deselectItem
(
BOARD_ITEM
*
aItem
)
{
/// Deselecting an item needs a few operations, so they are wrapped in a functor
class
deselectBase_
{
SELECTION
&
s
;
public
:
deselectBase_
(
SELECTION
&
s_
)
:
s
(
s_
)
{}
void
operator
()(
BOARD_ITEM
*
item
)
{
s
.
group
->
Remove
(
item
);
// Restore original item visibility
item
->
ViewSetVisible
(
true
);
item
->
ClearSelected
();
}
}
deselectBase
(
m_selection
);
// Modules are treated in a special way - when they are moved, we have to
// move all the parts that make the module, not the module itself
if
(
aItem
->
Type
()
==
PCB_MODULE_T
)
{
MODULE
*
module
=
static_cast
<
MODULE
*>
(
aItem
);
// Add everything that belongs to the module (besides the module itself)
for
(
D_PAD
*
pad
=
module
->
Pads
().
GetFirst
();
pad
;
pad
=
pad
->
Next
()
)
deselectBase
(
pad
);
for
(
BOARD_ITEM
*
drawing
=
module
->
GraphicalItems
().
GetFirst
();
drawing
;
drawing
=
drawing
->
Next
()
)
deselectBase
(
drawing
);
deselectBase
(
&
module
->
Reference
()
);
deselectBase
(
&
module
->
Value
()
);
}
deselectBase
(
aItem
);
m_selection
.
items
.
erase
(
aItem
);
}
bool
SELECTION_TOOL
::
containsSelected
(
const
VECTOR2I
&
aPoint
)
const
{
const
unsigned
GRIP_MARGIN
=
500000
;
// Check if the point is located within any of the currently selected items bounding boxes
std
::
set
<
BOARD_ITEM
*>::
iterator
it
,
it_end
;
for
(
it
=
m_select
edItems
.
begin
(),
it_end
=
m_selectedI
tems
.
end
();
it
!=
it_end
;
++
it
)
for
(
it
=
m_select
ion
.
items
.
begin
(),
it_end
=
m_selection
.
i
tems
.
end
();
it
!=
it_end
;
++
it
)
{
BOX2I
itemBox
=
(
*
it
)
->
ViewBBox
();
itemBox
.
Inflate
(
GRIP_MARGIN
);
// Give some margin for gripping an item
...
...
pcbnew/tools/selection_tool.h
View file @
ac489ece
...
...
@@ -36,6 +36,11 @@ class SELECTION_AREA;
class
BOARD_ITEM
;
class
GENERAL_COLLECTOR
;
namespace
KiGfx
{
class
VIEW_GROUP
;
}
/**
* Class SELECTION_TOOL
*
...
...
@@ -54,6 +59,18 @@ public:
SELECTION_TOOL
();
~
SELECTION_TOOL
();
struct
SELECTION
{
/// Set of selected items
std
::
set
<
BOARD_ITEM
*>
items
;
/// VIEW_GROUP that holds currently selected items
KiGfx
::
VIEW_GROUP
*
group
;
/// Checks if there is anything selected
bool
Empty
()
const
{
return
items
.
empty
();
}
};
/// @copydoc TOOL_INTERACTIVE::Reset()
void
Reset
();
...
...
@@ -69,9 +86,9 @@ public:
*
* Returns the set of currently selected items.
*/
const
std
::
set
<
BOARD_ITEM
*>
&
GetSelection
()
const
const
SELECTION
&
GetSelection
()
const
{
return
m_select
edItems
;
return
m_select
ion
;
}
/**
...
...
@@ -145,14 +162,7 @@ private:
*
* @param aItem is an item to be selected.
*/
void
selectItem
(
BOARD_ITEM
*
aItem
)
{
aItem
->
SetSelected
();
m_selectedItems
.
insert
(
aItem
);
// Now the context menu should be enabled
SetContextMenu
(
&
m_menu
,
CMENU_BUTTON
);
}
void
selectItem
(
BOARD_ITEM
*
aItem
);
/**
* Function deselectItem()
...
...
@@ -160,15 +170,7 @@ private:
*
* @param aItem is an item to be deselected.
*/
void
deselectItem
(
BOARD_ITEM
*
aItem
)
{
aItem
->
ClearSelected
();
m_selectedItems
.
erase
(
aItem
);
if
(
m_selectedItems
.
empty
()
)
// If there is nothing selected, disable the context menu
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
}
void
deselectItem
(
BOARD_ITEM
*
aItem
);
/**
* Function containsSelected()
...
...
@@ -178,12 +180,12 @@ private:
*/
bool
containsSelected
(
const
VECTOR2I
&
aPoint
)
const
;
/// Container storing currently selected items
std
::
set
<
BOARD_ITEM
*>
m_selectedItems
;
/// Visual representation of selection box
SELECTION_AREA
*
m_selArea
;
/// Current state of selection
SELECTION
m_selection
;
/// Flag saying if items should be added to the current selection or rather replace it
bool
m_additive
;
...
...
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