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
bc305859
Commit
bc305859
authored
Oct 14, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mainly case changes.
parent
0ac3e1fb
Changes
62
Show whitespace changes
Inline
Side-by-side
Showing
62 changed files
with
1717 additions
and
1637 deletions
+1717
-1637
cairo_gal.cpp
common/gal/cairo/cairo_gal.cpp
+19
-19
cached_container.cpp
common/gal/opengl/cached_container.cpp
+15
-15
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+3
-3
shader.cpp
common/gal/opengl/shader.cpp
+3
-3
stroke_font.cpp
common/gal/stroke_font.cpp
+9
-9
seg.cpp
common/geometry/seg.cpp
+29
-30
shape_collisions.cpp
common/geometry/shape_collisions.cpp
+14
-9
shape_index.cpp
common/geometry/shape_index.cpp
+1
-1
shape_line_chain.cpp
common/geometry/shape_line_chain.cpp
+31
-29
math_util.cpp
common/math/math_util.cpp
+12
-11
context_menu.cpp
common/tool/context_menu.cpp
+8
-8
tool_dispatcher.cpp
common/tool/tool_dispatcher.cpp
+17
-17
tool_event.cpp
common/tool/tool_event.cpp
+38
-38
tool_interactive.cpp
common/tool/tool_interactive.cpp
+2
-2
tool_manager.cpp
common/tool/tool_manager.cpp
+12
-12
view.cpp
common/view/view.cpp
+10
-10
view_group.cpp
common/view/view_group.cpp
+1
-1
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+16
-16
cairo_gal.h
include/gal/cairo/cairo_gal.h
+11
-10
definitions.h
include/gal/definitions.h
+2
-2
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+3
-3
cached_container.h
include/gal/opengl/cached_container.h
+17
-17
gpu_manager.h
include/gal/opengl/gpu_manager.h
+25
-14
opengl_gal.h
include/gal/opengl/opengl_gal.h
+8
-7
shader.h
include/gal/opengl/shader.h
+4
-4
vertex_common.h
include/gal/opengl/vertex_common.h
+1
-1
stroke_font.h
include/gal/stroke_font.h
+4
-4
seg.h
include/geometry/seg.h
+219
-212
shape.h
include/geometry/shape.h
+103
-96
shape_circle.h
include/geometry/shape_circle.h
+6
-3
shape_index_list.h
include/geometry/shape_index_list.h
+78
-75
shape_line_chain.h
include/geometry/shape_line_chain.h
+485
-479
shape_rect.h
include/geometry/shape_rect.h
+120
-116
math_util.h
include/math/math_util.h
+4
-4
matrix3x3.h
include/math/matrix3x3.h
+30
-28
vector2d.h
include/math/vector2d.h
+3
-1
coroutine.h
include/tool/coroutine.h
+6
-6
delegate.h
include/tool/delegate.h
+8
-8
tool_action.h
include/tool/tool_action.h
+3
-3
tool_base.h
include/tool/tool_base.h
+7
-7
tool_dispatcher.h
include/tool/tool_dispatcher.h
+7
-6
tool_event.h
include/tool/tool_event.h
+97
-97
tool_interactive.h
include/tool/tool_interactive.h
+7
-7
view.h
include/view/view.h
+33
-18
view_controls.h
include/view/view_controls.h
+10
-2
view_group.h
include/view/view_group.h
+21
-6
view_item.h
include/view/view_item.h
+4
-3
wx_view_controls.h
include/view/wx_view_controls.h
+6
-5
direction.h
pcbnew/router/direction.h
+1
-1
pns_line.cpp
pcbnew/router/pns_line.cpp
+76
-91
pns_line_placer.cpp
pcbnew/router/pns_line_placer.cpp
+9
-9
pns_node.cpp
pcbnew/router/pns_node.cpp
+17
-17
pns_optimizer.cpp
pcbnew/router/pns_optimizer.cpp
+8
-8
pns_router.cpp
pcbnew/router/pns_router.cpp
+8
-8
pns_segment.h
pcbnew/router/pns_segment.h
+4
-4
pns_shove.cpp
pcbnew/router/pns_shove.cpp
+2
-2
pns_walkaround.cpp
pcbnew/router/pns_walkaround.cpp
+2
-2
router_preview_item.cpp
pcbnew/router/router_preview_item.cpp
+2
-2
router_tool.cpp
pcbnew/router/router_tool.cpp
+3
-3
item_state.h
pcbnew/tools/item_state.h
+1
-1
move_tool.cpp
pcbnew/tools/move_tool.cpp
+3
-3
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+9
-9
No files found.
common/gal/cairo/cairo_gal.cpp
View file @
bc305859
...
...
@@ -325,7 +325,7 @@ void CAIRO_GAL::SetIsFill( bool aIsFillEnabled )
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_SET_FILL
;
groupElement
.
boolArgument
=
aIsFillEnabled
;
currentGroup
->
push_back
(
groupElement
);
...
...
@@ -340,7 +340,7 @@ void CAIRO_GAL::SetIsStroke( bool aIsStrokeEnabled )
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_SET_STROKE
;
groupElement
.
boolArgument
=
aIsStrokeEnabled
;
currentGroup
->
push_back
(
groupElement
);
...
...
@@ -355,7 +355,7 @@ void CAIRO_GAL::SetStrokeColor( const COLOR4D& aColor )
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_SET_STROKECOLOR
;
groupElement
.
arguments
[
0
]
=
strokeColor
.
r
;
groupElement
.
arguments
[
1
]
=
strokeColor
.
g
;
...
...
@@ -373,7 +373,7 @@ void CAIRO_GAL::SetFillColor( const COLOR4D& aColor )
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_SET_FILLCOLOR
;
groupElement
.
arguments
[
0
]
=
fillColor
.
r
;
groupElement
.
arguments
[
1
]
=
fillColor
.
g
;
...
...
@@ -392,7 +392,7 @@ void CAIRO_GAL::SetLineWidth( double aLineWidth )
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_SET_LINE_WIDTH
;
groupElement
.
arguments
[
0
]
=
aLineWidth
;
currentGroup
->
push_back
(
groupElement
);
...
...
@@ -446,7 +446,7 @@ void CAIRO_GAL::Rotate( double aAngle )
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_ROTATE
;
groupElement
.
arguments
[
0
]
=
aAngle
;
currentGroup
->
push_back
(
groupElement
);
...
...
@@ -464,7 +464,7 @@ void CAIRO_GAL::Translate( const VECTOR2D& aTranslation )
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_TRANSLATE
;
groupElement
.
arguments
[
0
]
=
aTranslation
.
x
;
groupElement
.
arguments
[
1
]
=
aTranslation
.
y
;
...
...
@@ -483,7 +483,7 @@ void CAIRO_GAL::Scale( const VECTOR2D& aScale )
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_SCALE
;
groupElement
.
arguments
[
0
]
=
aScale
.
x
;
groupElement
.
arguments
[
1
]
=
aScale
.
y
;
...
...
@@ -502,7 +502,7 @@ void CAIRO_GAL::Save()
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_SAVE
;
currentGroup
->
push_back
(
groupElement
);
}
...
...
@@ -519,7 +519,7 @@ void CAIRO_GAL::Restore()
if
(
isGrouping
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
command
=
CMD_RESTORE
;
currentGroup
->
push_back
(
groupElement
);
}
...
...
@@ -538,7 +538,7 @@ int CAIRO_GAL::BeginGroup()
// a attribute was changed or when grouping stops with the end group method.
storePath
();
G
roup
group
;
G
ROUP
group
;
int
groupNumber
=
getNewGroupNumber
();
groups
.
insert
(
std
::
make_pair
(
groupNumber
,
group
)
);
currentGroup
=
&
groups
[
groupNumber
];
...
...
@@ -564,7 +564,7 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber )
storePath
();
for
(
G
roup
::
iterator
it
=
groups
[
aGroupNumber
].
begin
();
for
(
G
ROUP
::
iterator
it
=
groups
[
aGroupNumber
].
begin
();
it
!=
groups
[
aGroupNumber
].
end
();
++
it
)
{
switch
(
it
->
command
)
...
...
@@ -649,7 +649,7 @@ void CAIRO_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor )
{
storePath
();
for
(
G
roup
::
iterator
it
=
groups
[
aGroupNumber
].
begin
();
for
(
G
ROUP
::
iterator
it
=
groups
[
aGroupNumber
].
begin
();
it
!=
groups
[
aGroupNumber
].
end
();
++
it
)
{
if
(
it
->
command
==
CMD_SET_FILLCOLOR
||
it
->
command
==
CMD_SET_STROKECOLOR
)
...
...
@@ -675,7 +675,7 @@ void CAIRO_GAL::DeleteGroup( int aGroupNumber )
storePath
();
// Delete the Cairo paths
std
::
deque
<
G
roupElement
>::
iterator
it
,
end
;
std
::
deque
<
G
ROUP_ELEMENT
>::
iterator
it
,
end
;
for
(
it
=
groups
[
aGroupNumber
].
begin
(),
end
=
groups
[
aGroupNumber
].
end
();
it
!=
end
;
++
it
)
{
...
...
@@ -730,7 +730,7 @@ void CAIRO_GAL::RestoreScreen()
}
void
CAIRO_GAL
::
SetTarget
(
R
enderTarget
aTarget
)
void
CAIRO_GAL
::
SetTarget
(
R
ENDER_TARGET
aTarget
)
{
// If the compositor is not set, that means that there is a recaching process going on
// and we do not need the compositor now
...
...
@@ -766,13 +766,13 @@ void CAIRO_GAL::SetTarget( RenderTarget aTarget )
}
R
enderTarget
CAIRO_GAL
::
GetTarget
()
const
R
ENDER_TARGET
CAIRO_GAL
::
GetTarget
()
const
{
return
currentTarget
;
}
void
CAIRO_GAL
::
ClearTarget
(
R
enderTarget
aTarget
)
void
CAIRO_GAL
::
ClearTarget
(
R
ENDER_TARGET
aTarget
)
{
// Save the current state
unsigned
int
currentBuffer
=
compositor
->
GetBuffer
();
...
...
@@ -844,7 +844,7 @@ void CAIRO_GAL::storePath()
// add this command to the group list;
if
(
isStrokeEnabled
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
cairoPath
=
cairo_copy_path
(
currentContext
);
groupElement
.
command
=
CMD_STROKE_PATH
;
currentGroup
->
push_back
(
groupElement
);
...
...
@@ -852,7 +852,7 @@ void CAIRO_GAL::storePath()
if
(
isFillEnabled
)
{
G
roupElement
groupElement
;
G
ROUP_ELEMENT
groupElement
;
groupElement
.
cairoPath
=
cairo_copy_path
(
currentContext
);
groupElement
.
command
=
CMD_FILL_PATH
;
currentGroup
->
push_back
(
groupElement
);
...
...
common/gal/opengl/cached_container.cpp
View file @
bc305859
...
...
@@ -45,7 +45,7 @@ CACHED_CONTAINER::CACHED_CONTAINER( unsigned int aSize ) :
VERTEX_CONTAINER
(
aSize
),
m_item
(
NULL
)
{
// In the beginning there is only free space
m_freeChunks
.
insert
(
C
hunk
(
aSize
,
0
)
);
m_freeChunks
.
insert
(
C
HUNK
(
aSize
,
0
)
);
}
...
...
@@ -80,7 +80,7 @@ void CACHED_CONTAINER::FinishItem()
int
itemOffset
=
m_item
->
GetOffset
();
// Add the not used memory back to the pool
m_freeChunks
.
insert
(
C
hunk
(
m_chunkSize
-
m_itemSize
,
itemOffset
+
m_itemSize
)
);
m_freeChunks
.
insert
(
C
HUNK
(
m_chunkSize
-
m_itemSize
,
itemOffset
+
m_itemSize
)
);
m_freeSpace
+=
(
m_chunkSize
-
m_itemSize
);
// mergeFreeChunks(); // veery slow and buggy
}
...
...
@@ -152,7 +152,7 @@ void CACHED_CONTAINER::Delete( VERTEX_ITEM* aItem )
// Insert a free memory chunk entry in the place where item was stored
if
(
size
>
0
)
{
m_freeChunks
.
insert
(
C
hunk
(
size
,
offset
)
);
m_freeChunks
.
insert
(
C
HUNK
(
size
,
offset
)
);
m_freeSpace
+=
size
;
// Indicate that the item is not stored in the container anymore
aItem
->
setSize
(
0
);
...
...
@@ -186,7 +186,7 @@ void CACHED_CONTAINER::Clear()
// Set the size of all the stored VERTEX_ITEMs to 0, so it is clear that they are not held
// in the container anymore
I
tems
::
iterator
it
;
I
TEMS
::
iterator
it
;
for
(
it
=
m_items
.
begin
();
it
!=
m_items
.
end
();
++
it
)
{
...
...
@@ -198,7 +198,7 @@ void CACHED_CONTAINER::Clear()
// Now there is only free space left
m_freeChunks
.
clear
();
m_freeChunks
.
insert
(
C
hunk
(
m_freeSpace
,
0
)
);
m_freeChunks
.
insert
(
C
HUNK
(
m_freeSpace
,
0
)
);
}
...
...
@@ -240,7 +240,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
}
// Look for the free space chunk of at least given size
F
reeChunkMap
::
iterator
newChunk
=
m_freeChunks
.
lower_bound
(
aSize
);
F
REE_CHUNK_MAP
::
iterator
newChunk
=
m_freeChunks
.
lower_bound
(
aSize
);
if
(
newChunk
==
m_freeChunks
.
end
()
)
{
...
...
@@ -277,7 +277,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
// Free the space previously used by the chunk
wxASSERT
(
m_itemSize
>
0
);
m_freeChunks
.
insert
(
C
hunk
(
m_itemSize
,
m_chunkOffset
)
);
m_freeChunks
.
insert
(
C
HUNK
(
m_itemSize
,
m_chunkOffset
)
);
m_freeSpace
+=
m_itemSize
;
}
...
...
@@ -287,7 +287,7 @@ unsigned int CACHED_CONTAINER::reallocate( unsigned int aSize )
// If there is some space left, return it to the pool - add an entry for it
if
(
chunkSize
>
aSize
)
{
m_freeChunks
.
insert
(
C
hunk
(
chunkSize
-
aSize
,
chunkOffset
+
aSize
)
);
m_freeChunks
.
insert
(
C
HUNK
(
chunkSize
-
aSize
,
chunkOffset
+
aSize
)
);
}
m_freeSpace
-=
aSize
;
...
...
@@ -321,7 +321,7 @@ bool CACHED_CONTAINER::defragment( VERTEX* aTarget )
}
int
newOffset
=
0
;
I
tems
::
iterator
it
,
it_end
;
I
TEMS
::
iterator
it
,
it_end
;
for
(
it
=
m_items
.
begin
(),
it_end
=
m_items
.
end
();
it
!=
it_end
;
++
it
)
{
...
...
@@ -345,7 +345,7 @@ 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
(
C
hunk
(
m_freeSpace
,
m_currentSize
-
m_freeSpace
)
);
m_freeChunks
.
insert
(
C
HUNK
(
m_freeSpace
,
m_currentSize
-
m_freeSpace
)
);
#if CACHED_CONTAINER_TEST > 0
prof_end
(
&
totalTime
);
...
...
@@ -369,9 +369,9 @@ void CACHED_CONTAINER::mergeFreeChunks()
#endif
// Reversed free chunks map - this one stores chunk size with its offset as the key
std
::
list
<
C
hunk
>
freeChunks
;
std
::
list
<
C
HUNK
>
freeChunks
;
F
reeChunkMap
::
const_iterator
it
,
it_end
;
F
REE_CHUNK_MAP
::
const_iterator
it
,
it_end
;
for
(
it
=
m_freeChunks
.
begin
(),
it_end
=
m_freeChunks
.
end
();
it
!=
it_end
;
++
it
)
{
...
...
@@ -381,7 +381,7 @@ void CACHED_CONTAINER::mergeFreeChunks()
m_freeChunks
.
clear
();
freeChunks
.
sort
();
std
::
list
<
C
hunk
>::
const_iterator
itf
,
itf_end
;
std
::
list
<
C
HUNK
>::
const_iterator
itf
,
itf_end
;
unsigned
int
offset
=
freeChunks
.
front
().
first
;
unsigned
int
size
=
freeChunks
.
front
().
second
;
freeChunks
.
pop_front
();
...
...
@@ -449,7 +449,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
(
C
hunk
(
aNewSize
-
reservedSpace
(),
reservedSpace
()
)
);
m_freeChunks
.
insert
(
C
HUNK
(
aNewSize
-
reservedSpace
(),
reservedSpace
()
)
);
}
else
{
...
...
@@ -463,7 +463,7 @@ bool CACHED_CONTAINER::resizeContainer( unsigned int aNewSize )
}
// Add an entry for the new memory chunk at the end of the container
m_freeChunks
.
insert
(
C
hunk
(
aNewSize
-
m_currentSize
,
m_currentSize
)
);
m_freeChunks
.
insert
(
C
HUNK
(
aNewSize
-
m_currentSize
,
m_currentSize
)
);
}
m_vertices
=
newContainer
;
...
...
common/gal/opengl/opengl_gal.cpp
View file @
bc305859
...
...
@@ -691,7 +691,7 @@ void OPENGL_GAL::RestoreScreen()
}
void
OPENGL_GAL
::
SetTarget
(
R
enderTarget
aTarget
)
void
OPENGL_GAL
::
SetTarget
(
R
ENDER_TARGET
aTarget
)
{
switch
(
aTarget
)
{
...
...
@@ -713,13 +713,13 @@ void OPENGL_GAL::SetTarget( RenderTarget aTarget )
}
R
enderTarget
OPENGL_GAL
::
GetTarget
()
const
R
ENDER_TARGET
OPENGL_GAL
::
GetTarget
()
const
{
return
currentTarget
;
}
void
OPENGL_GAL
::
ClearTarget
(
R
enderTarget
aTarget
)
void
OPENGL_GAL
::
ClearTarget
(
R
ENDER_TARGET
aTarget
)
{
// Save the current state
unsigned
int
oldTarget
=
compositor
.
GetBuffer
();
...
...
common/gal/opengl/shader.cpp
View file @
bc305859
...
...
@@ -63,7 +63,7 @@ SHADER::~SHADER()
}
bool
SHADER
::
LoadBuiltinShader
(
unsigned
int
aShaderNumber
,
S
haderType
aShaderType
)
bool
SHADER
::
LoadBuiltinShader
(
unsigned
int
aShaderNumber
,
S
HADER_TYPE
aShaderType
)
{
if
(
aShaderNumber
>=
shaders_number
)
return
false
;
...
...
@@ -72,7 +72,7 @@ bool SHADER::LoadBuiltinShader( unsigned int aShaderNumber, ShaderType aShaderTy
}
bool
SHADER
::
LoadShaderFromFile
(
const
std
::
string
&
aShaderSourceName
,
S
haderType
aShaderType
)
bool
SHADER
::
LoadShaderFromFile
(
const
std
::
string
&
aShaderSourceName
,
S
HADER_TYPE
aShaderType
)
{
// Load shader sources
const
std
::
string
shaderSource
=
readSource
(
aShaderSourceName
);
...
...
@@ -219,7 +219,7 @@ std::string SHADER::readSource( std::string aShaderSourceName )
}
bool
SHADER
::
addSource
(
const
std
::
string
&
aShaderSource
,
S
haderType
aShaderType
)
bool
SHADER
::
addSource
(
const
std
::
string
&
aShaderSource
,
S
HADER_TYPE
aShaderType
)
{
if
(
isShaderLinked
)
{
...
...
common/gal/stroke_font.cpp
View file @
bc305859
...
...
@@ -59,7 +59,7 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
for
(
int
j
=
0
;
j
<
aNewStrokeFontSize
;
j
++
)
{
G
lyph
glyph
;
G
LYPH
glyph
;
double
glyphStartX
=
0.0
;
double
glyphEndX
=
0.0
;
VECTOR2D
glyphBoundingX
;
...
...
@@ -118,21 +118,21 @@ bool STROKE_FONT::LoadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
}
BOX2D
STROKE_FONT
::
computeBoundingBox
(
const
G
lyph
&
aGlyph
,
const
VECTOR2D
&
aGlyph
BoundingX
)
const
BOX2D
STROKE_FONT
::
computeBoundingBox
(
const
G
LYPH
&
aGLYPH
,
const
VECTOR2D
&
aGLYPH
BoundingX
)
const
{
BOX2D
boundingBox
;
std
::
deque
<
VECTOR2D
>
boundingPoints
;
boundingPoints
.
push_back
(
VECTOR2D
(
aG
lyph
BoundingX
.
x
,
0
)
);
boundingPoints
.
push_back
(
VECTOR2D
(
aG
lyph
BoundingX
.
y
,
0
)
);
boundingPoints
.
push_back
(
VECTOR2D
(
aG
LYPH
BoundingX
.
x
,
0
)
);
boundingPoints
.
push_back
(
VECTOR2D
(
aG
LYPH
BoundingX
.
y
,
0
)
);
for
(
G
lyph
::
const_iterator
pointListIt
=
aGlyph
.
begin
();
pointListIt
!=
aGlyph
.
end
();
++
pointListIt
)
for
(
G
LYPH
::
const_iterator
pointListIt
=
aGLYPH
.
begin
();
pointListIt
!=
aGLYPH
.
end
();
++
pointListIt
)
{
for
(
std
::
deque
<
VECTOR2D
>::
const_iterator
pointIt
=
pointListIt
->
begin
();
pointIt
!=
pointListIt
->
end
();
++
pointIt
)
{
boundingPoints
.
push_back
(
VECTOR2D
(
aG
lyph
BoundingX
.
x
,
pointIt
->
y
)
);
boundingPoints
.
push_back
(
VECTOR2D
(
aG
LYPH
BoundingX
.
x
,
pointIt
->
y
)
);
}
}
...
...
@@ -241,15 +241,15 @@ void STROKE_FONT::Draw( std::string aText, const VECTOR2D& aPosition, double aRo
continue
;
}
G
lyphList
::
iterator
glyphIt
=
m_glyphs
.
begin
();
G
LYPH_LIST
::
iterator
glyphIt
=
m_glyphs
.
begin
();
std
::
deque
<
BOX2D
>::
iterator
bbIt
=
m_glyphBoundingBoxes
.
begin
();
advance
(
glyphIt
,
(
int
)
(
*
chIt
)
-
(
int
)
' '
);
advance
(
bbIt
,
(
int
)
(
*
chIt
)
-
(
int
)
' '
);
G
lyph
glyph
=
*
glyphIt
;
G
LYPH
glyph
=
*
glyphIt
;
for
(
G
lyph
::
iterator
pointListIt
=
glyph
.
begin
();
pointListIt
!=
glyph
.
end
();
for
(
G
LYPH
::
iterator
pointListIt
=
glyph
.
begin
();
pointListIt
!=
glyph
.
end
();
pointListIt
++
)
{
std
::
deque
<
VECTOR2D
>
pointListScaled
;
...
...
common/geometry/seg.cpp
View file @
bc305859
...
...
@@ -22,28 +22,27 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <geometry/seg.h>
template
<
typename
T
>
int
sgn
(
T
v
al
)
template
<
typename
T
>
int
sgn
(
T
aV
al
)
{
return
(
T
(
0
)
<
val
)
-
(
v
al
<
T
(
0
)
);
return
(
T
(
0
)
<
aVal
)
-
(
aV
al
<
T
(
0
)
);
}
bool
SEG
::
PointCloserThan
(
const
VECTOR2I
&
aP
,
int
d
ist
)
const
bool
SEG
::
PointCloserThan
(
const
VECTOR2I
&
aP
,
int
aD
ist
)
const
{
VECTOR2I
d
=
b
-
a
;
ecoord
dist_sq
=
(
ecoord
)
dist
*
d
ist
;
VECTOR2I
d
=
B
-
A
;
ecoord
dist_sq
=
(
ecoord
)
aDist
*
aD
ist
;
SEG
::
ecoord
l_squared
=
d
.
Dot
(
d
);
SEG
::
ecoord
t
=
d
.
Dot
(
aP
-
a
);
SEG
::
ecoord
t
=
d
.
Dot
(
aP
-
A
);
if
(
t
<=
0
||
!
l_squared
)
return
(
aP
-
a
).
SquaredEuclideanNorm
()
<
dist_sq
;
return
(
aP
-
A
).
SquaredEuclideanNorm
()
<
dist_sq
;
else
if
(
t
>=
l_squared
)
return
(
aP
-
b
).
SquaredEuclideanNorm
()
<
dist_sq
;
return
(
aP
-
B
).
SquaredEuclideanNorm
()
<
dist_sq
;
int
dxdy
=
abs
(
d
.
x
)
-
abs
(
d
.
y
);
...
...
@@ -51,7 +50,7 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const
{
int
ca
=
-
sgn
(
d
.
y
);
int
cb
=
sgn
(
d
.
x
);
int
cc
=
-
ca
*
a
.
x
-
cb
*
a
.
y
;
int
cc
=
-
ca
*
A
.
x
-
cb
*
A
.
y
;
ecoord
num
=
ca
*
aP
.
x
+
cb
*
aP
.
y
+
cc
;
num
*=
num
;
...
...
@@ -66,8 +65,8 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int dist ) const
}
VECTOR2I
nearest
;
nearest
.
x
=
a
.
x
+
rescale
(
t
,
(
ecoord
)
d
.
x
,
l_squared
);
nearest
.
y
=
a
.
y
+
rescale
(
t
,
(
ecoord
)
d
.
y
,
l_squared
);
nearest
.
x
=
A
.
x
+
rescale
(
t
,
(
ecoord
)
d
.
x
,
l_squared
);
nearest
.
y
=
A
.
y
+
rescale
(
t
,
(
ecoord
)
d
.
y
,
l_squared
);
return
(
nearest
-
aP
).
SquaredEuclideanNorm
()
<=
dist_sq
;
}
...
...
@@ -81,10 +80,10 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
const
VECTOR2I
pts
[
4
]
=
{
aSeg
.
NearestPoint
(
a
)
-
a
,
aSeg
.
NearestPoint
(
b
)
-
b
,
NearestPoint
(
aSeg
.
a
)
-
aSeg
.
a
,
NearestPoint
(
aSeg
.
b
)
-
aSeg
.
b
aSeg
.
NearestPoint
(
A
)
-
A
,
aSeg
.
NearestPoint
(
B
)
-
B
,
NearestPoint
(
aSeg
.
A
)
-
aSeg
.
A
,
NearestPoint
(
aSeg
.
B
)
-
aSeg
.
B
};
ecoord
m
=
VECTOR2I
::
ECOORD_MAX
;
...
...
@@ -98,9 +97,9 @@ SEG::ecoord SEG::SquaredDistance( const SEG& aSeg ) const
OPT_VECTOR2I
SEG
::
Intersect
(
const
SEG
&
aSeg
,
bool
aIgnoreEndpoints
,
bool
aLines
)
const
{
const
VECTOR2I
e
(
b
-
a
);
const
VECTOR2I
f
(
aSeg
.
b
-
aSeg
.
a
);
const
VECTOR2I
ac
(
aSeg
.
a
-
a
);
const
VECTOR2I
e
(
B
-
A
);
const
VECTOR2I
f
(
aSeg
.
B
-
aSeg
.
A
);
const
VECTOR2I
ac
(
aSeg
.
A
-
A
);
ecoord
d
=
f
.
Cross
(
e
);
ecoord
p
=
f
.
Cross
(
ac
);
...
...
@@ -118,16 +117,16 @@ OPT_VECTOR2I SEG::Intersect( const SEG& aSeg, bool aIgnoreEndpoints, bool aLines
if
(
!
aLines
&&
aIgnoreEndpoints
&&
(
q
==
0
||
q
==
d
)
&&
(
p
==
0
||
p
==
d
)
)
return
OPT_VECTOR2I
();
VECTOR2I
ip
(
aSeg
.
a
.
x
+
rescale
(
q
,
(
ecoord
)
f
.
x
,
d
),
aSeg
.
a
.
y
+
rescale
(
q
,
(
ecoord
)
f
.
y
,
d
)
);
VECTOR2I
ip
(
aSeg
.
A
.
x
+
rescale
(
q
,
(
ecoord
)
f
.
x
,
d
),
aSeg
.
A
.
y
+
rescale
(
q
,
(
ecoord
)
f
.
y
,
d
)
);
return
ip
;
}
bool
SEG
::
ccw
(
const
VECTOR2I
&
a
,
const
VECTOR2I
&
b
,
const
VECTOR2I
&
c
)
const
bool
SEG
::
ccw
(
const
VECTOR2I
&
a
A
,
const
VECTOR2I
&
aB
,
const
VECTOR2I
&
aC
)
const
{
return
(
ecoord
)
(
c
.
y
-
a
.
y
)
*
(
b
.
x
-
a
.
x
)
>
(
ecoord
)
(
b
.
y
-
a
.
y
)
*
(
c
.
x
-
a
.
x
);
return
(
ecoord
)
(
aC
.
y
-
aA
.
y
)
*
(
aB
.
x
-
aA
.
x
)
>
(
ecoord
)
(
aB
.
y
-
aA
.
y
)
*
(
aC
.
x
-
aA
.
x
);
}
...
...
@@ -135,17 +134,17 @@ bool SEG::Collide( const SEG& aSeg, int aClearance ) const
{
// check for intersection
// fixme: move to a method
if
(
ccw
(
a
,
aSeg
.
a
,
aSeg
.
b
)
!=
ccw
(
b
,
aSeg
.
a
,
aSeg
.
b
)
&&
ccw
(
a
,
b
,
aSeg
.
a
)
!=
ccw
(
a
,
b
,
aSeg
.
b
)
)
if
(
ccw
(
A
,
aSeg
.
A
,
aSeg
.
B
)
!=
ccw
(
B
,
aSeg
.
A
,
aSeg
.
B
)
&&
ccw
(
A
,
B
,
aSeg
.
A
)
!=
ccw
(
A
,
B
,
aSeg
.
B
)
)
return
true
;
#define CHK( _seg, _pt ) \
if( (_seg).PointCloserThan( _pt, aClearance ) ) return true;
CHK
(
*
this
,
aSeg
.
a
);
CHK
(
*
this
,
aSeg
.
b
);
CHK
(
aSeg
,
a
);
CHK
(
aSeg
,
b
);
CHK
(
*
this
,
aSeg
.
A
);
CHK
(
*
this
,
aSeg
.
B
);
CHK
(
aSeg
,
A
);
CHK
(
aSeg
,
B
);
#undef CHK
return
false
;
...
...
common/geometry/shape_collisions.cpp
View file @
bc305859
...
...
@@ -50,6 +50,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_CIRCLE& aB, int
return
true
;
}
static
inline
bool
Collide
(
const
SHAPE_RECT
&
aA
,
const
SHAPE_CIRCLE
&
aB
,
int
aClearance
,
bool
aNeedMTV
,
VECTOR2I
&
aMTV
)
{
...
...
@@ -154,7 +155,8 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN& aB, in
}
bool
CollideShapes
(
const
SHAPE
*
aA
,
const
SHAPE
*
aB
,
int
aClearance
,
bool
aNeedMTV
,
VECTOR2I
&
aMTV
)
bool
CollideShapes
(
const
SHAPE
*
aA
,
const
SHAPE
*
aB
,
int
aClearance
,
bool
aNeedMTV
,
VECTOR2I
&
aMTV
)
{
switch
(
aA
->
Type
()
)
{
...
...
@@ -172,6 +174,7 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed
default:
break
;
}
break
;
case
SH_CIRCLE
:
switch
(
aB
->
Type
()
)
...
...
@@ -191,6 +194,7 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed
default:
break
;
}
break
;
case
SH_LINE_CHAIN
:
switch
(
aB
->
Type
()
)
...
...
@@ -210,6 +214,7 @@ bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeed
default:
break
;
}
break
;
default:
break
;
...
...
common/geometry/shape_index.cpp
View file @
bc305859
...
...
@@ -25,7 +25,7 @@
#include <geometry/shape_index.h>
template
<>
template
<>
const
SHAPE
*
shapeFunctor
(
SHAPE
*
aItem
)
{
return
aItem
;
...
...
common/geometry/shape_line_chain.cpp
View file @
bc305859
...
...
@@ -31,6 +31,7 @@ using boost::optional;
bool
SHAPE_LINE_CHAIN
::
Collide
(
const
VECTOR2I
&
aP
,
int
aClearance
)
const
{
assert
(
false
);
return
false
;
}
...
...
@@ -38,19 +39,20 @@ bool SHAPE_LINE_CHAIN::Collide( const VECTOR2I& aP, int aClearance ) const
bool
SHAPE_LINE_CHAIN
::
Collide
(
const
BOX2I
&
aBox
,
int
aClearance
)
const
{
assert
(
false
);
return
false
;
}
bool
SHAPE_LINE_CHAIN
::
Collide
(
const
SEG
&
aSeg
,
int
aClearance
)
const
{
BOX2I
box_a
(
aSeg
.
a
,
aSeg
.
b
-
aSeg
.
a
);
BOX2I
box_a
(
aSeg
.
A
,
aSeg
.
B
-
aSeg
.
A
);
BOX2I
::
ecoord_type
dist_sq
=
(
BOX2I
::
ecoord_type
)
aClearance
*
aClearance
;
for
(
int
i
=
0
;
i
<
SegmentCount
();
i
++
)
{
const
SEG
&
s
=
CSegment
(
i
);
BOX2I
box_b
(
s
.
a
,
s
.
b
-
s
.
a
);
BOX2I
box_b
(
s
.
A
,
s
.
B
-
s
.
A
);
BOX2I
::
ecoord_type
d
=
box_a
.
SquaredDistance
(
box_b
);
...
...
@@ -158,7 +160,7 @@ int SHAPE_LINE_CHAIN::Split( const VECTOR2I& aP )
// make sure we are not producing a 'slightly concave' primitive. This might happen
// if aP lies very close to one of already existing points.
if
(
dist
<
min_dist
&&
seg
.
a
!=
aP
&&
seg
.
b
!=
aP
)
if
(
dist
<
min_dist
&&
seg
.
A
!=
aP
&&
seg
.
B
!=
aP
)
{
min_dist
=
dist
;
ii
=
s
;
...
...
@@ -208,8 +210,8 @@ struct compareOriginDistance
compareOriginDistance
(
VECTOR2I
&
aOrigin
)
:
m_origin
(
aOrigin
)
{};
bool
operator
()(
const
SHAPE_LINE_CHAIN
::
I
ntersection
&
aA
,
const
SHAPE_LINE_CHAIN
::
I
ntersection
&
aB
)
bool
operator
()(
const
SHAPE_LINE_CHAIN
::
I
NTERSECTION
&
aA
,
const
SHAPE_LINE_CHAIN
::
I
NTERSECTION
&
aB
)
{
return
(
m_origin
-
aA
.
p
).
EuclideanNorm
()
<
(
m_origin
-
aB
.
p
).
EuclideanNorm
();
}
...
...
@@ -218,7 +220,7 @@ struct compareOriginDistance
};
int
SHAPE_LINE_CHAIN
::
Intersect
(
const
SEG
&
aSeg
,
I
ntersections
&
aIp
)
const
int
SHAPE_LINE_CHAIN
::
Intersect
(
const
SEG
&
aSeg
,
I
NTERSECTIONS
&
aIp
)
const
{
for
(
int
s
=
0
;
s
<
SegmentCount
();
s
++
)
{
...
...
@@ -226,7 +228,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const
if
(
p
)
{
I
ntersection
is
;
I
NTERSECTION
is
;
is
.
our
=
CSegment
(
s
);
is
.
their
=
aSeg
;
is
.
p
=
*
p
;
...
...
@@ -234,21 +236,21 @@ int SHAPE_LINE_CHAIN::Intersect( const SEG& aSeg, Intersections& aIp ) const
}
}
compareOriginDistance
comp
(
aSeg
.
a
);
compareOriginDistance
comp
(
aSeg
.
A
);
sort
(
aIp
.
begin
(),
aIp
.
end
(),
comp
);
return
aIp
.
size
();
}
int
SHAPE_LINE_CHAIN
::
Intersect
(
const
SHAPE_LINE_CHAIN
&
aChain
,
I
ntersections
&
aIp
)
const
int
SHAPE_LINE_CHAIN
::
Intersect
(
const
SHAPE_LINE_CHAIN
&
aChain
,
I
NTERSECTIONS
&
aIp
)
const
{
BOX2I
bb_other
=
aChain
.
BBox
();
for
(
int
s1
=
0
;
s1
<
SegmentCount
();
s1
++
)
{
const
SEG
&
a
=
CSegment
(
s1
);
const
BOX2I
bb_cur
(
a
.
a
,
a
.
b
-
a
.
a
);
const
BOX2I
bb_cur
(
a
.
A
,
a
.
B
-
a
.
A
);
if
(
!
bb_other
.
Intersects
(
bb_cur
)
)
continue
;
...
...
@@ -256,14 +258,14 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
for
(
int
s2
=
0
;
s2
<
aChain
.
SegmentCount
();
s2
++
)
{
const
SEG
&
b
=
aChain
.
CSegment
(
s2
);
I
ntersection
is
;
I
NTERSECTION
is
;
if
(
a
.
Collinear
(
b
)
)
{
if
(
a
.
Contains
(
b
.
a
)
)
{
is
.
p
=
b
.
a
;
aIp
.
push_back
(
is
);
}
if
(
a
.
Contains
(
b
.
b
)
)
{
is
.
p
=
b
.
b
;
aIp
.
push_back
(
is
);
}
if
(
b
.
Contains
(
a
.
a
)
)
{
is
.
p
=
a
.
a
;
aIp
.
push_back
(
is
);
}
if
(
b
.
Contains
(
a
.
b
)
)
{
is
.
p
=
a
.
b
;
aIp
.
push_back
(
is
);
}
if
(
a
.
Contains
(
b
.
A
)
)
{
is
.
p
=
b
.
A
;
aIp
.
push_back
(
is
);
}
if
(
a
.
Contains
(
b
.
B
)
)
{
is
.
p
=
b
.
B
;
aIp
.
push_back
(
is
);
}
if
(
b
.
Contains
(
a
.
A
)
)
{
is
.
p
=
a
.
A
;
aIp
.
push_back
(
is
);
}
if
(
b
.
Contains
(
a
.
B
)
)
{
is
.
p
=
a
.
B
;
aIp
.
push_back
(
is
);
}
}
else
{
...
...
@@ -289,7 +291,7 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
const
SEG
&
a
=
CSegment
(
s1
);
const
SEG
&
b
=
aChain
.
CSegment
(
s2
);
OPT_VECTOR2I
p
=
a
.
Intersect
(
b
);
I
ntersection
is
;
I
NTERSECTION
is
;
if
(
p
)
{
...
...
@@ -300,16 +302,16 @@ int SHAPE_LINE_CHAIN::Intersect( const SHAPE_LINE_CHAIN& aChain, Intersections&
}
else
if
(
a
.
Collinear
(
b
)
)
{
if
(
a
.
a
!=
b
.
a
&&
a
.
a
!=
b
.
b
&&
b
.
Contains
(
a
.
a
)
)
if
(
a
.
A
!=
b
.
A
&&
a
.
A
!=
b
.
B
&&
b
.
Contains
(
a
.
A
)
)
{
is
.
p
=
a
.
a
;
is
.
p
=
a
.
A
;
is
.
our
=
a
;
is
.
their
=
b
;
aIp
.
push_back
(
is
);
}
else
if
(
a
.
b
!=
b
.
a
&&
a
.
b
!=
b
.
b
&&
b
.
Contains
(
a
.
b
)
)
else
if
(
a
.
B
!=
b
.
A
&&
a
.
B
!=
b
.
B
&&
b
.
Contains
(
a
.
B
)
)
{
is
.
p
=
a
.
b
;
is
.
p
=
a
.
B
;
is
.
our
=
a
;
is
.
their
=
b
;
aIp
.
push_back
(
is
);
...
...
@@ -333,7 +335,7 @@ int SHAPE_LINE_CHAIN::PathLength( const VECTOR2I& aP ) const
if
(
d
<=
1
)
{
sum
+=
(
aP
-
seg
.
a
).
EuclideanNorm
();
sum
+=
(
aP
-
seg
.
A
).
EuclideanNorm
();
return
sum
;
}
else
...
...
@@ -358,7 +360,7 @@ bool SHAPE_LINE_CHAIN::PointInside( const VECTOR2I& aP ) const
{
const
SEG
s
=
CSegment
(
i
);
if
(
aP
==
s
.
a
||
aP
==
s
.
b
)
// edge does not belong to the interior!
if
(
aP
==
s
.
A
||
aP
==
s
.
B
)
// edge does not belong to the interior!
return
false
;
if
(
s
.
Side
(
aP
)
!=
cur
)
...
...
@@ -378,7 +380,7 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const
{
const
SEG
s
=
CSegment
(
i
);
if
(
s
.
a
==
aP
||
s
.
b
==
aP
)
if
(
s
.
A
==
aP
||
s
.
B
==
aP
)
return
true
;
if
(
s
.
Distance
(
aP
)
<=
1
)
...
...
@@ -389,17 +391,17 @@ bool SHAPE_LINE_CHAIN::PointOnEdge( const VECTOR2I& aP ) const
}
const
optional
<
SHAPE_LINE_CHAIN
::
I
ntersection
>
SHAPE_LINE_CHAIN
::
SelfIntersecting
()
const
const
optional
<
SHAPE_LINE_CHAIN
::
I
NTERSECTION
>
SHAPE_LINE_CHAIN
::
SelfIntersecting
()
const
{
for
(
int
s1
=
0
;
s1
<
SegmentCount
();
s1
++
)
{
for
(
int
s2
=
s1
+
1
;
s2
<
SegmentCount
();
s2
++
)
{
const
VECTOR2I
s2a
=
CSegment
(
s2
).
a
,
s2b
=
CSegment
(
s2
).
b
;
const
VECTOR2I
s2a
=
CSegment
(
s2
).
A
,
s2b
=
CSegment
(
s2
).
B
;
if
(
s1
+
1
!=
s2
&&
CSegment
(
s1
).
Contains
(
s2a
)
)
{
I
ntersection
is
;
I
NTERSECTION
is
;
is
.
our
=
CSegment
(
s1
);
is
.
their
=
CSegment
(
s2
);
is
.
p
=
s2a
;
...
...
@@ -407,7 +409,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
}
else
if
(
CSegment
(
s1
).
Contains
(
s2b
)
)
{
I
ntersection
is
;
I
NTERSECTION
is
;
is
.
our
=
CSegment
(
s1
);
is
.
their
=
CSegment
(
s2
);
is
.
p
=
s2b
;
...
...
@@ -419,7 +421,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
if
(
p
)
{
I
ntersection
is
;
I
NTERSECTION
is
;
is
.
our
=
CSegment
(
s1
);
is
.
their
=
CSegment
(
s2
);
is
.
p
=
*
p
;
...
...
@@ -429,7 +431,7 @@ const optional<SHAPE_LINE_CHAIN::Intersection> SHAPE_LINE_CHAIN::SelfIntersectin
}
}
return
optional
<
I
ntersection
>
();
return
optional
<
I
NTERSECTION
>
();
}
...
...
common/math/math_util.cpp
View file @
bc305859
...
...
@@ -28,31 +28,32 @@
#include <climits>
#include <math/math_util.h>
template
<>
int
rescale
(
int
numerator
,
int
value
,
int
d
enominator
)
template
<>
int
rescale
(
int
aNumerator
,
int
aValue
,
int
aD
enominator
)
{
return
(
int
)
(
(
int64_t
)
numerator
*
(
int64_t
)
value
/
(
int64_t
)
d
enominator
);
return
(
int
)
(
(
int64_t
)
aNumerator
*
(
int64_t
)
aValue
/
(
int64_t
)
aD
enominator
);
}
template
<>
int64_t
rescale
(
int64_t
numerator
,
int64_t
value
,
int64_t
d
enominator
)
template
<>
int64_t
rescale
(
int64_t
aNumerator
,
int64_t
aValue
,
int64_t
aD
enominator
)
{
int64_t
r
=
0
;
int64_t
sign
=
(
(
numerator
<
0
)
?
-
1
:
1
)
*
(
denominator
<
0
?
-
1
:
1
)
*
(
value
<
0
?
-
1
:
1
);
int64_t
sign
=
(
(
aNumerator
<
0
)
?
-
1
:
1
)
*
(
aDenominator
<
0
?
-
1
:
1
)
*
(
aValue
<
0
?
-
1
:
1
);
int64_t
a
=
std
::
abs
(
n
umerator
);
int64_t
b
=
std
::
abs
(
v
alue
);
int64_t
c
=
std
::
abs
(
d
enominator
);
int64_t
a
=
std
::
abs
(
aN
umerator
);
int64_t
b
=
std
::
abs
(
aV
alue
);
int64_t
c
=
std
::
abs
(
aD
enominator
);
r
=
c
/
2
;
if
(
b
<=
INT_MAX
&&
c
<=
INT_MAX
)
{
if
(
a
<=
INT_MAX
)
return
sign
*
(
(
a
*
b
+
r
)
/
c
);
return
sign
*
(
(
a
*
b
+
r
)
/
c
);
else
return
sign
*
(
a
/
c
*
b
+
(
a
%
c
*
b
+
r
)
/
c
);
return
sign
*
(
a
/
c
*
b
+
(
a
%
c
*
b
+
r
)
/
c
);
}
else
{
...
...
common/tool/context_menu.cpp
View file @
bc305859
...
...
@@ -104,8 +104,8 @@ void CONTEXT_MENU::Add( const TOOL_ACTION& aAction )
wxString
menuEntry
;
if
(
aAction
.
HasHotKey
()
)
menuEntry
=
wxString
(
(
aAction
.
GetMenuItem
()
+
'\t'
+
getHotKeyDescription
(
aAction
)
).
c_str
(),
wxConvUTF8
);
menuEntry
=
wxString
(
(
aAction
.
GetMenuItem
()
+
'\t'
+
getHotKeyDescription
(
aAction
)
).
c_str
(),
wxConvUTF8
);
else
menuEntry
=
wxString
(
aAction
.
GetMenuItem
().
c_str
(),
wxConvUTF8
);
...
...
@@ -134,17 +134,17 @@ std::string CONTEXT_MENU::getHotKeyDescription( const TOOL_ACTION& aAction ) con
std
::
string
description
=
""
;
if
(
hotkey
&
MD_
ModAlt
)
if
(
hotkey
&
MD_
ALT
)
description
+=
"ALT+"
;
if
(
hotkey
&
MD_
ModCtrl
)
if
(
hotkey
&
MD_
CTRL
)
description
+=
"CTRL+"
;
if
(
hotkey
&
MD_
ModShift
)
if
(
hotkey
&
MD_
SHIFT
)
description
+=
"SHIFT+"
;
// TODO dispatch keys such as Fx, TAB, PG_UP/DN, HOME, END, etc.
description
+=
char
(
hotkey
&
~
MD_ModifierMask
);
description
+=
char
(
hotkey
&
~
MD_MODIFIER_MASK
);
return
description
;
}
...
...
@@ -159,7 +159,7 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent )
// For example, the selection tool can use this to dynamically highlight the current item
// from selection clarification popup.
if
(
type
==
wxEVT_MENU_HIGHLIGHT
)
evt
=
TOOL_EVENT
(
TC_C
ommand
,
TA_ContextMenuUpdate
,
aEvent
.
GetId
()
);
evt
=
TOOL_EVENT
(
TC_C
OMMAND
,
TA_CONTEXT_MENU_UPDATE
,
aEvent
.
GetId
()
);
// One of menu entries was selected..
else
if
(
type
==
wxEVT_COMMAND_MENU_SELECTED
)
...
...
@@ -172,7 +172,7 @@ void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent )
else
{
// Handling non-action menu entries (e.g. items in clarification list)
evt
=
TOOL_EVENT
(
TC_C
ommand
,
TA_ContextMenuChoice
,
aEvent
.
GetId
()
);
evt
=
TOOL_EVENT
(
TC_C
OMMAND
,
TA_CONTEXT_MENU_CHOICE
,
aEvent
.
GetId
()
);
}
}
...
...
common/tool/tool_dispatcher.cpp
View file @
bc305859
...
...
@@ -40,9 +40,9 @@
using
boost
::
optional
;
///> Stores information about a mouse button state
struct
TOOL_DISPATCHER
::
B
uttonState
struct
TOOL_DISPATCHER
::
B
UTTON_STATE
{
B
uttonState
(
TOOL_MouseButtons
aButton
,
const
wxEventType
&
aDownEvent
,
B
UTTON_STATE
(
TOOL_MOUSE_BUTTONS
aButton
,
const
wxEventType
&
aDownEvent
,
const
wxEventType
&
aUpEvent
)
:
button
(
aButton
),
downEvent
(
aDownEvent
),
...
...
@@ -66,7 +66,7 @@ struct TOOL_DISPATCHER::ButtonState
double
dragMaxDelta
;
///> Determines the mouse button for which information are stored.
TOOL_M
ouseButtons
button
;
TOOL_M
OUSE_BUTTONS
button
;
///> The type of wxEvent that determines mouse button press.
wxEventType
downEvent
;
...
...
@@ -89,9 +89,9 @@ struct TOOL_DISPATCHER::ButtonState
TOOL_DISPATCHER
::
TOOL_DISPATCHER
(
TOOL_MANAGER
*
aToolMgr
,
PCB_BASE_FRAME
*
aEditFrame
)
:
m_toolMgr
(
aToolMgr
),
m_editFrame
(
aEditFrame
)
{
m_buttons
.
push_back
(
new
B
uttonState
(
MB_Left
,
wxEVT_LEFT_DOWN
,
wxEVT_LEFT_UP
)
);
m_buttons
.
push_back
(
new
B
uttonState
(
MB_Right
,
wxEVT_RIGHT_DOWN
,
wxEVT_RIGHT_UP
)
);
m_buttons
.
push_back
(
new
B
uttonState
(
MB_Middle
,
wxEVT_MIDDLE_DOWN
,
wxEVT_MIDDLE_UP
)
);
m_buttons
.
push_back
(
new
B
UTTON_STATE
(
MB_LEFT
,
wxEVT_LEFT_DOWN
,
wxEVT_LEFT_UP
)
);
m_buttons
.
push_back
(
new
B
UTTON_STATE
(
MB_RIGHT
,
wxEVT_RIGHT_DOWN
,
wxEVT_RIGHT_UP
)
);
m_buttons
.
push_back
(
new
B
UTTON_STATE
(
MB_MIDDLE
,
wxEVT_MIDDLE_DOWN
,
wxEVT_MIDDLE_UP
)
);
ResetState
();
}
...
...
@@ -99,14 +99,14 @@ TOOL_DISPATCHER::TOOL_DISPATCHER( TOOL_MANAGER* aToolMgr, PCB_BASE_FRAME* aEditF
TOOL_DISPATCHER
::~
TOOL_DISPATCHER
()
{
BOOST_FOREACH
(
B
uttonState
*
st
,
m_buttons
)
BOOST_FOREACH
(
B
UTTON_STATE
*
st
,
m_buttons
)
delete
st
;
}
void
TOOL_DISPATCHER
::
ResetState
()
{
BOOST_FOREACH
(
B
uttonState
*
st
,
m_buttons
)
BOOST_FOREACH
(
B
UTTON_STATE
*
st
,
m_buttons
)
st
->
Reset
();
}
...
...
@@ -119,7 +119,7 @@ KIGFX::VIEW* TOOL_DISPATCHER::getView()
bool
TOOL_DISPATCHER
::
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
)
{
B
uttonState
*
st
=
m_buttons
[
aIndex
];
B
UTTON_STATE
*
st
=
m_buttons
[
aIndex
];
wxEventType
type
=
aEvent
.
GetEventType
();
optional
<
TOOL_EVENT
>
evt
;
bool
isClick
=
false
;
...
...
@@ -137,7 +137,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
st
->
downPosition
=
m_lastMousePos
;
st
->
dragMaxDelta
=
0
;
st
->
pressed
=
true
;
evt
=
TOOL_EVENT
(
TC_M
ouse
,
TA_MouseDown
,
args
);
evt
=
TOOL_EVENT
(
TC_M
OUSE
,
TA_MOUSE_DOWN
,
args
);
}
else
if
(
up
)
// Handle mouse button release
{
...
...
@@ -152,13 +152,13 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
st
->
dragMaxDelta
<
DragDistanceThreshold
)
isClick
=
true
;
else
evt
=
TOOL_EVENT
(
TC_M
ouse
,
TA_MouseUp
,
args
);
evt
=
TOOL_EVENT
(
TC_M
OUSE
,
TA_MOUSE_UP
,
args
);
}
else
isClick
=
true
;
if
(
isClick
)
evt
=
TOOL_EVENT
(
TC_M
ouse
,
TA_MouseClick
,
args
);
evt
=
TOOL_EVENT
(
TC_M
OUSE
,
TA_MOUSE_CLICK
,
args
);
st
->
dragging
=
false
;
}
...
...
@@ -174,7 +174,7 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
if
(
t
-
st
->
downTimestamp
>
DragTimeThreshold
||
st
->
dragMaxDelta
>
DragDistanceThreshold
)
{
evt
=
TOOL_EVENT
(
TC_M
ouse
,
TA_MouseDrag
,
args
);
evt
=
TOOL_EVENT
(
TC_M
OUSE
,
TA_MOUSE_DRAG
,
args
);
evt
->
SetMouseDragOrigin
(
st
->
dragOrigin
);
evt
->
SetMouseDelta
(
m_lastMousePos
-
st
->
dragOrigin
);
}
...
...
@@ -222,7 +222,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if
(
!
buttonEvents
&&
motion
)
{
evt
=
TOOL_EVENT
(
TC_M
ouse
,
TA_MouseMotion
);
evt
=
TOOL_EVENT
(
TC_M
OUSE
,
TA_MOUSE_MOTION
);
evt
->
SetMousePosition
(
pos
);
}
}
...
...
@@ -237,13 +237,13 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if
(
type
==
wxEVT_KEY_UP
)
{
if
(
key
==
WXK_ESCAPE
)
// ESC is the special key for cancelling tools
evt
=
TOOL_EVENT
(
TC_C
ommand
,
TA_CancelTool
);
evt
=
TOOL_EVENT
(
TC_C
OMMAND
,
TA_CANCEL_TOOL
);
else
evt
=
TOOL_EVENT
(
TC_K
eyboard
,
TA_KeyUp
,
key
|
mods
);
evt
=
TOOL_EVENT
(
TC_K
EYBOARD
,
TA_KEY_UP
,
key
|
mods
);
}
else
{
evt
=
TOOL_EVENT
(
TC_K
eyboard
,
TA_KeyDown
,
key
|
mods
);
evt
=
TOOL_EVENT
(
TC_K
EYBOARD
,
TA_KEY_DOWN
,
key
|
mods
);
}
}
...
...
common/tool/tool_event.cpp
View file @
bc305859
...
...
@@ -40,14 +40,14 @@ struct FlagString
};
static
const
std
::
string
flag2string
(
int
flag
,
const
FlagString
*
e
xps
)
static
const
std
::
string
flag2string
(
int
aFlag
,
const
FlagString
*
aE
xps
)
{
std
::
string
rv
;
for
(
int
i
=
0
;
e
xps
[
i
].
str
.
length
();
i
++
)
for
(
int
i
=
0
;
aE
xps
[
i
].
str
.
length
();
i
++
)
{
if
(
exps
[
i
].
flag
&
f
lag
)
rv
+=
e
xps
[
i
].
str
+
" "
;
if
(
aExps
[
i
].
flag
&
aF
lag
)
rv
+=
aE
xps
[
i
].
str
+
" "
;
}
return
rv
;
...
...
@@ -66,50 +66,50 @@ const std::string TOOL_EVENT::Format() const
const
FlagString
categories
[]
=
{
{
TC_M
ouse
,
"mouse"
},
{
TC_K
eyboard
,
"keyboard"
},
{
TC_C
ommand
,
"command"
},
{
TC_M
essage
,
"message"
},
{
TC_V
iew
,
"view"
},
{
TC_M
OUSE
,
"mouse"
},
{
TC_K
EYBOARD
,
"keyboard"
},
{
TC_C
OMMAND
,
"command"
},
{
TC_M
ESSAGE
,
"message"
},
{
TC_V
IEW
,
"view"
},
{
0
,
""
}
};
const
FlagString
actions
[]
=
{
{
TA_M
ouseClick
,
"click"
},
{
TA_M
ouseUp
,
"button-up"
},
{
TA_M
ouseDown
,
"button-down"
},
{
TA_M
ouseDrag
,
"drag"
},
{
TA_M
ouseMotion
,
"motion"
},
{
TA_M
ouseWheel
,
"wheel"
},
{
TA_K
eyUp
,
"key-up"
},
{
TA_K
eyDown
,
"key-down"
},
{
TA_V
iewRefresh
,
"view-refresh"
},
{
TA_V
iewZoom
,
"view-zoom"
},
{
TA_V
iewPan
,
"view-pan"
},
{
TA_V
iewDirty
,
"view-dirty"
},
{
TA_C
hangeLayer
,
"change-layer"
},
{
TA_C
ancelTool
,
"cancel-tool"
},
{
TA_C
ontextMenuUpdate
,
"context-menu-update"
},
{
TA_C
ontextMenuChoice
,
"context-menu-choice"
},
{
TA_A
ction
,
"action"
},
{
TA_M
OUSE_CLICK
,
"click"
},
{
TA_M
OUSE_UP
,
"button-up"
},
{
TA_M
OUSE_DOWN
,
"button-down"
},
{
TA_M
OUSE_DRAG
,
"drag"
},
{
TA_M
OUSE_MOTION
,
"motion"
},
{
TA_M
OUSE_WHEEL
,
"wheel"
},
{
TA_K
EY_UP
,
"key-up"
},
{
TA_K
EY_DOWN
,
"key-down"
},
{
TA_V
IEW_REFRESH
,
"view-refresh"
},
{
TA_V
IEW_ZOOM
,
"view-zoom"
},
{
TA_V
IEW_PAN
,
"view-pan"
},
{
TA_V
IEW_DIRTY
,
"view-dirty"
},
{
TA_C
HANGE_LAYER
,
"change-layer"
},
{
TA_C
ANCEL_TOOL
,
"cancel-tool"
},
{
TA_C
ONTEXT_MENU_UPDATE
,
"context-menu-update"
},
{
TA_C
ONTEXT_MENU_CHOICE
,
"context-menu-choice"
},
{
TA_A
CTION
,
"action"
},
{
0
,
""
}
};
const
FlagString
buttons
[]
=
{
{
MB_N
one
,
"none"
},
{
MB_L
eft
,
"left"
},
{
MB_R
ight
,
"right"
},
{
MB_M
iddle
,
"middle"
},
{
MB_N
ONE
,
"none"
},
{
MB_L
EFT
,
"left"
},
{
MB_R
IGHT
,
"right"
},
{
MB_M
IDDLE
,
"middle"
},
{
0
,
""
}
};
const
FlagString
modifiers
[]
=
{
{
MD_
ModShift
,
"shift"
},
{
MD_
ModCtrl
,
"ctrl"
},
{
MD_
ModAlt
,
"alt"
},
{
MD_
SHIFT
,
"shift"
},
{
MD_
CTRL
,
"ctrl"
},
{
MD_
ALT
,
"alt"
},
{
0
,
""
}
};
...
...
@@ -118,20 +118,20 @@ const std::string TOOL_EVENT::Format() const
ev
+=
" action: "
;
ev
+=
flag2string
(
m_actions
,
actions
);
if
(
m_actions
&
TA_M
ouse
)
if
(
m_actions
&
TA_M
OUSE
)
{
ev
+=
" btns: "
;
ev
+=
flag2string
(
m_mouseButtons
,
buttons
);
}
if
(
m_actions
&
TA_K
eyboard
)
if
(
m_actions
&
TA_K
EYBOARD
)
{
char
tmp
[
128
];
sprintf
(
tmp
,
"key: %d"
,
m_keyCode
);
ev
+=
tmp
;
}
if
(
m_actions
&
(
TA_M
ouse
|
TA_Keyboard
)
)
if
(
m_actions
&
(
TA_M
OUSE
|
TA_KEYBOARD
)
)
{
ev
+=
" mods: "
;
ev
+=
flag2string
(
m_modifiers
,
modifiers
);
...
...
common/tool/tool_interactive.cpp
View file @
bc305859
...
...
@@ -30,13 +30,13 @@
#include <tool/context_menu.h>
TOOL_INTERACTIVE
::
TOOL_INTERACTIVE
(
TOOL_ID
aId
,
const
std
::
string
&
aName
)
:
TOOL_BASE
(
TOOL_Interactive
,
aId
,
aName
)
TOOL_BASE
(
INTERACTIVE
,
aId
,
aName
)
{
}
TOOL_INTERACTIVE
::
TOOL_INTERACTIVE
(
const
std
::
string
&
aName
)
:
TOOL_BASE
(
TOOL_Interactive
,
TOOL_MANAGER
::
MakeToolId
(
aName
),
aName
)
TOOL_BASE
(
INTERACTIVE
,
TOOL_MANAGER
::
MakeToolId
(
aName
),
aName
)
{
}
...
...
common/tool/tool_manager.cpp
View file @
bc305859
...
...
@@ -134,7 +134,7 @@ void TOOL_MANAGER::RegisterTool( TOOL_BASE* aTool )
aTool
->
m_toolMgr
=
this
;
if
(
aTool
->
GetType
()
==
TOOL_Interactive
)
if
(
aTool
->
GetType
()
==
INTERACTIVE
)
{
bool
initState
=
static_cast
<
TOOL_INTERACTIVE
*>
(
aTool
)
->
Init
();
...
...
@@ -158,7 +158,7 @@ bool TOOL_MANAGER::InvokeTool( TOOL_ID aToolId )
{
TOOL_BASE
*
tool
=
FindTool
(
aToolId
);
if
(
tool
&&
tool
->
GetType
()
==
TOOL_Interactive
)
if
(
tool
&&
tool
->
GetType
()
==
INTERACTIVE
)
return
invokeTool
(
tool
);
return
false
;
// there is no tool with the given id
...
...
@@ -169,7 +169,7 @@ bool TOOL_MANAGER::InvokeTool( const std::string& aToolName )
{
TOOL_BASE
*
tool
=
FindTool
(
aToolName
);
if
(
tool
&&
tool
->
GetType
()
==
TOOL_Interactive
)
if
(
tool
&&
tool
->
GetType
()
==
INTERACTIVE
)
return
invokeTool
(
tool
);
return
false
;
// there is no tool with the given name
...
...
@@ -192,7 +192,7 @@ bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
{
wxASSERT
(
aTool
!=
NULL
);
TOOL_EVENT
evt
(
TC_C
ommand
,
TA_Action
,
aTool
->
GetName
()
);
TOOL_EVENT
evt
(
TC_C
OMMAND
,
TA_ACTION
,
aTool
->
GetName
()
);
ProcessEvent
(
evt
);
return
true
;
...
...
@@ -203,7 +203,7 @@ bool TOOL_MANAGER::runTool( TOOL_ID aToolId )
{
TOOL_BASE
*
tool
=
FindTool
(
aToolId
);
if
(
tool
&&
tool
->
GetType
()
==
TOOL_Interactive
)
if
(
tool
&&
tool
->
GetType
()
==
INTERACTIVE
)
return
runTool
(
tool
);
return
false
;
// there is no tool with the given id
...
...
@@ -214,7 +214,7 @@ bool TOOL_MANAGER::runTool( const std::string& aToolName )
{
TOOL_BASE
*
tool
=
FindTool
(
aToolName
);
if
(
tool
&&
tool
->
GetType
()
==
TOOL_Interactive
)
if
(
tool
&&
tool
->
GetType
()
==
INTERACTIVE
)
return
runTool
(
tool
);
return
false
;
// there is no tool with the given name
...
...
@@ -360,13 +360,13 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
bool
TOOL_MANAGER
::
dispatchStandardEvents
(
TOOL_EVENT
&
aEvent
)
{
if
(
aEvent
.
Action
()
==
TA_K
eyUp
)
if
(
aEvent
.
Action
()
==
TA_K
EY_UP
)
{
// Check if there is a hotkey associated
if
(
m_actionMgr
->
RunHotKey
(
aEvent
.
Modifier
()
|
aEvent
.
KeyCode
()
)
)
return
false
;
// hotkey event was handled so it does not go any further
}
else
if
(
aEvent
.
Category
()
==
TC_C
ommand
)
// it may be a tool activation event
else
if
(
aEvent
.
Category
()
==
TC_C
OMMAND
)
// it may be a tool activation event
{
dispatchActivation
(
aEvent
);
// do not return false, as the event has to go on to the destined tool
...
...
@@ -433,11 +433,11 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
// or immediately (CMENU_NOW) mode. The latter is used for clarification lists.
if
(
st
->
contextMenuTrigger
!=
CMENU_OFF
)
{
if
(
st
->
contextMenuTrigger
==
CMENU_BUTTON
&&
!
aEvent
.
IsClick
(
MB_R
ight
)
)
if
(
st
->
contextMenuTrigger
==
CMENU_BUTTON
&&
!
aEvent
.
IsClick
(
MB_R
IGHT
)
)
break
;
st
->
pendingWait
=
true
;
st
->
waitEvents
=
TOOL_EVENT
(
TC_A
ny
,
TA_Any
);
st
->
waitEvents
=
TOOL_EVENT
(
TC_A
NY
,
TA_ANY
);
if
(
st
->
contextMenuTrigger
==
CMENU_NOW
)
st
->
contextMenuTrigger
=
CMENU_OFF
;
...
...
@@ -446,7 +446,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
GetEditFrame
()
->
PopupMenu
(
menu
->
GetMenu
()
);
//
TOOL_EVENT
evt
(
TC_C
ommand
,
TA_ContextMenuChoice
);
TOOL_EVENT
evt
(
TC_C
OMMAND
,
TA_CONTEXT_MENU_CHOICE
);
dispatchInternal
(
evt
);
break
;
...
...
@@ -498,7 +498,7 @@ void TOOL_MANAGER::SetEnvironment( EDA_ITEM* aModel, KIGFX::VIEW* aView,
{
TOOL_BASE
*
tool
=
m_toolIdIndex
[
toolId
]
->
theTool
;
if
(
tool
->
GetType
()
==
TOOL_Interactive
)
if
(
tool
->
GetType
()
==
INTERACTIVE
)
static_cast
<
TOOL_INTERACTIVE
*>
(
tool
)
->
Reset
();
}
}
...
...
common/view/view.cpp
View file @
bc305859
...
...
@@ -67,7 +67,7 @@ VIEW::VIEW( bool aIsDynamic ) :
VIEW
::~
VIEW
()
{
BOOST_FOREACH
(
L
ayerMap
::
value_type
&
l
,
m_layers
)
BOOST_FOREACH
(
L
AYER_MAP
::
value_type
&
l
,
m_layers
)
{
delete
l
.
second
.
items
;
}
...
...
@@ -156,7 +156,7 @@ struct queryVisitor
void
operator
()(
VIEW_ITEM
*
aItem
)
{
if
(
aItem
->
ViewIsVisible
()
)
m_cont
.
push_back
(
VIEW
::
L
ayerItemPair
(
aItem
,
m_layer
)
);
m_cont
.
push_back
(
VIEW
::
L
AYER_ITEM_PAIR
(
aItem
,
m_layer
)
);
}
Container
&
m_cont
;
...
...
@@ -164,7 +164,7 @@ struct queryVisitor
};
int
VIEW
::
Query
(
const
BOX2I
&
aRect
,
std
::
vector
<
L
ayerItemPair
>&
aResult
)
int
VIEW
::
Query
(
const
BOX2I
&
aRect
,
std
::
vector
<
L
AYER_ITEM_PAIR
>&
aResult
)
{
if
(
m_orderedLayers
.
empty
()
)
return
0
;
...
...
@@ -179,7 +179,7 @@ int VIEW::Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult )
if
(
(
*
i
)
->
displayOnly
)
continue
;
queryVisitor
<
std
::
vector
<
L
ayerItemPair
>
>
visitor
(
aResult
,
(
*
i
)
->
id
);
queryVisitor
<
std
::
vector
<
L
AYER_ITEM_PAIR
>
>
visitor
(
aResult
,
(
*
i
)
->
id
);
(
*
i
)
->
items
->
Query
(
aRect
,
visitor
);
}
...
...
@@ -424,7 +424,7 @@ void VIEW::UpdateAllLayersColor()
r
.
SetMaximum
();
for
(
L
ayerMapIter
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
for
(
L
AYER_MAP_ITER
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
{
VIEW_LAYER
*
l
=
&
(
(
*
i
).
second
);
...
...
@@ -555,7 +555,7 @@ void VIEW::UpdateAllLayersOrder()
{
sortLayers
();
BOOST_FOREACH
(
L
ayerMap
::
value_type
&
l
,
m_layers
)
BOOST_FOREACH
(
L
AYER_MAP
::
value_type
&
l
,
m_layers
)
{
ChangeLayerDepth
(
l
.
first
,
l
.
second
.
renderingOrder
);
}
...
...
@@ -727,7 +727,7 @@ void VIEW::Clear()
r
.
SetMaximum
();
for
(
L
ayerMapIter
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
for
(
L
AYER_MAP_ITER
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
{
VIEW_LAYER
*
l
=
&
(
(
*
i
).
second
);
unlinkItem
v
;
...
...
@@ -811,7 +811,7 @@ void VIEW::clearGroupCache()
r
.
SetMaximum
();
clearLayerCache
visitor
(
this
);
for
(
L
ayerMapIter
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
for
(
L
AYER_MAP_ITER
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
{
VIEW_LAYER
*
l
=
&
(
(
*
i
).
second
);
l
->
items
->
Query
(
r
,
visitor
);
...
...
@@ -858,7 +858,7 @@ void VIEW::sortLayers()
m_orderedLayers
.
resize
(
m_layers
.
size
()
);
for
(
L
ayerMapIter
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
for
(
L
AYER_MAP_ITER
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
m_orderedLayers
[
n
++
]
=
&
i
->
second
;
sort
(
m_orderedLayers
.
begin
(),
m_orderedLayers
.
end
(),
compareRenderingOrder
);
...
...
@@ -974,7 +974,7 @@ void VIEW::RecacheAllItems( bool aImmediately )
prof_start
(
&
totalRealTime
,
false
);
#endif
/* __WXDEBUG__ */
for
(
L
ayerMapIter
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
for
(
L
AYER_MAP_ITER
i
=
m_layers
.
begin
();
i
!=
m_layers
.
end
();
++
i
)
{
VIEW_LAYER
*
l
=
&
(
(
*
i
).
second
);
...
...
common/view/view_group.cpp
View file @
bc305859
...
...
@@ -142,7 +142,7 @@ void VIEW_GROUP::ItemsSetVisibility( bool aVisible )
}
void
VIEW_GROUP
::
ItemsViewUpdate
(
VIEW_ITEM
::
V
iewUpdateFlags
aFlags
)
void
VIEW_GROUP
::
ItemsViewUpdate
(
VIEW_ITEM
::
V
IEW_UPDATE_FLAGS
aFlags
)
{
std
::
set
<
VIEW_ITEM
*>::
const_iterator
it
,
it_end
;
...
...
common/view/wx_view_controls.cpp
View file @
bc305859
...
...
@@ -39,26 +39,26 @@ WX_VIEW_CONTROLS::WX_VIEW_CONTROLS( VIEW* aView, wxWindow* aParentPanel ) :
m_state
(
IDLE
),
m_parentPanel
(
aParentPanel
)
{
m_parentPanel
->
Connect
(
wxEVT_MOTION
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onMotion
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_MOUSEWHEEL
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onWheel
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_MIDDLE_UP
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onButton
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_MIDDLE_DOWN
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onButton
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_LEFT_UP
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onButton
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onButton
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_MOTION
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onMotion
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_MOUSEWHEEL
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onWheel
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_MIDDLE_UP
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onButton
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_MIDDLE_DOWN
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onButton
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_LEFT_UP
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onButton
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onButton
),
NULL
,
this
);
#if defined _WIN32 || defined _WIN64
m_parentPanel
->
Connect
(
wxEVT_ENTER_WINDOW
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onEnter
),
NULL
,
this
);
m_parentPanel
->
Connect
(
wxEVT_ENTER_WINDOW
,
wxMouseEventHandler
(
WX_VIEW_CONTROLS
::
onEnter
),
NULL
,
this
);
#endif
m_panTimer
.
SetOwner
(
this
);
this
->
Connect
(
wxEVT_TIMER
,
wxTimerEventHandler
(
WX_VIEW_CONTROLS
::
onTimer
),
NULL
,
this
);
this
->
Connect
(
wxEVT_TIMER
,
wxTimerEventHandler
(
WX_VIEW_CONTROLS
::
onTimer
),
NULL
,
this
);
}
...
...
include/gal/cairo/cairo_gal.h
View file @
bc305859
...
...
@@ -217,13 +217,13 @@ public:
virtual
void
RestoreScreen
();
/// @copydoc GAL::SetTarget()
virtual
void
SetTarget
(
R
enderTarget
aTarget
);
virtual
void
SetTarget
(
R
ENDER_TARGET
aTarget
);
/// @copydoc GAL::GetTarget()
virtual
R
enderTarget
GetTarget
()
const
;
virtual
R
ENDER_TARGET
GetTarget
()
const
;
/// @copydoc GAL::ClearTarget()
virtual
void
ClearTarget
(
R
enderTarget
aTarget
);
virtual
void
ClearTarget
(
R
ENDER_TARGET
aTarget
);
// -------
// Cursor
...
...
@@ -267,7 +267,7 @@ private:
boost
::
shared_ptr
<
CAIRO_COMPOSITOR
>
compositor
;
///< Object for layers compositing
unsigned
int
mainBuffer
;
///< Handle to the main buffer
unsigned
int
overlayBuffer
;
///< Handle to the overlay buffer
R
enderTarget
currentTarget
;
///< Current rendering target
R
ENDER_TARGET
currentTarget
;
///< Current rendering target
bool
validCompositor
;
///< Compositor initialization flag
// Variables related to wxWidgets
...
...
@@ -290,7 +290,8 @@ private:
static
const
int
MAX_CAIRO_ARGUMENTS
=
6
;
/// Definitions for the command recorder
enum
GraphicsCommand
{
enum
GRAPHICS_COMMAND
{
CMD_SET_FILL
,
///< Enable/disable filling
CMD_SET_STROKE
,
///< Enable/disable stroking
CMD_SET_FILLCOLOR
,
///< Set the fill color
...
...
@@ -310,20 +311,20 @@ private:
/// Type definition for an graphics group element
typedef
struct
{
G
raphicsCommand
command
;
///< Command to execute
G
RAPHICS_COMMAND
command
;
///< Command to execute
double
arguments
[
MAX_CAIRO_ARGUMENTS
];
///< Arguments for Cairo commands
bool
boolArgument
;
///< A bool argument
int
intArgument
;
///< An int argument
cairo_path_t
*
cairoPath
;
///< Pointer to a Cairo path
}
G
roupElement
;
}
G
ROUP_ELEMENT
;
// Variables for the grouping function
bool
isGrouping
;
///< Is grouping enabled ?
bool
isElementAdded
;
///< Was an graphic element added ?
typedef
std
::
deque
<
G
roupElement
>
Group
;
///< A graphic group type definition
std
::
map
<
int
,
G
roup
>
groups
;
///< List of graphic groups
typedef
std
::
deque
<
G
ROUP_ELEMENT
>
GROUP
;
///< A graphic group type definition
std
::
map
<
int
,
G
ROUP
>
groups
;
///< List of graphic groups
unsigned
int
groupCounter
;
///< Counter used for generating keys for groups
G
roup
*
currentGroup
;
///< Currently used group
G
ROUP
*
currentGroup
;
///< Currently used group
// Variables related to Cairo <-> wxWidgets
cairo_matrix_t
cairoWorldScreenMatrix
;
///< Cairo world to screen transformation matrix
...
...
include/gal/definitions.h
View file @
bc305859
...
...
@@ -34,9 +34,9 @@
namespace
KIGFX
{
/**
* R
enderTarget
: Possible rendering targets
* R
ENDER_TARGET
: Possible rendering targets
*/
enum
R
enderTarget
enum
R
ENDER_TARGET
{
TARGET_CACHED
=
0
,
///< Main rendering target (cached)
TARGET_NONCACHED
,
///< Auxiliary rendering target (noncached)
...
...
include/gal/graphics_abstraction_layer.h
View file @
bc305859
...
...
@@ -589,21 +589,21 @@ public:
*
* @param aTarget is the new target for rendering.
*/
virtual
void
SetTarget
(
R
enderTarget
aTarget
)
=
0
;
virtual
void
SetTarget
(
R
ENDER_TARGET
aTarget
)
=
0
;
/**
* @brief Gets the currently used target for rendering.
*
* @return The current rendering target.
*/
virtual
R
enderTarget
GetTarget
()
const
=
0
;
virtual
R
ENDER_TARGET
GetTarget
()
const
=
0
;
/**
* @brief Clears the target for rendering.
*
* @param aTarget is the target to be cleared.
*/
virtual
void
ClearTarget
(
R
enderTarget
aTarget
)
=
0
;
virtual
void
ClearTarget
(
R
ENDER_TARGET
aTarget
)
=
0
;
// -------------
// Grid methods
...
...
include/gal/opengl/cached_container.h
View file @
bc305859
...
...
@@ -49,19 +49,19 @@ class CACHED_CONTAINER : public VERTEX_CONTAINER
public
:
CACHED_CONTAINER
(
unsigned
int
aSize
=
defaultInitSize
);
///
<
@copydoc VERTEX_CONTAINER::SetItem()
///
>
@copydoc VERTEX_CONTAINER::SetItem()
virtual
void
SetItem
(
VERTEX_ITEM
*
aItem
);
///
<
@copydoc VERTEX_CONTAINER::FinishItem()
///
>
@copydoc VERTEX_CONTAINER::FinishItem()
virtual
void
FinishItem
();
///
<
@copydoc VERTEX_CONTAINER::Allocate()
///
>
@copydoc VERTEX_CONTAINER::Allocate()
virtual
VERTEX
*
Allocate
(
unsigned
int
aSize
);
///
<
@copydoc VERTEX_CONTAINER::Delete()
///
>
@copydoc VERTEX_CONTAINER::Delete()
virtual
void
Delete
(
VERTEX_ITEM
*
aItem
);
///
<
@copydoc VERTEX_CONTAINER::Clear()
///
>
@copydoc VERTEX_CONTAINER::Clear()
virtual
void
Clear
();
/**
...
...
@@ -73,23 +73,23 @@ public:
virtual
VERTEX
*
GetVertices
(
const
VERTEX_ITEM
*
aItem
)
const
;
protected
:
///
<
Maps size of free memory chunks to their offsets
typedef
std
::
pair
<
unsigned
int
,
unsigned
int
>
C
hunk
;
typedef
std
::
multimap
<
unsigned
int
,
unsigned
int
>
F
reeChunkMap
;
///
>
Maps size of free memory chunks to their offsets
typedef
std
::
pair
<
unsigned
int
,
unsigned
int
>
C
HUNK
;
typedef
std
::
multimap
<
unsigned
int
,
unsigned
int
>
F
REE_CHUNK_MAP
;
/// List of all the stored items
typedef
std
::
set
<
VERTEX_ITEM
*>
I
tems
;
typedef
std
::
set
<
VERTEX_ITEM
*>
I
TEMS
;
///
<
Stores size & offset of free chunks.
F
reeChunkMap
m_freeChunks
;
///
>
Stores size & offset of free chunks.
F
REE_CHUNK_MAP
m_freeChunks
;
///
<
Stored VERTEX_ITEMs
I
tems
m_items
;
///
>
Stored VERTEX_ITEMs
I
TEMS
m_items
;
///
<
Currently modified item
///
>
Currently modified item
VERTEX_ITEM
*
m_item
;
///
<
Properties of currently modified chunk & item
///
>
Properties of currently modified chunk & item
unsigned
int
m_chunkSize
;
unsigned
int
m_chunkOffset
;
unsigned
int
m_itemSize
;
...
...
@@ -146,7 +146,7 @@ private:
*
* @param aChunk is the chunk.
*/
inline
int
getChunkSize
(
const
C
hunk
&
aChunk
)
const
inline
int
getChunkSize
(
const
C
HUNK
&
aChunk
)
const
{
return
aChunk
.
first
;
}
...
...
@@ -157,7 +157,7 @@ private:
*
* @param aChunk is the chunk.
*/
inline
unsigned
int
getChunkOffset
(
const
C
hunk
&
aChunk
)
const
inline
unsigned
int
getChunkOffset
(
const
C
HUNK
&
aChunk
)
const
{
return
aChunk
.
second
;
}
...
...
include/gal/opengl/gpu_manager.h
View file @
bc305859
...
...
@@ -89,15 +89,17 @@ public:
protected
:
GPU_MANAGER
(
VERTEX_CONTAINER
*
aContainer
);
///
<
Drawing status flag.
///
>
Drawing status flag.
bool
m_isDrawing
;
///
<
Container that stores vertices data.
///
>
Container that stores vertices data.
VERTEX_CONTAINER
*
m_container
;
///
<
Shader handling
///
>
Shader handling
SHADER
*
m_shader
;
int
m_shaderAttrib
;
///< Location of shader attributes (for glVertexAttribPointer)
///> Location of shader attributes (for glVertexAttribPointer)
int
m_shaderAttrib
;
};
...
...
@@ -107,19 +109,19 @@ public:
GPU_CACHED_MANAGER
(
VERTEX_CONTAINER
*
aContainer
);
~
GPU_CACHED_MANAGER
();
///
<
@copydoc GPU_MANAGER::Initialize()
///
>
@copydoc GPU_MANAGER::Initialize()
virtual
void
Initialize
();
///
<
@copydoc GPU_MANAGER::BeginDrawing()
///
>
@copydoc GPU_MANAGER::BeginDrawing()
virtual
void
BeginDrawing
();
///
<
@copydoc GPU_MANAGER::DrawIndices()
///
>
@copydoc GPU_MANAGER::DrawIndices()
virtual
void
DrawIndices
(
unsigned
int
aOffset
,
unsigned
int
aSize
);
///
<
@copydoc GPU_MANAGER::DrawAll()
///
>
@copydoc GPU_MANAGER::DrawAll()
virtual
void
DrawAll
();
///
<
@copydoc GPU_MANAGER::EndDrawing()
///
>
@copydoc GPU_MANAGER::EndDrawing()
virtual
void
EndDrawing
();
/**
...
...
@@ -130,10 +132,19 @@ public:
virtual
void
uploadToGpu
();
protected
:
///> Buffers initialization flag
bool
m_buffersInitialized
;
///> Pointer to the current indices buffer
boost
::
scoped_array
<
GLuint
>
m_indices
;
///> Pointer to the first free cell in the indices buffer
GLuint
*
m_indicesPtr
;
///> Handle to vertices buffer
GLuint
m_verticesBuffer
;
///> Number of indices stored in the indices buffer
unsigned
int
m_indicesSize
;
};
...
...
@@ -143,19 +154,19 @@ class GPU_NONCACHED_MANAGER : public GPU_MANAGER
public
:
GPU_NONCACHED_MANAGER
(
VERTEX_CONTAINER
*
aContainer
);
///
<
@copydoc GPU_MANAGER::Initialize()
///
>
@copydoc GPU_MANAGER::Initialize()
virtual
void
Initialize
();
///
<
@copydoc GPU_MANAGER::BeginDrawing()
///
>
@copydoc GPU_MANAGER::BeginDrawing()
virtual
void
BeginDrawing
();
///
<
@copydoc GPU_MANAGER::DrawIndices()
///
>
@copydoc GPU_MANAGER::DrawIndices()
virtual
void
DrawIndices
(
unsigned
int
aOffset
,
unsigned
int
aSize
);
///
<
@copydoc GPU_MANAGER::DrawAll()
///
>
@copydoc GPU_MANAGER::DrawAll()
virtual
void
DrawAll
();
///
<
@copydoc GPU_MANAGER::EndDrawing()
///
>
@copydoc GPU_MANAGER::EndDrawing()
virtual
void
EndDrawing
();
};
}
// namespace KIGFX
...
...
include/gal/opengl/opengl_gal.h
View file @
bc305859
...
...
@@ -106,7 +106,8 @@ public:
virtual
void
DrawLine
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
);
/// @copydoc GAL::DrawSegment()
virtual
void
DrawSegment
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
double
aWidth
);
virtual
void
DrawSegment
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
,
double
aWidth
);
/// @copydoc GAL::DrawCircle()
virtual
void
DrawCircle
(
const
VECTOR2D
&
aCenterPoint
,
double
aRadius
);
...
...
@@ -209,13 +210,13 @@ public:
virtual
void
RestoreScreen
();
/// @copydoc GAL::SetTarget()
virtual
void
SetTarget
(
R
enderTarget
aTarget
);
virtual
void
SetTarget
(
R
ENDER_TARGET
aTarget
);
/// @copydoc GAL::GetTarget()
virtual
R
enderTarget
GetTarget
()
const
;
virtual
R
ENDER_TARGET
GetTarget
()
const
;
/// @copydoc GAL::ClearTarget()
virtual
void
ClearTarget
(
R
enderTarget
aTarget
);
virtual
void
ClearTarget
(
R
ENDER_TARGET
aTarget
);
// -------
// Cursor
...
...
@@ -275,8 +276,8 @@ private:
wxEvtHandler
*
paintListener
;
// Vertex buffer objects related fields
typedef
std
::
map
<
unsigned
int
,
boost
::
shared_ptr
<
VERTEX_ITEM
>
>
G
roupsMap
;
G
roupsMap
groups
;
///< Stores informations about VBO objects (groups)
typedef
std
::
map
<
unsigned
int
,
boost
::
shared_ptr
<
VERTEX_ITEM
>
>
G
ROUPS_MAP
;
G
ROUPS_MAP
groups
;
///< Stores informations about VBO objects (groups)
unsigned
int
groupCounter
;
///< Counter used for generating keys for groups
VERTEX_MANAGER
*
currentManager
;
///< Currently used VERTEX_MANAGER (for storing VERTEX_ITEMs)
VERTEX_MANAGER
cachedManager
;
///< Container for storing cached VERTEX_ITEMs
...
...
@@ -287,7 +288,7 @@ private:
OPENGL_COMPOSITOR
compositor
;
///< Handles multiple rendering targets
unsigned
int
mainBuffer
;
///< Main rendering target
unsigned
int
overlayBuffer
;
///< Auxiliary rendering target (for menus etc.)
R
enderTarget
currentTarget
;
///< Current rendering target
R
ENDER_TARGET
currentTarget
;
///< Current rendering target
// Shader
SHADER
shader
;
///< There is only one shader used for different objects
...
...
include/gal/opengl/shader.h
View file @
bc305859
...
...
@@ -39,7 +39,7 @@ namespace KIGFX
class
OPENGL_GAL
;
/// Type definition for the shader
enum
S
haderType
enum
S
HADER_TYPE
{
SHADER_TYPE_VERTEX
=
GL_VERTEX_SHADER
,
///< Vertex shader
SHADER_TYPE_FRAGMENT
=
GL_FRAGMENT_SHADER
,
///< Fragment shader
...
...
@@ -77,7 +77,7 @@ public:
* @param aShaderType is the type of the shader.
* @return True in case of success, false otherwise.
*/
bool
LoadBuiltinShader
(
unsigned
int
aShaderNumber
,
S
haderType
aShaderType
);
bool
LoadBuiltinShader
(
unsigned
int
aShaderNumber
,
S
HADER_TYPE
aShaderType
);
/**
* @brief Loads one of the built-in shaders and compiles it.
...
...
@@ -86,7 +86,7 @@ public:
* @param aShaderType is the type of the shader.
* @return True in case of success, false otherwise.
*/
bool
LoadShaderFromFile
(
const
std
::
string
&
aShaderSourceName
,
S
haderType
aShaderType
);
bool
LoadShaderFromFile
(
const
std
::
string
&
aShaderSourceName
,
S
HADER_TYPE
aShaderType
);
/**
* @brief Link the shaders.
...
...
@@ -193,7 +193,7 @@ private:
* @param aShaderType is the type of the shader.
* @return True in case of success, false otherwise.
*/
bool
addSource
(
const
std
::
string
&
aShaderSource
,
S
haderType
aShaderType
);
bool
addSource
(
const
std
::
string
&
aShaderSource
,
S
HADER_TYPE
aShaderType
);
std
::
deque
<
GLuint
>
shaderNumbers
;
///< Shader number list
GLuint
programNumber
;
///< Shader program number
...
...
include/gal/opengl/vertex_common.h
View file @
bc305859
...
...
@@ -35,7 +35,7 @@
namespace
KIGFX
{
// Possible types of shaders
enum
SHADER_
TYP
E
enum
SHADER_
MOD
E
{
SHADER_NONE
=
0
,
SHADER_LINE
,
...
...
include/gal/stroke_font.h
View file @
bc305859
...
...
@@ -38,8 +38,8 @@ namespace KIGFX
{
class
GAL
;
typedef
std
::
deque
<
std
::
deque
<
VECTOR2D
>
>
G
lyph
;
typedef
std
::
deque
<
G
lyph
>
GlyphList
;
typedef
std
::
deque
<
std
::
deque
<
VECTOR2D
>
>
G
LYPH
;
typedef
std
::
deque
<
G
LYPH
>
GLYPH_LIST
;
/**
* @brief Class STROKE_FONT implements stroke font drawing.
...
...
@@ -157,7 +157,7 @@ public:
private
:
GAL
*
m_gal
;
///< Pointer to the GAL
G
lyphList
m_glyphs
;
///< Glyph list
G
LYPH_LIST
m_glyphs
;
///< Glyph list
std
::
deque
<
BOX2D
>
m_glyphBoundingBoxes
;
///< Bounding boxes of the glyphs
double
m_scaleFactor
;
///< Scale factor for the glyph
VECTOR2D
m_glyphSize
;
///< Size of the glyphs
...
...
@@ -172,7 +172,7 @@ private:
* @param aGlyphBoundingX is the x-component of the bounding box size.
* @return is the complete bounding box size.
*/
BOX2D
computeBoundingBox
(
const
G
lyph
&
aGlyph
,
const
VECTOR2D
&
aGlyphBoundingX
)
const
;
BOX2D
computeBoundingBox
(
const
G
LYPH
&
aGlyph
,
const
VECTOR2D
&
aGlyphBoundingX
)
const
;
/**
* @brief Compute the size of a given text.
...
...
include/geometry/seg.h
View file @
bc305859
...
...
@@ -43,18 +43,18 @@ public:
friend
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
aStream
,
const
SEG
&
aSeg
);
/* Start and the of the segment. Public, to make access simpler. These are references
* to an object the segment belongs to (e.g. a line chain) or references to locally stored
points
* (m_a, m_b).
* to an object the segment belongs to (e.g. a line chain) or references to locally stored
*
points
(m_a, m_b).
*/
VECTOR2I
&
a
,
b
;
VECTOR2I
&
A
,
B
;
/** Default constructor
* Creates an empty (0, 0) segment, locally-referenced
*/
SEG
()
:
a
(
m_a
),
b
(
m_b
)
SEG
()
:
A
(
m_a
),
B
(
m_b
)
{
a
=
m_a
;
b
=
m_b
;
A
=
m_a
;
B
=
m_b
;
m_is_local
=
true
;
m_index
=
-
1
;
}
...
...
@@ -63,12 +63,12 @@ public:
* Constructor
* Creates a segment between (aX1, aY1) and (aX2, aY2), locally referenced
*/
SEG
(
int
aX1
,
int
aY1
,
int
aX2
,
int
aY2
)
:
a
(
m_a
),
b
(
m_b
)
SEG
(
int
aX1
,
int
aY1
,
int
aX2
,
int
aY2
)
:
A
(
m_a
),
B
(
m_b
)
{
m_a
=
VECTOR2I
(
aX1
,
aY1
);
m_b
=
VECTOR2I
(
aX2
,
aY2
);
a
=
m_a
;
b
=
m_b
;
A
=
m_a
;
B
=
m_b
;
m_is_local
=
true
;
m_index
=
-
1
;
}
...
...
@@ -77,10 +77,10 @@ public:
* Constructor
* Creates a segment between (aA) and (aB), locally referenced
*/
SEG
(
const
VECTOR2I
&
aA
,
const
VECTOR2I
&
aB
)
:
a
(
m_a
),
b
(
m_b
),
m_a
(
aA
),
m_b
(
aB
)
SEG
(
const
VECTOR2I
&
aA
,
const
VECTOR2I
&
aB
)
:
A
(
m_a
),
B
(
m_b
),
m_a
(
aA
),
m_b
(
aB
)
{
a
=
m_a
;
b
=
m_b
;
A
=
m_a
;
B
=
m_b
;
m_is_local
=
true
;
m_index
=
-
1
;
}
...
...
@@ -92,7 +92,7 @@ public:
* @param aB reference to the end point in the parent shape
* @param aIndex index of the segment within the parent shape
*/
SEG
(
VECTOR2I
&
aA
,
VECTOR2I
&
aB
,
int
aIndex
)
:
a
(
aA
),
b
(
aB
)
SEG
(
VECTOR2I
&
aA
,
VECTOR2I
&
aB
,
int
aIndex
)
:
A
(
aA
),
B
(
aB
)
{
m_is_local
=
false
;
m_index
=
aIndex
;
...
...
@@ -101,19 +101,21 @@ public:
/**
* Copy constructor
*/
SEG
(
const
SEG
&
aSeg
)
:
a
(
m_a
),
b
(
m_b
)
SEG
(
const
SEG
&
aSeg
)
:
A
(
m_a
),
B
(
m_b
)
{
if
(
aSeg
.
m_is_local
)
if
(
aSeg
.
m_is_local
)
{
m_a
=
aSeg
.
m_a
;
m_b
=
aSeg
.
m_b
;
a
=
m_a
;
b
=
m_b
;
A
=
m_a
;
B
=
m_b
;
m_is_local
=
true
;
m_index
=
-
1
;
}
else
{
a
=
aSeg
.
a
;
b
=
aSeg
.
b
;
}
else
{
A
=
aSeg
.
A
;
B
=
aSeg
.
B
;
m_index
=
aSeg
.
m_index
;
m_is_local
=
false
;
}
...
...
@@ -121,12 +123,13 @@ public:
SEG
&
operator
=
(
const
SEG
&
aSeg
)
{
a
=
aSeg
.
a
;
b
=
aSeg
.
b
;
A
=
aSeg
.
A
;
B
=
aSeg
.
B
;
m_a
=
aSeg
.
m_a
;
m_b
=
aSeg
.
m_b
;
m_index
=
aSeg
.
m_index
;
m_is_local
=
aSeg
.
m_is_local
;
return
*
this
;
}
...
...
@@ -149,7 +152,7 @@ public:
*/
int
Side
(
const
VECTOR2I
&
aP
)
const
{
const
ecoord
det
=
(
b
-
a
).
Cross
(
aP
-
a
);
const
ecoord
det
=
(
B
-
A
).
Cross
(
aP
-
A
);
return
det
<
0
?
-
1
:
(
det
>
0
?
1
:
0
);
}
...
...
@@ -178,12 +181,13 @@ public:
*
* Computes intersection point of segment (this) with segment aSeg.
* @param aSeg: segment to intersect with
* @param aIgnoreEndpoints: don't treat corner cases (i.e. end of one segment touching the other)
*
as intersections.
* @param aIgnoreEndpoints: don't treat corner cases (i.e. end of one segment touching the
* other)
as intersections.
* @param aLines: treat segments as infinite lines
* @return intersection point, if exists
*/
OPT_VECTOR2I
Intersect
(
const
SEG
&
aSeg
,
bool
aIgnoreEndpoints
=
false
,
bool
aLines
=
false
)
const
;
OPT_VECTOR2I
Intersect
(
const
SEG
&
aSeg
,
bool
aIgnoreEndpoints
=
false
,
bool
aLines
=
false
)
const
;
/**
* Function IntersectLines()
...
...
@@ -240,12 +244,12 @@ public:
*/
bool
Collinear
(
const
SEG
&
aSeg
)
const
{
ecoord
qa1
=
a
.
y
-
b
.
y
;
ecoord
qb1
=
b
.
x
-
a
.
x
;
ecoord
qc1
=
-
qa1
*
a
.
x
-
qb1
*
a
.
y
;
ecoord
qa2
=
aSeg
.
a
.
y
-
aSeg
.
b
.
y
;
ecoord
qb2
=
aSeg
.
b
.
x
-
aSeg
.
a
.
x
;
ecoord
qc2
=
-
qa2
*
aSeg
.
a
.
x
-
qb2
*
aSeg
.
a
.
y
;
ecoord
qa1
=
A
.
y
-
B
.
y
;
ecoord
qb1
=
B
.
x
-
A
.
x
;
ecoord
qc1
=
-
qa1
*
A
.
x
-
qb1
*
A
.
y
;
ecoord
qa2
=
aSeg
.
A
.
y
-
aSeg
.
B
.
y
;
ecoord
qb2
=
aSeg
.
B
.
x
-
aSeg
.
A
.
x
;
ecoord
qc2
=
-
qa2
*
aSeg
.
A
.
x
-
qb2
*
aSeg
.
A
.
y
;
return
(
qa1
==
qa2
)
&&
(
qb1
==
qb2
)
&&
(
qc1
==
qc2
);
}
...
...
@@ -258,12 +262,12 @@ public:
*/
int
Length
()
const
{
return
(
a
-
b
).
EuclideanNorm
();
return
(
A
-
B
).
EuclideanNorm
();
}
ecoord
SquaredLength
()
const
{
return
(
a
-
b
).
SquaredEuclideanNorm
();
return
(
A
-
B
).
SquaredEuclideanNorm
();
}
/**
...
...
@@ -281,8 +285,8 @@ public:
bool
PointCloserThan
(
const
VECTOR2I
&
aP
,
int
aDist
)
const
;
// friend std::ostream& operator<<( std::ostream& stream, const SEG& aSeg );
private
:
// friend std::ostream& operator<<( std::ostream& stream, const SEG& aSeg );
private
:
bool
ccw
(
const
VECTOR2I
&
aA
,
const
VECTOR2I
&
aB
,
const
VECTOR2I
&
aC
)
const
;
///> locally stored start/end coordinates (used when m_is_local == true)
...
...
@@ -295,6 +299,7 @@ public:
bool
m_is_local
;
};
inline
VECTOR2I
SEG
::
LineProject
(
const
VECTOR2I
&
aP
)
const
{
// fixme: numerical errors for large integers
...
...
@@ -302,45 +307,47 @@ inline VECTOR2I SEG::LineProject( const VECTOR2I& aP ) const
return
VECTOR2I
(
0
,
0
);
}
inline
int
SEG
::
LineDistance
(
const
VECTOR2I
&
aP
,
bool
aDetermineSide
)
const
{
ecoord
p
=
a
.
y
-
b
.
y
;
ecoord
q
=
b
.
x
-
a
.
x
;
ecoord
r
=
-
p
*
a
.
x
-
q
*
a
.
y
;
ecoord
p
=
A
.
y
-
B
.
y
;
ecoord
q
=
B
.
x
-
A
.
x
;
ecoord
r
=
-
p
*
A
.
x
-
q
*
A
.
y
;
ecoord
dist
=
(
p
*
aP
.
x
+
q
*
aP
.
y
+
r
)
/
sqrt
(
p
*
p
+
q
*
q
);
return
aDetermineSide
?
dist
:
abs
(
dist
);
}
inline
const
VECTOR2I
SEG
::
NearestPoint
(
const
VECTOR2I
&
aP
)
const
{
VECTOR2I
d
=
b
-
a
;
VECTOR2I
d
=
B
-
A
;
ecoord
l_squared
=
d
.
Dot
(
d
);
if
(
l_squared
==
0
)
return
a
;
return
A
;
ecoord
t
=
d
.
Dot
(
aP
-
a
);
ecoord
t
=
d
.
Dot
(
aP
-
A
);
if
(
t
<
0
)
return
a
;
return
A
;
else
if
(
t
>
l_squared
)
return
b
;
return
B
;
int
xp
=
rescale
(
t
,
(
ecoord
)
d
.
x
,
l_squared
);
int
yp
=
rescale
(
t
,
(
ecoord
)
d
.
y
,
l_squared
);
return
a
+
VECTOR2I
(
xp
,
yp
);
return
A
+
VECTOR2I
(
xp
,
yp
);
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
aStream
,
const
SEG
&
aSeg
)
{
if
(
aSeg
.
m_is_local
)
aStream
<<
"[ local "
<<
aSeg
.
a
<<
" - "
<<
aSeg
.
b
<<
" ]"
;
aStream
<<
"[ local "
<<
aSeg
.
A
<<
" - "
<<
aSeg
.
B
<<
" ]"
;
return
aStream
;
}
#endif // __SEG_H
include/geometry/shape.h
View file @
bc305859
...
...
@@ -31,11 +31,11 @@
#include <geometry/seg.h>
/**
* Enum S
hapeType
* Enum S
HAPE_TYPE
* Lists all supported shapes
*/
enum
S
hapeType
enum
S
HAPE_TYPE
{
SH_RECT
=
0
,
///> axis-aligned rectangle
SH_SEGMENT
,
///> line segment
...
...
@@ -50,20 +50,22 @@ enum ShapeType
*/
class
SHAPE
{
protected
:
protected
:
typedef
VECTOR2I
::
extended_type
ecoord
;
public
:
public
:
/**
* Constructor
*
* Creates an empty shape of type aType
*/
SHAPE
(
ShapeType
aType
)
:
m_type
(
aType
)
{
};
SHAPE
(
SHAPE_TYPE
aType
)
:
m_type
(
aType
)
{}
// Destructor
virtual
~
SHAPE
()
{};
virtual
~
SHAPE
()
{}
/**
* Function Type()
...
...
@@ -71,7 +73,10 @@ class SHAPE
* Returns the type of the shape.
* @retval the type
*/
ShapeType
Type
()
const
{
return
m_type
;
}
SHAPE_TYPE
Type
()
const
{
return
m_type
;
}
/**
* Function Clone()
...
...
@@ -88,8 +93,8 @@ class SHAPE
/**
* Function Collide()
*
* Checks if the boundary of shape (this) lies closer to the point aP than aClearance, indicating
*
a collision.
* Checks if the boundary of shape (this) lies closer to the point aP than aClearance,
* indicating
a collision.
* @return true, if there is a collision.
*/
virtual
bool
Collide
(
const
VECTOR2I
&
aP
,
int
aClearance
=
0
)
const
...
...
@@ -100,8 +105,8 @@ class SHAPE
/**
* Function Collide()
*
* Checks if the boundary of shape (this) lies closer to the shape aShape than aClearance, indicating
*
a collision.
* Checks if the boundary of shape (this) lies closer to the shape aShape than aClearance,
* indicating
a collision.
* @param aShape shape to check collision against
* @param aClearance minimum clearance
* @param aMTV minimum translation vector
...
...
@@ -113,8 +118,8 @@ class SHAPE
/**
* Function Collide()
*
* Checks if the boundary of shape (this) lies closer to the segment aSeg than aClearance, indicating
*
a collision.
* Checks if the boundary of shape (this) lies closer to the segment aSeg than aClearance,
* indicating
a collision.
* @return true, if there is a collision.
*/
virtual
bool
Collide
(
const
SEG
&
aSeg
,
int
aClearance
=
0
)
const
=
0
;
...
...
@@ -124,7 +129,8 @@ class SHAPE
*
* Computes a bounding box of the shape, with a margin of aClearance
* a collision.
* @aClearance how much the bounding box is expanded wrs to the minimum enclosing rectangle for the shape.
* @aClearance how much the bounding box is expanded wrs to the minimum enclosing rectangle
* for the shape.
* @return the bounding box.
*/
virtual
const
BOX2I
BBox
(
int
aClearance
=
0
)
const
=
0
;
...
...
@@ -140,11 +146,12 @@ class SHAPE
return
BBox
(
0
).
Centre
();
// if nothing better is available....
}
private
:
private
:
///> type of our shape
ShapeType
m_type
;
SHAPE_TYPE
m_type
;
};
bool
CollideShapes
(
const
SHAPE
*
aA
,
const
SHAPE
*
aB
,
int
aClearance
,
bool
aNeedMTV
,
VECTOR2I
&
aMTV
);
bool
CollideShapes
(
const
SHAPE
*
aA
,
const
SHAPE
*
aB
,
int
aClearance
,
bool
aNeedMTV
,
VECTOR2I
&
aMTV
);
#endif // __SHAPE_H
include/geometry/shape_circle.h
View file @
bc305859
...
...
@@ -31,12 +31,15 @@ class SHAPE_CIRCLE : public SHAPE
{
public
:
SHAPE_CIRCLE
()
:
SHAPE
(
SH_CIRCLE
),
m_radius
(
0
)
{};
SHAPE
(
SH_CIRCLE
),
m_radius
(
0
)
{}
SHAPE_CIRCLE
(
const
VECTOR2I
&
aCenter
,
int
aRadius
)
:
SHAPE
(
SH_CIRCLE
),
m_radius
(
aRadius
),
m_center
(
aCenter
)
{};
SHAPE
(
SH_CIRCLE
),
m_radius
(
aRadius
),
m_center
(
aCenter
)
{}
~
SHAPE_CIRCLE
()
{};
~
SHAPE_CIRCLE
()
{}
const
BOX2I
BBox
(
int
aClearance
=
0
)
const
{
...
...
include/geometry/shape_index_list.h
View file @
bc305859
...
...
@@ -36,16 +36,16 @@ const SHAPE* defaultShapeFunctor( const T aItem )
template
<
class
T
,
const
SHAPE
*
(
ShapeFunctor
)
(
const
T
)
=
defaultShapeFunctor
<
T
>
>
class
SHAPE_INDEX_LIST
{
struct
S
hapeEntry
struct
S
HAPE_ENTRY
{
S
hapeEntry
(
T
aParent
)
S
HAPE_ENTRY
(
T
aParent
)
{
shape
=
ShapeFunctor
(
aParent
);
bbox
=
shape
->
BBox
(
0
);
parent
=
aParent
;
}
~
S
hapeEntry
()
~
S
HAPE_ENTRY
()
{
}
...
...
@@ -54,21 +54,24 @@ class SHAPE_INDEX_LIST
BOX2I
bbox
;
};
typedef
std
::
vector
<
S
hapeEntry
>
ShapeVec
;
typedef
typename
std
::
vector
<
S
hapeEntry
>::
iterator
ShapeVecIter
;
typedef
std
::
vector
<
S
HAPE_ENTRY
>
SHAPE_VEC
;
typedef
typename
std
::
vector
<
S
HAPE_ENTRY
>::
iterator
SHAPE_VEC_ITER
;
public
:
// "Normal" iterator interface, for STL algorithms.
class
iterator
{
public
:
iterator
()
{};
iterator
()
{}
iterator
(
ShapeVecIter
aCurrent
)
:
m_current
(
aCurrent
)
{};
iterator
(
SHAPE_VEC_ITER
aCurrent
)
:
m_current
(
aCurrent
)
{}
iterator
(
const
iterator
&
aB
)
:
m_current
(
aB
.
m_current
)
{};
m_current
(
aB
.
m_current
)
{}
T
operator
*
()
const
{
...
...
@@ -103,7 +106,7 @@ public:
}
private
:
S
hapeVecIter
m_current
;
S
HAPE_VEC_ITER
m_current
;
};
// "Query" iterator, for iterating over a set of spatially matching shapes.
...
...
@@ -114,7 +117,7 @@ public:
{
}
query_iterator
(
S
hapeVecIter
aCurrent
,
ShapeVecIter
aEnd
,
SHAPE
*
aShape
,
query_iterator
(
S
HAPE_VEC_ITER
aCurrent
,
SHAPE_VEC_ITER
aEnd
,
SHAPE
*
aShape
,
int
aMinDistance
,
bool
aExact
)
:
m_end
(
aEnd
),
m_current
(
aCurrent
),
...
...
@@ -194,8 +197,8 @@ public:
}
}
S
hapeVecIter
m_end
;
S
hapeVecIter
m_current
;
S
HAPE_VEC_ITER
m_end
;
S
HAPE_VEC_ITER
m_current
;
BOX2I
m_refBBox
;
bool
m_exact
;
SHAPE
*
m_shape
;
...
...
@@ -204,14 +207,14 @@ public:
void
Add
(
T
aItem
)
{
S
hapeEntry
s
(
aItem
);
S
HAPE_ENTRY
s
(
aItem
);
m_shapes
.
push_back
(
s
);
}
void
Remove
(
const
T
aItem
)
{
S
hapeVecIter
i
;
S
HAPE_VEC_ITER
i
;
for
(
i
=
m_shapes
.
begin
();
i
!=
m_shapes
.
end
();
++
i
)
{
...
...
@@ -233,7 +236,7 @@ public:
template
<
class
Visitor
>
int
Query
(
const
SHAPE
*
aShape
,
int
aMinDistance
,
Visitor
&
aV
,
bool
aExact
=
true
)
// const
{
S
hapeVecIter
i
;
S
HAPE_VEC_ITER
i
;
int
n
=
0
;
VECTOR2I
::
extended_type
minDistSq
=
(
VECTOR2I
::
extended_type
)
aMinDistance
*
aMinDistance
;
...
...
@@ -282,7 +285,7 @@ public:
}
private
:
S
hapeVec
m_shapes
;
S
HAPE_VEC
m_shapes
;
};
#endif
include/geometry/shape_line_chain.h
View file @
bc305859
...
...
@@ -38,23 +38,24 @@
* Class SHAPE_LINE_CHAIN
*
* Represents a polyline (an zero-thickness chain of connected line segments).
* I purposedly didn't name it "polyline" to avoid confusion with the existing CPolyLine class in pcbnew.
* I purposedly didn't name it "polyline" to avoid confusion with the existing CPolyLine
* class in pcbnew.
*
* SHAPE_LINE_CHAIN class shall not be used for polygons!
*/
class
SHAPE_LINE_CHAIN
:
public
SHAPE
{
private
:
class
SHAPE_LINE_CHAIN
:
public
SHAPE
{
private
:
typedef
std
::
vector
<
VECTOR2I
>::
iterator
point_iter
;
typedef
std
::
vector
<
VECTOR2I
>::
const_iterator
point_citer
;
public
:
public
:
/**
* Struct Intersection
* Struct INTERSECTION
*
* Represents an intersection between two line segments
*/
struct
Intersection
struct
INTERSECTION
{
/// segment belonging from the (this) argument of Intersect()
SEG
our
;
...
...
@@ -64,37 +65,37 @@ class SHAPE_LINE_CHAIN : public SHAPE {
VECTOR2I
p
;
};
typedef
std
::
vector
<
Intersection
>
Intersections
;
typedef
std
::
vector
<
INTERSECTION
>
INTERSECTIONS
;
/**
* Constructor
* Initializes an empty line chain.
*/
SHAPE_LINE_CHAIN
()
:
SHAPE
(
SH_LINE_CHAIN
),
m_closed
(
false
)
{};
SHAPE_LINE_CHAIN
()
:
SHAPE
(
SH_LINE_CHAIN
),
m_closed
(
false
)
{}
/**
* Copy Constructor
*/
SHAPE_LINE_CHAIN
(
const
SHAPE_LINE_CHAIN
&
aShape
)
:
SHAPE
(
SH_LINE_CHAIN
),
m_points
(
aShape
.
m_points
),
m_closed
(
aShape
.
m_closed
)
{};
SHAPE
(
SH_LINE_CHAIN
),
m_points
(
aShape
.
m_points
),
m_closed
(
aShape
.
m_closed
)
{}
/**
* Constructor
* Initializes a 2-point line chain (a single segment)
*/
SHAPE_LINE_CHAIN
(
const
VECTOR2I
&
aA
,
const
VECTOR2I
&
aB
)
:
SHAPE
(
SH_LINE_CHAIN
),
m_closed
(
false
)
SHAPE
(
SH_LINE_CHAIN
),
m_closed
(
false
)
{
m_points
.
resize
(
2
);
m_points
[
0
]
=
aA
;
m_points
[
1
]
=
aB
;
}
SHAPE_LINE_CHAIN
(
const
VECTOR2I
&
aA
,
const
VECTOR2I
&
aB
,
const
VECTOR2I
&
aC
)
:
SHAPE
(
SH_LINE_CHAIN
),
m_closed
(
false
)
SHAPE_LINE_CHAIN
(
const
VECTOR2I
&
aA
,
const
VECTOR2I
&
aB
,
const
VECTOR2I
&
aC
)
:
SHAPE
(
SH_LINE_CHAIN
),
m_closed
(
false
)
{
m_points
.
resize
(
3
);
m_points
[
0
]
=
aA
;
...
...
@@ -112,7 +113,8 @@ class SHAPE_LINE_CHAIN : public SHAPE {
m_points
[
i
]
=
*
aV
++
;
}
~
SHAPE_LINE_CHAIN
()
{};
~
SHAPE_LINE_CHAIN
()
{}
/**
* Function Clear()
...
...
@@ -127,7 +129,8 @@ class SHAPE_LINE_CHAIN : public SHAPE {
/**
* Function SetClosed()
*
* Marks the line chain as closed (i.e. with a segment connecting the last point with the first point).
* Marks the line chain as closed (i.e. with a segment connecting the last point with
* the first point).
* @param aClosed: whether the line chain is to be closed or not.
*/
void
SetClosed
(
bool
aClosed
)
...
...
@@ -176,8 +179,8 @@ class SHAPE_LINE_CHAIN : public SHAPE {
*
* Returns a segment referencing to the segment (index) in the line chain.
* Modifying ends of the returned segment will modify corresponding points in the line chain.
* @param aIndex: index of the segment in the line chain. Negative values are counted from the end (i.e. -1 means
*
the last segment in the line chain)
* @param aIndex: index of the segment in the line chain. Negative values are counted from
* the end (i.e. -1 means
the last segment in the line chain)
* @return SEG referenced to given segment in the line chain
*/
SEG
Segment
(
int
aIndex
)
...
...
@@ -195,8 +198,8 @@ class SHAPE_LINE_CHAIN : public SHAPE {
* Function CSegment()
*
* Returns a read-only segment referencing to the segment (index) in the line chain.
* @param aIndex: index of the segment in the line chain. Negative values are counted from the end (i.e. -1 means
*
the last segment in the line chain)
* @param aIndex: index of the segment in the line chain. Negative values are counted from
* the end (i.e. -1 means
the last segment in the line chain)
* @return SEG referenced to given segment in the line chain
*/
const
SEG
CSegment
(
int
aIndex
)
const
...
...
@@ -400,7 +403,8 @@ class SHAPE_LINE_CHAIN : public SHAPE {
* Inserts the point aP belonging to one of the our segments, splitting the adjacent
* segment in two.
* @param aP the point to be inserted
* @return index of the newly inserted point (or a negative value if aP does not lie on our line)
* @return index of the newly inserted point (or a negative value if aP does not lie on
* our line)
*/
int
Split
(
const
VECTOR2I
&
aP
);
...
...
@@ -421,14 +425,15 @@ class SHAPE_LINE_CHAIN : public SHAPE {
* @param aEndIndex end of the point range to be returned (inclusive)
* @return cut line chain.
*/
const
SHAPE_LINE_CHAIN
Slice
(
int
aStartIndex
,
int
aEndIndex
=
-
1
)
const
;
const
SHAPE_LINE_CHAIN
Slice
(
int
aStartIndex
,
int
aEndIndex
=
-
1
)
const
;
struct
compareOriginDistance
{
compareOriginDistance
(
VECTOR2I
&
aOrigin
)
:
m_origin
(
aOrigin
)
{};
m_origin
(
aOrigin
)
{}
bool
operator
()(
const
Intersection
&
aA
,
const
Intersection
&
aB
)
bool
operator
()(
const
INTERSECTION
&
aA
,
const
INTERSECTION
&
aB
)
{
return
(
m_origin
-
aA
.
p
).
EuclideanNorm
()
<
(
m_origin
-
aB
.
p
).
EuclideanNorm
();
}
...
...
@@ -445,7 +450,7 @@ class SHAPE_LINE_CHAIN : public SHAPE {
* are sorted with increasing distances from point aSeg.a.
* @return number of intersections found
*/
int
Intersect
(
const
SEG
&
aSeg
,
Intersections
&
aIp
)
const
;
int
Intersect
(
const
SEG
&
aSeg
,
INTERSECTIONS
&
aIp
)
const
;
/**
* Function Intersect()
...
...
@@ -456,14 +461,15 @@ class SHAPE_LINE_CHAIN : public SHAPE {
* are sorted with increasing path lengths from the starting point of aChain.
* @return number of intersections found
*/
int
Intersect
(
const
SHAPE_LINE_CHAIN
&
aChain
,
Intersections
&
aIp
)
const
;
int
Intersect
(
const
SHAPE_LINE_CHAIN
&
aChain
,
INTERSECTIONS
&
aIp
)
const
;
/**
* Function PathLength()
*
* Computes the walk path length from the beginning of the line chain and
* the point aP belonging to our line.
* @return: path length in Euclidean metric or negative if aP does not belong to the line chain.
* @return: path length in Euclidean metric or negative if aP does not belong to
* the line chain.
*/
int
PathLength
(
const
VECTOR2I
&
aP
)
const
;
...
...
@@ -492,7 +498,7 @@ class SHAPE_LINE_CHAIN : public SHAPE {
* Checks if the line chain is self-intersecting.
* @return (optional) first found self-intersection point.
*/
const
boost
::
optional
<
Intersection
>
SelfIntersecting
()
const
;
const
boost
::
optional
<
INTERSECTION
>
SelfIntersecting
()
const
;
/**
* Function Simplify()
...
...
@@ -527,7 +533,7 @@ class SHAPE_LINE_CHAIN : public SHAPE {
return
false
;
}
private
:
private
:
/// array of vertices
std
::
vector
<
VECTOR2I
>
m_points
;
...
...
include/geometry/shape_rect.h
View file @
bc305859
...
...
@@ -32,27 +32,30 @@
class
SHAPE_RECT
:
public
SHAPE
{
public
:
public
:
/**
* Constructor
* Creates an empty (0-sized) rectangle
*/
SHAPE_RECT
()
:
SHAPE
(
SH_RECT
),
m_w
(
0
),
m_h
(
0
)
{};
SHAPE
(
SH_RECT
),
m_w
(
0
),
m_h
(
0
)
{}
/**
* Constructor
* Creates a rectangle defined by top-left corner (aX0, aY0), width aW and height aH.
*/
SHAPE_RECT
(
int
aX0
,
int
aY0
,
int
aW
,
int
aH
)
:
SHAPE
(
SH_RECT
),
m_p0
(
aX0
,
aY0
),
m_w
(
aW
),
m_h
(
aH
)
{};
SHAPE
(
SH_RECT
),
m_p0
(
aX0
,
aY0
),
m_w
(
aW
),
m_h
(
aH
)
{}
/**
* Constructor
* Creates a rectangle defined by top-left corner aP0, width aW and height aH.
*/
SHAPE_RECT
(
const
VECTOR2I
&
aP0
,
int
aW
,
int
aH
)
:
SHAPE
(
SH_RECT
),
m_p0
(
aP0
),
m_w
(
aW
),
m_h
(
aH
)
{};
SHAPE
(
SH_RECT
),
m_p0
(
aP0
),
m_w
(
aW
),
m_h
(
aH
)
{}
/// @copydoc SHAPE::BBox()
const
BOX2I
BBox
(
int
aClearance
=
0
)
const
...
...
@@ -84,7 +87,7 @@ class SHAPE_RECT : public SHAPE
//if( BBox( 0 ).SquaredDistance( r ) > aClearance * aClearance )
// return false;
if
(
BBox
(
0
).
Contains
(
aSeg
.
a
)
||
BBox
(
0
).
Contains
(
aSeg
.
b
)
)
if
(
BBox
(
0
).
Contains
(
aSeg
.
A
)
||
BBox
(
0
).
Contains
(
aSeg
.
B
)
)
return
true
;
VECTOR2I
vts
[]
=
{
VECTOR2I
(
m_p0
.
x
,
m_p0
.
y
),
...
...
@@ -96,12 +99,13 @@ class SHAPE_RECT : public SHAPE
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
SEG
s
(
vts
[
i
],
vts
[
i
+
1
],
i
);
if
(
s
.
Distance
(
aSeg
)
<=
aClearance
)
return
true
;
}
return
false
;
};
}
/**
* Function GetPosition()
...
...
@@ -143,7 +147,7 @@ class SHAPE_RECT : public SHAPE
return
m_h
;
}
private
:
private
:
///> Top-left corner
VECTOR2I
m_p0
;
...
...
@@ -152,6 +156,6 @@ class SHAPE_RECT : public SHAPE
///> Height
int
m_h
;
};
};
#endif // __SHAPE_RECT_H
include/math/math_util.h
View file @
bc305859
...
...
@@ -35,17 +35,17 @@
*/
template
<
typename
T
>
T
rescale
(
T
numerator
,
T
value
,
T
d
enominator
)
T
rescale
(
T
aNumerator
,
T
aValue
,
T
aD
enominator
)
{
return
numerator
*
value
/
d
enominator
;
return
aNumerator
*
aValue
/
aD
enominator
;
}
// explicit specializations for integer types, taking care of overflow.
template
<>
int
rescale
(
int
numerator
,
int
value
,
int
d
enominator
);
int
rescale
(
int
aNumerator
,
int
aValue
,
int
aD
enominator
);
template
<>
int64_t
rescale
(
int64_t
numerator
,
int64_t
value
,
int64_t
d
enominator
);
int64_t
rescale
(
int64_t
aNumerator
,
int64_t
aValue
,
int64_t
aD
enominator
);
#endif // __MATH_UTIL_H
include/math/matrix3x3.h
View file @
bc305859
...
...
@@ -55,7 +55,7 @@ template <class T>
class
MATRIX3x3
;
template
<
class
T
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
const
MATRIX3x3
<
T
>&
m
atrix
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
aStream
,
const
MATRIX3x3
<
T
>&
aM
atrix
);
template
<
class
T
>
class
MATRIX3x3
...
...
@@ -92,7 +92,7 @@ public:
*
* The diagonal components of the matrix are set to 1.
*/
void
SetIdentity
(
void
);
void
SetIdentity
();
/**
* @brief Set the translation components of the matrix.
...
...
@@ -106,7 +106,7 @@ public:
*
* @return is the translation (2D-vector).
*/
VECTOR2
<
T
>
GetTranslation
(
void
)
const
;
VECTOR2
<
T
>
GetTranslation
()
const
;
/**
* @brief Set the rotation components of the matrix.
...
...
@@ -129,14 +129,14 @@ public:
*
* @return the scale factors, specified as 2D-vector.
*/
VECTOR2
<
T
>
GetScale
(
void
)
const
;
VECTOR2
<
T
>
GetScale
()
const
;
/**
* @brief Compute the determinant of the matrix.
*
* @return the determinant value.
*/
T
Determinant
(
void
)
const
;
T
Determinant
()
const
;
/**
* @brief Determine the inverse of the matrix.
...
...
@@ -148,33 +148,33 @@ public:
*
* @return the inverse matrix.
*/
MATRIX3x3
Inverse
(
void
)
const
;
MATRIX3x3
Inverse
()
const
;
/**
* @brief Get the transpose of the matrix.
*
* @return the transpose matrix.
*/
MATRIX3x3
Transpose
(
void
)
const
;
MATRIX3x3
Transpose
()
const
;
/**
* @brief Output to a stream.
*/
friend
std
::
ostream
&
operator
<<<
T
>
(
std
::
ostream
&
stream
,
const
MATRIX3x3
<
T
>&
m
atrix
);
friend
std
::
ostream
&
operator
<<<
T
>
(
std
::
ostream
&
aStream
,
const
MATRIX3x3
<
T
>&
aM
atrix
);
};
// Operators
//! @brief Matrix multiplication
template
<
class
T
>
MATRIX3x3
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
a
,
MATRIX3x3
<
T
>
const
&
b
);
template
<
class
T
>
MATRIX3x3
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
a
A
,
MATRIX3x3
<
T
>
const
&
aB
);
//! @brief Multiplication with a 2D vector, the 3rd z-component is assumed to be 1
template
<
class
T
>
VECTOR2
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
a
,
VECTOR2
<
T
>
const
&
b
);
template
<
class
T
>
VECTOR2
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
a
A
,
VECTOR2
<
T
>
const
&
aB
);
//! @brief Multiplication with a scalar
template
<
class
T
,
class
S
>
MATRIX3x3
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
a
,
T
s
calar
);
template
<
class
T
,
class
S
>
MATRIX3x3
<
T
>
const
operator
*
(
T
scalar
,
MATRIX3x3
<
T
>
const
&
m
atrix
);
template
<
class
T
,
class
S
>
MATRIX3x3
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
a
A
,
T
aS
calar
);
template
<
class
T
,
class
S
>
MATRIX3x3
<
T
>
const
operator
*
(
T
aScalar
,
MATRIX3x3
<
T
>
const
&
aM
atrix
);
// ----------------------
// --- Implementation ---
...
...
@@ -235,11 +235,12 @@ void MATRIX3x3<T>::SetTranslation( VECTOR2<T> aTranslation )
template
<
class
T
>
VECTOR2
<
T
>
MATRIX3x3
<
T
>::
GetTranslation
(
void
)
const
VECTOR2
<
T
>
MATRIX3x3
<
T
>::
GetTranslation
()
const
{
VECTOR2
<
T
>
result
;
result
.
x
=
m_data
[
0
][
2
];
result
.
y
=
m_data
[
1
][
2
];
return
result
;
}
...
...
@@ -265,15 +266,16 @@ void MATRIX3x3<T>::SetScale( VECTOR2<T> aScale )
template
<
class
T
>
VECTOR2
<
T
>
MATRIX3x3
<
T
>::
GetScale
(
void
)
const
VECTOR2
<
T
>
MATRIX3x3
<
T
>::
GetScale
()
const
{
VECTOR2
<
T
>
result
(
m_data
[
0
][
0
],
m_data
[
1
][
1
]
);
return
result
;
}
template
<
class
T
>
MATRIX3x3
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
a
,
MATRIX3x3
<
T
>
const
&
b
)
MATRIX3x3
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
a
A
,
MATRIX3x3
<
T
>
const
&
aB
)
{
MATRIX3x3
<
T
>
result
;
...
...
@@ -281,8 +283,9 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b )
{
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
result
.
m_data
[
i
][
j
]
=
a
.
m_data
[
i
][
0
]
*
b
.
m_data
[
0
][
j
]
+
a
.
m_data
[
i
][
1
]
*
b
.
m_data
[
1
][
j
]
+
a
.
m_data
[
i
][
2
]
*
b
.
m_data
[
2
][
j
];
result
.
m_data
[
i
][
j
]
=
aA
.
m_data
[
i
][
0
]
*
aB
.
m_data
[
0
][
j
]
+
aA
.
m_data
[
i
][
1
]
*
aB
.
m_data
[
1
][
j
]
+
aA
.
m_data
[
i
][
2
]
*
aB
.
m_data
[
2
][
j
];
}
}
...
...
@@ -291,21 +294,20 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& a, MATRIX3x3<T> const& b )
template
<
class
T
>
VECTOR2
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
matrix
,
VECTOR2
<
T
>
const
&
vector
)
VECTOR2
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
aMatrix
,
VECTOR2
<
T
>
const
&
aVector
)
{
VECTOR2
<
T
>
result
(
0
,
0
);
result
.
x
=
matrix
.
m_data
[
0
][
0
]
*
vector
.
x
+
matrix
.
m_data
[
0
][
1
]
*
v
ector
.
y
+
m
atrix
.
m_data
[
0
][
2
];
result
.
y
=
matrix
.
m_data
[
1
][
0
]
*
vector
.
x
+
matrix
.
m_data
[
1
][
1
]
*
v
ector
.
y
+
m
atrix
.
m_data
[
1
][
2
];
result
.
x
=
aMatrix
.
m_data
[
0
][
0
]
*
aVector
.
x
+
aMatrix
.
m_data
[
0
][
1
]
*
aV
ector
.
y
+
aM
atrix
.
m_data
[
0
][
2
];
result
.
y
=
aMatrix
.
m_data
[
1
][
0
]
*
aVector
.
x
+
aMatrix
.
m_data
[
1
][
1
]
*
aV
ector
.
y
+
aM
atrix
.
m_data
[
1
][
2
];
return
result
;
}
template
<
class
T
>
T
MATRIX3x3
<
T
>::
Determinant
(
void
)
const
T
MATRIX3x3
<
T
>::
Determinant
()
const
{
return
m_data
[
0
][
0
]
*
(
m_data
[
1
][
1
]
*
m_data
[
2
][
2
]
-
m_data
[
1
][
2
]
*
m_data
[
2
][
1
]
)
-
m_data
[
0
][
1
]
*
(
m_data
[
1
][
0
]
*
m_data
[
2
][
2
]
-
m_data
[
1
][
2
]
*
m_data
[
2
][
0
]
)
...
...
@@ -314,7 +316,7 @@ T MATRIX3x3<T>::Determinant( void ) const
template
<
class
T
,
class
S
>
MATRIX3x3
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
matrix
,
S
s
calar
)
MATRIX3x3
<
T
>
const
operator
*
(
MATRIX3x3
<
T
>
const
&
aMatrix
,
S
aS
calar
)
{
MATRIX3x3
<
T
>
result
;
...
...
@@ -322,7 +324,7 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar )
{
for
(
int
j
=
0
;
j
<
3
;
j
++
)
{
result
.
m_data
[
i
][
j
]
=
matrix
.
m_data
[
i
][
j
]
*
s
calar
;
result
.
m_data
[
i
][
j
]
=
aMatrix
.
m_data
[
i
][
j
]
*
aS
calar
;
}
}
...
...
@@ -331,9 +333,9 @@ MATRIX3x3<T> const operator*( MATRIX3x3<T> const& matrix, S scalar )
template
<
class
T
,
class
S
>
MATRIX3x3
<
T
>
const
operator
*
(
S
scalar
,
MATRIX3x3
<
T
>
const
&
m
atrix
)
MATRIX3x3
<
T
>
const
operator
*
(
S
aScalar
,
MATRIX3x3
<
T
>
const
&
aM
atrix
)
{
return
matrix
*
s
calar
;
return
aMatrix
*
aS
calar
;
}
...
...
include/math/vector2d.h
View file @
bc305859
...
...
@@ -62,7 +62,7 @@ struct VECTOR2_TRAITS<int>
template
<
class
T
>
class
VECTOR2
;
template
<
class
T
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
const
VECTOR2
<
T
>&
v
ector
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
aStream
,
const
VECTOR2
<
T
>&
aV
ector
);
/**
* Class VECTOR2
...
...
@@ -351,6 +351,8 @@ VECTOR2<T>& VECTOR2<T>::operator-=( const T& aScalar )
y
-=
aScalar
;
return
*
this
;
}
template
<
class
T
>
VECTOR2
<
T
>
VECTOR2
<
T
>::
Rotate
(
double
aAngle
)
const
{
...
...
include/tool/coroutine.h
View file @
bc305859
...
...
@@ -108,9 +108,9 @@ public:
* Yield with a value - passes a value of given type to the caller.
* Useful for implementing generator objects.
*/
void
Yield
(
ReturnType
&
r
etVal
)
void
Yield
(
ReturnType
&
aR
etVal
)
{
m_retVal
=
r
etVal
;
m_retVal
=
aR
etVal
;
boost
::
context
::
jump_fcontext
(
m_self
,
m_saved
,
0
);
}
...
...
@@ -130,7 +130,7 @@ public:
* @return true, if the coroutine has yielded and false if it has finished its
* execution (returned).
*/
bool
Call
(
ArgType
args
)
bool
Call
(
ArgType
a
A
rgs
)
{
// fixme: Clean up stack stuff. Add a guard
m_stack
=
malloc
(
c_defaultStackSize
);
...
...
@@ -138,7 +138,7 @@ public:
// align to 16 bytes
void
*
sp
=
(
void
*
)
(
(
(
(
ptrdiff_t
)
m_stack
)
+
m_stackSize
-
0xf
)
&
(
~
0x0f
)
);
m_args
=
&
args
;
m_args
=
&
a
A
rgs
;
m_self
=
boost
::
context
::
make_fcontext
(
sp
,
m_stackSize
,
callerStub
);
m_saved
=
new
boost
::
context
::
fcontext_t
();
...
...
@@ -186,10 +186,10 @@ private:
static
const
int
c_defaultStackSize
=
2000000
;
// fixme: make configurable
/* real entry point of the coroutine */
static
void
callerStub
(
intptr_t
d
ata
)
static
void
callerStub
(
intptr_t
aD
ata
)
{
// get pointer to self
COROUTINE
<
ReturnType
,
ArgType
>*
cor
=
reinterpret_cast
<
COROUTINE
<
ReturnType
,
ArgType
>*>
(
d
ata
);
COROUTINE
<
ReturnType
,
ArgType
>*
cor
=
reinterpret_cast
<
COROUTINE
<
ReturnType
,
ArgType
>*>
(
aD
ata
);
// call the coroutine method
cor
->
m_retVal
=
cor
->
m_func
(
*
cor
->
m_args
);
...
...
include/tool/delegate.h
View file @
bc305859
...
...
@@ -45,17 +45,17 @@ public:
}
template
<
class
T
>
DELEGATE
(
T
*
object
,
ReturnType
(
T
::*
p
tr
)(
Arg
)
)
DELEGATE
(
T
*
aObject
,
ReturnType
(
T
::*
aP
tr
)(
Arg
)
)
{
m_ptr
=
reinterpret_cast
<
MemberPointer
>
(
p
tr
);
m_object
=
reinterpret_cast
<
void
*>
(
o
bject
);
m_ptr
=
reinterpret_cast
<
MemberPointer
>
(
aP
tr
);
m_object
=
reinterpret_cast
<
void
*>
(
aO
bject
);
};
ReturnType
operator
()(
Arg
a
)
const
ReturnType
operator
()(
Arg
a
A
)
const
{
DELEGATE
<
ReturnType
,
Arg
>*
casted
=
reinterpret_cast
<
DELEGATE
<
ReturnType
,
Arg
>*>
(
m_object
);
return
(
casted
->*
m_ptr
)(
a
);
return
(
casted
->*
m_ptr
)(
a
A
);
}
private
:
...
...
@@ -79,10 +79,10 @@ public:
}
template
<
class
T
>
DELEGATE0
(
T
*
object
,
ReturnType
(
T
::*
p
tr
)()
)
DELEGATE0
(
T
*
aObject
,
ReturnType
(
T
::*
aP
tr
)()
)
{
m_ptr
=
reinterpret_cast
<
MemberPointer
>
(
p
tr
);
m_object
=
reinterpret_cast
<
void
*>
(
o
bject
);
m_ptr
=
reinterpret_cast
<
MemberPointer
>
(
aP
tr
);
m_object
=
reinterpret_cast
<
void
*>
(
aO
bject
);
};
...
...
include/tool/tool_action.h
View file @
bc305859
...
...
@@ -45,7 +45,7 @@
class
TOOL_ACTION
{
public
:
TOOL_ACTION
(
const
std
::
string
&
aName
,
TOOL_A
ctionScope
aScope
=
AS_CONTEXT
,
TOOL_ACTION
(
const
std
::
string
&
aName
,
TOOL_A
CTION_SCOPE
aScope
=
AS_CONTEXT
,
int
aDefaultHotKey
=
0
,
const
std
::
string
&
aMenuItem
=
std
::
string
(
""
),
const
std
::
string
&
aMenuDesc
=
std
::
string
(
""
)
)
:
m_name
(
aName
),
m_scope
(
aScope
),
m_defaultHotKey
(
aDefaultHotKey
),
...
...
@@ -148,7 +148,7 @@ public:
*/
TOOL_EVENT
MakeEvent
()
const
{
return
TOOL_EVENT
(
TC_C
ommand
,
TA_Action
,
m_name
,
m_scope
);
return
TOOL_EVENT
(
TC_C
OMMAND
,
TA_ACTION
,
m_name
,
m_scope
);
}
const
std
::
string
&
GetMenuItem
()
const
...
...
@@ -190,7 +190,7 @@ private:
std
::
string
m_name
;
/// Scope of the action (ie. the event that is issued after activation).
TOOL_A
ctionScope
m_scope
;
TOOL_A
CTION_SCOPE
m_scope
;
/// Default hot key that activates the action.
const
int
m_defaultHotKey
;
...
...
include/tool/tool_base.h
View file @
bc305859
...
...
@@ -40,13 +40,13 @@ class VIEW;
class
VIEW_CONTROLS
;
};
enum
TOOL_T
ype
enum
TOOL_T
YPE
{
///> Tool that interacts with the user
TOOL_Interactive
=
0x01
,
INTERACTIVE
=
0x01
,
///> Tool that runs in the background without any user intervention
TOOL_Batch
=
0x02
BATCH
=
0x02
};
/// Unique identifier for tools
...
...
@@ -62,7 +62,7 @@ typedef DELEGATE<int, TOOL_EVENT&> TOOL_STATE_FUNC;
class
TOOL_BASE
{
public
:
TOOL_BASE
(
TOOL_T
ype
aType
,
TOOL_ID
aId
,
const
std
::
string
&
aName
=
std
::
string
(
""
)
)
:
TOOL_BASE
(
TOOL_T
YPE
aType
,
TOOL_ID
aId
,
const
std
::
string
&
aName
=
std
::
string
(
""
)
)
:
m_type
(
aType
),
m_toolId
(
aId
),
m_toolName
(
aName
),
...
...
@@ -75,7 +75,7 @@ public:
* Returns the type of the tool.
* @return The type of the tool.
*/
TOOL_T
ype
GetType
()
const
TOOL_T
YPE
GetType
()
const
{
return
m_type
;
}
...
...
@@ -158,7 +158,7 @@ protected:
* Returns the model object if it matches the requested type.
*/
template
<
typename
T
>
T
*
getModel
(
KICAD_T
m
odelType
)
const
T
*
getModel
(
KICAD_T
aM
odelType
)
const
{
EDA_ITEM
*
m
=
getModelInt
();
...
...
@@ -166,7 +166,7 @@ protected:
}
///> Stores the type of the tool.
TOOL_T
ype
m_type
;
TOOL_T
YPE
m_type
;
///> Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
TOOL_ID
m_toolId
;
...
...
include/tool/tool_dispatcher.h
View file @
bc305859
...
...
@@ -32,7 +32,8 @@
class
TOOL_MANAGER
;
class
PCB_BASE_FRAME
;
namespace
KIGFX
{
namespace
KIGFX
{
class
VIEW
;
};
...
...
@@ -102,25 +103,25 @@ private:
int
mods
=
0
;
if
(
aState
->
ControlDown
()
)
mods
|=
MD_
ModCtrl
;
mods
|=
MD_
CTRL
;
if
(
aState
->
AltDown
()
)
mods
|=
MD_
ModAlt
;
mods
|=
MD_
ALT
;
if
(
aState
->
ShiftDown
()
)
mods
|=
MD_
ModShift
;
mods
|=
MD_
SHIFT
;
return
mods
;
}
///> Stores all the informations regarding a mouse button state.
struct
B
uttonState
;
struct
B
UTTON_STATE
;
///> The last mouse cursor position (in world coordinates).
VECTOR2D
m_lastMousePos
;
///> State of mouse buttons.
std
::
vector
<
B
uttonState
*>
m_buttons
;
std
::
vector
<
B
UTTON_STATE
*>
m_buttons
;
///> Returns the instance of VIEW, used by the application.
KIGFX
::
VIEW
*
getView
();
...
...
include/tool/tool_event.h
View file @
bc305859
...
...
@@ -40,77 +40,77 @@ class TOOL_MANAGER;
* Internal (GUI-independent) event definitions.
* Enums are mostly self-explanatory.
*/
enum
TOOL_E
ventCategory
enum
TOOL_E
VENT_CATEGORY
{
TC_N
one
=
0x00
,
TC_M
ouse
=
0x01
,
TC_K
eyboard
=
0x02
,
TC_C
ommand
=
0x04
,
TC_M
essage
=
0x08
,
TC_V
iew
=
0x10
,
TC_A
ny
=
0xffffffff
TC_N
ONE
=
0x00
,
TC_M
OUSE
=
0x01
,
TC_K
EYBOARD
=
0x02
,
TC_C
OMMAND
=
0x04
,
TC_M
ESSAGE
=
0x08
,
TC_V
IEW
=
0x10
,
TC_A
NY
=
0xffffffff
};
enum
TOOL_A
ctions
enum
TOOL_A
CTIONS
{
// UI input events
TA_N
one
=
0x0000
,
TA_M
ouseClick
=
0x0001
,
TA_M
ouseUp
=
0x0002
,
TA_M
ouseDown
=
0x0004
,
TA_M
ouseDrag
=
0x0008
,
TA_M
ouseMotion
=
0x0010
,
TA_M
ouseWheel
=
0x0020
,
TA_M
ouse
=
0x003f
,
TA_K
eyUp
=
0x0040
,
TA_K
eyDown
=
0x0080
,
TA_K
eyboard
=
TA_KeyUp
|
TA_KeyDown
,
TA_N
ONE
=
0x0000
,
TA_M
OUSE_CLICK
=
0x0001
,
TA_M
OUSE_UP
=
0x0002
,
TA_M
OUSE_DOWN
=
0x0004
,
TA_M
OUSE_DRAG
=
0x0008
,
TA_M
OUSE_MOTION
=
0x0010
,
TA_M
OUSE_WHEEL
=
0x0020
,
TA_M
OUSE
=
0x003f
,
TA_K
EY_UP
=
0x0040
,
TA_K
EY_DOWN
=
0x0080
,
TA_K
EYBOARD
=
TA_KEY_UP
|
TA_KEY_DOWN
,
// View related events
TA_V
iewRefresh
=
0x0100
,
TA_V
iewZoom
=
0x0200
,
TA_V
iewPan
=
0x0400
,
TA_V
iewDirty
=
0x0800
,
TA_C
hangeLayer
=
0x1000
,
TA_V
IEW_REFRESH
=
0x0100
,
TA_V
IEW_ZOOM
=
0x0200
,
TA_V
IEW_PAN
=
0x0400
,
TA_V
IEW_DIRTY
=
0x0800
,
TA_C
HANGE_LAYER
=
0x1000
,
// Tool cancel event. Issued automagically when the user hits escape or selects End Tool from
// the context menu.
TA_C
ancelTool
=
0x2000
,
TA_C
ANCEL_TOOL
=
0x2000
,
// Context menu update. Issued whenever context menu is open and the user hovers the mouse
// over one of choices. Used in dynamic highligting in disambiguation menu
TA_C
ontextMenuUpdate
=
0x4000
,
TA_C
ONTEXT_MENU_UPDATE
=
0x4000
,
// Context menu choice. Sent if the user picked something from the context menu or
// closed it without selecting anything.
TA_C
ontextMenuChoice
=
0x8000
,
TA_C
ONTEXT_MENU_CHOICE
=
0x8000
,
// Tool action (allows to control tools)
TA_A
ction
=
0x10000
,
TA_A
CTION
=
0x10000
,
TA_A
ny
=
0xffffffff
TA_A
NY
=
0xffffffff
};
enum
TOOL_M
ouseButtons
enum
TOOL_M
OUSE_BUTTONS
{
MB_N
one
=
0x0
,
MB_L
eft
=
0x1
,
MB_R
ight
=
0x2
,
MB_M
iddle
=
0x4
,
MB_B
uttonMask
=
MB_Left
|
MB_Right
|
MB_Middle
,
MB_A
ny
=
0xffffffff
MB_N
ONE
=
0x0
,
MB_L
EFT
=
0x1
,
MB_R
IGHT
=
0x2
,
MB_M
IDDLE
=
0x4
,
MB_B
UTTON_MASK
=
MB_LEFT
|
MB_RIGHT
|
MB_MIDDLE
,
MB_A
NY
=
0xffffffff
};
enum
TOOL_M
odifiers
enum
TOOL_M
ODIFIERS
{
MD_
ModShift
=
0x1000
,
MD_
ModCtrl
=
0x2000
,
MD_
ModAlt
=
0x4000
,
MD_M
odifierMask
=
MD_ModShift
|
MD_ModCtrl
|
MD_ModAlt
,
MD_
SHIFT
=
0x1000
,
MD_
CTRL
=
0x2000
,
MD_
ALT
=
0x4000
,
MD_M
ODIFIER_MASK
=
MD_SHIFT
|
MD_CTRL
|
MD_ALT
,
};
/// Scope of tool actions
enum
TOOL_A
ctionScope
enum
TOOL_A
CTION_SCOPE
{
AS_CONTEXT
=
1
,
///> Action belongs to a particular tool (i.e. a part of a pop-up menu)
AS_ACTIVE
,
///> All active tools
...
...
@@ -141,8 +141,8 @@ public:
*/
const
std
::
string
Format
()
const
;
TOOL_EVENT
(
TOOL_E
ventCategory
aCategory
=
TC_None
,
TOOL_Actions
aAction
=
TA_None
,
TOOL_A
ctionScope
aScope
=
AS_GLOBAL
)
:
TOOL_EVENT
(
TOOL_E
VENT_CATEGORY
aCategory
=
TC_NONE
,
TOOL_ACTIONS
aAction
=
TA_NONE
,
TOOL_A
CTION_SCOPE
aScope
=
AS_GLOBAL
)
:
m_category
(
aCategory
),
m_actions
(
aAction
),
m_scope
(
aScope
),
...
...
@@ -150,52 +150,50 @@ public:
m_keyCode
(
0
),
m_modifiers
(
0
)
{}
TOOL_EVENT
(
TOOL_EventCategory
aCategory
,
TOOL_Actions
aAction
,
int
aExtraParam
,
TOOL_ActionScope
aScope
=
AS_GLOBAL
)
:
TOOL_EVENT
(
TOOL_EVENT_CATEGORY
aCategory
,
TOOL_ACTIONS
aAction
,
int
aExtraParam
,
TOOL_ACTION_SCOPE
aScope
=
AS_GLOBAL
)
:
m_category
(
aCategory
),
m_actions
(
aAction
),
m_scope
(
aScope
)
{
if
(
aCategory
==
TC_M
ouse
)
if
(
aCategory
==
TC_M
OUSE
)
{
m_mouseButtons
=
aExtraParam
&
MB_B
uttonMask
;
m_mouseButtons
=
aExtraParam
&
MB_B
UTTON_MASK
;
}
else
if
(
aCategory
==
TC_K
eyboard
)
else
if
(
aCategory
==
TC_K
EYBOARD
)
{
m_keyCode
=
aExtraParam
&
~
MD_M
odifierMask
;
// Filter out modifiers
m_keyCode
=
aExtraParam
&
~
MD_M
ODIFIER_MASK
;
// Filter out modifiers
}
else
if
(
aCategory
==
TC_C
ommand
)
else
if
(
aCategory
==
TC_C
OMMAND
)
{
m_commandId
=
aExtraParam
;
}
if
(
aCategory
&
(
TC_M
ouse
|
TC_Keyboard
)
)
if
(
aCategory
&
(
TC_M
OUSE
|
TC_KEYBOARD
)
)
{
m_modifiers
=
aExtraParam
&
MD_M
odifierMask
;
m_modifiers
=
aExtraParam
&
MD_M
ODIFIER_MASK
;
}
}
TOOL_EVENT
(
TOOL_E
ventCategory
aCategory
,
TOOL_Actions
aAction
,
const
std
::
string
&
aExtraParam
,
TOOL_A
ctionScope
aScope
=
AS_GLOBAL
)
:
TOOL_EVENT
(
TOOL_E
VENT_CATEGORY
aCategory
,
TOOL_ACTIONS
aAction
,
const
std
::
string
&
aExtraParam
,
TOOL_A
CTION_SCOPE
aScope
=
AS_GLOBAL
)
:
m_category
(
aCategory
),
m_actions
(
aAction
),
m_scope
(
aScope
),
m_mouseButtons
(
0
)
{
if
(
aCategory
==
TC_C
ommand
)
if
(
aCategory
==
TC_C
OMMAND
)
m_commandStr
=
aExtraParam
;
}
///> Returns the category (eg. mouse/keyboard/action) of an event..
TOOL_E
ventCategory
Category
()
const
TOOL_E
VENT_CATEGORY
Category
()
const
{
return
m_category
;
}
///> Returns more specific information about the type of an event.
TOOL_A
ctions
Action
()
const
TOOL_A
CTIONS
Action
()
const
{
return
m_actions
;
}
...
...
@@ -204,59 +202,59 @@ public:
///> where dragging has started.
const
VECTOR2D
Delta
()
const
{
assert
(
m_category
==
TC_M
ouse
);
// this should be used only with mouse events
assert
(
m_category
==
TC_M
OUSE
);
// this should be used only with mouse events
return
m_mouseDelta
;
}
///> Returns mouse cursor position in world coordinates.
const
VECTOR2D
&
Position
()
const
{
assert
(
m_category
==
TC_M
ouse
);
// this should be used only with mouse events
assert
(
m_category
==
TC_M
OUSE
);
// this should be used only with mouse events
return
m_mousePos
;
}
///> Returns the point where dragging has started.
const
VECTOR2D
&
DragOrigin
()
const
{
assert
(
m_category
==
TC_M
ouse
);
// this should be used only with mouse events
assert
(
m_category
==
TC_M
OUSE
);
// this should be used only with mouse events
return
m_mouseDragOrigin
;
}
///> Returns information about mouse buttons state.
int
Buttons
()
const
{
assert
(
m_category
==
TC_M
ouse
);
// this should be used only with mouse events
assert
(
m_category
==
TC_M
OUSE
);
// this should be used only with mouse events
return
m_mouseButtons
;
}
bool
IsClick
(
int
aButtonMask
=
MB_A
ny
)
const
bool
IsClick
(
int
aButtonMask
=
MB_A
NY
)
const
{
return
(
m_actions
==
TA_M
ouseClick
)
return
(
m_actions
==
TA_M
OUSE_CLICK
)
&&
(
(
m_mouseButtons
&
aButtonMask
)
==
aButtonMask
);
}
bool
IsDrag
(
int
aButtonMask
=
MB_A
ny
)
const
bool
IsDrag
(
int
aButtonMask
=
MB_A
NY
)
const
{
return
(
m_actions
==
TA_M
ouseDrag
)
&&
(
(
m_mouseButtons
&
aButtonMask
)
==
aButtonMask
);
return
(
m_actions
==
TA_M
OUSE_DRAG
)
&&
(
(
m_mouseButtons
&
aButtonMask
)
==
aButtonMask
);
}
bool
IsMouseUp
(
int
aButtonMask
=
MB_A
ny
)
const
bool
IsMouseUp
(
int
aButtonMask
=
MB_A
NY
)
const
{
return
(
m_actions
==
TA_M
ouseUp
)
&&
(
(
m_mouseButtons
&
aButtonMask
)
==
aButtonMask
);
return
(
m_actions
==
TA_M
OUSE_UP
)
&&
(
(
m_mouseButtons
&
aButtonMask
)
==
aButtonMask
);
}
bool
IsMotion
()
const
{
return
m_actions
==
TA_M
ouseMotion
;
return
m_actions
==
TA_M
OUSE_MOTION
;
}
bool
IsCancel
()
const
{
return
m_actions
==
TA_C
ancelTool
;
return
m_actions
==
TA_C
ANCEL_TOOL
;
}
///> Returns information about key modifiers state (Ctrl, Alt, etc.)
int
Modifier
(
int
aMask
=
MD_M
odifierMask
)
const
int
Modifier
(
int
aMask
=
MD_M
ODIFIER_MASK
)
const
{
return
m_modifiers
&
aMask
;
}
...
...
@@ -268,12 +266,12 @@ public:
bool
IsKeyUp
()
const
{
return
m_actions
==
TA_K
eyUp
;
return
m_actions
==
TA_K
EY_UP
;
}
bool
IsKeyDown
()
const
{
return
m_actions
==
TA_K
eyDown
;
return
m_actions
==
TA_K
EY_DOWN
;
}
void
SetMouseDragOrigin
(
const
VECTOR2D
&
aP
)
...
...
@@ -306,7 +304,7 @@ public:
if
(
!
(
m_actions
&
aEvent
.
m_actions
)
)
return
false
;
if
(
m_category
==
TC_C
ommand
)
if
(
m_category
==
TC_C
OMMAND
)
{
if
(
m_commandStr
&&
aEvent
.
m_commandStr
)
return
*
m_commandStr
==
*
aEvent
.
m_commandStr
;
...
...
@@ -334,9 +332,9 @@ public:
private
:
friend
class
TOOL_MANAGER
;
TOOL_E
ventCategory
m_category
;
TOOL_A
ctions
m_actions
;
TOOL_A
ctionScope
m_scope
;
TOOL_E
VENT_CATEGORY
m_category
;
TOOL_A
CTIONS
m_actions
;
TOOL_A
CTION_SCOPE
m_scope
;
///> Difference between mouse cursor position and
///> the point where dragging event has started
...
...
@@ -377,7 +375,8 @@ public:
typedef
std
::
deque
<
TOOL_EVENT
>::
const_iterator
const_iterator
;
///> Default constructor. Creates an empty list.
TOOL_EVENT_LIST
()
{};
TOOL_EVENT_LIST
()
{}
///> Constructor for a list containing only one TOOL_EVENT.
TOOL_EVENT_LIST
(
const
TOOL_EVENT
&
aSingleEvent
)
...
...
@@ -393,10 +392,10 @@ public:
*/
const
std
::
string
Format
()
const
;
boost
::
optional
<
const
TOOL_EVENT
&>
Matches
(
const
TOOL_EVENT
&
b
)
const
boost
::
optional
<
const
TOOL_EVENT
&>
Matches
(
const
TOOL_EVENT
&
aEvent
)
const
{
for
(
const_iterator
i
=
m_events
.
begin
();
i
!=
m_events
.
end
();
++
i
)
if
(
i
->
Matches
(
b
)
)
if
(
i
->
Matches
(
aEvent
)
)
return
*
i
;
return
boost
::
optional
<
const
TOOL_EVENT
&>
();
...
...
@@ -442,12 +441,12 @@ public:
m_events
.
clear
();
}
TOOL_EVENT_LIST
&
operator
=
(
const
TOOL_EVENT_LIST
&
b
)
TOOL_EVENT_LIST
&
operator
=
(
const
TOOL_EVENT_LIST
&
aEventList
)
{
m_events
.
clear
();
for
(
std
::
deque
<
TOOL_EVENT
>::
const_iterator
i
=
b
.
m_events
.
begin
();
i
!=
b
.
m_events
.
end
();
++
i
)
for
(
std
::
deque
<
TOOL_EVENT
>::
const_iterator
i
=
aEventList
.
m_events
.
begin
();
i
!=
aEventList
.
m_events
.
end
();
++
i
)
{
m_events
.
push_back
(
*
i
);
}
...
...
@@ -455,20 +454,20 @@ public:
return
*
this
;
}
TOOL_EVENT_LIST
&
operator
=
(
const
TOOL_EVENT
&
b
)
TOOL_EVENT_LIST
&
operator
=
(
const
TOOL_EVENT
&
aEvent
)
{
m_events
.
clear
();
m_events
.
push_back
(
b
);
m_events
.
push_back
(
aEvent
);
return
*
this
;
}
TOOL_EVENT_LIST
&
operator
||
(
const
TOOL_EVENT
&
b
)
TOOL_EVENT_LIST
&
operator
||
(
const
TOOL_EVENT
&
aEvent
)
{
Add
(
b
);
Add
(
aEvent
);
return
*
this
;
}
TOOL_EVENT_LIST
&
operator
||
(
const
TOOL_EVENT_LIST
&
b
)
TOOL_EVENT_LIST
&
operator
||
(
const
TOOL_EVENT_LIST
&
aEvent
)
{
return
*
this
;
}
...
...
@@ -477,22 +476,23 @@ private:
std
::
deque
<
TOOL_EVENT
>
m_events
;
};
inline
const
TOOL_EVENT_LIST
operator
||
(
const
TOOL_EVENT
&
a
,
const
TOOL_EVENT
&
b
)
inline
const
TOOL_EVENT_LIST
operator
||
(
const
TOOL_EVENT
&
a
EventA
,
const
TOOL_EVENT
&
aEventB
)
{
TOOL_EVENT_LIST
l
;
l
.
Add
(
a
);
l
.
Add
(
b
);
l
.
Add
(
a
EventA
);
l
.
Add
(
aEventB
);
return
l
;
}
inline
const
TOOL_EVENT_LIST
operator
||
(
const
TOOL_EVENT
&
a
,
const
TOOL_EVENT_LIST
&
b
)
inline
const
TOOL_EVENT_LIST
operator
||
(
const
TOOL_EVENT
&
aEvent
,
const
TOOL_EVENT_LIST
&
aEventList
)
{
TOOL_EVENT_LIST
l
(
b
);
TOOL_EVENT_LIST
l
(
aEventList
);
l
.
Add
(
a
);
l
.
Add
(
a
Event
);
return
l
;
}
...
...
include/tool/tool_interactive.h
View file @
bc305859
...
...
@@ -83,7 +83,7 @@ public:
*/
template
<
class
T
>
void
Go
(
int
(
T
::*
aStateFunc
)(
TOOL_EVENT
&
),
const
TOOL_EVENT_LIST
&
aConditions
=
TOOL_EVENT
(
TC_A
ny
,
TA_Any
)
);
const
TOOL_EVENT_LIST
&
aConditions
=
TOOL_EVENT
(
TC_A
NY
,
TA_ANY
)
);
/**
* Function Wait()
...
...
@@ -91,7 +91,7 @@ public:
* Suspends execution of the tool until an event specified in aEventList arrives.
* No parameters means waiting for any event.
*/
OPT_TOOL_EVENT
Wait
(
const
TOOL_EVENT_LIST
&
aEventList
=
TOOL_EVENT
(
TC_Any
,
TA_Any
)
);
OPT_TOOL_EVENT
Wait
(
const
TOOL_EVENT_LIST
&
aEventList
=
TOOL_EVENT
(
TC_ANY
,
TA_ANY
)
);
/** functions below are not yet implemented - their interface may change */
/*template <class Parameters, class ReturnValue>
...
...
@@ -111,10 +111,10 @@ protected:
const
TOOL_EVENT
evCommand
(
int
aCommandId
=
-
1
);
const
TOOL_EVENT
evCommand
(
std
::
string
aCommandStr
=
""
);
const
TOOL_EVENT
evMotion
();
const
TOOL_EVENT
evClick
(
int
aButton
=
MB_A
ny
);
const
TOOL_EVENT
evDrag
(
int
aButton
=
MB_A
ny
);
const
TOOL_EVENT
evButtonUp
(
int
aButton
=
MB_A
ny
);
const
TOOL_EVENT
evButtonDown
(
int
aButton
=
MB_A
ny
);
const
TOOL_EVENT
evClick
(
int
aButton
=
MB_A
NY
);
const
TOOL_EVENT
evDrag
(
int
aButton
=
MB_A
NY
);
const
TOOL_EVENT
evButtonUp
(
int
aButton
=
MB_A
NY
);
const
TOOL_EVENT
evButtonDown
(
int
aButton
=
MB_A
NY
);
private
:
void
goInternal
(
TOOL_STATE_FUNC
&
aState
,
const
TOOL_EVENT_LIST
&
aConditions
);
...
...
include/view/view.h
View file @
bc305859
...
...
@@ -60,7 +60,7 @@ class VIEW
public
:
friend
class
VIEW_ITEM
;
typedef
std
::
pair
<
VIEW_ITEM
*
,
int
>
L
ayerItemPair
;
typedef
std
::
pair
<
VIEW_ITEM
*
,
int
>
L
AYER_ITEM_PAIR
;
/**
* Constructor.
...
...
@@ -94,7 +94,7 @@ public:
* first).
* @return Number of found items.
*/
int
Query
(
const
BOX2I
&
aRect
,
std
::
vector
<
L
ayerItemPair
>&
aResult
);
int
Query
(
const
BOX2I
&
aRect
,
std
::
vector
<
L
AYER_ITEM_PAIR
>&
aResult
);
/**
* Function SetRequired()
...
...
@@ -131,7 +131,10 @@ public:
* Returns the GAL this view is using to draw graphical primitives.
* @return Pointer to the currently used GAL instance.
*/
GAL
*
GetGAL
()
const
{
return
m_gal
;
}
GAL
*
GetGAL
()
const
{
return
m_gal
;
}
/**
* Function SetPainter()
...
...
@@ -144,7 +147,10 @@ public:
* Returns the painter object used by the view for drawing VIEW_ITEMS.
* @return Pointer to the currently used Painter instance.
*/
PAINTER
*
GetPainter
()
const
{
return
m_painter
;
};
PAINTER
*
GetPainter
()
const
{
return
m_painter
;
}
/**
* Function SetViewport()
...
...
@@ -189,7 +195,10 @@ public:
* Function GetScale()
* @return Current scalefactor of this VIEW
*/
double
GetScale
()
const
{
return
m_scale
;
}
double
GetScale
()
const
{
return
m_scale
;
}
/**
* Function SetCenter()
...
...
@@ -204,7 +213,10 @@ public:
* Returns the center point of this VIEW (in world space coordinates)
* @return center point of the view
*/
const
VECTOR2D
&
GetCenter
()
const
{
return
m_center
;
}
const
VECTOR2D
&
GetCenter
()
const
{
return
m_center
;
}
/**
* Function ToWorld()
...
...
@@ -291,7 +303,7 @@ public:
* @param aLayer is the layer.
* @param aTarget is the rendering target.
*/
inline
void
SetLayerTarget
(
int
aLayer
,
R
enderTarget
aTarget
)
inline
void
SetLayerTarget
(
int
aLayer
,
R
ENDER_TARGET
aTarget
)
{
m_layers
[
aLayer
].
target
=
aTarget
;
}
...
...
@@ -410,7 +422,10 @@ public:
* Tells if the VIEW is dynamic (ie. can be changed, for example displaying PCBs in a window)
* or static (that cannot be modified, eg. displaying image/PDF).
*/
bool
IsDynamic
()
const
{
return
m_dynamic
;
}
bool
IsDynamic
()
const
{
return
m_dynamic
;
}
/**
* Function IsDirty()
...
...
@@ -488,15 +503,15 @@ private:
VIEW_RTREE
*
items
;
///* R-tree indexing all items on this layer.
int
renderingOrder
;
///* rendering order of this layer
int
id
;
///* layer ID
R
enderTarget
target
;
///* where the layer should be rendered
std
::
set
<
int
>
requiredLayers
;
///* layers that
are required
to be enabled to show the layer
R
ENDER_TARGET
target
;
///* where the layer should be rendered
std
::
set
<
int
>
requiredLayers
;
///* layers that
have
to be enabled to show the layer
};
// Convenience typedefs
typedef
boost
::
unordered_map
<
int
,
VIEW_LAYER
>
L
ayerMap
;
typedef
L
ayerMap
::
iterator
LayerMapIter
;
typedef
std
::
vector
<
VIEW_LAYER
*>
L
ayerOrder
;
typedef
std
::
vector
<
VIEW_LAYER
*>::
iterator
L
ayerOrderIter
;
typedef
boost
::
unordered_map
<
int
,
VIEW_LAYER
>
L
AYER_MAP
;
typedef
L
AYER_MAP
::
iterator
LAYER_MAP_ITER
;
typedef
std
::
vector
<
VIEW_LAYER
*>
L
AYER_ORDER
;
typedef
std
::
vector
<
VIEW_LAYER
*>::
iterator
L
AYER_ORDER_ITER
;
// Function objects that need to access VIEW/VIEW_ITEM private/protected members
struct
clearLayerCache
;
...
...
@@ -573,9 +588,9 @@ private:
void
updateLayers
(
VIEW_ITEM
*
aItem
);
/// Determines rendering order of layers. Used in display order sorting function.
static
bool
compareRenderingOrder
(
VIEW_LAYER
*
i
,
VIEW_LAYER
*
j
)
static
bool
compareRenderingOrder
(
VIEW_LAYER
*
aI
,
VIEW_LAYER
*
aJ
)
{
return
i
->
renderingOrder
>
j
->
renderingOrder
;
return
aI
->
renderingOrder
>
aJ
->
renderingOrder
;
}
/// Checks if every layer required by the aLayerId layer is enabled.
...
...
@@ -585,10 +600,10 @@ private:
bool
m_enableOrderModifier
;
/// Contains set of possible displayed layers and its properties
L
ayerMap
m_layers
;
L
AYER_MAP
m_layers
;
/// Sorted list of pointers to members of m_layers
L
ayerOrder
m_orderedLayers
;
L
AYER_ORDER
m_orderedLayers
;
/// Stores set of layers that are displayed on the top
std
::
set
<
unsigned
int
>
m_topLayers
;
...
...
include/view/view_controls.h
View file @
bc305859
...
...
@@ -48,8 +48,11 @@ class VIEW_CONTROLS
public
:
VIEW_CONTROLS
(
VIEW
*
aView
)
:
m_view
(
aView
),
m_forceCursorPosition
(
false
),
m_snappingEnabled
(
false
),
m_grabMouse
(
false
),
m_autoPanEnabled
(
false
),
m_autoPanMargin
(
0
.
1
),
m_autoPanSpeed
(
0
.
15
)
{};
virtual
~
VIEW_CONTROLS
()
{};
m_autoPanMargin
(
0
.
1
),
m_autoPanSpeed
(
0
.
15
)
{}
virtual
~
VIEW_CONTROLS
()
{}
/**
* Function SetSnapping()
...
...
@@ -134,6 +137,11 @@ public:
m_forceCursorPosition
=
aEnabled
;
}
/**
* Function ShowCursor()
* Enables or disables display of cursor.
* @param aEnabled decides if the cursor should be shown.
*/
virtual
void
ShowCursor
(
bool
aEnabled
);
protected
:
...
...
include/view/view_group.h
View file @
bc305859
...
...
@@ -164,17 +164,32 @@ public:
*
* @param aFlags determines the way in which items will be updated.
*/
virtual
void
ItemsViewUpdate
(
VIEW_ITEM
::
V
iewUpdateFlags
aFlags
);
virtual
void
ItemsViewUpdate
(
VIEW_ITEM
::
V
IEW_UPDATE_FLAGS
aFlags
);
protected
:
/// These functions cannot be used with VIEW_GROUP as they are intended only to work with
/// singular VIEW_ITEMs (there is only one-to-one relation between item/layer combination and
/// its group).
int
getGroup
(
int
aLayer
)
const
{
return
-
1
;
};
std
::
vector
<
int
>
getAllGroups
()
const
{
return
std
::
vector
<
int
>
();
};
void
setGroup
(
int
aLayer
,
int
aGroup
)
{};
void
deleteGroups
()
{};
bool
storesGroups
()
const
{
return
false
;
};
int
getGroup
(
int
aLayer
)
const
{
return
-
1
;
}
std
::
vector
<
int
>
getAllGroups
()
const
{
return
std
::
vector
<
int
>
();
}
void
setGroup
(
int
aLayer
,
int
aGroup
)
{}
void
deleteGroups
()
{}
bool
storesGroups
()
const
{
return
false
;
}
/// Layer on which the group is drawn
int
m_layer
;
...
...
include/view/view_item.h
View file @
bc305859
...
...
@@ -155,14 +155,14 @@ class VIEW_ITEM
{
public
:
/**
* Enum V
iewUpdateFlags
.
* Enum V
IEW_UPDATE_FLAGS
.
* Defines the how severely the shape/appearance of the item has been changed:
* - APPEARANCE: shape or layer set of the item have not been affected,
* only colors or visibility.
* - GEOMETRY: shape or layer set of the item have changed, VIEW may need to reindex it.
* - ALL: all flags above */
enum
V
iewUpdateFlags
{
enum
V
IEW_UPDATE_FLAGS
{
APPEARANCE
=
0x01
,
/// Visibility flag has changed
COLOR
=
0x02
,
/// Color has changed
GEOMETRY
=
0x04
,
/// Position or shape has changed
...
...
@@ -212,7 +212,8 @@ public:
* @param aLayer: current drawing layer
* @param aGal: pointer to the GAL device we are drawing on
*/
virtual
void
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
{};
virtual
void
ViewDraw
(
int
aLayer
,
GAL
*
aGal
)
const
{}
/**
* Function ViewGetLayers()
...
...
include/view/wx_view_controls.h
View file @
bc305859
...
...
@@ -48,7 +48,8 @@ class WX_VIEW_CONTROLS : public VIEW_CONTROLS, public wxEvtHandler
{
public
:
WX_VIEW_CONTROLS
(
VIEW
*
aView
,
wxWindow
*
aParentPanel
);
~
WX_VIEW_CONTROLS
()
{};
~
WX_VIEW_CONTROLS
()
{}
/// Handler functions
void
onWheel
(
wxMouseEvent
&
aEvent
);
...
...
@@ -80,10 +81,10 @@ public:
}
/// @copydoc VIEW_CONTROLS::GetMousePosition()
virtual
const
VECTOR2D
GetMousePosition
()
const
;
const
VECTOR2D
GetMousePosition
()
const
;
/// @copydoc VIEW_CONTROLS::GetCursorPosition()
virtual
const
VECTOR2D
GetCursorPosition
()
const
;
const
VECTOR2D
GetCursorPosition
()
const
;
/// Event that forces mouse move event in the dispatcher (eg. used in autopanning, when mouse
/// cursor does not move in screen coordinates, but does in world coordinates)
...
...
@@ -91,7 +92,7 @@ public:
private
:
/// Possible states for WX_VIEW_CONTROLS
enum
S
tate
enum
S
TATE
{
IDLE
=
1
,
/// Nothing is happening
DRAG_PANNING
,
/// Panning with mouse button pressed
...
...
@@ -109,7 +110,7 @@ private:
bool
handleAutoPanning
(
const
wxMouseEvent
&
aEvent
);
/// Current state of VIEW_CONTROLS
S
tate
m_state
;
S
TATE
m_state
;
/// Panel that is affected by VIEW_CONTROLS
wxWindow
*
m_parentPanel
;
...
...
pcbnew/router/direction.h
View file @
bc305859
...
...
@@ -82,7 +82,7 @@ public:
*/
DIRECTION_45
(
const
SEG
&
aSeg
)
{
construct
(
aSeg
.
b
-
aSeg
.
a
);
construct
(
aSeg
.
B
-
aSeg
.
A
);
}
/**
...
...
pcbnew/router/pns_line.cpp
View file @
bc305859
...
...
@@ -118,22 +118,22 @@ bool PNS_LINE::MergeObtuseSegments()
if
(
s1
.
Distance
(
ip
)
<=
1
||
s2
.
Distance
(
ip
)
<=
1
)
{
s1opt
=
SEG
(
s1
.
a
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
b
);
s1opt
=
SEG
(
s1
.
A
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
B
);
}
else
{
s1opt
=
SEG
(
s1
.
a
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
b
);
s1opt
=
SEG
(
s1
.
A
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
B
);
}
if
(
DIRECTION_45
(
s1opt
).
IsObtuse
(
DIRECTION_45
(
s2opt
)
)
)
{
SHAPE_LINE_CHAIN
opt_path
;
opt_path
.
Append
(
s1opt
.
a
);
opt_path
.
Append
(
s1opt
.
b
);
opt_path
.
Append
(
s2opt
.
b
);
opt_path
.
Append
(
s1opt
.
A
);
opt_path
.
Append
(
s1opt
.
B
);
opt_path
.
Append
(
s2opt
.
B
);
PNS_LINE
opt_track
(
*
this
,
opt_path
);
...
...
@@ -204,12 +204,10 @@ bool PNS_LINE::MergeSegments()
if
(
n
>
0
)
{
SHAPE_LINE_CHAIN
path_straight
=
DIRECTION_45
().
BuildInitialTrace
(
s1
.
a
,
s2
.
a
,
false
);
SHAPE_LINE_CHAIN
path_diagonal
=
DIRECTION_45
().
BuildInitialTrace
(
s1
.
a
,
s2
.
a
,
true
);
SHAPE_LINE_CHAIN
path_straight
=
DIRECTION_45
().
BuildInitialTrace
(
s1
.
A
,
s2
.
A
,
false
);
SHAPE_LINE_CHAIN
path_diagonal
=
DIRECTION_45
().
BuildInitialTrace
(
s1
.
A
,
s2
.
A
,
true
);
}
if
(
DIRECTION_45
(
s1
)
==
DIRECTION_45
(
s2
)
)
...
...
@@ -219,8 +217,8 @@ bool PNS_LINE::MergeSegments()
// printf("Colinear: np %d step %d n1 %d n2 %d\n", n_segs, step, n, n+step);
SHAPE_LINE_CHAIN
opt_path
;
opt_path
.
Append
(
s1
.
a
);
opt_path
.
Append
(
s2
.
b
);
opt_path
.
Append
(
s1
.
A
);
opt_path
.
Append
(
s2
.
B
);
PNS_LINE
tmp
(
*
this
,
opt_path
);
...
...
@@ -239,22 +237,22 @@ bool PNS_LINE::MergeSegments()
if
(
s1
.
Distance
(
ip
)
<=
1
||
s2
.
Distance
(
ip
)
<=
1
)
{
s1opt
=
SEG
(
s1
.
a
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
b
);
s1opt
=
SEG
(
s1
.
A
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
B
);
}
else
{
s1opt
=
SEG
(
s1
.
a
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
b
);
s1opt
=
SEG
(
s1
.
A
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
B
);
}
if
(
DIRECTION_45
(
s1opt
).
IsObtuse
(
DIRECTION_45
(
s2opt
)
)
)
{
SHAPE_LINE_CHAIN
opt_path
;
opt_path
.
Append
(
s1opt
.
a
);
opt_path
.
Append
(
s1opt
.
b
);
opt_path
.
Append
(
s2opt
.
b
);
opt_path
.
Append
(
s1opt
.
A
);
opt_path
.
Append
(
s1opt
.
B
);
opt_path
.
Append
(
s2opt
.
B
);
PNS_LINE
opt_track
(
*
this
,
opt_path
);
...
...
@@ -319,14 +317,14 @@ void PNS_LINE::NewWalkaround( const SHAPE_LINE_CHAIN& aObstacle,
SHAPE_LINE_CHAIN
&
aPostPath
,
bool
aCw
)
const
{
typedef
SHAPE_LINE_CHAIN
::
I
ntersection
Intersection
;
typedef
SHAPE_LINE_CHAIN
::
I
NTERSECTION
INTERSECTION
;
SHAPE_LINE_CHAIN
l_orig
(
m_line
);
SHAPE_LINE_CHAIN
l_hull
;
vector
<
bool
>
outside
,
on_edge
,
inside
;
SHAPE_LINE_CHAIN
path
;
vector
<
I
ntersection
>
isects
;
vector
<
I
NTERSECTION
>
isects
;
// don't calculate walkaround for empty lines
if
(
m_line
.
PointCount
()
<
2
)
...
...
@@ -345,7 +343,7 @@ void PNS_LINE::NewWalkaround( const SHAPE_LINE_CHAIN& aObstacle,
else
l_hull
=
aObstacle
;
BOOST_FOREACH
(
I
ntersection
isect
,
isects
)
{
BOOST_FOREACH
(
I
NTERSECTION
isect
,
isects
)
{
l_orig
.
Split
(
isect
.
p
);
l_hull
.
Split
(
isect
.
p
);
}
...
...
@@ -379,7 +377,7 @@ void PNS_LINE::NewWalkaround( const SHAPE_LINE_CHAIN& aObstacle,
for
(
int
i
=
l_orig
.
PointCount
()
-
1
;
i
>=
1
;
i
--
)
if
(
inside
[
i
]
&&
outside
[
i
-
1
]
)
{
SHAPE_LINE_CHAIN
::
I
ntersections
ips
;
SHAPE_LINE_CHAIN
::
I
NTERSECTIONS
ips
;
l_hull
.
Intersect
(
SEG
(
l_orig
.
CPoint
(
i
),
l_orig
.
CPoint
(
i
-
1
)
),
ips
);
l_orig
.
Remove
(
i
,
-
1
);
l_orig
.
Append
(
ips
[
0
].
p
);
...
...
@@ -488,55 +486,50 @@ bool PNS_LINE::onEdge( const SHAPE_LINE_CHAIN& obstacle, VECTOR2I p, int& ei,
}
bool
PNS_LINE
::
walkScan
(
const
SHAPE_LINE_CHAIN
&
line
,
const
SHAPE_LINE_CHAIN
&
obstacle
,
bool
reverse
,
VECTOR2I
&
ip
,
int
&
index_o
,
int
&
index_l
,
bool
&
is_vertex
)
const
bool
PNS_LINE
::
walkScan
(
const
SHAPE_LINE_CHAIN
&
aLine
,
const
SHAPE_LINE_CHAIN
&
aObstacle
,
bool
aReverse
,
VECTOR2I
&
aIp
,
int
&
aIndexO
,
int
&
aIndexL
,
bool
&
aIsVertex
)
const
{
int
sc
=
l
ine
.
SegmentCount
();
int
sc
=
aL
ine
.
SegmentCount
();
for
(
int
i
=
0
;
i
<
l
ine
.
SegmentCount
();
i
++
)
for
(
int
i
=
0
;
i
<
aL
ine
.
SegmentCount
();
i
++
)
{
printf
(
"check-seg rev %d %d/%d %d
\n
"
,
r
everse
,
i
,
sc
,
sc
-
1
-
i
);
SEG
tmp
=
line
.
CSegment
(
r
everse
?
sc
-
1
-
i
:
i
);
SEG
s
(
tmp
.
a
,
tmp
.
b
);
printf
(
"check-seg rev %d %d/%d %d
\n
"
,
aR
everse
,
i
,
sc
,
sc
-
1
-
i
);
SEG
tmp
=
aLine
.
CSegment
(
aR
everse
?
sc
-
1
-
i
:
i
);
SEG
s
(
tmp
.
A
,
tmp
.
B
);
if
(
r
everse
)
if
(
aR
everse
)
{
s
.
a
=
tmp
.
b
;
s
.
b
=
tmp
.
a
;
s
.
A
=
tmp
.
B
;
s
.
B
=
tmp
.
A
;
}
if
(
onEdge
(
obstacle
,
s
.
a
,
index_o
,
is_v
ertex
)
)
if
(
onEdge
(
aObstacle
,
s
.
A
,
aIndexO
,
aIsV
ertex
)
)
{
index_l
=
(
r
everse
?
sc
-
1
-
i
:
i
);
ip
=
s
.
a
;
printf
(
"vertex %d on-%s %d
\n
"
,
index_l
,
is_vertex
?
"vertex"
:
"edge"
,
index_o
);
aIndexL
=
(
aR
everse
?
sc
-
1
-
i
:
i
);
aIp
=
s
.
A
;
printf
(
"vertex %d on-%s %d
\n
"
,
aIndexL
,
aIsVertex
?
"vertex"
:
"edge"
,
aIndexO
);
return
true
;
}
if
(
onEdge
(
obstacle
,
s
.
b
,
index_o
,
is_v
ertex
)
)
if
(
onEdge
(
aObstacle
,
s
.
B
,
aIndexO
,
aIsV
ertex
)
)
{
index_l
=
(
r
everse
?
sc
-
1
-
i
-
1
:
i
+
1
);
ip
=
s
.
b
;
printf
(
"vertex %d on-%s %d
\n
"
,
index_l
,
is_vertex
?
"vertex"
:
"edge"
,
index_o
);
aIndexL
=
(
aR
everse
?
sc
-
1
-
i
-
1
:
i
+
1
);
aIp
=
s
.
B
;
printf
(
"vertex %d on-%s %d
\n
"
,
aIndexL
,
aIsVertex
?
"vertex"
:
"edge"
,
aIndexO
);
return
true
;
}
SHAPE_LINE_CHAIN
::
I
ntersections
ips
;
int
n_is
=
o
bstacle
.
Intersect
(
s
,
ips
);
SHAPE_LINE_CHAIN
::
I
NTERSECTIONS
ips
;
int
n_is
=
aO
bstacle
.
Intersect
(
s
,
ips
);
if
(
n_is
>
0
)
{
index_o
=
ips
[
0
].
our
.
Index
();
index_l
=
r
everse
?
sc
-
1
-
i
:
i
;
printf
(
"segment-%d intersects edge-%d
\n
"
,
index_l
,
index_o
);
i
p
=
ips
[
0
].
p
;
aIndexO
=
ips
[
0
].
our
.
Index
();
aIndexL
=
aR
everse
?
sc
-
1
-
i
:
i
;
printf
(
"segment-%d intersects edge-%d
\n
"
,
aIndexL
,
aIndexO
);
aI
p
=
ips
[
0
].
p
;
return
true
;
}
}
...
...
@@ -545,11 +538,8 @@ bool PNS_LINE::walkScan( const SHAPE_LINE_CHAIN& line,
}
bool
PNS_LINE
::
Walkaround
(
SHAPE_LINE_CHAIN
obstacle
,
SHAPE_LINE_CHAIN
&
pre
,
SHAPE_LINE_CHAIN
&
walk
,
SHAPE_LINE_CHAIN
&
post
,
bool
cw
)
const
bool
PNS_LINE
::
Walkaround
(
SHAPE_LINE_CHAIN
aObstacle
,
SHAPE_LINE_CHAIN
&
aPre
,
SHAPE_LINE_CHAIN
&
aWalk
,
SHAPE_LINE_CHAIN
&
aPost
,
bool
aCw
)
const
{
const
SHAPE_LINE_CHAIN
&
line
=
GetCLine
();
VECTOR2I
ip_start
;
...
...
@@ -562,60 +552,55 @@ bool PNS_LINE::Walkaround( SHAPE_LINE_CHAIN obstacle,
if
(
line
.
SegmentCount
()
<
1
)
return
false
;
if
(
o
bstacle
.
PointInside
(
line
.
CPoint
(
0
)
)
||
o
bstacle
.
PointInside
(
line
.
CPoint
(
-
1
)
)
)
if
(
aO
bstacle
.
PointInside
(
line
.
CPoint
(
0
)
)
||
aO
bstacle
.
PointInside
(
line
.
CPoint
(
-
1
)
)
)
return
false
;
// printf("forward:\n");
bool
found
=
walkScan
(
line
,
obstacle
,
false
,
ip_start
,
index_o_start
,
index_l_start
,
is_vertex_start
);
bool
found
=
walkScan
(
line
,
aObstacle
,
false
,
ip_start
,
index_o_start
,
index_l_start
,
is_vertex_start
);
// printf("reverse:\n");
found
|=
walkScan
(
line
,
o
bstacle
,
true
,
ip_end
,
index_o_end
,
index_l_end
,
is_vertex_end
);
found
|=
walkScan
(
line
,
aO
bstacle
,
true
,
ip_end
,
index_o_end
,
index_l_end
,
is_vertex_end
);
if
(
!
found
||
ip_start
==
ip_end
)
{
p
re
=
line
;
aP
re
=
line
;
return
true
;
}
p
re
=
line
.
Slice
(
0
,
index_l_start
);
p
re
.
Append
(
ip_start
);
w
alk
.
Clear
();
w
alk
.
Append
(
ip_start
);
aP
re
=
line
.
Slice
(
0
,
index_l_start
);
aP
re
.
Append
(
ip_start
);
aW
alk
.
Clear
();
aW
alk
.
Append
(
ip_start
);
if
(
c
w
)
if
(
aC
w
)
{
int
is
=
(
index_o_start
+
1
)
%
o
bstacle
.
PointCount
();
int
ie
=
(
is_vertex_end
?
index_o_end
:
index_o_end
+
1
)
%
o
bstacle
.
PointCount
();
int
is
=
(
index_o_start
+
1
)
%
aO
bstacle
.
PointCount
();
int
ie
=
(
is_vertex_end
?
index_o_end
:
index_o_end
+
1
)
%
aO
bstacle
.
PointCount
();
while
(
1
)
{
printf
(
"is %d
\n
"
,
is
);
walk
.
Append
(
o
bstacle
.
CPoint
(
is
)
);
aWalk
.
Append
(
aO
bstacle
.
CPoint
(
is
)
);
if
(
is
==
ie
)
break
;
is
++
;
if
(
is
==
o
bstacle
.
PointCount
()
)
if
(
is
==
aO
bstacle
.
PointCount
()
)
is
=
0
;
}
}
else
{
int
is
=
index_o_start
;
int
ie
=
(
is_vertex_end
?
index_o_end
:
index_o_end
)
%
o
bstacle
.
PointCount
();
int
ie
=
(
is_vertex_end
?
index_o_end
:
index_o_end
)
%
aO
bstacle
.
PointCount
();
while
(
1
)
{
printf
(
"is %d
\n
"
,
is
);
walk
.
Append
(
o
bstacle
.
CPoint
(
is
)
);
aWalk
.
Append
(
aO
bstacle
.
CPoint
(
is
)
);
if
(
is
==
ie
)
break
;
...
...
@@ -623,15 +608,15 @@ bool PNS_LINE::Walkaround( SHAPE_LINE_CHAIN obstacle,
is
--
;
if
(
is
<
0
)
is
=
o
bstacle
.
PointCount
()
-
1
;
is
=
aO
bstacle
.
PointCount
()
-
1
;
}
}
w
alk
.
Append
(
ip_end
);
aW
alk
.
Append
(
ip_end
);
p
ost
.
Clear
();
p
ost
.
Append
(
ip_end
);
p
ost
.
Append
(
line
.
Slice
(
is_vertex_end
?
index_l_end
:
index_l_end
+
1
,
-
1
)
);
aP
ost
.
Clear
();
aP
ost
.
Append
(
ip_end
);
aP
ost
.
Append
(
line
.
Slice
(
is_vertex_end
?
index_l_end
:
index_l_end
+
1
,
-
1
)
);
// for(int i = (index_o_start + 1) % obstacle.PointCount();
// i != (index_o_end + 1) % obstacle.PointCount(); i=(i+1) % obstacle.PointCount())
...
...
@@ -714,8 +699,8 @@ bool PNS_LINE::Is45Degree()
const
SEG
&
s
=
m_line
.
CSegment
(
i
);
double
angle
=
180.0
/
M_PI
*
atan2
(
(
double
)
s
.
b
.
y
-
(
double
)
s
.
a
.
y
,
(
double
)
s
.
b
.
x
-
(
double
)
s
.
a
.
x
);
atan2
(
(
double
)
s
.
B
.
y
-
(
double
)
s
.
A
.
y
,
(
double
)
s
.
B
.
x
-
(
double
)
s
.
A
.
x
);
if
(
angle
<
0
)
angle
+=
360.0
;
...
...
pcbnew/router/pns_line_placer.cpp
View file @
bc305859
...
...
@@ -100,7 +100,7 @@ void PNS_LINE_PLACER::SetInitialDirection( const DIRECTION_45& aDirection )
bool
PNS_LINE_PLACER
::
handleSelfIntersections
()
{
SHAPE_LINE_CHAIN
::
I
ntersections
ips
;
SHAPE_LINE_CHAIN
::
I
NTERSECTIONS
ips
;
SHAPE_LINE_CHAIN
&
head
=
m_head
.
GetLine
();
SHAPE_LINE_CHAIN
&
tail
=
m_tail
.
GetLine
();
...
...
@@ -119,7 +119,7 @@ bool PNS_LINE_PLACER::handleSelfIntersections()
// if there is more than one intersection, find the one that is
// closest to the beginning of the tail.
BOOST_FOREACH
(
SHAPE_LINE_CHAIN
::
I
ntersection
i
,
ips
)
BOOST_FOREACH
(
SHAPE_LINE_CHAIN
::
I
NTERSECTION
i
,
ips
)
{
if
(
i
.
our
.
Index
()
<
n
)
{
...
...
@@ -147,7 +147,7 @@ bool PNS_LINE_PLACER::handleSelfIntersections()
// Clip till the last tail segment before intersection.
// Set the direction to the one of this segment.
const
SEG
last
=
tail
.
CSegment
(
n
-
1
);
m_p_start
=
last
.
a
;
m_p_start
=
last
.
A
;
m_direction
=
DIRECTION_45
(
last
);
tail
.
Remove
(
n
,
-
1
);
return
true
;
...
...
@@ -190,7 +190,7 @@ bool PNS_LINE_PLACER::handlePullback()
{
const
SEG
last
=
tail
.
CSegment
(
-
1
);
m_direction
=
DIRECTION_45
(
last
);
m_p_start
=
last
.
a
;
m_p_start
=
last
.
A
;
TRACE
(
0
,
"Placer: pullback triggered [%d] [%s %s]"
,
n
%
last_tail
.
Format
().
c_str
()
%
first_head
.
Format
().
c_str
()
);
...
...
@@ -240,7 +240,7 @@ bool PNS_LINE_PLACER::reduceTail( const VECTOR2I& aEnd )
// calculate a replacement route and check if it matches
// the direction of the segment to be replaced
SHAPE_LINE_CHAIN
replacement
=
dir
.
BuildInitialTrace
(
s
.
a
,
aEnd
);
SHAPE_LINE_CHAIN
replacement
=
dir
.
BuildInitialTrace
(
s
.
A
,
aEnd
);
PNS_LINE
tmp
(
m_tail
,
replacement
);
...
...
@@ -249,7 +249,7 @@ bool PNS_LINE_PLACER::reduceTail( const VECTOR2I& aEnd )
if
(
DIRECTION_45
(
replacement
.
Segment
(
0
)
)
==
dir
)
{
new_start
=
s
.
a
;
new_start
=
s
.
A
;
new_direction
=
dir
;
reduce_index
=
i
;
}
...
...
@@ -326,18 +326,18 @@ bool PNS_LINE_PLACER::mergeHead()
}
if
(
!
n_tail
)
tail
.
Append
(
head
.
CSegment
(
0
).
a
);
tail
.
Append
(
head
.
CSegment
(
0
).
A
);
for
(
int
i
=
0
;
i
<
n_head
-
2
;
i
++
)
{
tail
.
Append
(
head
.
CSegment
(
i
).
b
);
tail
.
Append
(
head
.
CSegment
(
i
).
B
);
}
tail
.
Simplify
();
SEG
last
=
tail
.
CSegment
(
-
1
);
m_p_start
=
last
.
b
;
m_p_start
=
last
.
B
;
m_direction
=
DIRECTION_45
(
last
).
Right
();
head
.
Remove
(
0
,
n_head
-
2
);
...
...
pcbnew/router/pns_node.cpp
View file @
bc305859
...
...
@@ -284,7 +284,7 @@ PNS_NODE::OptObstacle PNS_NODE::NearestObstacle( const PNS_LINE* aItem, int aKin
VECTOR2I
ip_first
,
ip_last
;
int
dist_max
=
INT_MIN
;
vector
<
SHAPE_LINE_CHAIN
::
I
ntersection
>
isect_list
;
vector
<
SHAPE_LINE_CHAIN
::
I
NTERSECTION
>
isect_list
;
int
clearance
=
GetClearance
(
obs
.
item
,
&
aLine
);
...
...
@@ -298,7 +298,7 @@ PNS_NODE::OptObstacle PNS_NODE::NearestObstacle( const PNS_LINE* aItem, int aKin
viaHull
.
Intersect
(
hull
,
isect_list
);
BOOST_FOREACH
(
SHAPE_LINE_CHAIN
::
I
ntersection
isect
,
isect_list
)
BOOST_FOREACH
(
SHAPE_LINE_CHAIN
::
I
NTERSECTION
isect
,
isect_list
)
{
int
dist
=
aLine
.
GetCLine
().
Length
()
+
(
isect
.
p
-
aLine
.
GetVia
().
GetPos
()
).
EuclideanNorm
();
...
...
@@ -324,7 +324,7 @@ PNS_NODE::OptObstacle PNS_NODE::NearestObstacle( const PNS_LINE* aItem, int aKin
hull
.
Intersect
(
aLine
.
GetCLine
(),
isect_list
);
BOOST_FOREACH
(
SHAPE_LINE_CHAIN
::
I
ntersection
isect
,
isect_list
)
BOOST_FOREACH
(
SHAPE_LINE_CHAIN
::
I
NTERSECTION
isect
,
isect_list
)
{
int
dist
=
aLine
.
GetCLine
().
PathLength
(
isect
.
p
);
...
...
@@ -473,14 +473,14 @@ void PNS_NODE::addLine( PNS_LINE* aLine )
{
SEG
s
=
l
.
CSegment
(
i
);
if
(
s
.
a
!=
s
.
b
)
if
(
s
.
A
!=
s
.
B
)
{
PNS_SEGMENT
*
pseg
=
new
PNS_SEGMENT
(
*
aLine
,
s
);
pseg
->
SetOwner
(
this
);
linkJoint
(
s
.
a
,
pseg
->
GetLayers
(),
aLine
->
GetNet
(),
pseg
);
linkJoint
(
s
.
b
,
pseg
->
GetLayers
(),
aLine
->
GetNet
(),
pseg
);
linkJoint
(
s
.
A
,
pseg
->
GetLayers
(),
aLine
->
GetNet
(),
pseg
);
linkJoint
(
s
.
B
,
pseg
->
GetLayers
(),
aLine
->
GetNet
(),
pseg
);
aLine
->
LinkSegment
(
pseg
);
...
...
@@ -492,7 +492,7 @@ void PNS_NODE::addLine( PNS_LINE* aLine )
void
PNS_NODE
::
addSegment
(
PNS_SEGMENT
*
aSeg
)
{
if
(
aSeg
->
GetSeg
().
a
==
aSeg
->
GetSeg
().
b
)
if
(
aSeg
->
GetSeg
().
A
==
aSeg
->
GetSeg
().
B
)
{
TRACEn
(
0
,
"attempting to add a segment with same end coordinates, ignoring."
)
return
;
...
...
@@ -500,8 +500,8 @@ void PNS_NODE::addSegment( PNS_SEGMENT* aSeg )
aSeg
->
SetOwner
(
this
);
linkJoint
(
aSeg
->
GetSeg
().
a
,
aSeg
->
GetLayers
(),
aSeg
->
GetNet
(),
aSeg
);
linkJoint
(
aSeg
->
GetSeg
().
b
,
aSeg
->
GetLayers
(),
aSeg
->
GetNet
(),
aSeg
);
linkJoint
(
aSeg
->
GetSeg
().
A
,
aSeg
->
GetLayers
(),
aSeg
->
GetNet
(),
aSeg
);
linkJoint
(
aSeg
->
GetSeg
().
B
,
aSeg
->
GetLayers
(),
aSeg
->
GetNet
(),
aSeg
);
m_index
->
Add
(
aSeg
);
}
...
...
@@ -555,8 +555,8 @@ void PNS_NODE::doRemove( PNS_ITEM* aItem )
void
PNS_NODE
::
removeSegment
(
PNS_SEGMENT
*
aSeg
)
{
unlinkJoint
(
aSeg
->
GetSeg
().
a
,
aSeg
->
GetLayers
(),
aSeg
->
GetNet
(),
aSeg
);
unlinkJoint
(
aSeg
->
GetSeg
().
b
,
aSeg
->
GetLayers
(),
aSeg
->
GetNet
(),
aSeg
);
unlinkJoint
(
aSeg
->
GetSeg
().
A
,
aSeg
->
GetLayers
(),
aSeg
->
GetNet
(),
aSeg
);
unlinkJoint
(
aSeg
->
GetSeg
().
B
,
aSeg
->
GetLayers
(),
aSeg
->
GetNet
(),
aSeg
);
doRemove
(
aSeg
);
}
...
...
@@ -629,7 +629,7 @@ void PNS_NODE::followLine( PNS_SEGMENT* current, bool scanDirection, int& pos,
for
(
;
;
)
{
const
VECTOR2I
p
=
(
scanDirection
^
prevReversed
)
?
current
->
GetSeg
().
b
:
current
->
GetSeg
().
a
;
(
scanDirection
^
prevReversed
)
?
current
->
GetSeg
().
B
:
current
->
GetSeg
().
A
;
const
OptJoint
jt
=
FindJoint
(
p
,
current
->
GetLayer
(),
current
->
GetNet
()
);
assert
(
jt
);
...
...
@@ -645,7 +645,7 @@ void PNS_NODE::followLine( PNS_SEGMENT* current, bool scanDirection, int& pos,
current
=
jt
->
NextSegment
(
current
);
prevReversed
=
(
jt
->
GetPos
()
==
(
scanDirection
?
current
->
GetSeg
().
b
:
current
->
GetSeg
().
a
)
);
(
jt
->
GetPos
()
==
(
scanDirection
?
current
->
GetSeg
().
B
:
current
->
GetSeg
().
A
)
);
}
}
...
...
@@ -870,8 +870,8 @@ void PNS_NODE::Dump( bool aLong )
case PNS_ITEM::SEGMENT:
{
const PNS_SEGMENT* seg = static_cast<const PNS_SEGMENT*>(item);
printf( " -> seg %s %s\n", seg->GetSeg().
a
.Format().c_str(),
seg->GetSeg().
b
.Format().c_str() );
printf( " -> seg %s %s\n", seg->GetSeg().
A
.Format().c_str(),
seg->GetSeg().
B
.Format().c_str() );
break;
}
...
...
@@ -897,10 +897,10 @@ void PNS_NODE::Dump( bool aLong )
for( vector<PNS_SEGMENT*>::iterator j = seg_refs->begin(); j != seg_refs->end(); ++j )
{
printf( "%s ", (*j)->GetSeg().
a
.Format().c_str() );
printf( "%s ", (*j)->GetSeg().
A
.Format().c_str() );
if( j + 1 == seg_refs->end() )
printf( "%s\n", (*j)->GetSeg().
b
.Format().c_str() );
printf( "%s\n", (*j)->GetSeg().
B
.Format().c_str() );
all_segs.erase( *j );
}
...
...
pcbnew/router/pns_optimizer.cpp
View file @
bc305859
...
...
@@ -311,22 +311,22 @@ bool PNS_OPTIMIZER::mergeObtuse( PNS_LINE* aLine )
if
(
s1
.
Distance
(
ip
)
<=
1
||
s2
.
Distance
(
ip
)
<=
1
)
{
s1opt
=
SEG
(
s1
.
a
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
b
);
s1opt
=
SEG
(
s1
.
A
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
B
);
}
else
{
s1opt
=
SEG
(
s1
.
a
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
b
);
s1opt
=
SEG
(
s1
.
A
,
ip
);
s2opt
=
SEG
(
ip
,
s2
.
B
);
}
if
(
DIRECTION_45
(
s1opt
).
IsObtuse
(
DIRECTION_45
(
s2opt
)
)
)
{
SHAPE_LINE_CHAIN
opt_path
;
opt_path
.
Append
(
s1opt
.
a
);
opt_path
.
Append
(
s1opt
.
b
);
opt_path
.
Append
(
s2opt
.
b
);
opt_path
.
Append
(
s1opt
.
A
);
opt_path
.
Append
(
s1opt
.
B
);
opt_path
.
Append
(
s2opt
.
B
);
PNS_LINE
opt_track
(
*
aLine
,
opt_path
);
...
...
@@ -446,7 +446,7 @@ bool PNS_OPTIMIZER::mergeStep( PNS_LINE* aLine, SHAPE_LINE_CHAIN& aCurrentPath,
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
bool
postureMatch
=
true
;
SHAPE_LINE_CHAIN
bypass
=
DIRECTION_45
().
BuildInitialTrace
(
s1
.
a
,
s2
.
b
,
i
);
SHAPE_LINE_CHAIN
bypass
=
DIRECTION_45
().
BuildInitialTrace
(
s1
.
A
,
s2
.
B
,
i
);
cost
[
i
]
=
INT_MAX
;
...
...
pcbnew/router/pns_router.cpp
View file @
bc305859
...
...
@@ -392,10 +392,10 @@ const VECTOR2I PNS_ROUTER::SnapToItem( PNS_ITEM* item, VECTOR2I aP, bool& aSplit
aSplitsSegment
=
false
;
if
(
(
aP
-
s
.
a
).
EuclideanNorm
()
<
w
/
2
)
anchor
=
s
.
a
;
else
if
(
(
aP
-
s
.
b
).
EuclideanNorm
()
<
w
/
2
)
anchor
=
s
.
b
;
if
(
(
aP
-
s
.
A
).
EuclideanNorm
()
<
w
/
2
)
anchor
=
s
.
A
;
else
if
(
(
aP
-
s
.
B
).
EuclideanNorm
()
<
w
/
2
)
anchor
=
s
.
B
;
else
{
anchor
=
s
.
NearestPoint
(
aP
);
...
...
@@ -559,8 +559,8 @@ void PNS_ROUTER::splitAdjacentSegments( PNS_NODE* aNode, PNS_ITEM* aSeg, const V
s_new
[
0
]
=
s_old
->
Clone
();
s_new
[
1
]
=
s_old
->
Clone
();
s_new
[
0
]
->
SetEnds
(
s_old
->
GetSeg
().
a
,
aP
);
s_new
[
1
]
->
SetEnds
(
aP
,
s_old
->
GetSeg
().
b
);
s_new
[
0
]
->
SetEnds
(
s_old
->
GetSeg
().
A
,
aP
);
s_new
[
1
]
->
SetEnds
(
aP
,
s_old
->
GetSeg
().
B
);
aNode
->
Remove
(
s_old
);
aNode
->
Add
(
s_new
[
0
]
);
...
...
@@ -598,8 +598,8 @@ void PNS_ROUTER::commitRouting( PNS_NODE* aNode )
TRACK
*
track
=
new
TRACK
(
m_board
);
const
SEG
&
s
=
seg
->
GetSeg
();
track
->
SetStart
(
wxPoint
(
s
.
a
.
x
,
s
.
a
.
y
)
);
track
->
SetEnd
(
wxPoint
(
s
.
b
.
x
,
s
.
b
.
y
)
);
track
->
SetStart
(
wxPoint
(
s
.
A
.
x
,
s
.
A
.
y
)
);
track
->
SetEnd
(
wxPoint
(
s
.
B
.
x
,
s
.
B
.
y
)
);
track
->
SetWidth
(
seg
->
GetWidth
()
);
track
->
SetLayer
(
seg
->
GetLayers
().
Start
()
);
track
->
SetNet
(
seg
->
GetNet
()
);
...
...
pcbnew/router/pns_segment.h
View file @
bc305859
...
...
@@ -44,8 +44,8 @@ public:
{
m_net
=
aNet
;
m_shape
.
Clear
();
m_shape
.
Append
(
aSeg
.
a
);
m_shape
.
Append
(
aSeg
.
b
);
m_shape
.
Append
(
aSeg
.
A
);
m_shape
.
Append
(
aSeg
.
B
);
};
PNS_SEGMENT
(
const
PNS_LINE
&
aParentLine
,
const
SEG
&
aSeg
)
:
...
...
@@ -55,8 +55,8 @@ public:
m_layers
=
aParentLine
.
GetLayers
();
m_width
=
aParentLine
.
GetWidth
();
m_shape
.
Clear
();
m_shape
.
Append
(
aSeg
.
a
);
m_shape
.
Append
(
aSeg
.
b
);
m_shape
.
Append
(
aSeg
.
A
);
m_shape
.
Append
(
aSeg
.
B
);
};
...
...
pcbnew/router/pns_shove.cpp
View file @
bc305859
...
...
@@ -128,8 +128,8 @@ bool PNS_SHOVE::tryShove( PNS_NODE* aNode, PNS_LINE* aHead, PNS_LINE* aObstacle,
if
(
aNode
->
CheckColliding
(
&
hs
,
aObstacle
)
)
{
VECTOR2I
v1
=
hs
.
GetSeg
().
b
-
hs
.
GetSeg
().
a
;
VECTOR2I
v2
=
aObstacleSeg
.
GetSeg
().
b
-
aObstacleSeg
.
GetSeg
().
a
;
VECTOR2I
v1
=
hs
.
GetSeg
().
B
-
hs
.
GetSeg
().
A
;
VECTOR2I
v2
=
aObstacleSeg
.
GetSeg
().
B
-
aObstacleSeg
.
GetSeg
().
A
;
VECTOR2I
::
extended_type
det
=
v1
.
Cross
(
v2
);
...
...
pcbnew/router/pns_walkaround.cpp
View file @
bc305859
...
...
@@ -196,8 +196,8 @@ PNS_WALKAROUND::WalkaroundStatus PNS_WALKAROUND::Route( const PNS_LINE& aInitial
const
SEG
s
=
l
.
Segment
(
i
);
VECTOR2I
nearest
=
s
.
NearestPoint
(
m_cursorPos
);
VECTOR2I
::
extended_type
dist_a
=
(
s
.
a
-
m_cursorPos
).
SquaredEuclideanNorm
();
VECTOR2I
::
extended_type
dist_b
=
(
s
.
b
-
m_cursorPos
).
SquaredEuclideanNorm
();
VECTOR2I
::
extended_type
dist_a
=
(
s
.
A
-
m_cursorPos
).
SquaredEuclideanNorm
();
VECTOR2I
::
extended_type
dist_b
=
(
s
.
B
-
m_cursorPos
).
SquaredEuclideanNorm
();
VECTOR2I
::
extended_type
dist_n
=
(
nearest
-
m_cursorPos
).
SquaredEuclideanNorm
();
if
(
dist_n
<=
dist_a
&&
dist_n
<
dist_b
)
...
...
pcbnew/router/router_preview_item.cpp
View file @
bc305859
...
...
@@ -127,10 +127,10 @@ void ROUTER_PREVIEW_ITEM::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
aGal
->
SetIsFill
(
false
);
for
(
int
s
=
0
;
s
<
m_line
.
SegmentCount
();
s
++
)
aGal
->
DrawLine
(
m_line
.
CSegment
(
s
).
a
,
m_line
.
CSegment
(
s
).
b
);
aGal
->
DrawLine
(
m_line
.
CSegment
(
s
).
A
,
m_line
.
CSegment
(
s
).
B
);
if
(
m_line
.
IsClosed
()
)
aGal
->
DrawLine
(
m_line
.
CSegment
(
-
1
).
b
,
m_line
.
CSegment
(
0
).
a
);
aGal
->
DrawLine
(
m_line
.
CSegment
(
-
1
).
B
,
m_line
.
CSegment
(
0
).
A
);
break
;
case
PR_VIA
:
...
...
pcbnew/router/router_tool.cpp
View file @
bc305859
...
...
@@ -87,7 +87,7 @@ void ROUTER_TOOL::Reset()
if
(
getView
()
)
m_router
->
SetView
(
getView
()
);
Go
(
&
ROUTER_TOOL
::
Main
,
TOOL_EVENT
(
TC_C
ommand
,
TA_Action
,
GetName
()
)
);
Go
(
&
ROUTER_TOOL
::
Main
,
TOOL_EVENT
(
TC_C
OMMAND
,
TA_ACTION
,
GetName
()
)
);
}
...
...
@@ -323,7 +323,7 @@ void ROUTER_TOOL::startRouting()
updateEndItem
(
*
evt
);
m_router
->
Move
(
m_endSnapPoint
,
m_endItem
);
}
else
if
(
evt
->
IsClick
(
MB_L
eft
)
)
else
if
(
evt
->
IsClick
(
MB_L
EFT
)
)
{
updateEndItem
(
*
evt
);
...
...
@@ -396,7 +396,7 @@ int ROUTER_TOOL::Main( TOOL_EVENT& aEvent )
break
;
// Finish
else
if
(
evt
->
IsMotion
()
)
updateStartItem
(
*
evt
);
else
if
(
evt
->
IsClick
(
MB_L
eft
)
)
else
if
(
evt
->
IsClick
(
MB_L
EFT
)
)
{
updateStartItem
(
*
evt
);
startRouting
();
...
...
pcbnew/tools/item_state.h
View file @
bc305859
...
...
@@ -182,7 +182,7 @@ public:
* them properly.
* @return Flag required to refresh items.
*/
KIGFX
::
VIEW_ITEM
::
V
iewUpdateFlags
GetUpdateFlag
()
const
KIGFX
::
VIEW_ITEM
::
V
IEW_UPDATE_FLAGS
GetUpdateFlag
()
const
{
if
(
m_flips
%
2
==
1
)
// If number of flips is odd, then we need to change layers
return
KIGFX
::
VIEW_ITEM
::
LAYERS
;
...
...
pcbnew/tools/move_tool.cpp
View file @
bc305859
...
...
@@ -102,7 +102,7 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
}
// Dispatch TOOL_ACTIONs
else
if
(
evt
->
Category
()
==
TC_C
ommand
)
else
if
(
evt
->
Category
()
==
TC_C
OMMAND
)
{
VECTOR2D
cursorPos
=
getView
()
->
ToWorld
(
getViewControls
()
->
GetCursorPosition
()
);
...
...
@@ -118,7 +118,7 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
}
}
else
if
(
evt
->
IsMotion
()
||
evt
->
IsDrag
(
MB_L
eft
)
)
else
if
(
evt
->
IsMotion
()
||
evt
->
IsDrag
(
MB_L
EFT
)
)
{
if
(
dragging
)
{
...
...
@@ -143,7 +143,7 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
selection
.
group
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
dragPosition
=
evt
->
Position
();
}
else
if
(
evt
->
IsMouseUp
(
MB_L
eft
)
||
evt
->
IsClick
(
MB_Left
)
)
else
if
(
evt
->
IsMouseUp
(
MB_L
EFT
)
||
evt
->
IsClick
(
MB_LEFT
)
)
break
;
// Finish
}
...
...
pcbnew/tools/selection_tool.cpp
View file @
bc305859
...
...
@@ -92,7 +92,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
{
// Should selected items be added to the current selection or
// become the new selection (discarding previously selected items)
m_additive
=
evt
->
Modifier
(
MD_
ModShift
);
m_additive
=
evt
->
Modifier
(
MD_
SHIFT
);
if
(
evt
->
IsCancel
()
)
{
...
...
@@ -103,11 +103,11 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
}
// single click? Select single object
if
(
evt
->
IsClick
(
MB_L
eft
)
)
if
(
evt
->
IsClick
(
MB_L
EFT
)
)
selectSingle
(
evt
->
Position
()
);
// drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
if
(
evt
->
IsDrag
(
MB_L
eft
)
)
if
(
evt
->
IsDrag
(
MB_L
EFT
)
)
{
if
(
m_selection
.
Empty
()
||
m_additive
)
{
...
...
@@ -299,7 +299,7 @@ bool SELECTION_TOOL::selectMultiple()
break
;
}
if
(
evt
->
IsDrag
(
MB_L
eft
)
)
if
(
evt
->
IsDrag
(
MB_L
EFT
)
)
{
if
(
!
m_additive
)
clearSelection
();
...
...
@@ -311,17 +311,17 @@ bool SELECTION_TOOL::selectMultiple()
m_selArea
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
}
if
(
evt
->
IsMouseUp
(
MB_L
eft
)
)
if
(
evt
->
IsMouseUp
(
MB_L
EFT
)
)
{
// End drawing the selection box
m_selArea
->
ViewSetVisible
(
false
);
// Mark items within the selection box as selected
std
::
vector
<
VIEW
::
L
ayerItemPair
>
selectedItems
;
std
::
vector
<
VIEW
::
L
AYER_ITEM_PAIR
>
selectedItems
;
BOX2I
selectionBox
=
m_selArea
->
ViewBBox
();
view
->
Query
(
selectionBox
,
selectedItems
);
// Get the list of selected items
std
::
vector
<
VIEW
::
L
ayerItemPair
>::
iterator
it
,
it_end
;
std
::
vector
<
VIEW
::
L
AYER_ITEM_PAIR
>::
iterator
it
,
it_end
;
for
(
it
=
selectedItems
.
begin
(),
it_end
=
selectedItems
.
end
();
it
!=
it_end
;
++
it
)
{
...
...
@@ -369,7 +369,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
if
(
evt
->
Action
()
==
TA_C
ontextMenuUpdate
)
if
(
evt
->
Action
()
==
TA_C
ONTEXT_MENU_UPDATE
)
{
if
(
current
)
current
->
ClearBrightened
();
...
...
@@ -385,7 +385,7 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
else
current
=
NULL
;
}
else
if
(
evt
->
Action
()
==
TA_C
ontextMenuChoice
)
else
if
(
evt
->
Action
()
==
TA_C
ONTEXT_MENU_CHOICE
)
{
optional
<
int
>
id
=
evt
->
GetCommandId
();
...
...
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