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
1206177c
Commit
1206177c
authored
Oct 23, 2010
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gerbview: minor enhancement. Boost::Polygon: commit forgotten file
parent
bd022c23
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
321 additions
and
44 deletions
+321
-44
gr_basic.cpp
common/gr_basic.cpp
+6
-2
CMakeLists.txt
gerbview/CMakeLists.txt
+2
-2
class_aperture_macro.cpp
gerbview/class_aperture_macro.cpp
+156
-33
class_aperture_macro.h
gerbview/class_aperture_macro.h
+26
-1
dcode.cpp
gerbview/dcode.cpp
+41
-0
dcode.h
gerbview/dcode.h
+12
-0
draw_gerber_screen.cpp
gerbview/draw_gerber_screen.cpp
+11
-6
polygon_sort_adaptor.hpp
include/boost/polygon/detail/polygon_sort_adaptor.hpp
+67
-0
No files found.
common/gr_basic.cpp
View file @
1206177c
...
@@ -56,7 +56,7 @@ int g_DrawBgColor = WHITE;
...
@@ -56,7 +56,7 @@ int g_DrawBgColor = WHITE;
#define USE_CLIP_FILLED_POLYGONS
#define USE_CLIP_FILLED_POLYGONS
#ifdef USE_CLIP_FILLED_POLYGONS
#ifdef USE_CLIP_FILLED_POLYGONS
void
ClipAndDrawFilledPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
wxPoint
Points
[],
int
n
);
static
void
ClipAndDrawFilledPoly
(
EDA_Rect
*
ClipBox
,
wxDC
*
DC
,
wxPoint
Points
[],
int
n
);
#endif
#endif
/* These functions are used by corresponding functions
/* These functions are used by corresponding functions
...
@@ -1281,7 +1281,11 @@ static void GRSClosedPoly( EDA_Rect* ClipBox,
...
@@ -1281,7 +1281,11 @@ static void GRSClosedPoly( EDA_Rect* ClipBox,
{
{
GRSMoveTo
(
aPoints
[
aPointCount
-
1
].
x
,
aPoints
[
aPointCount
-
1
].
y
);
GRSMoveTo
(
aPoints
[
aPointCount
-
1
].
x
,
aPoints
[
aPointCount
-
1
].
y
);
GRSetBrush
(
DC
,
BgColor
,
FILLED
);
GRSetBrush
(
DC
,
BgColor
,
FILLED
);
DC
->
DrawPolygon
(
aPointCount
,
aPoints
,
0
,
0
,
wxODDEVEN_RULE
);
#ifdef USE_CLIP_FILLED_POLYGONS
ClipAndDrawFilledPoly
(
ClipBox
,
DC
,
aPoints
,
aPointCount
);
#else
DC
->
DrawPolygon
(
aPointCount
,
aPoints
);
// does not work very well under linux
#endif
}
}
else
else
{
{
...
...
gerbview/CMakeLists.txt
View file @
1206177c
...
@@ -26,6 +26,7 @@ set(GERBVIEW_SRCS
...
@@ -26,6 +26,7 @@ set(GERBVIEW_SRCS
dialog_print_using_printer.cpp
dialog_print_using_printer.cpp
dialog_print_using_printer_base.cpp
dialog_print_using_printer_base.cpp
dummy_functions.cpp
dummy_functions.cpp
draw_gerber_screen.cpp
edit.cpp
edit.cpp
export_to_pcbnew.cpp
export_to_pcbnew.cpp
files.cpp
files.cpp
...
@@ -46,8 +47,7 @@ set(GERBVIEW_SRCS
...
@@ -46,8 +47,7 @@ set(GERBVIEW_SRCS
rs274d.cpp
rs274d.cpp
rs274x.cpp
rs274x.cpp
select_layers_to_pcb.cpp
select_layers_to_pcb.cpp
toolbars_gerber.cpp
toolbars_gerber.cpp
)
tracepcb.cpp
)
###
###
# We need some extra sources from pcbnew
# We need some extra sources from pcbnew
...
...
gerbview/class_aperture_macro.cpp
View file @
1206177c
This diff is collapsed.
Click to expand it.
gerbview/class_aperture_macro.h
View file @
1206177c
...
@@ -119,6 +119,18 @@ public:
...
@@ -119,6 +119,18 @@ public:
void
DrawBasicShape
(
GERBER_DRAW_ITEM
*
aParent
,
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
void
DrawBasicShape
(
GERBER_DRAW_ITEM
*
aParent
,
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
int
aColor
,
int
aAltColor
,
wxPoint
aShapePos
,
bool
aFilledShape
);
int
aColor
,
int
aAltColor
,
wxPoint
aShapePos
,
bool
aFilledShape
);
/** GetShapeDim
* Calculate a value that can be used to evaluate the size of text
* when displaying the D-Code of an item
* due to the complexity of the shape of some primitives
* one cannot calculate the "size" of a shape (only a bounding box)
* but here, the "dimension" of the shape is the diameter of the primitive
* or for lines the width of the line
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate
*/
int
GetShapeDim
(
GERBER_DRAW_ITEM
*
aParent
);
private
:
private
:
/** function ConvertShapeToPolygon
/** function ConvertShapeToPolygon
...
@@ -127,7 +139,7 @@ private:
...
@@ -127,7 +139,7 @@ private:
* Useful when a shape is not a graphic primitive (shape with hole,
* Useful when a shape is not a graphic primitive (shape with hole,
* rotated shape ... ) and cannot be easily drawn.
* rotated shape ... ) and cannot be easily drawn.
*/
*/
void
ConvertShapeToPolygon
(
GERBER_DRAW_ITEM
*
aParent
,
std
::
vector
<
wxPoint
>&
aBuffer
,
bool
aUnitsMetric
);
void
ConvertShapeToPolygon
(
GERBER_DRAW_ITEM
*
aParent
,
std
::
vector
<
wxPoint
>&
aBuffer
);
};
};
...
@@ -155,6 +167,19 @@ struct APERTURE_MACRO
...
@@ -155,6 +167,19 @@ struct APERTURE_MACRO
*/
*/
void
DrawApertureMacroShape
(
GERBER_DRAW_ITEM
*
aParent
,
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
void
DrawApertureMacroShape
(
GERBER_DRAW_ITEM
*
aParent
,
EDA_Rect
*
aClipBox
,
wxDC
*
aDC
,
int
aColor
,
int
aAltColor
,
wxPoint
aShapePos
,
bool
aFilledShape
);
int
aColor
,
int
aAltColor
,
wxPoint
aShapePos
,
bool
aFilledShape
);
/** GetShapeDim
* Calculate a value that can be used to evaluate the size of text
* when displaying the D-Code of an item
* due to the complexity of a shape using many primitives
* one cannot calculate the "size" of a shape (only abounding box)
* but most of aperture macro are using one or few primitives
* and the "dimension" of the shape is the diameter of the primitive
* (or the max diameter of primitives)
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate
*/
int
GetShapeDim
(
GERBER_DRAW_ITEM
*
aParent
);
};
};
...
...
gerbview/dcode.cpp
View file @
1206177c
...
@@ -98,6 +98,47 @@ const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
...
@@ -98,6 +98,47 @@ const wxChar* D_CODE::ShowApertureType( APERTURE_T aType )
return
ret
;
return
ret
;
}
}
/** GetShapeDim
* Calculate a value that can be used to evaluate the size of text
* when displaying the D-Code of an item
* due to the complexity of some shapes,
* one cannot calculate the "size" of a shape (only a bounding box)
* but here, the "dimension" of the shape is the diameter of the primitive
* or for lines the width of the line if the shape is a line
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate
*/
int
D_CODE
::
GetShapeDim
(
GERBER_DRAW_ITEM
*
aParent
)
{
int
dim
=
-
1
;
switch
(
m_Shape
)
{
case
APT_CIRCLE
:
case
APT_LINE
:
dim
=
m_Size
.
x
;
break
;
case
APT_RECT
:
case
APT_OVAL
:
dim
=
MIN
(
m_Size
.
x
,
m_Size
.
y
);
break
;
case
APT_POLYGON
:
dim
=
MIN
(
m_Size
.
x
,
m_Size
.
y
);
break
;
case
APT_MACRO
:
if
(
m_Macro
)
dim
=
m_Macro
->
GetShapeDim
(
aParent
);
break
;
default
:
break
;
}
return
dim
;
}
/** Function Read_D_Code_File
/** Function Read_D_Code_File
* Can be useful only with old RS274D Gerber file format.
* Can be useful only with old RS274D Gerber file format.
...
...
gerbview/dcode.h
View file @
1206177c
...
@@ -228,6 +228,18 @@ public:
...
@@ -228,6 +228,18 @@ public:
* rotated shape ... ) and cannot be easily drawn.
* rotated shape ... ) and cannot be easily drawn.
*/
*/
void
ConvertShapeToPolygon
();
void
ConvertShapeToPolygon
();
/** GetShapeDim
* Calculate a value that can be used to evaluate the size of text
* when displaying the D-Code of an item
* due to the complexity of some shapes,
* one cannot calculate the "size" of a shape (only a bounding box)
* but here, the "dimension" of the shape is the diameter of the primitive
* or for lines the width of the line if the shape is a line
* @param aParent = the parent GERBER_DRAW_ITEM which is actually drawn
* @return a dimension, or -1 if no dim to calculate
*/
int
GetShapeDim
(
GERBER_DRAW_ITEM
*
aParent
);
};
};
...
...
gerbview/
tracepcb
.cpp
→
gerbview/
draw_gerber_screen
.cpp
View file @
1206177c
...
@@ -177,19 +177,24 @@ void Show_Items_DCode_Value( WinEDA_DrawPanel* aPanel, wxDC* aDC, BOARD* aPcb, i
...
@@ -177,19 +177,24 @@ void Show_Items_DCode_Value( WinEDA_DrawPanel* aPanel, wxDC* aDC, BOARD* aPcb, i
Line
.
Printf
(
wxT
(
"D%d"
),
gerb_item
->
m_DCode
);
Line
.
Printf
(
wxT
(
"D%d"
),
gerb_item
->
m_DCode
);
if
(
gerb_item
->
GetDcodeDescr
()
)
width
=
gerb_item
->
GetDcodeDescr
()
->
GetShapeDim
(
gerb_item
);
else
width
=
MIN
(
gerb_item
->
m_Size
.
x
,
gerb_item
->
m_Size
.
y
);
width
=
MIN
(
gerb_item
->
m_Size
.
x
,
gerb_item
->
m_Size
.
y
);
orient
=
TEXT_ORIENT_HORIZ
;
orient
=
TEXT_ORIENT_HORIZ
;
if
(
gerb_item
->
m_Flashed
)
if
(
gerb_item
->
m_Flashed
)
{
{
// A reasonnable size for text is width/3 because most ot time this text has 3 chars.
width
/=
3
;
width
/=
3
;
}
}
else
//
lines
else
//
this item is a line
{
{
int
dx
,
dy
;
wxPoint
delta
=
gerb_item
->
m_Start
-
gerb_item
->
m_End
;
dx
=
gerb_item
->
m_Start
.
x
-
gerb_item
->
m_End
.
x
;
if
(
abs
(
delta
.
x
)
<
abs
(
delta
.
y
)
)
dy
=
gerb_item
->
m_Start
.
y
-
gerb_item
->
m_End
.
y
;
if
(
abs
(
dx
)
<
abs
(
dy
)
)
orient
=
TEXT_ORIENT_VERT
;
orient
=
TEXT_ORIENT_VERT
;
// A reasonnable size for text is width/2 because text needs margin below and above it.
// a margin = width/4 seems good
width
/=
2
;
width
/=
2
;
}
}
...
...
include/boost/polygon/detail/polygon_sort_adaptor.hpp
0 → 100644
View file @
1206177c
/*
Copyright 2008 Intel Corporation
Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
*/
#ifndef BOOST_POLYGON_SORT_ADAPTOR_HPP
#define BOOST_POLYGON_SORT_ADAPTOR_HPP
#ifdef __ICC
#pragma warning(disable:2022)
#pragma warning(disable:2023)
#endif
#include <algorithm>
//! @brief gtlsort_adaptor default implementation that calls std::sort
namespace
boost
{
namespace
polygon
{
template
<
typename
iterator_type
>
struct
dummy_to_delay_instantiation
{
typedef
int
unit_type
;
// default GTL unit
};
//! @brief gtlsort_adaptor default implementation that calls std::sort
template
<
typename
T
>
struct
gtlsort_adaptor
{
//! @brief wrapper that mimics std::sort() function and takes
// the same arguments
template
<
typename
RandomAccessIterator_Type
>
static
void
sort
(
RandomAccessIterator_Type
_First
,
RandomAccessIterator_Type
_Last
)
{
std
::
sort
(
_First
,
_Last
);
}
//! @brief wrapper that mimics std::sort() function overload and takes
// the same arguments
template
<
typename
RandomAccessIterator_Type
,
typename
Pred_Type
>
static
void
sort
(
RandomAccessIterator_Type
_First
,
RandomAccessIterator_Type
_Last
,
const
Pred_Type
&
_Comp
)
{
std
::
sort
(
_First
,
_Last
,
_Comp
);
}
};
//! @brief user level wrapper for sorting quantities
template
<
typename
iter_type
>
void
gtlsort
(
iter_type
_b_
,
iter_type
_e_
)
{
gtlsort_adaptor
<
typename
dummy_to_delay_instantiation
<
iter_type
>::
unit_type
>::
sort
(
_b_
,
_e_
);
}
//! @brief user level wrapper for sorting quantities that takes predicate
// as additional argument
template
<
typename
iter_type
,
typename
pred_type
>
void
gtlsort
(
iter_type
_b_
,
iter_type
_e_
,
const
pred_type
&
_pred_
)
{
gtlsort_adaptor
<
typename
dummy_to_delay_instantiation
<
iter_type
>::
unit_type
>::
sort
(
_b_
,
_e_
,
_pred_
);
}
}
// namespace polygon
}
// namespace boost
#endif
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