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
886a3e93
Commit
886a3e93
authored
Sep 13, 2013
by
tomasz.wlostowski@cern.ch
Browse files
Options
Browse Files
Download
Plain Diff
Merged Orson's branch
parents
299f4243
9adbdd80
Changes
75
Hide whitespace changes
Inline
Side-by-side
Showing
75 changed files
with
1091 additions
and
489 deletions
+1091
-489
CMakeLists.txt
common/CMakeLists.txt
+12
-11
drawframe.cpp
common/drawframe.cpp
+5
-7
drawpanel_gal.cpp
common/drawpanel_gal.cpp
+16
-11
color4d.cpp
common/gal/color4d.cpp
+58
-46
graphics_abstraction_layer.cpp
common/gal/graphics_abstraction_layer.cpp
+5
-4
cached_container.cpp
common/gal/opengl/cached_container.cpp
+84
-63
noncached_container.cpp
common/gal/opengl/noncached_container.cpp
+0
-5
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+7
-2
vertex_manager.cpp
common/gal/opengl/vertex_manager.cpp
+7
-2
gr_basic.cpp
common/gr_basic.cpp
+10
-10
painter.cpp
common/painter.cpp
+10
-10
context_menu.cpp
common/tool/context_menu.cpp
+1
-1
tool_dispatcher.cpp
common/tool/tool_dispatcher.cpp
+14
-12
tool_manager.cpp
common/tool/tool_manager.cpp
+16
-4
view.cpp
common/view/view.cpp
+16
-23
view_group.cpp
common/view/view_group.cpp
+4
-2
view_item.cpp
common/view/view_item.cpp
+1
-12
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+5
-1
worksheet.cpp
common/worksheet.cpp
+1
-1
worksheet_item.cpp
common/worksheet_item.cpp
+205
-0
dialog_edit_component_in_schematic.cpp
eeschema/dialogs/dialog_edit_component_in_schematic.cpp
+6
-6
dialog_edit_libentry_fields_in_lib.cpp
eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
+6
-6
eeschema_config.cpp
eeschema/eeschema_config.cpp
+3
-3
lib_field.cpp
eeschema/lib_field.cpp
+1
-1
netform.cpp
eeschema/netform.cpp
+2
-2
schframe.cpp
eeschema/schframe.cpp
+1
-1
template_fieldnames.cpp
eeschema/template_fieldnames.cpp
+2
-2
class_aperture_macro.cpp
gerbview/class_aperture_macro.cpp
+1
-1
rs274x.cpp
gerbview/rs274x.cpp
+3
-3
colors.h
include/colors.h
+8
-0
color4d.h
include/gal/color4d.h
+31
-2
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+6
-0
cached_container.h
include/gal/opengl/cached_container.h
+7
-14
noncached_container.h
include/gal/opengl/noncached_container.h
+2
-2
vertex_container.h
include/gal/opengl/vertex_container.h
+11
-3
vertex_manager.h
include/gal/opengl/vertex_manager.h
+6
-0
layers_id_colors_and_visibility.h
include/layers_id_colors_and_visibility.h
+3
-1
box2.h
include/math/box2.h
+4
-4
vector2d.h
include/math/vector2d.h
+1
-1
painter.h
include/painter.h
+22
-18
tool_dispatcher.h
include/tool/tool_dispatcher.h
+4
-1
tool_event.h
include/tool/tool_event.h
+10
-0
view.h
include/view/view.h
+8
-5
view_group.h
include/view/view_group.h
+11
-5
view_item.h
include/view/view_item.h
+8
-11
worksheet_item.h
include/worksheet_item.h
+163
-0
worksheet_shape_builder.h
include/worksheet_shape_builder.h
+6
-6
wxBasePcbFrame.h
include/wxBasePcbFrame.h
+2
-2
wxEeschemaStruct.h
include/wxEeschemaStruct.h
+1
-1
wxPcbStruct.h
include/wxPcbStruct.h
+9
-10
wxstruct.h
include/wxstruct.h
+1
-1
basepcbframe.cpp
pcbnew/basepcbframe.cpp
+16
-1
class_pcb_layer_widget.cpp
pcbnew/class_pcb_layer_widget.cpp
+2
-2
deltrack.cpp
pcbnew/deltrack.cpp
+2
-2
dialog_general_options.cpp
pcbnew/dialogs/dialog_general_options.cpp
+2
-2
dialog_global_deletion.cpp
pcbnew/dialogs/dialog_global_deletion.cpp
+1
-1
dialog_layers_setup.cpp
pcbnew/dialogs/dialog_layers_setup.cpp
+5
-5
dimension.cpp
pcbnew/dimension.cpp
+1
-1
edit.cpp
pcbnew/edit.cpp
+10
-10
editedge.cpp
pcbnew/editedge.cpp
+2
-2
editrack-part2.cpp
pcbnew/editrack-part2.cpp
+6
-6
hotkeys_board_editor.cpp
pcbnew/hotkeys_board_editor.cpp
+5
-5
onleftclick.cpp
pcbnew/onleftclick.cpp
+3
-3
pcb_painter.cpp
pcbnew/pcb_painter.cpp
+50
-45
pcb_painter.h
pcbnew/pcb_painter.h
+8
-6
pcbframe.cpp
pcbnew/pcbframe.cpp
+88
-40
tool_pcb.cpp
pcbnew/tool_pcb.cpp
+1
-1
toolbars_update_user_interface.cpp
pcbnew/toolbars_update_user_interface.cpp
+1
-1
move_tool.cpp
pcbnew/tools/move_tool.cpp
+1
-1
move_tool.h
pcbnew/tools/move_tool.h
+2
-1
pcb_tools.cpp
pcbnew/tools/pcb_tools.cpp
+9
-2
selection_area.cpp
pcbnew/tools/selection_area.cpp
+1
-1
selection_area.h
pcbnew/tools/selection_area.h
+2
-2
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+43
-6
zones_by_polygon.cpp
pcbnew/zones_by_polygon.cpp
+4
-4
No files found.
common/CMakeLists.txt
View file @
886a3e93
...
...
@@ -32,6 +32,7 @@ set(GAL_SRCS
# Common part
drawpanel_gal.cpp
painter.cpp
worksheet_item.cpp
gal/graphics_abstraction_layer.cpp
gal/stroke_font.cpp
gal/color4d.cpp
...
...
@@ -156,17 +157,17 @@ set(COMMON_SRCS
system/fcontext.s
tool/tool_base.cpp
tool/tool_manager.cpp
tool/tool_dispatcher.cpp
tool/tool_event.cpp
tool/tool_interactive.cpp
tool/context_menu.cpp
geometry/seg.cpp
geometry/shape_line_chain.cpp
geometry/shape_collisions.cpp
)
tool/tool_base.cpp
tool/tool_manager.cpp
tool/tool_dispatcher.cpp
tool/tool_event.cpp
tool/tool_interactive.cpp
tool/context_menu.cpp
geometry/seg.cpp
geometry/shape_line_chain.cpp
geometry/shape_collisions.cpp
)
add_library
(
common STATIC
${
COMMON_SRCS
}
)
...
...
common/drawframe.cpp
View file @
886a3e93
...
...
@@ -981,18 +981,16 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
// Switch to GAL rendering
if
(
!
m_galCanvasActive
)
{
// Set up grid settings
gal
->
SetGridVisibility
(
IsGridVisible
()
);
gal
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGridSize
().
x
,
screen
->
GetGridSize
().
y
)
);
gal
->
SetGridOrigin
(
VECTOR2D
(
screen
->
GetGridOrigin
()
)
);
gal
->
SetGridOriginMarkerSize
(
15
);
gal
->
SetGridDrawThreshold
(
10
);
// Set up viewport
double
zoom
=
1.0
/
(
zoomFactor
*
m_canvas
->
GetZoom
()
);
view
->
SetScale
(
zoom
);
view
->
SetCenter
(
VECTOR2D
(
m_canvas
->
GetScreenCenterLogicalPosition
()
)
);
}
// Set up grid settings
gal
->
SetGridVisibility
(
IsGridVisible
()
);
gal
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGridSize
().
x
,
screen
->
GetGridSize
().
y
)
);
gal
->
SetGridOrigin
(
VECTOR2D
(
screen
->
GetGridOrigin
()
)
);
}
else
{
...
...
common/drawpanel_gal.cpp
View file @
886a3e93
...
...
@@ -90,9 +90,10 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
Connect
(
wxEVT_CHAR_HOOK
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
skipEvent
)
);
Connect
(
wxEVT_KEY_UP
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_KEY_DOWN
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
Connect
(
wxEVT_ENTER_WINDOW
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEnter
),
NULL
,
this
);
Connect
(
wxEVT_ENTER_WINDOW
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEnter
),
NULL
,
this
);
Connect
(
TOOL_DISPATCHER
::
EVT_REFRESH_MOUSE
,
wxEventHandler
(
EDA_DRAW_PANEL_GAL
::
onEvent
),
NULL
,
this
);
m_refreshTimer
.
SetOwner
(
this
);
Connect
(
wxEVT_TIMER
,
wxTimerEventHandler
(
EDA_DRAW_PANEL_GAL
::
onRefreshTimer
),
NULL
,
this
);
...
...
@@ -108,7 +109,7 @@ EDA_DRAW_PANEL_GAL::~EDA_DRAW_PANEL_GAL()
if
(
m_viewControls
)
delete
m_viewControls
;
if
(
m_view
)
if
(
m_view
)
delete
m_view
;
if
(
m_gal
)
...
...
@@ -130,7 +131,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
m_gal
->
SetBackgroundColor
(
KiGfx
::
COLOR4D
(
0.0
,
0.0
,
0.0
,
1.0
)
);
m_gal
->
ClearScreen
();
m_view
->
Prepare
Targets
();
m_view
->
Clear
Targets
();
// Grid has to be redrawn only when the NONCACHED target is redrawn
if
(
m_view
->
IsTargetDirty
(
KiGfx
::
TARGET_NONCACHED
)
)
m_gal
->
DrawGrid
();
...
...
@@ -164,19 +165,22 @@ void EDA_DRAW_PANEL_GAL::onRefreshTimer( wxTimerEvent& aEvent )
void
EDA_DRAW_PANEL_GAL
::
Refresh
(
bool
eraseBackground
,
const
wxRect
*
rect
)
{
if
(
m_pendingRefresh
)
if
(
m_pendingRefresh
)
return
;
wxLongLong
t
=
wxGetLocalTimeMillis
();
wxLongLong
delta
=
t
-
m_lastRefresh
;
if
(
t
>=
MinRefreshPeriod
)
if
(
delta
>=
MinRefreshPeriod
)
{
wxPaintEvent
redrawEvent
;
wxPostEvent
(
this
,
redrawEvent
);
m_pendingRefresh
=
true
;
}
else
{
m_refreshTimer
.
Start
(
(
MinRefreshPeriod
-
t
).
ToLong
(),
true
);
}
else
{
// One shot timer
m_refreshTimer
.
Start
(
(
MinRefreshPeriod
-
delta
).
ToLong
(),
true
);
m_pendingRefresh
=
true
;
}
}
...
...
@@ -236,16 +240,17 @@ void EDA_DRAW_PANEL_GAL::onEvent( wxEvent& aEvent )
m_eventDispatcher
->
DispatchWxEvent
(
aEvent
);
}
if
(
m_view
->
IsDirty
())
Refresh
();
Refresh
();
}
void
EDA_DRAW_PANEL_GAL
::
onEnter
(
wxEvent
&
aEvent
)
void
EDA_DRAW_PANEL_GAL
::
onEnter
(
wxEvent
&
aEvent
)
{
// Getting focus is necessary in order to receive key events properly
SetFocus
();
}
void
EDA_DRAW_PANEL_GAL
::
skipEvent
(
wxEvent
&
aEvent
)
{
// This is necessary for CHAR_HOOK event to generate KEY_UP and KEY_DOWN events
...
...
common/gal/color4d.cpp
View file @
886a3e93
...
...
@@ -30,9 +30,9 @@ using namespace KiGfx;
COLOR4D
::
COLOR4D
(
EDA_COLOR_T
aColor
)
{
r
=
g_ColorRefs
[
aColor
].
m_Red
;
g
=
g_ColorRefs
[
aColor
].
m_Green
;
b
=
g_ColorRefs
[
aColor
].
m_Blue
;
r
=
g_ColorRefs
[
aColor
].
m_Red
/
255.0
;
g
=
g_ColorRefs
[
aColor
].
m_Green
/
255.0
;
b
=
g_ColorRefs
[
aColor
].
m_Blue
/
255.0
;
a
=
1.0
;
}
...
...
@@ -59,91 +59,102 @@ const bool COLOR4D::operator!=( const COLOR4D& aColor )
return
a
!=
aColor
.
a
||
r
!=
aColor
.
r
||
g
!=
aColor
.
g
||
b
!=
aColor
.
b
;
}
void
COLOR4D
::
ToHSV
(
double
&
out_h
,
double
&
out_s
,
double
&
out_v
)
const
void
COLOR4D
::
ToHSV
(
double
&
aOutH
,
double
&
aOutS
,
double
&
aOutV
)
const
{
double
min
,
max
,
delta
;
double
min
,
max
,
delta
;
min
=
r
<
g
?
r
:
g
;
min
=
min
<
b
?
min
:
b
;
min
=
min
<
b
?
min
:
b
;
max
=
r
>
g
?
r
:
g
;
max
=
max
>
b
?
max
:
b
;
max
=
max
>
b
?
max
:
b
;
out_v
=
max
;
// v
aOutV
=
max
;
// v
delta
=
max
-
min
;
if
(
max
>
0.0
)
{
out_s
=
(
delta
/
max
);
// s
}
else
{
if
(
max
>
0.0
)
{
aOutS
=
(
delta
/
max
);
// s
}
else
{
// r = g = b = 0 // s = 0, v is undefined
out_s
=
0.0
;
out_h
=
NAN
;
// its now undefined
aOutS
=
0.0
;
aOutH
=
NAN
;
// its now undefined
return
;
}
if
(
r
>=
max
)
// > is bogus, just keeps compilor happy
out_h
=
(
g
-
b
)
/
delta
;
// between yellow & magenta
else
if
(
g
>=
max
)
out_h
=
2.0
+
(
b
-
r
)
/
delta
;
// between cyan & yellow
if
(
r
>=
max
)
// > is bogus, just keeps compiler happy
aOutH
=
(
g
-
b
)
/
delta
;
// between yellow & magenta
else
if
(
g
>=
max
)
aOutH
=
2.0
+
(
b
-
r
)
/
delta
;
// between cyan & yellow
else
out_h
=
4.0
+
(
r
-
g
)
/
delta
;
// between magenta & cyan
aOutH
=
4.0
+
(
r
-
g
)
/
delta
;
// between magenta & cyan
out_h
*=
60.0
;
// degrees
aOutH
*=
60.0
;
// degrees
if
(
out_h
<
0.0
)
out_h
+=
360.0
;
if
(
aOutH
<
0.0
)
aOutH
+=
360.0
;
}
void
COLOR4D
::
FromHSV
(
double
in_h
,
double
in_s
,
double
in_v
)
void
COLOR4D
::
FromHSV
(
double
aInH
,
double
aInS
,
double
aInV
)
{
double
hh
,
p
,
q
,
t
,
ff
;
long
i
;
double
hh
,
p
,
q
,
t
,
ff
;
long
i
;
if
(
in_s
<=
0.0
)
{
// < is bogus, just shuts up warnings
r
=
in_v
;
g
=
in_v
;
b
=
in_v
;
if
(
aInS
<=
0.0
)
// < is bogus, just shuts up warnings
{
r
=
aInV
;
g
=
aInV
;
b
=
aInV
;
return
;
}
hh
=
in_h
;
if
(
hh
>=
360.0
)
hh
=
0.0
;
hh
=
aInH
;
if
(
hh
>=
360.0
)
hh
=
0.0
;
hh
/=
60.0
;
i
=
(
long
)
hh
;
i
=
(
long
)
hh
;
ff
=
hh
-
i
;
p
=
in_v
*
(
1.0
-
in_s
);
q
=
in_v
*
(
1.0
-
(
in_s
*
ff
));
t
=
in_v
*
(
1.0
-
(
in_s
*
(
1.0
-
ff
)));
switch
(
i
)
{
p
=
aInV
*
(
1.0
-
aInS
);
q
=
aInV
*
(
1.0
-
(
aInS
*
ff
)
);
t
=
aInV
*
(
1.0
-
(
aInS
*
(
1.0
-
ff
)
)
);
switch
(
i
)
{
case
0
:
r
=
in_v
;
r
=
aInV
;
g
=
t
;
b
=
p
;
break
;
case
1
:
r
=
q
;
g
=
in_v
;
g
=
aInV
;
b
=
p
;
break
;
case
2
:
r
=
p
;
g
=
in_v
;
g
=
aInV
;
b
=
t
;
break
;
case
3
:
r
=
p
;
g
=
q
;
b
=
in_v
;
b
=
aInV
;
break
;
case
4
:
r
=
t
;
g
=
p
;
b
=
in_v
;
b
=
aInV
;
break
;
case
5
:
default
:
r
=
in_v
;
r
=
aInV
;
g
=
p
;
b
=
q
;
break
;
...
...
@@ -151,12 +162,13 @@ void COLOR4D::FromHSV(double in_h, double in_s, double in_v)
}
COLOR4D
&
COLOR4D
::
Saturate
(
double
aFactor
)
{
double
h
,
s
,
v
;
ToHSV
(
h
,
s
,
v
);
FromHSV
(
h
,
aFactor
,
1.0
);
ToHSV
(
h
,
s
,
v
);
FromHSV
(
h
,
aFactor
,
1.0
);
return
*
this
;
}
\ No newline at end of file
common/gal/graphics_abstraction_layer.cpp
View file @
886a3e93
...
...
@@ -29,7 +29,6 @@
#include <gal/graphics_abstraction_layer.h>
#include <gal/definitions.h>
using
namespace
KiGfx
;
GAL
::
GAL
()
:
...
...
@@ -41,19 +40,21 @@ GAL::GAL() :
SetFillColor
(
COLOR4D
(
0.0
,
0.0
,
0.0
,
0.0
)
);
SetStrokeColor
(
COLOR4D
(
1.0
,
1.0
,
1.0
,
1.0
)
);
SetZoomFactor
(
1.0
);
SetDepthRange
(
VECTOR2D
(
-
2048
,
2047
)
);
SetDepthRange
(
VECTOR2D
(
GAL
::
MIN_DEPTH
,
GAL
::
MAX_DEPTH
)
);
SetFlip
(
false
,
false
);
SetLineWidth
(
1.0
);
// Set grid defaults
SetGridVisibility
(
true
);
SetGridStyle
(
GRID_STYLE_LINES
);
SetGridOriginMarkerSize
(
15
);
SetGridDrawThreshold
(
10
);
SetCoarseGrid
(
10
);
SetGridLineWidth
(
0.5
);
// Initialize the cursor shape
SetCursorColor
(
COLOR4D
(
1.0
,
1.0
,
1.0
,
1.0
)
);
SetCursorSize
(
20
);
SetCursorSize
(
15
);
SetCursorEnabled
(
true
);
strokeFont
.
LoadNewStrokeFont
(
newstroke_font
,
newstroke_font_bufsize
);
...
...
@@ -112,7 +113,7 @@ void GAL::DrawGrid()
// Draw the origin marker
double
origSize
=
static_cast
<
double
>
(
gridOriginMarkerSize
)
/
worldScale
;
SetLayerDepth
(
0.0
);
SetLayerDepth
(
GAL
::
GRID_DEPTH
);
SetIsFill
(
false
);
SetIsStroke
(
true
);
SetStrokeColor
(
COLOR4D
(
1.0
,
1.0
,
1.0
,
1.0
)
);
...
...
common/gal/opengl/cached_container.cpp
View file @
886a3e93
...
...
@@ -42,7 +42,7 @@
using
namespace
KiGfx
;
CACHED_CONTAINER
::
CACHED_CONTAINER
(
unsigned
int
aSize
)
:
VERTEX_CONTAINER
(
aSize
)
VERTEX_CONTAINER
(
aSize
)
,
m_item
(
NULL
)
{
// In the beginning there is only free space
m_freeChunks
.
insert
(
Chunk
(
aSize
,
0
)
);
...
...
@@ -51,35 +51,45 @@ CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) :
void
CACHED_CONTAINER
::
SetItem
(
VERTEX_ITEM
*
aItem
)
{
if
(
aItem
==
NULL
)
{
wxASSERT
(
m_item
!=
NULL
);
wxASSERT
(
aItem
!=
NULL
);
// Finishing the item
if
(
m_itemSize
<
m_chunkSize
)
{
// There is some not used but reserved memory left, so we should return it to the pool
int
itemOffset
=
m_item
->
GetOffset
();
m_item
=
aItem
;
m_itemSize
=
m_item
->
GetSize
();
m_chunkSize
=
m_itemSize
;
// Add the not used memory back to the pool
m_freeChunks
.
insert
(
Chunk
(
m_chunkSize
-
m_itemSize
,
itemOffset
+
m_itemSize
)
);
m_freeSpace
+=
(
m_chunkSize
-
m_itemSize
);
// mergeFreeChunks();
}
m_item
=
NULL
;
}
if
(
m_itemSize
==
0
)
m_items
.
insert
(
m_item
);
// The item was not stored before
else
m_chunkOffset
=
m_item
->
GetOffset
();
#if CACHED_CONTAINER_TEST > 1
wxLogDebug
(
wxT
(
"Adding/editing item 0x%08lx (size %d)"
),
(
long
)
m_item
,
m_itemSize
);
#endif
}
void
CACHED_CONTAINER
::
FinishItem
()
{
wxASSERT
(
m_item
!=
NULL
);
wxASSERT
(
m_item
->
GetSize
()
==
m_itemSize
);
// Finishing the previously edited item
if
(
m_itemSize
<
m_chunkSize
)
{
m_item
=
aItem
;
m_itemSize
=
m_item
->
GetSize
();
m_chunkSize
=
m_itemSize
;
// There is some not used but reserved memory left, so we should return it to the pool
int
itemOffset
=
m_item
->
GetOffset
();
if
(
m_itemSize
==
0
)
m_items
.
insert
(
m_item
);
// The item was not stored before
else
m_chunkOffset
=
m_item
->
GetOffset
();
// Add the not used memory back to the pool
m_freeChunks
.
insert
(
Chunk
(
m_chunkSize
-
m_itemSize
,
itemOffset
+
m_itemSize
)
);
m_freeSpace
+=
(
m_chunkSize
-
m_itemSize
);
// mergeFreeChunks(); // veery slow and buggy
}
#if CACHED_CONTAINER_TEST > 1
wxLogDebug
(
wxT
(
"Finishing item 0x%08lx (size %d)"
),
(
long
)
m_item
,
m_itemSize
);
test
();
m_item
=
NULL
;
// electric fence
#endif
}
...
...
@@ -109,6 +119,7 @@ VERTEX* CACHED_CONTAINER::Allocate( unsigned int aSize )
VERTEX
*
reserved
=
&
m_vertices
[
m_chunkOffset
+
m_itemSize
];
m_itemSize
+=
aSize
;
// Now the item officially possesses the memory chunk
m_item
->
setSize
(
m_itemSize
);
// The content has to be updated
...
...
@@ -117,16 +128,40 @@ VERTEX* CACHED_CONTAINER::Allocate( unsigned int aSize )
#if CACHED_CONTAINER_TEST > 1
test
();
#endif
#if CACHED_CONTAINER_TEST > 2
showFreeChunks
();
showReservedChunks
();
#endif
return
reserved
;
}
void
CACHED_CONTAINER
::
Erase
(
)
void
CACHED_CONTAINER
::
Delete
(
VERTEX_ITEM
*
aItem
)
{
wxASSERT
(
m_item
!=
NULL
);
wxASSERT
(
aItem
!=
NULL
);
wxASSERT
(
m_items
.
find
(
aItem
)
!=
m_items
.
end
()
);
int
size
=
aItem
->
GetSize
();
int
offset
=
aItem
->
GetOffset
();
freeItem
(
m_item
);
#if CACHED_CONTAINER_TEST > 1
wxLogDebug
(
wxT
(
"Removing 0x%08lx (size %d offset %d)"
),
(
long
)
aItem
,
size
,
offset
);
#endif
// Insert a free memory chunk entry in the place where item was stored
if
(
size
>
0
)
{
m_freeChunks
.
insert
(
Chunk
(
size
,
offset
)
);
m_freeSpace
+=
size
;
// Indicate that the item is not stored in the container anymore
aItem
->
setSize
(
0
);
}
m_items
.
erase
(
aItem
);
#if CACHED_CONTAINER_TEST > 1
test
();
#endif
// Dynamic memory freeing, there is no point in holding
// a large amount of memory when there is no use for it
...
...
@@ -176,10 +211,10 @@ VERTEX* CACHED_CONTAINER::GetVertices( const VERTEX_ITEM* aItem ) const
unsigned
int
CACHED_CONTAINER
::
reallocate
(
unsigned
int
aSize
)
{
wxASSERT
(
aSize
>
0
);
#if CACHED_CONTAINER_TEST > 2
wxLogDebug
(
wxT
(
"Resize 0x%08x to %d"
),
(
int
)
m_item
,
aSize
);
showFreeChunks
();
showReservedChunks
();
wxLogDebug
(
wxT
(
"Resize 0x%08lx from %d to %d"
),
(
long
)
m_item
,
m_itemSize
,
aSize
);
#endif
// Is there enough space to store vertices?
...
...
@@ -203,7 +238,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
return
UINT_MAX
;
}
// Look for the free space of at least given size
// Look for the free space
chunk
of at least given size
FreeChunkMap
::
iterator
newChunk
=
m_freeChunks
.
lower_bound
(
aSize
);
if
(
newChunk
==
m_freeChunks
.
end
()
)
...
...
@@ -240,6 +275,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
m_itemSize
*
VertexSize
);
// Free the space previously used by the chunk
wxASSERT
(
m_itemSize
>
0
);
m_freeChunks
.
insert
(
Chunk
(
m_itemSize
,
m_chunkOffset
)
);
m_freeSpace
+=
m_itemSize
;
}
...
...
@@ -254,15 +290,10 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
}
m_freeSpace
-=
aSize
;
// mergeFreeChunks();
// mergeFreeChunks();
// veery slow and buggy
m_item
->
setOffset
(
chunkOffset
);
#if CACHED_CONTAINER_TEST > 2
showFreeChunks
();
showReservedChunks
();
#endif
return
chunkOffset
;
}
...
...
@@ -271,11 +302,10 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
{
#if CACHED_CONTAINER_TEST > 0
wxLogDebug
(
wxT
(
"Defragmenting"
)
);
#endif
#ifdef __WXDEBUG__
prof_counter
totalTime
;
prof_start
(
&
totalTime
,
false
);
#endif
/* __WXDEBUG__ */
#endif
if
(
aTarget
==
NULL
)
{
...
...
@@ -313,14 +343,15 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
// Now there is only one big chunk of free memory
m_freeChunks
.
clear
();
wxASSERT
(
m_freeSpace
>
0
);
m_freeChunks
.
insert
(
Chunk
(
m_freeSpace
,
m_currentSize
-
m_freeSpace
)
);
#if
def __WXDEBUG__
#if
CACHED_CONTAINER_TEST > 0
prof_end
(
&
totalTime
);
wxLogDebug
(
wxT
(
"Defragmented the container storing %d vertices / %.1f ms"
),
m_currentSize
-
m_freeSpace
,
(
double
)
totalTime
.
value
/
1000.0
);
#endif
/* __WXDEBUG__ */
#endif
return
true
;
}
...
...
@@ -331,10 +362,10 @@ void CACHED_CONTAINER::mergeFreeChunks()
if
(
m_freeChunks
.
size
()
<=
1
)
// There are no chunks that can be merged
return
;
#ifdef
__WXDEBUG__
#ifdef
CACHED_CONTAINER_TEST > 0
prof_counter
totalTime
;
prof_start
(
&
totalTime
,
false
);
#endif
/* __WXDEBUG__ */
#endif
// Reversed free chunks map - this one stores chunk size with its offset as the key
std
::
list
<
Chunk
>
freeChunks
;
...
...
@@ -375,11 +406,11 @@ void CACHED_CONTAINER::mergeFreeChunks()
// Add the last one
m_freeChunks
.
insert
(
std
::
make_pair
(
size
,
offset
)
);
#ifdef
__WXDEBUG__
#ifdef
CACHED_CONTAINER_TEST > 0
prof_end
(
&
totalTime
);
wxLogDebug
(
wxT
(
"Merged free chunks / %.1f ms"
),
(
double
)
totalTime
.
value
/
1000.0
);
#endif
/* __WXDEBUG__ */
#endif
test
();
}
...
...
@@ -387,6 +418,8 @@ void CACHED_CONTAINER::mergeFreeChunks()
bool
CACHED_CONTAINER
::
resizeContainer
(
unsigned
int
aNewSize
)
{
wxASSERT
(
aNewSize
!=
m_currentSize
);
#if CACHED_CONTAINER_TEST > 0
wxLogDebug
(
wxT
(
"Resizing container from %d to %d"
),
m_currentSize
,
aNewSize
);
#endif
...
...
@@ -413,6 +446,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
// We have to correct freeChunks after defragmentation
m_freeChunks
.
clear
();
wxASSERT
(
aNewSize
-
reservedSpace
()
>
0
);
m_freeChunks
.
insert
(
Chunk
(
aNewSize
-
reservedSpace
(),
reservedSpace
()
)
);
}
else
...
...
@@ -439,21 +473,6 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
}
void
CACHED_CONTAINER
::
freeItem
(
VERTEX_ITEM
*
aItem
)
{
int
size
=
aItem
->
GetSize
();
int
offset
=
aItem
->
GetOffset
();
// Insert a free memory chunk entry in the place where item was stored
m_freeChunks
.
insert
(
Chunk
(
size
,
offset
)
);
m_freeSpace
+=
size
;
m_items
.
erase
(
aItem
);
// Indicate that the item is not stored in the container anymore
aItem
->
setSize
(
0
);
}
unsigned
int
CACHED_CONTAINER
::
getPowerOf2
(
unsigned
int
aNumber
)
const
{
unsigned
int
power
=
1
;
...
...
@@ -476,6 +495,7 @@ void CACHED_CONTAINER::showFreeChunks()
{
unsigned
int
offset
=
getChunkOffset
(
*
it
);
unsigned
int
size
=
getChunkSize
(
*
it
);
wxASSERT
(
size
>
0
);
wxLogDebug
(
wxT
(
"[0x%08x-0x%08x] (size %d)"
),
offset
,
offset
+
size
-
1
,
size
);
...
...
@@ -494,9 +514,10 @@ void CACHED_CONTAINER::showReservedChunks()
VERTEX_ITEM
*
item
=
*
it
;
unsigned
int
offset
=
item
->
GetOffset
();
unsigned
int
size
=
item
->
GetSize
();
wxASSERT
(
size
>
0
);
wxLogDebug
(
wxT
(
"[0x%08x-0x%08x] @ 0x%08x (size %d)"
),
offset
,
offset
+
size
-
1
,
(
int
)
item
,
size
);
wxLogDebug
(
wxT
(
"[0x%08x-0x%08x] @ 0x%08
l
x (size %d)"
),
offset
,
offset
+
size
-
1
,
(
long
)
item
,
size
);
}
}
...
...
common/gal/opengl/noncached_container.cpp
View file @
886a3e93
...
...
@@ -82,11 +82,6 @@ VERTEX* NONCACHED_CONTAINER::Allocate( unsigned int aSize )
}
void
NONCACHED_CONTAINER
::
Erase
()
{
}
void
NONCACHED_CONTAINER
::
Clear
()
{
m_freePtr
=
0
;
...
...
common/gal/opengl/opengl_gal.cpp
View file @
886a3e93
...
...
@@ -233,8 +233,11 @@ void OPENGL_GAL::DrawLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEndPoin
drawLineQuad
(
aStartPoint
,
aEndPoint
);
// Line caps
drawFilledSemiCircle
(
aStartPoint
,
lineWidth
/
2
,
lineAngle
+
M_PI
/
2
);
drawFilledSemiCircle
(
aEndPoint
,
lineWidth
/
2
,
lineAngle
-
M_PI
/
2
);
if
(
lineWidth
>
1.0
)
{
drawFilledSemiCircle
(
aStartPoint
,
lineWidth
/
2
,
lineAngle
+
M_PI
/
2
);
drawFilledSemiCircle
(
aEndPoint
,
lineWidth
/
2
,
lineAngle
-
M_PI
/
2
);
}
}
...
...
@@ -638,6 +641,7 @@ int OPENGL_GAL::BeginGroup()
void
OPENGL_GAL
::
EndGroup
()
{
cachedManager
.
FinishItem
();
isGrouping
=
false
;
}
...
...
@@ -662,6 +666,7 @@ void OPENGL_GAL::ChangeGroupDepth( int aGroupNumber, int aDepth )
void
OPENGL_GAL
::
DeleteGroup
(
int
aGroupNumber
)
{
// Frees memory in the container as well
groups
.
erase
(
aGroupNumber
);
}
...
...
common/gal/opengl/vertex_manager.cpp
View file @
886a3e93
...
...
@@ -88,10 +88,15 @@ void VERTEX_MANAGER::SetItem( VERTEX_ITEM& aItem ) const
}
void
VERTEX_MANAGER
::
FinishItem
()
const
{
m_container
->
FinishItem
();
}
void
VERTEX_MANAGER
::
FreeItem
(
VERTEX_ITEM
&
aItem
)
const
{
m_container
->
SetItem
(
&
aItem
);
m_container
->
Erase
();
m_container
->
Delete
(
&
aItem
);
}
...
...
common/gr_basic.cpp
View file @
886a3e93
...
...
@@ -1488,12 +1488,12 @@ bool ColorIsLight( EDA_COLOR_T aColor )
EDA_COLOR_T
ColorFindNearest
(
const
wxColour
&
aColor
)
{
EDA_COLOR_T
candidate
=
BLACK
;
return
ColorFindNearest
(
aColor
.
Red
(),
aColor
.
Green
(),
aColor
.
Blue
()
);
}
// These are ints because we will subtract them later
int
r
=
aColor
.
Red
();
int
g
=
aColor
.
Green
();
int
b
=
aColor
.
Blue
();
EDA_COLOR_T
ColorFindNearest
(
int
aR
,
int
aG
,
int
aB
)
{
EDA_COLOR_T
candidate
=
BLACK
;
/* Find the 'nearest' color in the palette. This is fun. There is
a gazilion of metrics for the color space and no one of the
...
...
@@ -1511,11 +1511,11 @@ EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
for
(
EDA_COLOR_T
trying
=
BLACK
;
trying
<
NBCOLORS
;
trying
=
NextColor
(
trying
)
)
{
const
StructColors
&
c
=
g_ColorRefs
[
trying
];
int
distance
=
(
r
-
c
.
m_Red
)
*
(
r
-
c
.
m_Red
)
+
(
g
-
c
.
m_Green
)
*
(
g
-
c
.
m_Green
)
+
(
b
-
c
.
m_Blue
)
*
(
b
-
c
.
m_Blue
);
if
(
distance
<
nearest_distance
&&
c
.
m_Red
>=
r
&&
c
.
m_Green
>=
g
&&
c
.
m_Blue
>=
b
)
int
distance
=
(
aR
-
c
.
m_Red
)
*
(
aR
-
c
.
m_Red
)
+
(
aG
-
c
.
m_Green
)
*
(
aG
-
c
.
m_Green
)
+
(
aB
-
c
.
m_Blue
)
*
(
aB
-
c
.
m_Blue
);
if
(
distance
<
nearest_distance
&&
c
.
m_Red
>=
aR
&&
c
.
m_Green
>=
aG
&&
c
.
m_Blue
>=
aB
)
{
nearest_distance
=
distance
;
candidate
=
trying
;
...
...
common/painter.cpp
View file @
886a3e93
...
...
@@ -32,13 +32,14 @@ using namespace KiGfx;
RENDER_SETTINGS
::
RENDER_SETTINGS
()
{
// Set the default initial values
m_highlightFactor
=
0.5
;
m_selectFactor
=
0.5
;
m_layerOpacity
=
0.8
;
m_highlightEnabled
=
false
;
m_hiContrastEnabled
=
false
;
m_hiContrastFactor
=
0.2
;
m_outlineWidth
=
1
;
m_highlightFactor
=
0.5
;
m_selectFactor
=
0.5
;
m_layerOpacity
=
0.8
;
m_highlightEnabled
=
false
;
m_hiContrastEnabled
=
false
;
m_hiContrastFactor
=
0.2
;
m_outlineWidth
=
1
;
m_worksheetLineWidth
=
100000
;
// Store the predefined colors used in KiCad in format used by GAL
for
(
int
i
=
0
;
i
<
NBCOLORS
;
i
++
)
...
...
@@ -64,14 +65,13 @@ void RENDER_SETTINGS::update()
PAINTER
::
PAINTER
(
GAL
*
aGal
)
:
m_gal
(
aGal
),
m_
settings
(
NULL
),
m_
brightenedColor
(
0.0
,
1.0
,
0.0
,
0.9
)
m_gal
(
aGal
),
m_brightenedColor
(
0.0
,
1.0
,
0.0
,
0.9
)
{
}
PAINTER
::~
PAINTER
()
{
delete
m_settings
;
}
...
...
@@ -91,7 +91,7 @@ void PAINTER::DrawBrightened( const VIEW_ITEM* aItem )
m_gal
->
PushDepth
();
m_gal
->
SetLayerDepth
(
-
1.0
);
// Draw
semitransparent box
that marks items as brightened
// Draw
an outline
that marks items as brightened
m_gal
->
SetIsStroke
(
true
);
m_gal
->
SetLineWidth
(
100000.0
);
m_gal
->
SetStrokeColor
(
m_brightenedColor
);
...
...
common/tool/context_menu.cpp
View file @
886a3e93
...
...
@@ -47,7 +47,7 @@ public:
else
if
(
type
==
wxEVT_COMMAND_MENU_SELECTED
)
evt
=
TOOL_EVENT
(
TC_Command
,
TA_ContextMenuChoice
,
aEvent
.
GetId
()
);
if
(
m_menu
->
m_tool
)
if
(
m_menu
->
m_tool
)
m_menu
->
m_tool
->
GetManager
()
->
ProcessEvent
(
evt
);
}
...
...
common/tool/tool_dispatcher.cpp
View file @
886a3e93
...
...
@@ -41,6 +41,8 @@
using
boost
::
optional
;
const
wxEventType
TOOL_DISPATCHER
::
EVT_REFRESH_MOUSE
=
wxNewEventType
();
struct
TOOL_DISPATCHER
::
ButtonState
{
ButtonState
(
TOOL_MouseButtons
aButton
,
const
wxEventType
&
aDownEvent
,
...
...
@@ -119,14 +121,16 @@ int TOOL_DISPATCHER::decodeModifiers( const wxKeyboardState* aState ) const
return
mods
;
}
wxPoint
TOOL_DISPATCHER
::
getCurrentMousePos
()
wxPoint
TOOL_DISPATCHER
::
getCurrentMousePos
()
const
{
wxPoint
msp
=
wxGetMousePosition
()
;
wxPoint
winp
=
m_editFrame
->
GetGalCanvas
()
->
GetScreenPosition
();
wxPoint
msp
=
wxGetMousePosition
()
;
wxPoint
winp
=
m_editFrame
->
GetGalCanvas
()
->
GetScreenPosition
();
return
wxPoint
(
msp
.
x
-
winp
.
x
,
msp
.
y
-
winp
.
y
);
return
wxPoint
(
msp
.
x
-
winp
.
x
,
msp
.
y
-
winp
.
y
);
}
bool
TOOL_DISPATCHER
::
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
)
{
ButtonState
*
st
=
m_buttons
[
aIndex
];
...
...
@@ -157,7 +161,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
{
wxLongLong
t
=
wxGetLocalTimeMillis
();
if
(
t
-
st
->
downTimestamp
<
DragTimeThreshold
||
if
(
t
-
st
->
downTimestamp
<
DragTimeThreshold
&&
st
->
dragMaxDelta
<
DragDistanceThreshold
)
isClick
=
true
;
else
...
...
@@ -181,7 +185,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
wxLongLong
t
=
wxGetLocalTimeMillis
();
if
(
t
-
st
->
downTimestamp
>
DragTimeThreshold
&&
st
->
dragMaxDelta
>
DragDistanceThreshold
)
if
(
t
-
st
->
downTimestamp
>
DragTimeThreshold
||
st
->
dragMaxDelta
>
DragDistanceThreshold
)
{
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseDrag
,
args
);
evt
->
SetMouseDragOrigin
(
st
->
dragOrigin
);
...
...
@@ -213,13 +217,11 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if
(
type
==
wxEVT_MOTION
||
type
==
wxEVT_MOUSEWHEEL
||
type
==
wxEVT_LEFT_DOWN
||
type
==
wxEVT_LEFT_UP
||
type
==
wxEVT_MIDDLE_DOWN
||
type
==
wxEVT_MIDDLE_UP
||
type
==
wxEVT_RIGHT_DOWN
||
type
==
wxEVT_RIGHT_UP
)
type
==
wxEVT_RIGHT_DOWN
||
type
==
wxEVT_RIGHT_UP
||
type
==
EVT_REFRESH_MOUSE
)
{
wxMouseEvent
*
me
=
static_cast
<
wxMouseEvent
*>
(
&
aEvent
);
pos
=
getView
()
->
ToWorld
(
getCurrentMousePos
()
);
if
(
pos
!=
m_lastMousePos
)
if
(
pos
!=
m_lastMousePos
||
type
==
EVT_REFRESH_MOUSE
)
{
motion
=
true
;
m_lastMousePos
=
pos
;
...
...
@@ -262,7 +264,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
}
void
TOOL_DISPATCHER
::
DispatchWxCommand
(
wxCommandEvent
&
aEvent
)
void
TOOL_DISPATCHER
::
DispatchWxCommand
(
wxCommandEvent
&
aEvent
)
{
bool
activateTool
=
false
;
std
::
string
toolName
;
...
...
common/tool/tool_manager.cpp
View file @
886a3e93
...
...
@@ -82,13 +82,25 @@ struct TOOL_MANAGER::TOOL_STATE
TOOL_MANAGER
::
TOOL_MANAGER
()
:
m_model
(
NULL
),
m_view
(
NULL
)
m_model
(
NULL
),
m_view
(
NULL
)
{
}
TOOL_MANAGER
::~
TOOL_MANAGER
()
{
std
::
map
<
TOOL_BASE
*
,
TOOL_STATE
*>::
iterator
it
,
it_end
;
for
(
it
=
m_toolState
.
begin
(),
it_end
=
m_toolState
.
end
();
it
!=
it_end
;
++
it
)
{
delete
it
->
second
->
cofunc
;
// delete cofunction
delete
it
->
second
;
// delete TOOL_STATE
delete
it
->
first
;
// delete the tool itself
}
}
void
TOOL_MANAGER
::
RegisterTool
(
TOOL_BASE
*
aTool
)
{
TOOL_STATE
*
st
=
new
TOOL_STATE
;
...
...
@@ -282,13 +294,13 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
if
(
st
->
contextMenuTrigger
!=
CMENU_OFF
)
{
if
(
st
->
contextMenuTrigger
==
CMENU_BUTTON
&&
!
aEvent
.
IsClick
(
MB_Right
)
)
if
(
st
->
contextMenuTrigger
==
CMENU_BUTTON
&&
!
aEvent
.
IsClick
(
MB_Right
)
)
break
;
st
->
pendingWait
=
true
;
st
->
waitEvents
=
TOOL_EVENT
(
TC_Any
,
TA_Any
);
if
(
st
->
contextMenuTrigger
==
CMENU_NOW
)
if
(
st
->
contextMenuTrigger
==
CMENU_NOW
)
st
->
contextMenuTrigger
=
CMENU_OFF
;
GetEditFrame
()
->
PopupMenu
(
st
->
contextMenu
->
GetMenu
()
);
...
...
common/view/view.cpp
View file @
886a3e93
...
...
@@ -41,7 +41,7 @@
using
namespace
KiGfx
;
VIEW
::
VIEW
(
bool
aIsDynamic
)
:
m_enableOrderModifier
(
fals
e
),
m_enableOrderModifier
(
tru
e
),
m_scale
(
1.0
),
m_painter
(
NULL
),
m_gal
(
NULL
),
...
...
@@ -80,7 +80,6 @@ void VIEW::AddLayer( int aLayer, bool aDisplayOnly )
m_layers
[
aLayer
].
items
=
new
VIEW_RTREE
();
m_layers
[
aLayer
].
renderingOrder
=
aLayer
;
m_layers
[
aLayer
].
enabled
=
true
;
m_layers
[
aLayer
].
isDirty
=
false
;
m_layers
[
aLayer
].
displayOnly
=
aDisplayOnly
;
m_layers
[
aLayer
].
target
=
TARGET_CACHED
;
}
...
...
@@ -100,7 +99,7 @@ void VIEW::Add( VIEW_ITEM* aItem )
{
VIEW_LAYER
&
l
=
m_layers
[
layers
[
i
]];
l
.
items
->
Insert
(
aItem
);
l
.
isDirty
=
true
;
MarkTargetDirty
(
l
.
target
)
;
}
if
(
m_dynamic
)
...
...
@@ -120,7 +119,6 @@ void VIEW::Remove( VIEW_ITEM* aItem )
{
VIEW_LAYER
&
l
=
m_layers
[
layers
[
i
]];
l
.
items
->
Remove
(
aItem
);
l
.
isDirty
=
true
;
}
}
...
...
@@ -370,7 +368,7 @@ struct VIEW::updateItemsColor
void
operator
()(
VIEW_ITEM
*
aItem
)
{
// Obtain the color that should be used for coloring the item
const
COLOR4D
color
=
painter
->
GetColor
(
aItem
,
layer
);
const
COLOR4D
color
=
painter
->
Get
Settings
()
->
Get
Color
(
aItem
,
layer
);
int
group
=
aItem
->
getGroup
(
layer
);
if
(
group
>=
0
)
...
...
@@ -415,6 +413,8 @@ void VIEW::UpdateAllLayersColor()
updateItemsColor
visitor
(
l
->
id
,
m_painter
,
m_gal
);
l
->
items
->
Query
(
r
,
visitor
);
}
MarkDirty
();
}
...
...
@@ -525,6 +525,8 @@ void VIEW::UpdateAllLayersOrder()
{
ChangeLayerDepth
(
l
.
first
,
l
.
second
.
renderingOrder
);
}
MarkDirty
();
}
...
...
@@ -564,8 +566,6 @@ void VIEW::redrawRect( const BOX2I& aRect )
m_gal
->
SetLayerDepth
(
l
->
renderingOrder
);
l
->
items
->
Query
(
aRect
,
drawFunc
);
}
l
->
isDirty
=
false
;
}
}
...
...
@@ -586,7 +586,7 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const
group
=
m_gal
->
BeginGroup
();
aItem
->
setGroup
(
aLayer
,
group
);
if
(
!
m_painter
->
Draw
(
aItem
,
aLayer
)
)
aItem
->
ViewDraw
(
aLayer
,
m_gal
,
BOX2I
()
);
// Alternative drawing method
aItem
->
ViewDraw
(
aLayer
,
m_gal
);
// Alternative drawing method
m_gal
->
EndGroup
();
}
}
...
...
@@ -594,7 +594,7 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const
{
// Immediate mode
if
(
!
m_painter
->
Draw
(
aItem
,
aLayer
)
)
aItem
->
ViewDraw
(
aLayer
,
m_gal
,
BOX2I
()
);
// Alternative drawing method
aItem
->
ViewDraw
(
aLayer
,
m_gal
);
// Alternative drawing method
}
// Draws a bright contour around the item
...
...
@@ -672,7 +672,8 @@ struct VIEW::recacheLayer
{
int
group
=
gal
->
BeginGroup
();
aItem
->
setGroup
(
layer
,
group
);
view
->
m_painter
->
Draw
(
static_cast
<
EDA_ITEM
*>
(
aItem
),
layer
);
if
(
!
view
->
m_painter
->
Draw
(
aItem
,
layer
)
)
aItem
->
ViewDraw
(
layer
,
gal
);
// Alternative drawing method
gal
->
EndGroup
();
}
else
...
...
@@ -709,7 +710,7 @@ void VIEW::Clear()
}
void
VIEW
::
Prepare
Targets
()
void
VIEW
::
Clear
Targets
()
{
if
(
IsTargetDirty
(
TARGET_CACHED
)
||
IsTargetDirty
(
TARGET_NONCACHED
)
)
{
...
...
@@ -810,8 +811,7 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
}
// Mark those layers as dirty, so the VIEW will be refreshed
m_layers
[
layerId
].
isDirty
=
true
;
MarkTargetDirty
(
m_layers
[
layerId
].
target
);
// TODO remove?
MarkTargetDirty
(
m_layers
[
layerId
].
target
);
}
}
...
...
@@ -836,7 +836,7 @@ void VIEW::updateItemColor( VIEW_ITEM* aItem, int aLayer )
wxASSERT
(
(
unsigned
)
aLayer
<
m_layers
.
size
()
);
// Obtain the color that should be used for coloring the item on the specific layerId
const
COLOR4D
color
=
m_painter
->
GetColor
(
aItem
,
aLayer
);
const
COLOR4D
color
=
m_painter
->
Get
Settings
()
->
Get
Color
(
aItem
,
aLayer
);
int
group
=
aItem
->
getGroup
(
aLayer
);
// Change the color, only if it has group assigned
...
...
@@ -871,7 +871,7 @@ void VIEW::updateBbox( VIEW_ITEM* aItem )
VIEW_LAYER
&
l
=
m_layers
[
layers
[
i
]];
l
.
items
->
Remove
(
aItem
);
l
.
items
->
Insert
(
aItem
);
l
.
isDirty
=
true
;
MarkTargetDirty
(
l
.
target
)
;
}
}
...
...
@@ -915,7 +915,7 @@ void VIEW::RecacheAllItems( bool aImmediately )
m_gal
->
SetLayerDepth
(
l
->
renderingOrder
);
recacheLayer
visitor
(
this
,
m_gal
,
l
->
id
,
aImmediately
);
l
->
items
->
Query
(
r
,
visitor
);
l
->
isDirty
=
true
;
MarkTargetDirty
(
l
->
target
)
;
}
}
...
...
@@ -936,12 +936,5 @@ bool VIEW::IsTargetDirty( int aTarget ) const
if
(
m_dirtyTargets
[
aTarget
]
)
return
true
;
// Check if any of layers belonging to the target is dirty
BOOST_FOREACH
(
VIEW_LAYER
*
l
,
m_orderedLayers
)
{
if
(
l
->
target
==
aTarget
&&
l
->
isDirty
)
return
true
;
}
return
false
;
}
common/view/view_group.cpp
View file @
886a3e93
...
...
@@ -70,6 +70,7 @@ void VIEW_GROUP::Clear()
m_items
.
clear
();
}
void
VIEW_GROUP
::
FreeItems
()
{
BOOST_FOREACH
(
VIEW_ITEM
*
item
,
m_items
)
...
...
@@ -79,6 +80,7 @@ void VIEW_GROUP::FreeItems()
m_items
.
clear
();
}
unsigned
int
VIEW_GROUP
::
GetSize
()
const
{
return
m_items
.
size
();
...
...
@@ -93,7 +95,7 @@ const BOX2I VIEW_GROUP::ViewBBox() const
}
void
VIEW_GROUP
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
,
const
BOX2I
&
aVisibleArea
)
const
void
VIEW_GROUP
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
{
PAINTER
*
painter
=
m_view
->
GetPainter
();
...
...
@@ -111,7 +113,7 @@ void VIEW_GROUP::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea ) co
aGal
->
SetLayerDepth
(
m_view
->
GetLayerOrder
(
layers
[
i
]
)
);
if
(
!
painter
->
Draw
(
item
,
layers
[
i
]
)
)
item
->
ViewDraw
(
layers
[
i
],
aGal
,
aVisibleArea
);
// Alternative drawing method
item
->
ViewDraw
(
layers
[
i
],
aGal
);
// Alternative drawing method
}
}
}
...
...
common/view/view_item.cpp
View file @
886a3e93
...
...
@@ -48,17 +48,12 @@ void VIEW_ITEM::ViewSetVisible( bool aIsVisible )
}
void
VIEW_ITEM
::
ViewUpdate
(
int
aUpdateFlags
,
bool
aForceImmediateRedraw
)
void
VIEW_ITEM
::
ViewUpdate
(
int
aUpdateFlags
)
{
if
(
!
m_view
)
return
;
m_view
->
invalidateItem
(
this
,
aUpdateFlags
);
if
(
aForceImmediateRedraw
)
{
m_view
->
Redraw
();
}
}
...
...
@@ -142,9 +137,3 @@ void VIEW_ITEM::deleteGroups()
m_groups
=
NULL
;
m_groupsSize
=
0
;
}
bool
VIEW_ITEM
::
storesGroups
()
const
{
return
(
m_groupsSize
>
0
);
}
common/view/wx_view_controls.cpp
View file @
886a3e93
...
...
@@ -28,6 +28,7 @@
#include <view/view.h>
#include <view/wx_view_controls.h>
#include <gal/graphics_abstraction_layer.h>
#include <tool/tool_dispatcher.h>
using
namespace
KiGfx
;
...
...
@@ -196,7 +197,10 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir
=
m_view
->
ToWorld
(
dir
,
false
);
m_view
->
SetCenter
(
m_view
->
GetCenter
()
+
dir
*
m_autoPanSpeed
);
m_view
->
MakeDirty
();
// Notify tools that the cursor position has changed in the world coordinates
wxCommandEvent
moveEvent
(
TOOL_DISPATCHER
::
EVT_REFRESH_MOUSE
);
wxPostEvent
(
m_parentPanel
,
moveEvent
);
}
break
;
...
...
common/worksheet.cpp
View file @
886a3e93
...
...
@@ -101,7 +101,7 @@ void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWi
}
wxString
EDA_DRAW_FRAME
::
GetScreenDesc
()
wxString
EDA_DRAW_FRAME
::
GetScreenDesc
()
const
{
// Virtual function. In basic class, returns
// an empty string.
...
...
common/worksheet_item.cpp
0 → 100644
View file @
886a3e93
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file worksheet_item.cpp
* @brief Class that handles properties and drawing of worksheet layout.
*/
#include <worksheet_item.h>
#include <worksheet_shape_builder.h>
#include <gal/graphics_abstraction_layer.h>
#include <painter.h>
#include <layers_id_colors_and_visibility.h>
#include <boost/foreach.hpp>
using
namespace
KiGfx
;
WORKSHEET_ITEM
::
WORKSHEET_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
)
{
m_pageInfo
=
aPageInfo
;
ViewUpdate
(
GEOMETRY
);
}
void
WORKSHEET_ITEM
::
SetTitleBlock
(
const
TITLE_BLOCK
*
aTitleBlock
)
{
m_titleBlock
=
aTitleBlock
;
ViewUpdate
(
GEOMETRY
);
}
const
BOX2I
WORKSHEET_ITEM
::
ViewBBox
()
const
{
BOX2I
bbox
;
if
(
m_pageInfo
!=
NULL
)
{
bbox
.
SetOrigin
(
VECTOR2I
(
0
,
0
)
);
bbox
.
SetEnd
(
VECTOR2I
(
m_pageInfo
->
GetWidthMils
()
*
25400
,
m_pageInfo
->
GetHeightMils
()
*
25400
)
);
}
else
{
bbox
.
SetMaximum
();
}
return
bbox
;
}
void
WORKSHEET_ITEM
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
{
RENDER_SETTINGS
*
settings
=
m_view
->
GetPainter
()
->
GetSettings
();
wxString
fileName
(
m_fileName
);
wxString
sheetName
(
m_sheetName
);
WS_DRAW_ITEM_LIST
drawList
;
drawList
.
SetPenSize
(
settings
->
GetWorksheetLineWidth
()
);
// Sorry, but I don't get this multi #ifdef from include/convert_to_biu.h, so here goes a magic
// number. IU_PER_MILS should be 25400 (as in a different compilation unit), but somehow
// it equals 1 in this case..
drawList
.
SetMilsToIUfactor
(
25400
/* IU_PER_MILS */
);
drawList
.
SetSheetNumber
(
m_sheetNumber
);
drawList
.
SetSheetCount
(
m_sheetCount
);
drawList
.
SetFileName
(
fileName
);
drawList
.
SetSheetName
(
sheetName
);
COLOR4D
color
=
settings
->
GetColor
(
this
,
aLayer
);
EDA_COLOR_T
edaColor
=
ColorFindNearest
(
color
.
r
*
255
,
color
.
g
*
255
,
color
.
b
*
255
);
drawList
.
BuildWorkSheetGraphicList
(
*
m_pageInfo
,
*
m_titleBlock
,
edaColor
,
edaColor
);
// Draw gray line that outlines the sheet size
drawBorder
(
aGal
);
// Draw all the components that make the page layout
WS_DRAW_ITEM_BASE
*
item
=
drawList
.
GetFirst
();
while
(
item
)
{
switch
(
item
->
GetType
()
)
{
case
WS_DRAW_ITEM_BASE
:
:
wsg_line
:
draw
(
static_cast
<
const
WS_DRAW_ITEM_LINE
*>
(
item
),
aGal
);
break
;
case
WS_DRAW_ITEM_BASE
:
:
wsg_rect
:
draw
(
static_cast
<
const
WS_DRAW_ITEM_RECT
*>
(
item
),
aGal
);
break
;
case
WS_DRAW_ITEM_BASE
:
:
wsg_poly
:
draw
(
static_cast
<
const
WS_DRAW_ITEM_POLYGON
*>
(
item
),
aGal
);
break
;
case
WS_DRAW_ITEM_BASE
:
:
wsg_text
:
draw
(
static_cast
<
const
WS_DRAW_ITEM_TEXT
*>
(
item
),
aGal
);
break
;
}
item
=
drawList
.
GetNext
();
}
}
void
WORKSHEET_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
{
aGal
->
SetIsStroke
(
true
);
aGal
->
SetIsFill
(
false
);
aGal
->
SetStrokeColor
(
COLOR4D
(
aItem
->
GetColor
()
)
);
aGal
->
SetLineWidth
(
aItem
->
GetPenWidth
()
);
aGal
->
DrawLine
(
VECTOR2D
(
aItem
->
GetStart
()
),
VECTOR2D
(
aItem
->
GetEnd
()
)
);
}
void
WORKSHEET_ITEM
::
draw
(
const
WS_DRAW_ITEM_RECT
*
aItem
,
GAL
*
aGal
)
const
{
aGal
->
SetIsStroke
(
true
);
aGal
->
SetIsFill
(
false
);
aGal
->
SetStrokeColor
(
COLOR4D
(
aItem
->
GetColor
()
)
);
aGal
->
SetLineWidth
(
aItem
->
GetPenWidth
()
);
aGal
->
DrawRectangle
(
VECTOR2D
(
aItem
->
GetStart
()
),
VECTOR2D
(
aItem
->
GetEnd
()
)
);
}
void
WORKSHEET_ITEM
::
draw
(
const
WS_DRAW_ITEM_POLYGON
*
aItem
,
GAL
*
aGal
)
const
{
std
::
deque
<
VECTOR2D
>
corners
;
BOOST_FOREACH
(
wxPoint
point
,
aItem
->
m_Corners
)
{
corners
.
push_back
(
VECTOR2D
(
point
)
);
}
if
(
aItem
->
IsFilled
()
)
{
aGal
->
SetFillColor
(
COLOR4D
(
aItem
->
GetColor
()
)
);
aGal
->
SetIsFill
(
true
);
aGal
->
SetIsStroke
(
false
);
aGal
->
DrawPolygon
(
corners
);
}
else
{
aGal
->
SetStrokeColor
(
COLOR4D
(
aItem
->
GetColor
()
)
);
aGal
->
SetIsFill
(
false
);
aGal
->
SetIsStroke
(
true
);
aGal
->
SetLineWidth
(
aItem
->
GetPenWidth
()
);
aGal
->
DrawPolyline
(
corners
);
}
}
void
WORKSHEET_ITEM
::
draw
(
const
WS_DRAW_ITEM_TEXT
*
aItem
,
GAL
*
aGal
)
const
{
VECTOR2D
position
(
aItem
->
GetTextPosition
().
x
,
aItem
->
GetTextPosition
().
y
);
aGal
->
SetStrokeColor
(
COLOR4D
(
aItem
->
GetColor
()
)
);
aGal
->
SetLineWidth
(
aItem
->
GetThickness
()
);
aGal
->
SetTextAttributes
(
aItem
);
aGal
->
StrokeText
(
std
::
string
(
aItem
->
GetText
().
mb_str
()
),
position
,
0.0
);
}
void
WORKSHEET_ITEM
::
drawBorder
(
GAL
*
aGal
)
const
{
VECTOR2D
origin
=
VECTOR2D
(
0.0
,
0.0
);
VECTOR2D
end
=
VECTOR2D
(
m_pageInfo
->
GetWidthMils
()
*
25400
,
m_pageInfo
->
GetHeightMils
()
*
25400
);
aGal
->
SetIsStroke
(
true
);
aGal
->
SetIsFill
(
false
);
aGal
->
SetStrokeColor
(
COLOR4D
(
0.5
,
0.5
,
0.5
,
1.0
)
);
aGal
->
DrawRectangle
(
origin
,
end
);
}
eeschema/dialogs/dialog_edit_component_in_schematic.cpp
View file @
886a3e93
...
...
@@ -188,7 +188,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
void
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
OnListItemDeselected
(
wxListEvent
&
event
)
{
D
(
printf
(
"OnListItemDeselected()
\n
"
);
)
D
BG
(
printf
(
"OnListItemDeselected()
\n
"
);
)
if
(
!
m_skipCopyFromPanel
)
{
...
...
@@ -200,7 +200,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnListItemDeselected( wxListEvent& even
void
DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
::
OnListItemSelected
(
wxListEvent
&
event
)
{
D
(
printf
(
"OnListItemSelected()
\n
"
);
)
D
BG
(
printf
(
"OnListItemSelected()
\n
"
);
)
// remember the selected row, statically
s_SelectedRow
=
event
.
GetIndex
();
...
...
@@ -448,7 +448,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::moveUpButtonHandler( wxCommandEvent& ev
// and in the fieldListCtrl
SCH_FIELD
tmp
=
m_FieldsBuf
[
fieldNdx
-
1
];
D
(
printf
(
"tmp.m_Text=
\"
%s
\"
tmp.m_Name=
\"
%s
\"\n
"
,
D
BG
(
printf
(
"tmp.m_Text=
\"
%s
\"
tmp.m_Name=
\"
%s
\"\n
"
,
TO_UTF8
(
tmp
.
GetText
()
),
TO_UTF8
(
tmp
.
GetName
(
false
)
)
);
)
m_FieldsBuf
[
fieldNdx
-
1
]
=
m_FieldsBuf
[
fieldNdx
];
...
...
@@ -866,12 +866,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
if
(
mirror
==
CMP_MIRROR_X
)
{
mirrorRadioBox
->
SetSelection
(
1
);
D
(
printf
(
"mirror=X,1
\n
"
);
)
D
BG
(
printf
(
"mirror=X,1
\n
"
);
)
}
else
if
(
mirror
==
CMP_MIRROR_Y
)
{
mirrorRadioBox
->
SetSelection
(
2
);
D
(
printf
(
"mirror=Y,2
\n
"
);
)
D
BG
(
printf
(
"mirror=Y,2
\n
"
);
)
}
else
mirrorRadioBox
->
SetSelection
(
0
);
...
...
@@ -891,7 +891,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel()
// Show the "Parts Locked" option?
if
(
!
m_LibEntry
||
!
m_LibEntry
->
UnitsLocked
()
)
{
D
(
printf
(
"partsAreLocked->false
\n
"
);
)
D
BG
(
printf
(
"partsAreLocked->false
\n
"
);
)
partsAreLockedLabel
->
Show
(
false
);
}
...
...
eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp
View file @
886a3e93
...
...
@@ -472,7 +472,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
// fixed fields:
for
(
int
i
=
0
;
i
<
MANDATORY_FIELDS
;
++
i
)
{
D
(
printf
(
"add fixed:%s
\n
"
,
TO_UTF8
(
cmpFields
[
i
].
GetName
()
)
);
)
D
BG
(
printf
(
"add fixed:%s
\n
"
,
TO_UTF8
(
cmpFields
[
i
].
GetName
()
)
);
)
m_FieldsBuf
.
push_back
(
cmpFields
[
i
]
);
}
...
...
@@ -497,7 +497,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
// values from the component will be set.
if
(
!
libField
)
{
D
(
printf
(
"add template:%s
\n
"
,
TO_UTF8
(
it
->
m_Name
)
);
)
D
BG
(
printf
(
"add template:%s
\n
"
,
TO_UTF8
(
it
->
m_Name
)
);
)
fld
.
SetName
(
it
->
m_Name
);
fld
.
SetText
(
it
->
m_Value
);
// empty? ok too.
...
...
@@ -509,7 +509,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
}
else
{
D
(
printf
(
"match template:%s
\n
"
,
TO_UTF8
(
libField
->
GetName
()
)
);
)
D
BG
(
printf
(
"match template:%s
\n
"
,
TO_UTF8
(
libField
->
GetName
()
)
);
)
fld
=
*
libField
;
// copy values from component, m_Name too
}
...
...
@@ -525,7 +525,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers()
if
(
!
buf
)
{
D
(
printf
(
"add cmp:%s
\n
"
,
TO_UTF8
(
cmp
->
GetName
()
)
);
)
D
BG
(
printf
(
"add cmp:%s
\n
"
,
TO_UTF8
(
cmp
->
GetName
()
)
);
)
m_FieldsBuf
.
push_back
(
*
cmp
);
}
}
...
...
@@ -721,11 +721,11 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
if
(
field
.
GetId
()
>=
MANDATORY_FIELDS
)
{
wxString
name
=
fieldNameTextCtrl
->
GetValue
();
D
(
printf
(
"name:%s
\n
"
,
TO_UTF8
(
name
)
);
)
D
BG
(
printf
(
"name:%s
\n
"
,
TO_UTF8
(
name
)
);
)
field
.
SetName
(
name
);
}
D
(
printf
(
"setname:%s
\n
"
,
TO_UTF8
(
field
.
GetName
()
)
);
)
D
BG
(
printf
(
"setname:%s
\n
"
,
TO_UTF8
(
field
.
GetName
()
)
);
)
setRowItem
(
fieldNdx
,
field
);
// update fieldListCtrl
...
...
eeschema/eeschema_config.cpp
View file @
886a3e93
...
...
@@ -292,7 +292,7 @@ void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
for
(
unsigned
i
=
0
;
i
<
tfnames
.
size
();
++
i
)
{
D
(
printf
(
"dlg.SetFieldName(%d, '%s')
\n
"
,
i
,
TO_UTF8
(
tfnames
[
i
].
m_Name
)
);)
D
BG
(
printf
(
"dlg.SetFieldName(%d, '%s')
\n
"
,
i
,
TO_UTF8
(
tfnames
[
i
].
m_Name
)
);)
dlg
.
SetFieldName
(
i
,
tfnames
[
i
].
m_Name
);
}
...
...
@@ -680,7 +680,7 @@ void SCH_EDIT_FRAME::LoadSettings()
catch
(
IO_ERROR
&
e
)
{
// @todo show error msg
D
(
printf
(
"templatefieldnames parsing error: '%s'
\n
"
,
D
BG
(
printf
(
"templatefieldnames parsing error: '%s'
\n
"
,
TO_UTF8
(
e
.
errorText
)
);
)
}
}
...
...
@@ -751,7 +751,7 @@ void SCH_EDIT_FRAME::SaveSettings()
m_TemplateFieldNames
.
Format
(
&
sf
,
0
);
D
(
printf
(
"saving formatted template fieldnames:'%s'
\n
"
,
sf
.
GetString
().
c_str
()
);)
D
BG
(
printf
(
"saving formatted template fieldnames:'%s'
\n
"
,
sf
.
GetString
().
c_str
()
);)
wxString
record
=
FROM_UTF8
(
sf
.
GetString
().
c_str
()
);
record
.
Replace
(
wxT
(
"
\n
"
),
wxT
(
""
),
true
);
// strip all newlines
...
...
eeschema/lib_field.cpp
View file @
886a3e93
...
...
@@ -640,7 +640,7 @@ void LIB_FIELD::SetName( const wxString& aName )
// Besides, m_id is a relic that is untrustworthy now.
if
(
m_id
>=
0
&&
m_id
<
MANDATORY_FIELDS
)
{
D
(
printf
(
"trying to set a MANDATORY_FIELD's name
\n
"
);)
D
BG
(
printf
(
"trying to set a MANDATORY_FIELD's name
\n
"
);)
return
;
}
...
...
eeschema/netform.cpp
View file @
886a3e93
...
...
@@ -417,7 +417,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
wxFileName
tmpFile
=
aFullFileName
;
tmpFile
.
SetExt
(
INTERMEDIATE_NETLIST_EXT
);
D
(
printf
(
"tmpFile:'%s'
\n
"
,
TO_UTF8
(
tmpFile
.
GetFullPath
()
)
);)
D
BG
(
printf
(
"tmpFile:'%s'
\n
"
,
TO_UTF8
(
tmpFile
.
GetFullPath
()
)
);)
ret
=
helper
.
WriteGENERICNetList
(
tmpFile
.
GetFullPath
()
);
if
(
!
ret
)
...
...
@@ -435,7 +435,7 @@ bool SCH_EDIT_FRAME::WriteNetListFile( int aFormat, const wxString& aFullFileNam
tmpFile
.
GetFullPath
(),
aFullFileName
);
D
(
printf
(
"commandLine:'%s'
\n
"
,
TO_UTF8
(
commandLine
)
);)
D
BG
(
printf
(
"commandLine:'%s'
\n
"
,
TO_UTF8
(
commandLine
)
);)
ProcessExecute
(
commandLine
,
wxEXEC_SYNC
);
...
...
eeschema/schframe.cpp
View file @
886a3e93
...
...
@@ -324,7 +324,7 @@ SCH_SCREEN* SCH_EDIT_FRAME::GetScreen() const
}
wxString
SCH_EDIT_FRAME
::
GetScreenDesc
()
wxString
SCH_EDIT_FRAME
::
GetScreenDesc
()
const
{
wxString
s
=
m_CurrentSheet
->
PathHumanReadable
();
...
...
eeschema/template_fieldnames.cpp
View file @
886a3e93
...
...
@@ -151,7 +151,7 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName )
{
if
(
m_Fields
[
i
].
m_Name
==
aFieldName
.
m_Name
)
{
D
(
printf
(
"inserting template fieldname:'%s' at %d
\n
"
,
D
BG
(
printf
(
"inserting template fieldname:'%s' at %d
\n
"
,
TO_UTF8
(
aFieldName
.
m_Name
),
i
);
)
m_Fields
[
i
]
=
aFieldName
;
...
...
@@ -159,7 +159,7 @@ int TEMPLATES::AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName )
}
}
// D(printf("appending template fieldname:'%s'\n", aFieldName.m_Name.utf8_str() );)
// D
BG
(printf("appending template fieldname:'%s'\n", aFieldName.m_Name.utf8_str() );)
// the name is legal and not previously added to the config container, append
// it and return its index within the container.
...
...
gerbview/class_aperture_macro.cpp
View file @
886a3e93
...
...
@@ -409,7 +409,7 @@ void AM_PRIMITIVE::DrawBasicShape( GERBER_DRAW_ITEM* aParent,
case
AMP_UNKNOWN
:
default
:
D
(
printf
(
"AM_PRIMITIVE::DrawBasicShape() err: unknown prim id %d
\n
"
,
primitive_id
)
);
D
BG
(
printf
(
"AM_PRIMITIVE::DrawBasicShape() err: unknown prim id %d
\n
"
,
primitive_id
)
);
break
;
}
}
...
...
gerbview/rs274x.cpp
View file @
886a3e93
...
...
@@ -167,7 +167,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if
(
m_GerbMetric
)
conv_scale
/=
25.4
;
// D( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); )
// D
BG
( printf( "%22s: Command <%c%c>\n", __func__, (command >> 8) & 0xFF, command & 0xFF ); )
switch
(
command
)
{
...
...
@@ -521,7 +521,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
m_ImageNegative
=
true
;
else
m_ImageNegative
=
false
;
D
(
printf
(
"%22s: IMAGE_POLARITY m_ImageNegative=%s
\n
"
,
__func__
,
D
BG
(
printf
(
"%22s: IMAGE_POLARITY m_ImageNegative=%s
\n
"
,
__func__
,
m_ImageNegative
?
"true"
:
"false"
);
)
break
;
...
...
@@ -531,7 +531,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
else
GetLayerParams
().
m_LayerNegative
=
false
;
D
(
printf
(
"%22s: LAYER_POLARITY m_LayerNegative=%s
\n
"
,
__func__
,
D
BG
(
printf
(
"%22s: LAYER_POLARITY m_LayerNegative=%s
\n
"
,
__func__
,
GetLayerParams
().
m_LayerNegative
?
"true"
:
"false"
);
)
break
;
...
...
include/colors.h
View file @
886a3e93
...
...
@@ -139,6 +139,14 @@ EDA_COLOR_T ColorByName( const wxChar *aName );
/// Find the nearest color match
EDA_COLOR_T
ColorFindNearest
(
const
wxColour
&
aColor
);
/**
* Find the nearest color match
* @param aR is the red component of the color to be matched (in range 0-255)
* @param aG is the green component of the color to be matched (in range 0-255)
* @param aG is the blue component of the color to be matched (in range 0-255)
*/
EDA_COLOR_T
ColorFindNearest
(
int
aR
,
int
aG
,
int
aB
);
/**
* Check if a color is light i.e. if black would be more readable than
* white on it
...
...
include/gal/color4d.h
View file @
886a3e93
...
...
@@ -28,6 +28,7 @@
#define COLOR4D_H_
#include <colors.h>
#include <cassert>
namespace
KiGfx
{
...
...
@@ -55,6 +56,10 @@ public:
COLOR4D
(
double
aRed
,
double
aGreen
,
double
aBlue
,
double
aAlpha
)
:
r
(
aRed
),
g
(
aGreen
),
b
(
aBlue
),
a
(
aAlpha
)
{
assert
(
r
>=
0
.
0
&&
r
<=
1
.
0
);
assert
(
g
>=
0
.
0
&&
g
<=
1
.
0
);
assert
(
b
>=
0
.
0
&&
b
<=
1
.
0
);
assert
(
a
>=
0
.
0
&&
a
<=
1
.
0
);
}
/**
...
...
@@ -82,6 +87,8 @@ public:
*/
COLOR4D
&
Brighten
(
double
aFactor
)
{
assert
(
aFactor
>=
0
.
0
&&
aFactor
<=
1
.
0
);
r
=
r
*
(
1
.
0
-
aFactor
)
+
aFactor
;
g
=
g
*
(
1
.
0
-
aFactor
)
+
aFactor
;
b
=
b
*
(
1
.
0
-
aFactor
)
+
aFactor
;
...
...
@@ -97,6 +104,8 @@ public:
*/
COLOR4D
&
Darken
(
double
aFactor
)
{
assert
(
aFactor
>=
0
.
0
&&
aFactor
<=
1
.
0
);
r
=
r
*
(
1
.
0
-
aFactor
);
g
=
g
*
(
1
.
0
-
aFactor
);
b
=
b
*
(
1
.
0
-
aFactor
);
...
...
@@ -131,6 +140,8 @@ public:
*/
COLOR4D
Brightened
(
double
aFactor
)
const
{
assert
(
aFactor
>=
0
.
0
&&
aFactor
<=
1
.
0
);
return
COLOR4D
(
r
*
(
1
.
0
-
aFactor
)
+
aFactor
,
g
*
(
1
.
0
-
aFactor
)
+
aFactor
,
b
*
(
1
.
0
-
aFactor
)
+
aFactor
,
...
...
@@ -145,6 +156,8 @@ public:
*/
COLOR4D
Darkened
(
double
aFactor
)
const
{
assert
(
aFactor
>=
0
.
0
&&
aFactor
<=
1
.
0
);
return
COLOR4D
(
r
*
(
1
.
0
-
aFactor
),
g
*
(
1
.
0
-
aFactor
),
b
*
(
1
.
0
-
aFactor
),
...
...
@@ -172,9 +185,25 @@ public:
return
(
r
*
0
.
299
+
g
*
0
.
587
+
b
*
0
.
117
);
}
void
ToHSV
(
double
&
out_h
,
double
&
out_s
,
double
&
out_v
)
const
;
void
FromHSV
(
double
in_h
,
double
in_s
,
double
in_v
);
/**
* Function ToHSV()
* Converts current color (stored in RGB) to HSV format.
*
* @param aOutH is conversion result for hue component.
* @param aOutS is conversion result for saturation component.
* @param aOutV is conversion result for value component.
*/
void
ToHSV
(
double
&
aOutH
,
double
&
aOutS
,
double
&
aOutV
)
const
;
/**
* Function FromHSV()
* Changes currently used color to the one given by hue, saturation and value parameters.
*
* @param aOutH is hue component.
* @param aOutS is saturation component.
* @param aOutV is value component.
*/
void
FromHSV
(
double
aInH
,
double
aInS
,
double
aInV
);
/// @brief Equality operator, are two colors equal
const
bool
operator
==
(
const
COLOR4D
&
aColor
);
...
...
include/gal/graphics_abstraction_layer.h
View file @
886a3e93
...
...
@@ -818,6 +818,9 @@ public:
depthStack
.
pop
();
}
/// Depth level on which the grid is drawn
static
const
int
GRID_DEPTH
=
1024
;
protected
:
std
::
stack
<
double
>
depthStack
;
///< Stored depth values
VECTOR2D
screenSize
;
///< Screen size in screen coordinates
...
...
@@ -884,6 +887,9 @@ protected:
* @param aCursorSize is the size of the cursor.
*/
virtual
void
initCursor
(
int
aCursorSize
)
=
0
;
static
const
int
MIN_DEPTH
=
-
2048
;
static
const
int
MAX_DEPTH
=
2047
;
};
}
// namespace KiGfx
...
...
include/gal/opengl/cached_container.h
View file @
886a3e93
...
...
@@ -36,10 +36,8 @@
#include <map>
#include <set>
#ifdef __WXDEBUG__
// Debug messages verbosity level
// #define CACHED_CONTAINER_TEST 2
#endif
//#define CACHED_CONTAINER_TEST 1
namespace
KiGfx
{
...
...
@@ -54,11 +52,14 @@ public:
///< @copydoc VERTEX_CONTAINER::SetItem()
virtual
void
SetItem
(
VERTEX_ITEM
*
aItem
);
///< @copydoc VERTEX_CONTAINER::FinishItem()
virtual
void
FinishItem
();
///< @copydoc VERTEX_CONTAINER::Allocate()
virtual
VERTEX
*
Allocate
(
unsigned
int
aSize
);
///< @copydoc VERTEX_CONTAINER::
Eras
e()
virtual
void
Erase
(
);
///< @copydoc VERTEX_CONTAINER::
Delet
e()
virtual
void
Delete
(
VERTEX_ITEM
*
aItem
);
///< @copydoc VERTEX_CONTAINER::Clear()
virtual
void
Clear
();
...
...
@@ -130,14 +131,6 @@ protected:
*/
virtual
bool
resizeContainer
(
unsigned
int
aNewSize
);
/**
* Function freeItem()
* frees the space occupied by the item and returns it to the free space pool.
*
* @param aItem is the item to be freed.
*/
virtual
void
freeItem
(
VERTEX_ITEM
*
aItem
);
/**
* Function getPowerOf2()
* returns the nearest power of 2, bigger than aNumber.
...
...
@@ -170,7 +163,7 @@ private:
}
/// Debug & test functions
#if
def CACHED_CONTAINER_TEST
#if
CACHED_CONTAINER_TEST > 0
void
showFreeChunks
();
void
showReservedChunks
();
void
test
();
...
...
include/gal/opengl/noncached_container.h
View file @
886a3e93
...
...
@@ -50,8 +50,8 @@ public:
///< @copydoc VERTEX_CONTAINER::Allocate()
virtual
VERTEX
*
Allocate
(
unsigned
int
aSize
);
///< @copydoc VERTEX_CONTAINER::
Eras
e()
v
irtual
void
Erase
()
;
///< @copydoc VERTEX_CONTAINER::
Delet
e()
v
oid
Delete
(
VERTEX_ITEM
*
aItem
)
{}
;
///< @copydoc VERTEX_CONTAINER::Clear()
virtual
void
Clear
();
...
...
include/gal/opengl/vertex_container.h
View file @
886a3e93
...
...
@@ -54,6 +54,12 @@ public:
*/
virtual
void
SetItem
(
VERTEX_ITEM
*
aItem
)
=
0
;
/**
* Function FinishItem()
* does the cleaning after adding an item.
*/
virtual
void
FinishItem
()
{};
/**
* Function Allocate()
* returns allocated space (possibly resizing the reserved memory chunk or allocating a new
...
...
@@ -66,10 +72,12 @@ public:
virtual
VERTEX
*
Allocate
(
unsigned
int
aSize
)
=
0
;
/**
* Function Erase()
* erases all vertices associated with the current item (set by SetItem()).
* Function Delete()
* erases the selected item.
*
* @param aItem is the item to be erased.
*/
virtual
void
Erase
(
)
=
0
;
virtual
void
Delete
(
VERTEX_ITEM
*
aItem
)
=
0
;
/**
* Function Clear()
...
...
include/gal/opengl/vertex_manager.h
View file @
886a3e93
...
...
@@ -232,6 +232,12 @@ public:
*/
void
SetItem
(
VERTEX_ITEM
&
aItem
)
const
;
/**
* Function FinishItem()
* does the cleaning after adding an item.
*/
void
FinishItem
()
const
;
/**
* Function FreeItem()
* frees the memory occupied by the item, so it is no longer stored in the container.
...
...
include/layers_id_colors_and_visibility.h
View file @
886a3e93
...
...
@@ -241,6 +241,7 @@ enum PCB_VISIBLE
PADS_NETNAMES_VISIBLE
,
SELECTION
,
WORKSHEET
,
GP_OVERLAY
,
// General purpose overlay
END_PCB_VISIBLE_LIST
// sentinel
...
...
@@ -290,7 +291,8 @@ const LAYER_NUM GalLayerOrder[] =
ITEM_GAL_LAYER
(
LAYER_1_NETNAMES_VISIBLE
),
LAYER_N_BACK
,
ADHESIVE_N_BACK
,
SOLDERPASTE_N_BACK
,
SILKSCREEN_N_BACK
,
ITEM_GAL_LAYER
(
MOD_TEXT_BK_VISIBLE
)
ITEM_GAL_LAYER
(
MOD_TEXT_BK_VISIBLE
),
ITEM_GAL_LAYER
(
WORKSHEET
)
};
/**
...
...
include/math/box2.h
View file @
886a3e93
...
...
@@ -68,7 +68,7 @@ public:
m_Size
(
aSize
)
{
Normalize
();
}
}
void
SetMaximum
()
{
...
...
@@ -418,10 +418,10 @@ public:
{
ecoord_type
x2
=
m_Pos
.
x
+
m_Size
.
x
;
ecoord_type
y2
=
m_Pos
.
y
+
m_Size
.
y
;
ecoord_type
xdiff
=
std
::
max
(
aP
.
x
<
m_Pos
.
x
?
m_Pos
.
x
-
aP
.
x
:
m_Pos
.
x
-
x2
,
(
ecoord_type
)
0
);
ecoord_type
ydiff
=
std
::
max
(
aP
.
y
<
m_Pos
.
y
?
m_Pos
.
y
-
aP
.
y
:
m_Pos
.
y
-
y2
,
(
ecoord_type
)
0
);
ecoord_type
xdiff
=
std
::
max
(
aP
.
x
<
m_Pos
.
x
?
m_Pos
.
x
-
aP
.
x
:
m_Pos
.
x
-
x2
,
(
ecoord_type
)
0
);
ecoord_type
ydiff
=
std
::
max
(
aP
.
y
<
m_Pos
.
y
?
m_Pos
.
y
-
aP
.
y
:
m_Pos
.
y
-
y2
,
(
ecoord_type
)
0
);
return
xdiff
*
xdiff
+
ydiff
*
ydiff
;
}
}
ecoord_type
Distance
(
const
Vec
&
aP
)
const
{
...
...
include/math/vector2d.h
View file @
886a3e93
...
...
@@ -54,7 +54,7 @@ template <>
struct
VECTOR2_TRAITS
<
int
>
{
typedef
int64_t
extended_type
;
static
const
extended_type
ECOORD_MAX
=
0x7fffffffffffffffULL
;
static
const
extended_type
ECOORD_MAX
=
0x7fffffffffffffffULL
;
static
const
extended_type
ECOORD_MIN
=
0x8000000000000000ULL
;
};
...
...
include/painter.h
View file @
886a3e93
...
...
@@ -32,7 +32,8 @@
#include <gal/color4d.h>
#include <colors.h>
#include <worksheet_shape_builder.h>
#include <boost/shared_ptr.hpp>
class
EDA_ITEM
;
class
COLORS_DESIGN_SETTINGS
;
...
...
@@ -113,6 +114,21 @@ public:
m_hiContrastEnabled
=
aEnabled
;
}
/**
* Function GetColor
* Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer
* using currently used render settings.
* @param aItem is the VIEW_ITEM.
* @param aLayer is the layer.
* @return The color.
*/
virtual
const
COLOR4D
&
GetColor
(
const
VIEW_ITEM
*
aItem
,
int
aLayer
)
const
=
0
;
float
GetWorksheetLineWidth
()
const
{
return
m_worksheetLineWidth
;
}
protected
:
/**
* Function update
...
...
@@ -137,6 +153,7 @@ protected:
float
m_selectFactor
;
///< Specifies how color of selected items is changed
float
m_layerOpacity
;
///< Determines opacity of all layers
float
m_outlineWidth
;
///< Line width used when drawing outlines
float
m_worksheetLineWidth
;
///< Line width used when drawing worksheet
/// Map of colors that were usually used for display
std
::
map
<
EDA_COLOR_T
,
COLOR4D
>
m_legacyColorMap
;
...
...
@@ -177,10 +194,7 @@ public:
*/
virtual
void
ApplySettings
(
RENDER_SETTINGS
*
aSettings
)
{
if
(
m_settings
)
delete
m_settings
;
m_settings
=
aSettings
;
m_settings
.
reset
(
aSettings
);
}
/**
...
...
@@ -195,9 +209,9 @@ public:
* Returns pointer to current settings that are going to be used when drawing items.
* @return Current rendering settings.
*/
virtual
RENDER_SETTINGS
*
GetSettings
()
virtual
RENDER_SETTINGS
*
GetSettings
()
const
{
return
m_settings
;
return
m_settings
.
get
()
;
}
/**
...
...
@@ -217,23 +231,13 @@ public:
*/
virtual
void
DrawBrightened
(
const
VIEW_ITEM
*
aItem
);
/**
* Function GetColor
* Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer
* using currently used render settings.
* @param aItem is the VIEW_ITEM.
* @param aLayer is the layer.
* @return The color.
*/
virtual
const
COLOR4D
&
GetColor
(
const
VIEW_ITEM
*
aItem
,
int
aLayer
)
=
0
;
protected
:
/// Instance of graphic abstraction layer that gives an interface to call
/// commands used to draw (eg. DrawLine, DrawCircle, etc.)
GAL
*
m_gal
;
/// Colors and display modes settings that are going to be used when drawing items.
RENDER_SETTINGS
*
m_settings
;
boost
::
shared_ptr
<
RENDER_SETTINGS
>
m_settings
;
/// Color of brightened item frame
COLOR4D
m_brightenedColor
;
...
...
include/tool/tool_dispatcher.h
View file @
886a3e93
...
...
@@ -65,6 +65,9 @@ public:
virtual
void
DispatchWxEvent
(
wxEvent
&
aEvent
);
virtual
void
DispatchWxCommand
(
wxCommandEvent
&
aEvent
);
/// Event that forces mouse move event in the dispatcher
static
const
wxEventType
EVT_REFRESH_MOUSE
;
private
:
static
const
int
MouseButtonCount
=
3
;
static
const
int
DragTimeThreshold
=
300
;
...
...
@@ -73,7 +76,7 @@ private:
bool
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
);
bool
handlePopupMenu
(
wxEvent
&
aEvent
);
wxPoint
getCurrentMousePos
();
wxPoint
getCurrentMousePos
()
const
;
int
decodeModifiers
(
const
wxKeyboardState
*
aState
)
const
;
...
...
include/tool/tool_event.h
View file @
886a3e93
...
...
@@ -229,6 +229,16 @@ public:
return
m_keyCode
;
}
bool
IsKeyUp
()
const
{
return
m_actions
==
TA_KeyUp
;
}
bool
IsKeyDown
()
const
{
return
m_actions
==
TA_KeyDown
;
}
void
Ignore
();
void
SetMouseDragOrigin
(
const
VECTOR2D
&
aP
)
...
...
include/view/view.h
View file @
886a3e93
...
...
@@ -377,10 +377,10 @@ public:
void
UpdateAllLayersOrder
();
/**
* Function
Prepare
Targets()
* Function
Clear
Targets()
* Clears targets that are marked as dirty.
*/
void
Prepare
Targets
();
void
Clear
Targets
();
/**
* Function Redraw()
...
...
@@ -443,9 +443,13 @@ public:
return
(
m_layers
.
at
(
aLayer
).
target
==
TARGET_CACHED
);
}
void
MakeDirty
()
/**
* Function MarkDirty()
* Forces redraw of view on the next rendering.
*/
void
MarkDirty
()
{
for
(
int
i
=
0
;
i
<
TARGETS_NUMBER
;
i
++
)
for
(
int
i
=
0
;
i
<
TARGETS_NUMBER
;
++
i
)
m_dirtyTargets
[
i
]
=
true
;
}
...
...
@@ -455,7 +459,6 @@ private:
struct
VIEW_LAYER
{
bool
enabled
;
///* is the layer to be rendered?
bool
isDirty
;
///* does it contain any dirty items (updated since last redraw)
bool
displayOnly
;
///* is the layer display only?
VIEW_RTREE
*
items
;
///* R-tree indexing all items on this layer.
int
renderingOrder
;
///* rendering order of this layer
...
...
include/view/view_group.h
View file @
886a3e93
...
...
@@ -107,9 +107,8 @@ public:
*
* @param aLayer is the layer which should be drawn.
* @param aGal is the GAL that should be used for drawing.
* @param aVisibleArea is limiting the drawing area.
*/
virtual
void
ViewDraw
(
int
aLayer
,
GAL
*
aGal
,
const
BOX2I
&
aVisibleArea
)
const
;
virtual
void
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
;
/**
* Function ViewGetLayers()
...
...
@@ -120,9 +119,6 @@ public:
*/
virtual
void
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
;
/// @copydoc VIEW_ITEM::ViewUpdate()
//virtual void ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw );
/**
* Function SetLayer()
* Sets layer used to draw the group.
...
...
@@ -134,8 +130,18 @@ public:
m_layer
=
aLayer
;
}
/**
* Function FreeItems()
* Frees all the items that were added to the group.
*/
void
FreeItems
();
/**
* Function GetView()
* Returns pointer to the VIEW instance used by items.
*
* @return Pointer to the VIEW instance.
*/
KiGfx
::
VIEW
*
GetView
()
const
{
return
m_view
;
...
...
include/view/view_item.h
View file @
886a3e93
...
...
@@ -70,8 +70,7 @@ public:
ALL
=
0xff
};
VIEW_ITEM
()
:
m_view
(
NULL
),
m_visible
(
true
),
m_groups
(
NULL
),
m_groupsSize
(
0
)
{}
VIEW_ITEM
()
:
m_view
(
NULL
),
m_visible
(
true
),
m_groups
(
NULL
),
m_groupsSize
(
0
)
{}
/**
* Destructor. For dynamic views, removes the item from the view.
...
...
@@ -101,11 +100,8 @@ public:
*
* @param aLayer: current drawing layer
* @param aGal: pointer to the GAL device we are drawing on
* @param aVisibleArea: area (in world space coordinates) that is relevant for drawing. For
* example, when drawing a bitmap, one can clip the blitting area to aVisibleArea, reducing
* drawing time.
*/
virtual
void
ViewDraw
(
int
aLayer
,
GAL
*
aGal
,
const
BOX2I
&
aVisibleArea
)
const
{
};
virtual
void
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
{
};
/**
* Function ViewGetLayers()
...
...
@@ -155,10 +151,8 @@ public:
* this item has changed. For static views calling has no effect.
*
* @param aUpdateFlags: how much the object has changed
* @param aForceImmediateRedraw: when true, the VIEW is redrawn immediately,
* otherwise, it will be redrawn upon next call of VIEW::Update()
*/
virtual
void
ViewUpdate
(
int
aUpdateFlags
=
ALL
,
bool
aForceImmediateRedraw
=
false
);
virtual
void
ViewUpdate
(
int
aUpdateFlags
=
ALL
);
/**
* Function ViewRelease()
...
...
@@ -241,7 +235,10 @@ protected:
*
* @returns true in case it is cached at least for one layer.
*/
virtual
bool
storesGroups
()
const
;
inline
virtual
bool
storesGroups
()
const
{
return
(
m_groupsSize
>
0
);
}
/// Stores layer numbers used by the item.
std
::
bitset
<
VIEW
::
VIEW_MAX_LAYERS
>
m_layers
;
...
...
@@ -258,7 +255,7 @@ protected:
m_layers
.
reset
();
for
(
int
i
=
0
;
i
<
aCount
;
++
i
)
m_layers
.
set
(
aLayers
[
i
]
);
m_layers
.
set
(
aLayers
[
i
]
);
}
};
...
...
include/worksheet_item.h
0 → 100644
View file @
886a3e93
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file worksheet_item.h
* @brief Class that handles properties and drawing of worksheet layout.
*/
#ifndef WORKSHEET_ITEM_H
#define WORKSHEET_ITEM_H
#include <base_struct.h>
class
BOARD
;
class
PAGE_INFO
;
class
TITLE_BLOCK
;
class
WS_DRAW_ITEM_LINE
;
class
WS_DRAW_ITEM_RECT
;
class
WS_DRAW_ITEM_POLYGON
;
class
WS_DRAW_ITEM_TEXT
;
namespace
KiGfx
{
class
GAL
;
class
WORKSHEET_ITEM
:
public
EDA_ITEM
{
public
:
WORKSHEET_ITEM
(
const
std
::
string
&
aFileName
,
const
std
::
string
&
aSheetName
,
const
PAGE_INFO
*
aPageInfo
,
const
TITLE_BLOCK
*
aTitleBlock
);
~
WORKSHEET_ITEM
()
{}
/**
* Function SetFileName()
* Sets the file name displayed in the title block.
*
* @param aFileName is the new file name.
*/
void
SetFileName
(
const
std
::
string
&
aFileName
)
{
m_fileName
=
aFileName
;
ViewUpdate
(
GEOMETRY
);
}
/**
* Function SetSheetName()
* Sets the sheet name displayed in the title block.
*
* @param aSheetName is the new sheet name.
*/
void
SetSheetName
(
const
std
::
string
&
aSheetName
)
{
m_sheetName
=
aSheetName
;
ViewUpdate
(
GEOMETRY
);
}
/**
* Function SetPageInfo()
* Changes the PAGE_INFO object used to draw the worksheet.
*
* @param aPageInfo is the new PAGE_INFO object.
*/
void
SetPageInfo
(
const
PAGE_INFO
*
aPageInfo
);
/**
* Function SetTitleBlock()
* Changes the TITLE_BLOCK object used to draw the worksheet.
*
* @param aTitleBlock is the new TITLE_BLOCK object.
*/
void
SetTitleBlock
(
const
TITLE_BLOCK
*
aTitleBlock
);
/**
* Function SetSheetNumber()
* Changes the sheet number displayed in the title block.
*
* @param aSheetNumber is the new sheet number.
*/
void
SetSheetNumber
(
int
aSheetNumber
)
{
m_sheetNumber
=
aSheetNumber
;
ViewUpdate
(
GEOMETRY
);
}
/**
* Function SetSheetCount()
* Changes the sheets count number displayed in the title block.
*
* @param aSheetCount is the new sheets count number.
*/
void
SetSheetCount
(
int
aSheetCount
)
{
m_sheetCount
=
aSheetCount
;
ViewUpdate
(
GEOMETRY
);
}
/// @copydoc VIEW_ITEM::ViewBBox()
const
BOX2I
ViewBBox
()
const
;
/// @copydoc VIEW_ITEM::ViewDraw()
void
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
;
/// @copydoc VIEW_ITEM::ViewGetLayers()
void
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
;
/// @copydoc EDA_ITEM::Show()
void
Show
(
int
x
,
std
::
ostream
&
st
)
const
{
}
protected
:
/// File name displayed in the title block
std
::
string
m_fileName
;
/// Sheet name displayed in the title block
std
::
string
m_sheetName
;
/// Title block that contains properties of the title block displayed in the worksheet.
const
TITLE_BLOCK
*
m_titleBlock
;
/// Worksheet page information.
const
PAGE_INFO
*
m_pageInfo
;
/// Sheet number displayed in the title block.
int
m_sheetNumber
;
/// Sheets count number displayed in the title block.
int
m_sheetCount
;
// Functions for drawing items that makes a worksheet
void
draw
(
const
WS_DRAW_ITEM_LINE
*
aItem
,
GAL
*
aGal
)
const
;
void
draw
(
const
WS_DRAW_ITEM_RECT
*
aItem
,
GAL
*
aGal
)
const
;
void
draw
(
const
WS_DRAW_ITEM_POLYGON
*
aItem
,
GAL
*
aGal
)
const
;
void
draw
(
const
WS_DRAW_ITEM_TEXT
*
aItem
,
GAL
*
aGal
)
const
;
/// Draws a border that determines the page size.
void
drawBorder
(
GAL
*
aGal
)
const
;
};
}
#endif
/* WORKSHEET_ITEM_H */
include/worksheet_shape_builder.h
View file @
886a3e93
...
...
@@ -108,9 +108,9 @@ public:
}
// Accessors:
int
GetPenWidth
()
{
return
m_penWidth
;
}
const
wxPoint
&
GetStart
()
{
return
m_start
;
}
const
wxPoint
&
GetEnd
()
{
return
m_end
;
}
int
GetPenWidth
()
const
{
return
m_penWidth
;
}
const
wxPoint
&
GetStart
()
const
{
return
m_start
;
}
const
wxPoint
&
GetEnd
()
const
{
return
m_end
;
}
/** The function to draw a WS_DRAW_ITEM_LINE
*/
...
...
@@ -158,9 +158,9 @@ public:
}
// Accessors:
int
GetPenWidth
()
{
return
m_penWidth
;
}
bool
IsFilled
()
{
return
m_fill
;
}
const
wxPoint
&
GetPosition
()
{
return
m_pos
;
}
int
GetPenWidth
()
const
{
return
m_penWidth
;
}
bool
IsFilled
()
const
{
return
m_fill
;
}
const
wxPoint
&
GetPosition
()
const
{
return
m_pos
;
}
/** The function to draw a WS_DRAW_ITEM_POLYGON
*/
...
...
include/wxBasePcbFrame.h
View file @
886a3e93
...
...
@@ -95,8 +95,8 @@ protected:
/// main window.
wxAuiToolBar
*
m_auxiliaryToolBar
;
TOOL_MANAGER
*
m_toolManager
;
TOOL_DISPATCHER
*
m_toolDispatcher
;
TOOL_MANAGER
*
m_toolManager
;
TOOL_DISPATCHER
*
m_toolDispatcher
;
void
updateGridSelectBox
();
void
updateZoomSelectBox
();
...
...
include/wxEeschemaStruct.h
View file @
886a3e93
...
...
@@ -356,7 +356,7 @@ public:
*/
void
OnModify
();
virtual
wxString
GetScreenDesc
();
virtual
wxString
GetScreenDesc
()
const
;
void
InstallConfigFrame
(
wxCommandEvent
&
event
);
...
...
include/wxPcbStruct.h
View file @
886a3e93
...
...
@@ -118,6 +118,7 @@ protected:
// to know the footprint name of components.
void
setupTools
();
void
destroyTools
();
void
onGenericCommand
(
wxCommandEvent
&
aEvent
);
// we'll use lower case function names for private member functions.
...
...
@@ -135,21 +136,13 @@ protected:
* will change the currently active layer to \a aLayer and also
* update the PCB_LAYER_WIDGET.
*/
void
setActiveLayer
(
LAYER_NUM
aLayer
,
bool
doLayerWidgetUpdate
=
true
)
{
(
(
PCB_SCREEN
*
)
GetScreen
()
)
->
m_Active_Layer
=
aLayer
;
setHighContrastLayer
(
aLayer
);
if
(
doLayerWidgetUpdate
)
syncLayerWidgetLayer
();
}
void
setCurrentLayer
(
LAYER_NUM
aLayer
,
bool
doLayerWidgetUpdate
=
true
);
/**
* Function getActiveLayer
* returns the active layer
*/
LAYER_NUM
get
Active
Layer
()
LAYER_NUM
get
Current
Layer
()
{
return
(
(
PCB_SCREEN
*
)
GetScreen
()
)
->
m_Active_Layer
;
}
...
...
@@ -160,6 +153,12 @@ protected:
*/
void
setHighContrastLayer
(
LAYER_NUM
aLayer
);
/**
* Function setTopLayer
* moves the selected layer to the top, so it is displayed above all others.
*/
void
setTopLayer
(
LAYER_NUM
aLayer
);
/**
* Function syncLayerWidgetLayer
* updates the currently layer "selection" within the PCB_LAYER_WIDGET.
...
...
include/wxstruct.h
View file @
886a3e93
...
...
@@ -499,7 +499,7 @@ public:
EDA_DRAW_PANEL
*
GetCanvas
()
{
return
m_canvas
;
}
virtual
wxString
GetScreenDesc
();
virtual
wxString
GetScreenDesc
()
const
;
/**
* Function GetScreen
...
...
pcbnew/basepcbframe.cpp
View file @
886a3e93
...
...
@@ -53,6 +53,7 @@
#include <math/vector2d.h>
#include <trigo.h>
#include <pcb_painter.h>
#include <worksheet_item.h>
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
...
...
@@ -202,6 +203,20 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view
->
Add
(
zone
);
}
// Add an entry for the worksheet layout
KiGfx
::
WORKSHEET_ITEM
*
worksheet
=
new
KiGfx
::
WORKSHEET_ITEM
(
std
::
string
(
aBoard
->
GetFileName
().
mb_str
()
),
std
::
string
(
GetScreenDesc
().
mb_str
()
),
&
GetPageSettings
(),
&
GetTitleBlock
()
);
BASE_SCREEN
*
screen
=
GetScreen
();
if
(
screen
!=
NULL
)
{
worksheet
->
SetSheetNumber
(
GetScreen
()
->
m_ScreenNumber
);
worksheet
->
SetSheetCount
(
GetScreen
()
->
m_NumberOfScreens
);
}
view
->
Add
(
worksheet
);
view
->
RecacheAllItems
(
true
);
if
(
m_galCanvasActive
)
...
...
@@ -828,7 +843,7 @@ void PCB_BASE_FRAME::LoadSettings()
{
// Copper layers are required for netname layers
view
->
SetRequired
(
GetNetnameLayer
(
layer
),
layer
);
view
->
SetLayerTarget
(
layer
,
KiGfx
::
TARGET_
NON
CACHED
);
view
->
SetLayerTarget
(
layer
,
KiGfx
::
TARGET_CACHED
);
}
else
if
(
IsNetnameLayer
(
layer
)
)
{
...
...
pcbnew/class_pcb_layer_widget.cpp
View file @
886a3e93
...
...
@@ -183,7 +183,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
if
(
IsCopperLayer
(
layer
)
)
{
bool
loc_visible
=
visible
;
if
(
force_active_layer_visible
&&
(
layer
==
myframe
->
get
Active
Layer
()
)
)
if
(
force_active_layer_visible
&&
(
layer
==
myframe
->
get
Current
Layer
()
)
)
loc_visible
=
true
;
cb
->
SetValue
(
loc_visible
);
...
...
@@ -354,7 +354,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
{
// the layer change from the PCB_LAYER_WIDGET can be denied by returning
// false from this function.
myframe
->
set
Active
Layer
(
aLayer
,
false
);
myframe
->
set
Current
Layer
(
aLayer
,
false
);
if
(
m_alwaysShowActiveCopperLayer
)
OnLayerSelected
();
...
...
pcbnew/deltrack.cpp
View file @
886a3e93
...
...
@@ -53,7 +53,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
{
if
(
g_CurrentTrackList
.
GetCount
()
>
0
)
{
LAYER_NUM
previous_layer
=
get
Active
Layer
();
LAYER_NUM
previous_layer
=
get
Current
Layer
();
DBG
(
g_CurrentTrackList
.
VerifyListIntegrity
();
)
...
...
@@ -86,7 +86,7 @@ TRACK* PCB_EDIT_FRAME::Delete_Segment( wxDC* DC, TRACK* aTrack )
// Correct active layer which could change if a via
// has been erased
set
Active
Layer
(
previous_layer
);
set
Current
Layer
(
previous_layer
);
UpdateStatusBar
();
...
...
pcbnew/dialogs/dialog_general_options.cpp
View file @
886a3e93
...
...
@@ -238,8 +238,8 @@ void PCB_EDIT_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
// Apply new display options to the GAL canvas (this is faster than recaching)
settings
->
LoadDisplayOptions
(
DisplayOpt
);
setHighContrastLayer
(
get
Active
Layer
()
);
m_galCanvas
->
GetView
()
->
EnableTopLayer
(
state
);
setHighContrastLayer
(
get
Current
Layer
()
);
//
m_galCanvas->GetView()->EnableTopLayer( state );
if
(
m_galCanvasActive
)
m_galCanvas
->
Refresh
();
...
...
pcbnew/dialogs/dialog_global_deletion.cpp
View file @
886a3e93
...
...
@@ -37,7 +37,7 @@ DIALOG_GLOBAL_DELETION::DIALOG_GLOBAL_DELETION( PCB_EDIT_FRAME* parent )
void
PCB_EDIT_FRAME
::
InstallPcbGlobalDeleteFrame
(
const
wxPoint
&
pos
)
{
DIALOG_GLOBAL_DELETION
dlg
(
this
);
dlg
.
SetCurrentLayer
(
get
Active
Layer
()
);
dlg
.
SetCurrentLayer
(
get
Current
Layer
()
);
dlg
.
ShowModal
();
}
...
...
pcbnew/dialogs/dialog_layers_setup.cpp
View file @
886a3e93
...
...
@@ -669,11 +669,11 @@ void PCB_EDIT_FRAME::InstallDialogLayerSetup()
if
(
dlg
.
ShowModal
()
==
wxID_CANCEL
)
return
;
wxLogDebug
(
wxT
(
"Current layer selected %d."
),
get
Active
Layer
()
);
wxLogDebug
(
wxT
(
"Current layer selected %d."
),
get
Current
Layer
()
);
// If the current active layer was removed, find the next avaiable layer to set as the
// active layer.
if
(
!
(
GetLayerMask
(
get
Active
Layer
()
)
&
GetBoard
()
->
GetEnabledLayers
()
)
)
if
(
!
(
GetLayerMask
(
get
Current
Layer
()
)
&
GetBoard
()
->
GetEnabledLayers
()
)
)
{
for
(
LAYER_NUM
i
=
FIRST_LAYER
;
i
<
NB_LAYERS
;
++
i
)
{
...
...
@@ -684,14 +684,14 @@ void PCB_EDIT_FRAME::InstallDialogLayerSetup()
if
(
GetLayerMask
(
tmp
)
&
GetBoard
()
->
GetEnabledLayers
()
)
{
wxLogDebug
(
wxT
(
"Setting current layer to %d."
),
get
Active
Layer
()
);
set
Active
Layer
(
tmp
,
true
);
wxLogDebug
(
wxT
(
"Setting current layer to %d."
),
get
Current
Layer
()
);
set
Current
Layer
(
tmp
,
true
);
break
;
}
}
}
else
{
set
ActiveLayer
(
getActive
Layer
(),
true
);
set
CurrentLayer
(
getCurrent
Layer
(),
true
);
}
}
pcbnew/dimension.cpp
View file @
886a3e93
...
...
@@ -245,7 +245,7 @@ DIMENSION* PCB_EDIT_FRAME::EditDimension( DIMENSION* aDimension, wxDC* aDC )
aDimension
=
new
DIMENSION
(
GetBoard
()
);
aDimension
->
SetFlags
(
IS_NEW
);
aDimension
->
SetLayer
(
get
Active
Layer
()
);
aDimension
->
SetLayer
(
get
Current
Layer
()
);
aDimension
->
m_crossBarO
=
aDimension
->
m_crossBarF
=
pos
;
aDimension
->
m_featureLineDO
=
aDimension
->
m_featureLineDF
=
pos
;
...
...
pcbnew/edit.cpp
View file @
886a3e93
...
...
@@ -917,10 +917,10 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break
;
case
ID_POPUP_PCB_SELECT_LAYER
:
itmp
=
SelectLayer
(
get
Active
Layer
(),
UNDEFINED_LAYER
,
UNDEFINED_LAYER
);
itmp
=
SelectLayer
(
get
Current
Layer
(),
UNDEFINED_LAYER
,
UNDEFINED_LAYER
);
if
(
itmp
>=
0
)
set
Active
Layer
(
itmp
);
set
Current
Layer
(
itmp
);
m_canvas
->
MoveCursorToCrossHair
();
break
;
...
...
@@ -930,19 +930,19 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break
;
case
ID_POPUP_PCB_SELECT_NO_CU_LAYER
:
itmp
=
SelectLayer
(
get
Active
Layer
(),
FIRST_NON_COPPER_LAYER
,
UNDEFINED_LAYER
);
itmp
=
SelectLayer
(
get
Current
Layer
(),
FIRST_NON_COPPER_LAYER
,
UNDEFINED_LAYER
);
if
(
itmp
>=
0
)
set
Active
Layer
(
itmp
);
set
Current
Layer
(
itmp
);
m_canvas
->
MoveCursorToCrossHair
();
break
;
case
ID_POPUP_PCB_SELECT_CU_LAYER
:
itmp
=
SelectLayer
(
get
Active
Layer
(),
UNDEFINED_LAYER
,
LAST_COPPER_LAYER
);
itmp
=
SelectLayer
(
get
Current
Layer
(),
UNDEFINED_LAYER
,
LAST_COPPER_LAYER
);
if
(
itmp
>=
0
)
set
Active
Layer
(
itmp
);
set
Current
Layer
(
itmp
);
break
;
...
...
@@ -952,7 +952,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break
;
case
ID_TOOLBARH_PCB_SELECT_LAYER
:
set
Active
Layer
(
m_SelLayerBox
->
GetLayerSelection
()
);
set
Current
Layer
(
m_SelLayerBox
->
GetLayerSelection
()
);
if
(
DisplayOpt
.
ContrastModeDisplay
)
m_canvas
->
Refresh
(
true
);
...
...
@@ -1240,7 +1240,7 @@ void PCB_EDIT_FRAME::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
void
PCB_EDIT_FRAME
::
SwitchLayer
(
wxDC
*
DC
,
LAYER_NUM
layer
)
{
LAYER_NUM
curLayer
=
get
Active
Layer
();
LAYER_NUM
curLayer
=
get
Current
Layer
();
// Check if the specified layer matches the present layer
if
(
layer
==
curLayer
)
...
...
@@ -1282,7 +1282,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
GetScreen
()
->
m_Route_Layer_TOP
=
curLayer
;
GetScreen
()
->
m_Route_Layer_BOTTOM
=
layer
;
set
Active
Layer
(
curLayer
);
set
Current
Layer
(
curLayer
);
if
(
Other_Layer_Route
(
(
TRACK
*
)
GetScreen
()
->
GetCurItem
(),
DC
)
)
{
...
...
@@ -1303,7 +1303,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, LAYER_NUM layer )
// and a non-copper layer, or vice-versa?
// ...
set
Active
Layer
(
layer
);
set
Current
Layer
(
layer
);
if
(
DisplayOpt
.
ContrastModeDisplay
)
RefreshCanvas
();
...
...
pcbnew/editedge.cpp
View file @
886a3e93
...
...
@@ -246,7 +246,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s
s_large
=
GetDesignSettings
().
m_DrawSegmentWidth
;
if
(
get
Active
Layer
()
==
EDGE_N
)
if
(
get
Current
Layer
()
==
EDGE_N
)
{
s_large
=
GetDesignSettings
().
m_EdgeSegmentWidth
;
}
...
...
@@ -255,7 +255,7 @@ DRAWSEGMENT* PCB_EDIT_FRAME::Begin_DrawSegment( DRAWSEGMENT* Segment, STROKE_T s
{
SetCurItem
(
Segment
=
new
DRAWSEGMENT
(
GetBoard
()
)
);
Segment
->
SetFlags
(
IS_NEW
);
Segment
->
SetLayer
(
get
Active
Layer
()
);
Segment
->
SetLayer
(
get
Current
Layer
()
);
Segment
->
SetWidth
(
s_large
);
Segment
->
SetShape
(
shape
);
Segment
->
SetAngle
(
900
);
...
...
pcbnew/editrack-part2.cpp
View file @
886a3e93
...
...
@@ -52,10 +52,10 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
if
(
aTrack
==
NULL
)
{
if
(
get
Active
Layer
()
!=
((
PCB_SCREEN
*
)
GetScreen
())
->
m_Route_Layer_TOP
)
set
Active
Layer
(
((
PCB_SCREEN
*
)
GetScreen
())
->
m_Route_Layer_TOP
);
if
(
get
Current
Layer
()
!=
((
PCB_SCREEN
*
)
GetScreen
())
->
m_Route_Layer_TOP
)
set
Current
Layer
(
((
PCB_SCREEN
*
)
GetScreen
())
->
m_Route_Layer_TOP
);
else
set
Active
Layer
(((
PCB_SCREEN
*
)
GetScreen
())
->
m_Route_Layer_BOTTOM
);
set
Current
Layer
(((
PCB_SCREEN
*
)
GetScreen
())
->
m_Route_Layer_BOTTOM
);
UpdateStatusBar
();
return
true
;
...
...
@@ -109,7 +109,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
via
->
SetLayerPair
(
LAYER_N_BACK
,
LAYER_N_FRONT
);
via
->
SetDrill
(
GetBoard
()
->
GetCurrentViaDrill
()
);
LAYER_NUM
first_layer
=
get
Active
Layer
();
LAYER_NUM
first_layer
=
get
Current
Layer
();
LAYER_NUM
last_layer
;
// prepare switch to new active layer:
...
...
@@ -172,7 +172,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
return
false
;
}
set
Active
Layer
(
last_layer
);
set
Current
Layer
(
last_layer
);
TRACK
*
lastNonVia
=
g_CurrentTrackSegment
;
...
...
@@ -194,7 +194,7 @@ bool PCB_EDIT_FRAME::Other_Layer_Route( TRACK* aTrack, wxDC* DC )
*/
// set the layer to the new value
track
->
SetLayer
(
get
Active
Layer
()
);
track
->
SetLayer
(
get
Current
Layer
()
);
/* the start point is the via position and the end point is the cursor
* which also is on the via (will change when moving mouse)
...
...
pcbnew/hotkeys_board_editor.cpp
View file @
886a3e93
...
...
@@ -243,7 +243,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break
;
case
HK_SWITCH_LAYER_TO_PREVIOUS
:
ll
=
get
Active
Layer
();
ll
=
get
Current
Layer
();
if
(
(
ll
<=
LAYER_N_BACK
)
||
(
ll
>
LAYER_N_FRONT
)
)
break
;
...
...
@@ -259,7 +259,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break
;
case
HK_SWITCH_LAYER_TO_NEXT
:
ll
=
get
Active
Layer
();
ll
=
get
Current
Layer
();
if
(
(
ll
<
LAYER_N_BACK
)
||
(
ll
>=
LAYER_N_FRONT
)
)
break
;
...
...
@@ -365,7 +365,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
break
;
case
HK_BACK_SPACE
:
if
(
/*m_ID_current_state == ID_TRACK_BUTT &&*/
(
get
Active
Layer
()
<=
LAYER_N_FRONT
)
)
if
(
/*m_ID_current_state == ID_TRACK_BUTT &&*/
(
get
Current
Layer
()
<=
LAYER_N_FRONT
)
)
{
if
(
!
itemCurrentlyEdited
)
{
...
...
@@ -572,7 +572,7 @@ bool PCB_EDIT_FRAME::OnHotkeyDeleteItem( wxDC* aDC )
switch
(
GetToolId
()
)
{
case
ID_TRACK_BUTT
:
if
(
get
Active
Layer
()
>
LAYER_N_FRONT
)
if
(
get
Current
Layer
()
>
LAYER_N_FRONT
)
return
false
;
if
(
ItemFree
)
...
...
@@ -941,7 +941,7 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC )
*/
TRACK
*
PCB_EDIT_FRAME
::
OnHotkeyBeginRoute
(
wxDC
*
aDC
)
{
if
(
get
Active
Layer
()
>
LAYER_N_FRONT
)
if
(
get
Current
Layer
()
>
LAYER_N_FRONT
)
return
NULL
;
bool
itemCurrentlyEdited
=
(
GetCurItem
()
&&
GetCurItem
()
->
GetFlags
());
...
...
pcbnew/onleftclick.cpp
View file @
886a3e93
...
...
@@ -243,7 +243,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
if
(
GetToolId
()
==
ID_PCB_ARC_BUTT
)
shape
=
S_ARC
;
if
(
IsCopperLayer
(
get
Active
Layer
()
)
)
if
(
IsCopperLayer
(
get
Current
Layer
()
)
)
{
DisplayError
(
this
,
_
(
"Graphic not allowed on Copper layers"
)
);
break
;
...
...
@@ -267,7 +267,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break
;
case
ID_TRACK_BUTT
:
if
(
!
IsCopperLayer
(
get
Active
Layer
()
)
)
if
(
!
IsCopperLayer
(
get
Current
Layer
()
)
)
{
DisplayError
(
this
,
_
(
"Tracks on Copper layers only "
)
);
break
;
...
...
@@ -367,7 +367,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
break
;
case
ID_PCB_DIMENSION_BUTT
:
if
(
IsCopperLayer
(
get
Active
Layer
()
)
)
if
(
IsCopperLayer
(
get
Current
Layer
()
)
)
{
DisplayError
(
this
,
_
(
"Dimension not allowed on Copper layers"
)
);
break
;
...
...
pcbnew/pcb_painter.cpp
View file @
886a3e93
...
...
@@ -75,6 +75,7 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
m_layerColors
[
ITEM_GAL_LAYER
(
PADS_NETNAMES_VISIBLE
)]
=
COLOR4D
(
0.8
,
0.8
,
0.8
,
0.7
);
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
);
// Netnames for copper layers
for
(
LAYER_NUM
layer
=
FIRST_COPPER_LAYER
;
layer
<=
LAST_COPPER_LAYER
;
++
layer
)
...
...
@@ -137,29 +138,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const DISPLAY_OPTIONS& aOptions )
}
void
PCB_RENDER_SETTINGS
::
update
()
{
// Calculate darkened/highlighted variants of layer colors
for
(
int
i
=
0
;
i
<
TOTAL_LAYER_COUNT
;
i
++
)
{
m_layerColors
[
i
].
a
=
m_layerOpacity
;
m_layerColorsHi
[
i
]
=
m_layerColors
[
i
].
Brightened
(
m_highlightFactor
);
m_layerColorsDark
[
i
]
=
m_layerColors
[
i
].
Darkened
(
1.0
-
m_highlightFactor
);
m_layerColorsSel
[
i
]
=
m_layerColors
[
i
].
Brightened
(
m_selectFactor
);
}
m_hiContrastColor
=
COLOR4D
(
m_hiContrastFactor
,
m_hiContrastFactor
,
m_hiContrastFactor
,
m_layerOpacity
);
}
PCB_PAINTER
::
PCB_PAINTER
(
GAL
*
aGal
)
:
PAINTER
(
aGal
)
{
}
const
COLOR4D
&
PCB_PAINTER
::
GetColor
(
const
VIEW_ITEM
*
aItem
,
int
aLayer
)
const
COLOR4D
&
PCB_RENDER_SETTINGS
::
GetColor
(
const
VIEW_ITEM
*
aItem
,
int
aLayer
)
const
{
int
netCode
=
-
1
;
...
...
@@ -167,7 +146,7 @@ const COLOR4D& PCB_PAINTER::GetColor( const VIEW_ITEM* aItem, int aLayer )
{
if
(
static_cast
<
const
EDA_ITEM
*>
(
aItem
)
->
IsSelected
()
)
{
return
m_
pcbSettings
->
m_
layerColorsSel
[
aLayer
];
return
m_layerColorsSel
[
aLayer
];
}
// Try to obtain the netcode for the item
...
...
@@ -177,27 +156,53 @@ const COLOR4D& PCB_PAINTER::GetColor( const VIEW_ITEM* aItem, int aLayer )
}
// Return grayish color for non-highlighted layers in the high contrast mode
if
(
m_
pcbSettings
->
m_hiContrastEnabled
&&
m_pcbSettings
->
m_activeLayers
.
count
(
aLayer
)
==
0
)
return
m_
pcbSettings
->
m_
hiContrastColor
;
if
(
m_
hiContrastEnabled
&&
m_activeLayers
.
count
(
aLayer
)
==
0
)
return
m_hiContrastColor
;
// Single net highlight mode
if
(
m_
pcbSettings
->
m_
highlightEnabled
)
if
(
m_highlightEnabled
)
{
if
(
netCode
==
m_
pcbSettings
->
m_
highlightNetcode
)
return
m_
pcbSettings
->
m_
layerColorsHi
[
aLayer
];
if
(
netCode
==
m_highlightNetcode
)
return
m_layerColorsHi
[
aLayer
];
else
return
m_
pcbSettings
->
m_
layerColorsDark
[
aLayer
];
return
m_layerColorsDark
[
aLayer
];
}
// No special modificators enabled
return
m_pcbSettings
->
m_layerColors
[
aLayer
];
return
m_layerColors
[
aLayer
];
}
void
PCB_RENDER_SETTINGS
::
update
()
{
// Calculate darkened/highlighted variants of layer colors
for
(
int
i
=
0
;
i
<
TOTAL_LAYER_COUNT
;
i
++
)
{
m_layerColors
[
i
].
a
=
m_layerOpacity
;
m_layerColorsHi
[
i
]
=
m_layerColors
[
i
].
Brightened
(
m_highlightFactor
);
m_layerColorsDark
[
i
]
=
m_layerColors
[
i
].
Darkened
(
1.0
-
m_highlightFactor
);
m_layerColorsSel
[
i
]
=
m_layerColors
[
i
].
Brightened
(
m_selectFactor
);
}
m_hiContrastColor
=
COLOR4D
(
m_hiContrastFactor
,
m_hiContrastFactor
,
m_hiContrastFactor
,
m_layerOpacity
);
}
const
COLOR4D
&
PCB_RENDER_SETTINGS
::
GetLayerColor
(
int
aLayer
)
const
{
return
m_layerColors
[
aLayer
];
}
PCB_PAINTER
::
PCB_PAINTER
(
GAL
*
aGal
)
:
PAINTER
(
aGal
)
{
m_settings
.
reset
(
new
PCB_RENDER_SETTINGS
()
);
m_pcbSettings
=
(
PCB_RENDER_SETTINGS
*
)
m_settings
.
get
();
}
bool
PCB_PAINTER
::
Draw
(
const
VIEW_ITEM
*
aItem
,
int
aLayer
)
{
const
BOARD_ITEM
*
item
=
static_cast
<
const
BOARD_ITEM
*>
(
aItem
);
...
...
@@ -284,8 +289,8 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
double
textSize
=
std
::
min
(
static_cast
<
double
>
(
width
),
length
/
netName
.
length
()
);
// Set a proper color for the label
color
=
GetColor
(
aTrack
,
aTrack
->
GetLayer
()
);
COLOR4D
labelColor
=
GetColor
(
NULL
,
aLayer
);
color
=
m_pcbSettings
->
GetColor
(
aTrack
,
aTrack
->
GetLayer
()
);
COLOR4D
labelColor
=
m_pcbSettings
->
GetColor
(
NULL
,
aLayer
);
if
(
color
.
GetBrightness
()
>
0.5
)
m_gal
->
SetStrokeColor
(
labelColor
.
Inverted
()
);
...
...
@@ -305,7 +310,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
else
if
(
IsCopperLayer
(
aLayer
))
{
// Draw a regular track
color
=
GetColor
(
aTrack
,
aLayer
);
color
=
m_pcbSettings
->
GetColor
(
aTrack
,
aLayer
);
m_gal
->
SetStrokeColor
(
color
);
m_gal
->
SetIsStroke
(
true
);
...
...
@@ -344,7 +349,7 @@ void PCB_PAINTER::draw( const SEGVIA* aVia, int aLayer )
else
return
;
color
=
GetColor
(
aVia
,
aLayer
);
color
=
m_pcbSettings
->
GetColor
(
aVia
,
aLayer
);
if
(
m_pcbSettings
->
m_sketchModeSelect
[
VIAS_VISIBLE
]
)
{
...
...
@@ -423,8 +428,8 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m_gal
->
SetMirrored
(
false
);
// Set a proper color for the label
color
=
GetColor
(
aPad
,
aPad
->
GetLayer
()
);
COLOR4D
labelColor
=
GetColor
(
NULL
,
aLayer
);
color
=
m_pcbSettings
->
GetColor
(
aPad
,
aPad
->
GetLayer
()
);
COLOR4D
labelColor
=
m_pcbSettings
->
GetColor
(
NULL
,
aLayer
);
if
(
color
.
GetBrightness
()
>
0.5
)
m_gal
->
SetStrokeColor
(
labelColor
.
Inverted
()
);
...
...
@@ -470,7 +475,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
}
// Pad drawing
color
=
GetColor
(
aPad
,
aLayer
);
color
=
m_pcbSettings
->
GetColor
(
aPad
,
aLayer
);
if
(
m_pcbSettings
->
m_sketchModeSelect
[
PADS_VISIBLE
]
)
{
// Outline mode
...
...
@@ -623,7 +628,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
void
PCB_PAINTER
::
draw
(
const
DRAWSEGMENT
*
aSegment
)
{
COLOR4D
color
=
GetColor
(
NULL
,
aSegment
->
GetLayer
()
);
COLOR4D
color
=
m_pcbSettings
->
GetColor
(
NULL
,
aSegment
->
GetLayer
()
);
m_gal
->
SetIsFill
(
false
);
m_gal
->
SetIsStroke
(
true
);
...
...
@@ -712,7 +717,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
if
(
aText
->
GetText
().
Length
()
==
0
)
return
;
COLOR4D
strokeColor
=
GetColor
(
NULL
,
aText
->
GetLayer
()
);
COLOR4D
strokeColor
=
m_pcbSettings
->
GetColor
(
NULL
,
aText
->
GetLayer
()
);
VECTOR2D
position
(
aText
->
GetTextPosition
().
x
,
aText
->
GetTextPosition
().
y
);
double
orientation
=
aText
->
GetOrientation
()
*
M_PI
/
1800.0
;
...
...
@@ -736,8 +741,8 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
if
(
aText
->
GetLength
()
==
0
)
return
;
COLOR4D
strokeColor
=
GetColor
(
NULL
,
aLayer
);
VECTOR2D
position
(
aText
->
GetTextPosition
().
x
,
aText
->
GetTextPosition
().
y
);
COLOR4D
strokeColor
=
m_pcbSettings
->
GetColor
(
NULL
,
aLayer
);
VECTOR2D
position
(
aText
->
GetTextPosition
().
x
,
aText
->
GetTextPosition
().
y
);
double
orientation
=
aText
->
GetDrawRotation
()
*
M_PI
/
1800.0
;
m_gal
->
SetStrokeColor
(
strokeColor
);
...
...
@@ -751,7 +756,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
void
PCB_PAINTER
::
draw
(
const
ZONE_CONTAINER
*
aZone
)
{
COLOR4D
color
=
GetColor
(
NULL
,
aZone
->
GetLayer
()
);
COLOR4D
color
=
m_pcbSettings
->
GetColor
(
NULL
,
aZone
->
GetLayer
()
);
std
::
deque
<
VECTOR2D
>
corners
;
PCB_RENDER_SETTINGS
::
DisplayZonesMode
displayMode
=
m_pcbSettings
->
m_displayZoneMode
;
...
...
@@ -828,7 +833,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
else
{
int
layer
=
aDimension
->
GetLayer
();
COLOR4D
strokeColor
=
GetColor
(
NULL
,
layer
);
COLOR4D
strokeColor
=
m_pcbSettings
->
GetColor
(
NULL
,
layer
);
m_gal
->
SetStrokeColor
(
strokeColor
);
m_gal
->
SetIsFill
(
false
);
...
...
@@ -854,7 +859,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
void
PCB_PAINTER
::
draw
(
const
PCB_TARGET
*
aTarget
)
{
COLOR4D
strokeColor
=
GetColor
(
NULL
,
aTarget
->
GetLayer
()
);
COLOR4D
strokeColor
=
m_pcbSettings
->
GetColor
(
NULL
,
aTarget
->
GetLayer
()
);
VECTOR2D
position
(
aTarget
->
GetPosition
()
);
double
size
,
radius
;
...
...
pcbnew/pcb_painter.h
View file @
886a3e93
...
...
@@ -27,6 +27,7 @@
#define __CLASS_PCB_PAINTER_H
#include <layers_id_colors_and_visibility.h>
#include <boost/shared_ptr.hpp>
#include <painter.h>
class
EDA_ITEM
;
...
...
@@ -85,8 +86,11 @@ public:
*/
void
LoadDisplayOptions
(
const
DISPLAY_OPTIONS
&
aOptions
);
const
COLOR4D
&
GetLayerColor
(
int
aLayer
)
const
;
/// @copydoc RENDER_SETTINGS::GetColor()
virtual
const
COLOR4D
&
GetColor
(
const
VIEW_ITEM
*
aItem
,
int
aLayer
)
const
;
const
COLOR4D
&
GetLayerColor
(
int
aLayer
)
const
;
protected
:
/// @copydoc RENDER_SETTINGS::Update()
void
update
();
...
...
@@ -129,13 +133,11 @@ public:
PAINTER
::
ApplySettings
(
aSettings
);
// Store PCB specific render settings
m_pcbSettings
=
dynamic_cast
<
PCB_RENDER_SETTINGS
*>
(
aSettings
);
m_pcbSettings
=
(
PCB_RENDER_SETTINGS
*
)
m_settings
.
get
();
//
dynamic_cast<PCB_RENDER_SETTINGS*>( aSettings );
}
/// @copydoc PAINTER::GetColor()
virtual
const
COLOR4D
&
GetColor
(
const
VIEW_ITEM
*
aItem
,
int
aLayer
);
protected
:
/// Just a properly casted pointer to settings
PCB_RENDER_SETTINGS
*
m_pcbSettings
;
// Drawing functions for various types of PCB-specific items
...
...
pcbnew/pcbframe.cpp
View file @
886a3e93
...
...
@@ -120,9 +120,9 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
// menu Config
/* Tom's hacks start */
EVT_MENU
(
ID_SELECTION_TOOL
,
PCB_EDIT_FRAME
::
onGenericCommand
)
EVT_MENU
(
ID_SELECTION_TOOL
,
PCB_EDIT_FRAME
::
onGenericCommand
)
EVT_TOOL
(
ID_SELECTION_TOOL
,
PCB_EDIT_FRAME
::
onGenericCommand
)
EVT_MENU
(
ID_PNS_ROUTER_TOOL
,
PCB_EDIT_FRAME
::
onGenericCommand
)
EVT_MENU
(
ID_PNS_ROUTER_TOOL
,
PCB_EDIT_FRAME
::
onGenericCommand
)
EVT_TOOL
(
ID_PNS_ROUTER_TOOL
,
PCB_EDIT_FRAME
::
onGenericCommand
)
/* Tom's hacks end */
...
...
@@ -487,6 +487,7 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
PCB_EDIT_FRAME
::~
PCB_EDIT_FRAME
()
{
destroyTools
();
m_RecordingMacros
=
-
1
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
...
...
@@ -729,7 +730,7 @@ void PCB_EDIT_FRAME::SetGridColor(EDA_COLOR_T aColor)
bool
PCB_EDIT_FRAME
::
IsMicroViaAcceptable
(
void
)
{
int
copperlayercnt
=
GetBoard
()
->
GetCopperLayerCount
(
);
LAYER_NUM
currLayer
=
get
Active
Layer
();
LAYER_NUM
currLayer
=
get
Current
Layer
();
if
(
!
GetDesignSettings
().
m_MicroViasAllowed
)
return
false
;
// Obvious..
...
...
@@ -753,55 +754,102 @@ void PCB_EDIT_FRAME::setHighContrastLayer( LAYER_NUM aLayer )
KiGfx
::
VIEW
*
view
=
m_galCanvas
->
GetView
();
KiGfx
::
RENDER_SETTINGS
*
rSettings
=
view
->
GetPainter
()
->
GetSettings
();
if
(
DisplayOpt
.
ContrastModeDisplay
)
setTopLayer
(
aLayer
);
rSettings
->
ClearActiveLayers
();
rSettings
->
SetActiveLayer
(
aLayer
);
if
(
IsCopperLayer
(
aLayer
)
)
{
view
->
ClearTopLayers
();
view
->
SetTopLayer
(
aLayer
);
// Bring some other layers to the front in case of copper layers and make them colored
// fixme do not like the idea of storing the list of layers here,
// should be done in some other way I guess..
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
(
SELECTION
)
};
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
layers
)
/
sizeof
(
LAYER_NUM
);
++
i
)
rSettings
->
SetActiveLayer
(
layers
[
i
]
);
// Pads should be shown too
if
(
aLayer
==
FIRST_COPPER_LAYER
)
{
rSettings
->
SetActiveLayer
(
ITEM_GAL_LAYER
(
PAD_BK_VISIBLE
)
);
rSettings
->
SetActiveLayer
(
ITEM_GAL_LAYER
(
PAD_BK_NETNAMES_VISIBLE
)
);
}
else
if
(
aLayer
==
LAST_COPPER_LAYER
)
{
rSettings
->
SetActiveLayer
(
ITEM_GAL_LAYER
(
PAD_FR_VISIBLE
)
);
rSettings
->
SetActiveLayer
(
ITEM_GAL_LAYER
(
PAD_FR_NETNAMES_VISIBLE
)
);
}
}
view
->
UpdateAllLayersColor
();
}
void
PCB_EDIT_FRAME
::
setTopLayer
(
LAYER_NUM
aLayer
)
{
// Set display settings for high contrast mode
KiGfx
::
VIEW
*
view
=
m_galCanvas
->
GetView
();
rSettings
->
ClearActive
Layers
();
rSettings
->
SetActive
Layer
(
aLayer
);
view
->
ClearTop
Layers
();
view
->
SetTop
Layer
(
aLayer
);
if
(
IsCopperLayer
(
aLayer
)
)
if
(
IsCopperLayer
(
aLayer
)
)
{
// Bring some other layers to the front in case of copper layers and make them colored
// fixme do not like the idea of storing the list of layers here,
// should be done in some other way I guess..
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
(
SELECTION
)
};
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
layers
)
/
sizeof
(
LAYER_NUM
);
++
i
)
{
// Bring some other layers to the front in case of copper layers and make them colored
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
)
};
for
(
unsigned
int
i
=
0
;
i
<
sizeof
(
layers
)
/
sizeof
(
LAYER_NUM
);
++
i
)
{
view
->
SetTopLayer
(
layers
[
i
]
);
rSettings
->
SetActiveLayer
(
layers
[
i
]
);
}
// Pads should be shown too
if
(
aLayer
==
FIRST_COPPER_LAYER
)
{
view
->
SetTopLayer
(
ITEM_GAL_LAYER
(
PAD_BK_VISIBLE
)
);
view
->
SetTopLayer
(
ITEM_GAL_LAYER
(
PAD_BK_NETNAMES_VISIBLE
)
);
rSettings
->
SetActiveLayer
(
ITEM_GAL_LAYER
(
PAD_BK_VISIBLE
)
);
rSettings
->
SetActiveLayer
(
ITEM_GAL_LAYER
(
PAD_BK_NETNAMES_VISIBLE
)
);
}
else
if
(
aLayer
==
LAST_COPPER_LAYER
)
{
view
->
SetTopLayer
(
ITEM_GAL_LAYER
(
PAD_FR_VISIBLE
)
);
view
->
SetTopLayer
(
ITEM_GAL_LAYER
(
PAD_FR_NETNAMES_VISIBLE
)
);
rSettings
->
SetActiveLayer
(
ITEM_GAL_LAYER
(
PAD_FR_VISIBLE
)
);
rSettings
->
SetActiveLayer
(
ITEM_GAL_LAYER
(
PAD_FR_NETNAMES_VISIBLE
)
);
}
view
->
SetTopLayer
(
layers
[
i
]
);
}
view
->
UpdateAllLayersOrder
();
view
->
UpdateAllLayersColor
();
// Pads should be shown too
if
(
aLayer
==
FIRST_COPPER_LAYER
)
{
view
->
SetTopLayer
(
ITEM_GAL_LAYER
(
PAD_BK_VISIBLE
)
);
view
->
SetTopLayer
(
ITEM_GAL_LAYER
(
PAD_BK_NETNAMES_VISIBLE
)
);
}
else
if
(
aLayer
==
LAST_COPPER_LAYER
)
{
view
->
SetTopLayer
(
ITEM_GAL_LAYER
(
PAD_FR_VISIBLE
)
);
view
->
SetTopLayer
(
ITEM_GAL_LAYER
(
PAD_FR_NETNAMES_VISIBLE
)
);
}
}
view
->
UpdateAllLayersOrder
();
}
void
PCB_EDIT_FRAME
::
setCurrentLayer
(
LAYER_NUM
aLayer
,
bool
doLayerWidgetUpdate
)
{
(
(
PCB_SCREEN
*
)
GetScreen
()
)
->
m_Active_Layer
=
aLayer
;
setHighContrastLayer
(
aLayer
);
if
(
doLayerWidgetUpdate
)
syncLayerWidgetLayer
();
if
(
m_galCanvasActive
)
m_galCanvas
->
Refresh
();
}
void
PCB_EDIT_FRAME
::
syncLayerWidgetLayer
()
{
m_Layers
->
SelectLayer
(
get
Active
Layer
()
);
m_Layers
->
SelectLayer
(
get
Current
Layer
()
);
m_Layers
->
OnLayerSelected
();
}
...
...
pcbnew/tool_pcb.cpp
View file @
886a3e93
...
...
@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::PrepareLayerIndicator()
previous_Route_Layer_BOTTOM_color
,
previous_via_color
;
/* get colors, and redraw bitmap button only on changes */
active_layer_color
=
GetBoard
()
->
GetLayerColor
(
get
Active
Layer
());
active_layer_color
=
GetBoard
()
->
GetLayerColor
(
get
Current
Layer
());
if
(
previous_active_layer_color
!=
active_layer_color
)
{
...
...
pcbnew/toolbars_update_user_interface.cpp
View file @
886a3e93
...
...
@@ -96,7 +96,7 @@ void PCB_EDIT_FRAME::OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent )
void
PCB_EDIT_FRAME
::
OnUpdateLayerSelectBox
(
wxUpdateUIEvent
&
aEvent
)
{
m_SelLayerBox
->
SetLayerSelection
(
get
Active
Layer
()
);
m_SelLayerBox
->
SetLayerSelection
(
get
Current
Layer
()
);
}
...
...
pcbnew/tools/move_tool.cpp
View file @
886a3e93
...
...
@@ -61,7 +61,7 @@ void MOVE_TOOL::Reset()
}
// the tool launches upon reception of activate ("pcbnew.InteractiveMove")
Go
(
&
MOVE_TOOL
::
Main
,
TOOL_EVENT
(
TC_Command
,
TA_ActivateTool
,
GetName
()
)
);
//"pcbnew.InteractiveMove"));
Go
(
&
MOVE_TOOL
::
Main
,
TOOL_EVENT
(
TC_Command
,
TA_ActivateTool
,
GetName
()
)
);
}
...
...
pcbnew/tools/move_tool.h
View file @
886a3e93
...
...
@@ -89,7 +89,8 @@ private:
void
RestorePosition
()
{
item
->
SetPosition
(
wxPoint
(
position
.
x
,
position
.
y
)
);
wxPoint
curPosition
=
item
->
GetPosition
();
item
->
Move
(
wxPoint
(
position
.
x
-
curPosition
.
x
,
position
.
y
-
curPosition
.
y
)
);
}
void
RestoreVisibility
()
...
...
pcbnew/tools/pcb_tools.cpp
View file @
886a3e93
...
...
@@ -40,18 +40,25 @@
void
PCB_EDIT_FRAME
::
setupTools
()
{
//
create the manager and dispatcher. Route draw panel events to the dispatcher.
//
Create the manager and dispatcher & route draw panel events to the dispatcher
m_toolManager
=
new
TOOL_MANAGER
;
m_toolDispatcher
=
new
TOOL_DISPATCHER
(
m_toolManager
,
this
);
m_galCanvas
->
SetEventDispatcher
(
m_toolDispatcher
);
//
register our selection tool
.
//
Register tools
.
m_toolManager
->
RegisterTool
(
new
SELECTION_TOOL
);
m_toolManager
->
RegisterTool
(
new
ROUTER_TOOL
);
m_toolManager
->
RegisterTool
(
new
MOVE_TOOL
);
}
void
PCB_EDIT_FRAME
::
destroyTools
()
{
delete
m_toolDispatcher
;
delete
m_toolManager
;
}
void
PCB_EDIT_FRAME
::
onGenericCommand
(
wxCommandEvent
&
aEvent
)
{
m_toolDispatcher
->
DispatchWxCommand
(
aEvent
);
...
...
pcbnew/tools/selection_area.cpp
View file @
886a3e93
...
...
@@ -47,7 +47,7 @@ void SELECTION_AREA::ViewGetLayers( int aLayers[], int& aCount ) const
}
void
SELECTION_AREA
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
,
const
BOX2I
&
aVisibleArea
)
const
void
SELECTION_AREA
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
{
aGal
->
SetLineWidth
(
1.0
);
aGal
->
SetStrokeColor
(
COLOR4D
(
1.0
,
1.0
,
0.4
,
1.0
)
);
...
...
pcbnew/tools/selection_area.h
View file @
886a3e93
...
...
@@ -50,7 +50,7 @@ public:
virtual
const
BOX2I
ViewBBox
()
const
;
void
ViewDraw
(
int
aLayer
,
KiGfx
::
GAL
*
aGal
,
const
BOX2I
&
aVisibleArea
)
const
;
void
ViewDraw
(
int
aLayer
,
KiGfx
::
GAL
*
aGal
)
const
;
void
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
;
void
SetOrigin
(
VECTOR2I
aOrigin
)
...
...
@@ -63,7 +63,7 @@ public:
m_end
=
aEnd
;
}
void
Show
(
int
x
,
std
::
ostream
&
st
)
const
void
Show
(
int
x
,
std
::
ostream
&
st
)
const
{
}
...
...
pcbnew/tools/selection_tool.cpp
View file @
886a3e93
...
...
@@ -111,8 +111,28 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
}
else
{
// Now user wants to drag the selected items
m_toolMgr
->
InvokeTool
(
"pcbnew.InteractiveMove"
);
bool
runTool
=
false
;
// Check if dragging event started within the currently selected items bounding box
std
::
set
<
BOARD_ITEM
*>::
iterator
it
,
it_end
;
for
(
it
=
m_selectedItems
.
begin
(),
it_end
=
m_selectedItems
.
end
();
it
!=
it_end
;
++
it
)
{
BOX2I
itemBox
=
(
*
it
)
->
ViewBBox
();
itemBox
.
Inflate
(
500000
);
// Give some margin for gripping an item
if
(
itemBox
.
Contains
(
evt
->
Position
()
)
)
{
// Click event occurred within a selected item bounding box
// -> user wants to drag selected items
runTool
=
true
;
break
;
}
}
if
(
runTool
)
m_toolMgr
->
InvokeTool
(
"pcbnew.InteractiveMove"
);
else
clearSelection
();
}
}
else
if
(
dragging
)
...
...
@@ -184,9 +204,26 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
break
;
default
:
item
=
disambiguationMenu
(
&
collector
);
if
(
item
)
toggleSelection
(
item
);
// Remove footprints, they have to be selected by clicking on area that does not
// contain anything but footprint
for
(
int
i
=
0
;
i
<
collector
.
GetCount
();
++
i
)
{
BOARD_ITEM
*
boardItem
=
(
collector
)[
i
];
if
(
boardItem
->
Type
()
==
PCB_MODULE_T
)
collector
.
Remove
(
i
);
}
// Let's see if there is still disambiguation in selection..
if
(
collector
.
GetCount
()
==
1
)
{
toggleSelection
(
collector
[
0
]
);
}
else
{
item
=
disambiguationMenu
(
&
collector
);
if
(
item
)
toggleSelection
(
item
);
}
break
;
}
}
...
...
@@ -306,7 +343,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
for
(
int
i
=
0
;
i
<
limit
;
++
i
)
{
wxString
text
;
BOARD_ITEM
*
item
=
(
*
aCollector
)[
i
];
BOARD_ITEM
*
item
=
(
*
aCollector
)[
i
];
text
=
item
->
GetSelectMenuText
();
m_menu
->
Add
(
text
,
i
);
}
...
...
pcbnew/zones_by_polygon.cpp
View file @
886a3e93
...
...
@@ -518,7 +518,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
if
(
!
GetBoard
()
->
m_CurrentZoneContour
)
{
if
(
GetToolId
()
==
ID_PCB_KEEPOUT_AREA_BUTT
&&
get
Active
Layer
()
>=
FIRST_NON_COPPER_LAYER
)
get
Current
Layer
()
>=
FIRST_NON_COPPER_LAYER
)
{
DisplayError
(
this
,
_
(
"Error: a keepout area is allowed only on copper layers"
)
);
...
...
@@ -537,7 +537,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
ZONE_EDIT_T
edited
;
// Init zone params to reasonable values
zone
->
SetLayer
(
get
Active
Layer
()
);
zone
->
SetLayer
(
get
Current
Layer
()
);
// Prompt user for parameters:
m_canvas
->
SetIgnoreMouseEvents
(
true
);
...
...
@@ -602,7 +602,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
return
0
;
// Switch active layer to the selected zone layer
set
Active
Layer
(
zoneInfo
.
m_CurrentZone_Layer
);
set
Current
Layer
(
zoneInfo
.
m_CurrentZone_Layer
);
SetZoneSettings
(
zoneInfo
);
}
...
...
@@ -612,7 +612,7 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
// zone (add cutout or similar zone)
zoneInfo
.
m_CurrentZone_Layer
=
s_CurrentZone
->
GetLayer
();
set
Active
Layer
(
s_CurrentZone
->
GetLayer
()
);
set
Current
Layer
(
s_CurrentZone
->
GetLayer
()
);
zoneInfo
<<
*
s_CurrentZone
;
...
...
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