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
f3503723
Commit
f3503723
authored
Apr 30, 2012
by
Miguel Angel Ajo
Browse files
Options
Browse Files
Download
Plain Diff
merged to testing, fixed some scripting imports
parents
b939f3bc
b322a885
Changes
61
Hide whitespace changes
Inline
Side-by-side
Showing
61 changed files
with
1404 additions
and
875 deletions
+1404
-875
3d_aux.cpp
3d-viewer/3d_aux.cpp
+1
-1
TODO.txt
TODO.txt
+21
-9
CMakeLists.txt
common/CMakeLists.txt
+0
-2
base_screen.cpp
common/base_screen.cpp
+13
-18
base_units.cpp
common/base_units.cpp
+22
-18
common.cpp
common/common.cpp
+0
-33
dialog_page_settings.cpp
common/dialogs/dialog_page_settings.cpp
+1
-2
drawframe.cpp
common/drawframe.cpp
+191
-205
drawpanel.cpp
common/drawpanel.cpp
+30
-25
eda_text.cpp
common/eda_text.cpp
+1
-5
zoom.cpp
common/zoom.cpp
+15
-17
CMakeLists.txt
cvpcb/CMakeLists.txt
+1
-0
class_drc_erc_item.cpp
eeschema/class_drc_erc_item.cpp
+2
-6
dialog_SVG_print.cpp
eeschema/dialogs/dialog_SVG_print.cpp
+289
-289
dialog_print_using_printer.cpp
eeschema/dialogs/dialog_print_using_printer.cpp
+1
-1
eeredraw.cpp
eeschema/eeredraw.cpp
+1
-1
schframe.cpp
eeschema/schframe.cpp
+1
-1
CMakeLists.txt
gerbview/CMakeLists.txt
+3
-1
class_gbr_screen.cpp
gerbview/class_gbr_screen.cpp
+122
-0
class_gbr_screen.h
gerbview/class_gbr_screen.h
+33
-0
dcode.cpp
gerbview/dcode.cpp
+3
-2
draw_gerber_screen.cpp
gerbview/draw_gerber_screen.cpp
+1
-1
excellon_read_drill_file.cpp
gerbview/excellon_read_drill_file.cpp
+1
-1
gerbview_frame.cpp
gerbview/gerbview_frame.cpp
+8
-5
gerbview_frame.h
gerbview/gerbview_frame.h
+5
-7
onleftclick.cpp
gerbview/onleftclick.cpp
+2
-2
onrightclick.cpp
gerbview/onrightclick.cpp
+2
-2
options.cpp
gerbview/options.cpp
+4
-12
rs274_read_XY_and_IJ_coordinates.cpp
gerbview/rs274_read_XY_and_IJ_coordinates.cpp
+16
-16
rs274x.cpp
gerbview/rs274x.cpp
+9
-10
base_units.h
include/base_units.h
+24
-15
class_base_screen.h
include/class_base_screen.h
+11
-5
common.h
include/common.h
+23
-40
convert_to_biu.h
include/convert_to_biu.h
+27
-7
fctsys.h
include/fctsys.h
+0
-3
vector2d.h
include/vector2d.h
+399
-0
wxstruct.h
include/wxstruct.h
+17
-1
CMakeLists.txt
pcbnew/CMakeLists.txt
+5
-2
basepcbframe.cpp
pcbnew/basepcbframe.cpp
+7
-2
class_dimension.cpp
pcbnew/class_dimension.cpp
+2
-1
class_drawsegment.cpp
pcbnew/class_drawsegment.cpp
+4
-4
class_drc_item.cpp
pcbnew/class_drc_item.cpp
+1
-0
class_edge_mod.cpp
pcbnew/class_edge_mod.cpp
+1
-1
class_mire.cpp
pcbnew/class_mire.cpp
+2
-1
class_pad.cpp
pcbnew/class_pad.cpp
+8
-8
class_pcb_text.cpp
pcbnew/class_pcb_text.cpp
+3
-3
class_text_mod.cpp
pcbnew/class_text_mod.cpp
+3
-3
class_track.cpp
pcbnew/class_track.cpp
+4
-6
classpcb.cpp
pcbnew/classpcb.cpp
+20
-16
dialog_SVG_print.cpp
pcbnew/dialogs/dialog_SVG_print.cpp
+1
-1
editrack.cpp
pcbnew/editrack.cpp
+2
-2
legacy_plugin.cpp
pcbnew/legacy_plugin.cpp
+3
-6
printout_controler.cpp
pcbnew/printout_controler.cpp
+8
-11
module.i
pcbnew/scripting/module.i
+1
-1
pcbnew.i
pcbnew/scripting/pcbnew.i
+4
-2
specctra_export.cpp
pcbnew/specctra_export.cpp
+5
-8
tracepcb.cpp
pcbnew/tracepcb.cpp
+2
-2
PolyLine.cpp
polygon/PolyLine.cpp
+2
-5
PolyLine.h
polygon/PolyLine.h
+1
-2
math_for_graphics.cpp
polygon/math_for_graphics.cpp
+12
-24
math_for_graphics.h
polygon/math_for_graphics.h
+3
-1
No files found.
3d-viewer/3d_aux.cpp
View file @
f3503723
...
...
@@ -70,7 +70,7 @@ void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices )
RotatePoint
(
&
aVertices
[
ii
].
x
,
&
aVertices
[
ii
].
y
,
(
int
)
(
m_MatRotation
.
z
*
10
)
);
/* adjust offset position (offset is given in UNIT 3D (0.1 inch) */
#define SCALE_3D_CONV (
PCB_INTERNAL_UNIT
/ UNITS3D_TO_UNITSPCB)
#define SCALE_3D_CONV (
(IU_PER_MILS * 1000)
/ UNITS3D_TO_UNITSPCB)
aVertices
[
ii
].
x
+=
m_MatPosition
.
x
*
SCALE_3D_CONV
;
aVertices
[
ii
].
y
+=
m_MatPosition
.
y
*
SCALE_3D_CONV
;
aVertices
[
ii
].
z
+=
m_MatPosition
.
z
*
SCALE_3D_CONV
;
...
...
TODO.txt
View file @
f3503723
...
...
@@ -52,21 +52,33 @@ PCBNew
See the @todos in class_zone.cpp
Dick's Peronal TODO Items (Last Update:
5
-April-2012)
Dick's Peronal TODO Items (Last Update:
24
-April-2012)
-----------------------------------------------------
0) Check that the new load visibility BOARD settings is properly setting the toolbar
1) Work through some scroll, pan, zoom overflows in PCBNEW's nanometer build mode.
It is thought that if we can constrain the virtual IU space to within
INT_MIN to INT_MAX then a whole host of other problems will go away. Most
of the evil is in EDA_DRAW_FRAME::AdjustScrollBars() which assumes the
virtual IU space is infinite. This function triggers a movement of the
viewport within the virtual IU space and also a change in size of the virtual
IU space. Once this happens, you can end up thinking there are problems in
functions like EDA_DRAW_PANE::DrawCrossHair(), but this may be an artifact
of having traveled outside a limited virtual IU space.
2) Check that the new load visibility BOARD settings is properly setting the toolbar
buttons like show grid or ratsnest. Add PCB_EDIT_FRAME::SetVisibleElements() so
toolbar crap is not known to a BOARD.
1)
Finish removing global access requirements from KICAD_PLUGIN, so that:
*)
a BOARD is a fully self contained document description.
*)
plugin developers do not have to access globals, since a plugin could
3)
Finish removing global access requirements from KICAD_PLUGIN, so that:
*)
a BOARD is a fully self contained document description.
*)
plugin developers do not have to access globals, since a plugin could
very well be a dynamically loaded DLL/DSO.
One final problem remains with BASE_SCREEN's grid origin, easy solution is to
move just that one field into the BOARD.
One final problem remains with BASE_SCREEN's grid origin, easy solution is to
move just that one field into the BOARD.
2
) Do an EAGLE XML import PCBNEW PLUGIN, and possibly add export support to it.
4
) Do an EAGLE XML import PCBNEW PLUGIN, and possibly add export support to it.
This is PLUGIN::Load() and maybe PLUGIN::Save().
3
) Get back to the SWEET work.
5
) Get back to the SWEET work.
common/CMakeLists.txt
View file @
f3503723
...
...
@@ -83,7 +83,6 @@ add_library(common STATIC ${COMMON_SRCS})
set
(
PCB_COMMON_SRCS
base_screen.cpp
base_units.cpp
eda_text.cpp
class_page_info.cpp
pcbcommon.cpp
...
...
@@ -120,7 +119,6 @@ set(PCB_COMMON_SRCS
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
pcb_plot_params_keywords.cpp
dialogs/dialog_page_settings.cpp
)
...
...
common/base_screen.cpp
View file @
f3503723
...
...
@@ -70,17 +70,19 @@ void BASE_SCREEN::InitDataPoints( const wxSize& aPageSizeIU )
{
if
(
m_Center
)
{
m_crossHairPosition
.
x
=
m_crossHairPosition
.
y
=
0
;
m_crossHairPosition
.
x
=
0
;
m_crossHairPosition
.
y
=
0
;
m_DrawOrg
.
x
=
-
aPageSizeIU
.
x
/
2
;
m_DrawOrg
.
y
=
-
aPageSizeIU
.
y
/
2
;
}
else
{
m_DrawOrg
.
x
=
m_DrawOrg
.
y
=
0
;
m_crossHairPosition
.
x
=
aPageSizeIU
.
x
/
2
;
m_crossHairPosition
.
y
=
aPageSizeIU
.
y
/
2
;
m_DrawOrg
.
x
=
0
;
m_DrawOrg
.
y
=
0
;
}
m_O_Curseur
.
x
=
m_O_Curseur
.
y
=
0
;
...
...
@@ -142,6 +144,8 @@ bool BASE_SCREEN::SetZoom( double coeff )
if
(
coeff
==
m_Zoom
)
return
false
;
wxLogDebug
(
"Zoom:%16g 1/Zoom:%16g"
,
coeff
,
1
/
coeff
);
m_Zoom
=
coeff
;
return
true
;
...
...
@@ -168,12 +172,10 @@ bool BASE_SCREEN::SetNextZoom()
bool
BASE_SCREEN
::
SetPreviousZoom
()
{
size_t
i
;
if
(
m_ZoomList
.
IsEmpty
()
||
m_Zoom
<=
m_ZoomList
[
0
]
)
return
false
;
for
(
i
=
m_ZoomList
.
GetCount
();
i
!=
0
;
i
--
)
for
(
unsigned
i
=
m_ZoomList
.
GetCount
();
i
!=
0
;
i
--
)
{
if
(
m_Zoom
>
m_ZoomList
[
i
-
1
]
)
{
...
...
@@ -191,8 +193,7 @@ bool BASE_SCREEN::SetLastZoom()
if
(
m_ZoomList
.
IsEmpty
()
||
m_Zoom
==
m_ZoomList
.
Last
()
)
return
false
;
SetZoom
(
m_ZoomList
.
Last
()
);
return
true
;
return
SetZoom
(
m_ZoomList
.
Last
()
);
}
...
...
@@ -216,11 +217,9 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size )
{
wxASSERT
(
!
m_grids
.
empty
()
);
size_t
i
;
GRID_TYPE
nearest_grid
=
m_grids
[
0
];
for
(
i
=
0
;
i
<
m_grids
.
size
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
m_grids
.
size
();
i
++
)
{
if
(
m_grids
[
i
].
m_Size
==
size
)
{
...
...
@@ -228,7 +227,7 @@ void BASE_SCREEN::SetGrid( const wxRealPoint& size )
return
;
}
// keep trac
e of the nearest grill
size, if the exact size is not found
// keep trac
k of the nearest larger grid
size, if the exact size is not found
if
(
size
.
x
<
m_grids
[
i
].
m_Size
.
x
)
nearest_grid
=
m_grids
[
i
];
}
...
...
@@ -245,9 +244,7 @@ void BASE_SCREEN::SetGrid( int id )
{
wxASSERT
(
!
m_grids
.
empty
()
);
size_t
i
;
for
(
i
=
0
;
i
<
m_grids
.
size
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
m_grids
.
size
();
i
++
)
{
if
(
m_grids
[
i
].
m_Id
==
id
)
{
...
...
@@ -266,9 +263,7 @@ void BASE_SCREEN::SetGrid( int id )
void
BASE_SCREEN
::
AddGrid
(
const
GRID_TYPE
&
grid
)
{
size_t
i
;
for
(
i
=
0
;
i
<
m_grids
.
size
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
m_grids
.
size
();
i
++
)
{
if
(
m_grids
[
i
].
m_Size
==
grid
.
m_Size
&&
grid
.
m_Id
!=
ID_POPUP_GRID_USER
)
{
...
...
common/base_units.cpp
View file @
f3503723
...
...
@@ -40,25 +40,13 @@
#include <base_units.h>
#if defined( PCBNEW )
#if defined( USE_PCBNEW_NANOMETRES )
#define IU_TO_MM( x ) ( x * 1e-6 )
#define IU_TO_IN( x ) ( ( x * 1e-6 ) / 25.4 )
#define MM_TO_IU( x ) ( x * 1e6 )
#define IN_TO_IU( x ) ( ( x * 25.4 ) * 1e6 )
#else
#define IU_TO_MM( x ) ( ( x * 0.0001 ) * 25.4 )
#define IU_TO_IN( x ) ( x * 0.0001 )
#define MM_TO_IU( x ) ( ( x / 25.4 ) * 10000.0 )
#define IN_TO_IU( x ) ( x * 10000.0 )
#endif
#elif defined( EESCHEMA )
#define IU_TO_MM( x ) ( ( x * 0.001 ) * 25.4 )
#define IU_TO_IN( x ) ( x * 0.001 )
#define MM_TO_IU( x ) ( ( x / 25.4 ) * 1000.0 )
#define IN_TO_IU( x ) ( x * 1000.0 )
#if defined( PCBNEW ) || defined( CVPCB ) || defined( EESCHEMA )
#define IU_TO_MM( x ) ( x / IU_PER_MM )
#define IU_TO_IN( x ) ( x / IU_PER_MILS / 1000 )
#define MM_TO_IU( x ) ( x * IU_PER_MM )
#define IN_TO_IU( x ) ( x * IU_PER_MILS * 1000 )
#else
#error "Cannot resolve internal units due to no definition of EESCHEMA or PCBNEW."
#error "Cannot resolve internal units due to no definition of EESCHEMA
, CVPCB
or PCBNEW."
#endif
...
...
@@ -79,6 +67,11 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue )
wxString
CoordinateToString
(
int
aValue
,
bool
aConvertToMils
)
{
return
LengthDoubleToString
(
(
double
)
aValue
,
aConvertToMils
);
}
wxString
LengthDoubleToString
(
double
aValue
,
bool
aConvertToMils
)
{
wxString
text
;
const
wxChar
*
format
;
...
...
@@ -261,3 +254,14 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
return
value
;
}
wxString
&
operator
<<
(
wxString
&
aString
,
const
wxPoint
&
aPos
)
{
aString
<<
wxT
(
"@ ("
)
<<
CoordinateToString
(
aPos
.
x
);
aString
<<
wxT
(
","
)
<<
CoordinateToString
(
aPos
.
y
);
aString
<<
wxT
(
")"
);
return
aString
;
}
common/common.cpp
View file @
f3503723
...
...
@@ -334,39 +334,6 @@ unsigned long GetNewTimeStamp()
}
const
wxString
&
valeur_param
(
int
valeur
,
wxString
&
buf_texte
)
{
switch
(
g_UserUnit
)
{
case
MILLIMETRES
:
buf_texte
.
Printf
(
_
(
"%3.3f mm"
),
valeur
*
0.00254
);
break
;
case
INCHES
:
buf_texte
.
Printf
(
wxT
(
"%2.4f
\"
"
),
valeur
*
0.0001
);
break
;
case
UNSCALED_UNITS
:
buf_texte
.
Printf
(
wxT
(
"%d"
),
valeur
);
break
;
}
return
buf_texte
;
}
wxString
&
operator
<<
(
wxString
&
aString
,
const
wxPoint
&
aPos
)
{
wxString
temp
;
aString
<<
wxT
(
"@ ("
)
<<
valeur_param
(
aPos
.
x
,
temp
);
aString
<<
wxT
(
","
)
<<
valeur_param
(
aPos
.
y
,
temp
);
aString
<<
wxT
(
")"
);
return
aString
;
}
double
RoundTo0
(
double
x
,
double
precision
)
{
assert
(
precision
!=
0
);
...
...
common/dialogs/dialog_page_settings.cpp
View file @
f3503723
...
...
@@ -34,7 +34,6 @@
#include <class_title_block.h>
#include <wxstruct.h>
#include <class_base_screen.h>
#include <base_units.h> // MILS_TO_IU_SCALAR
#include <wx/valgen.h>
#include <wx/tokenzr.h>
...
...
@@ -617,7 +616,7 @@ void DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample()
m_Parent
->
GetCanvas
()
->
SetClipBox
(
EDA_RECT
(
wxPoint
(
0
,
0
),
wxSize
(
INT_MAX
/
2
,
INT_MAX
/
2
)
)
);
// Calculate layout preview scale.
int
appScale
=
MILS_TO_IU_SCALAR
;
int
appScale
=
m_Screen
->
MilsToIuScalar
()
;
double
scaleW
=
(
double
)
lyWidth
/
clamped_layout_size
.
x
/
appScale
;
double
scaleH
=
(
double
)
lyHeight
/
clamped_layout_size
.
y
/
appScale
;
...
...
common/drawframe.cpp
View file @
f3503723
...
...
@@ -41,6 +41,7 @@
#include <kicad_device_context.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <vector2d.h>
#include <wx/fontdlg.h>
...
...
@@ -495,211 +496,6 @@ bool EDA_DRAW_FRAME::HandleBlockEnd( wxDC* DC )
}
void
EDA_DRAW_FRAME
::
AdjustScrollBars
(
const
wxPoint
&
aCenterPosition
)
{
int
unitsX
,
unitsY
,
posX
,
posY
;
wxSize
clientSize
,
logicalClientSize
,
virtualSize
;
BASE_SCREEN
*
screen
=
GetScreen
();
bool
noRefresh
=
true
;
if
(
screen
==
NULL
||
m_canvas
==
NULL
)
return
;
double
scalar
=
screen
->
GetScalingFactor
();
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Center Position = ( %d, %d ), scalar = %0.5f."
),
aCenterPosition
.
x
,
aCenterPosition
.
y
,
scalar
);
// Calculate the portion of the drawing that can be displayed in the
// client area at the current zoom level.
clientSize
=
m_canvas
->
GetClientSize
();
// The logical size of the client window.
logicalClientSize
.
x
=
KiROUND
(
(
double
)
clientSize
.
x
/
scalar
);
logicalClientSize
.
y
=
KiROUND
(
(
double
)
clientSize
.
y
/
scalar
);
// A corner of the drawing in internal units.
wxSize
corner
=
GetPageSizeIU
();
// The drawing rectangle logical units
wxRect
drawingRect
(
wxPoint
(
0
,
0
),
corner
);
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Logical drawing rect = ( %d, %d, %d, %d )."
),
drawingRect
.
x
,
drawingRect
.
y
,
drawingRect
.
width
,
drawingRect
.
height
);
wxLogTrace
(
traceScrollSettings
,
wxT
(
" left %d, right %d, top %d, bottome %d"
),
drawingRect
.
GetLeft
(),
drawingRect
.
GetRight
(),
drawingRect
.
GetTop
(),
drawingRect
.
GetBottom
()
);
// The size of the client rectangle in logical units.
int
x
=
KiROUND
(
(
double
)
aCenterPosition
.
x
-
(
(
double
)
logicalClientSize
.
x
/
2.0
)
);
int
y
=
KiROUND
(
(
double
)
aCenterPosition
.
y
-
(
(
double
)
logicalClientSize
.
y
/
2.0
)
);
// If drawn around the center, adjust the client rectangle accordingly.
if
(
screen
->
m_Center
)
{
x
+=
KiROUND
(
(
double
)
drawingRect
.
width
/
2.0
);
y
+=
KiROUND
(
(
double
)
drawingRect
.
height
/
2.0
);
}
wxRect
logicalClientRect
(
wxPoint
(
x
,
y
),
logicalClientSize
);
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Logical client rect = ( %d, %d, %d, %d )."
),
logicalClientRect
.
x
,
logicalClientRect
.
y
,
logicalClientRect
.
width
,
logicalClientRect
.
height
);
wxLogTrace
(
traceScrollSettings
,
wxT
(
" left %d, right %d, top %d, bottome %d"
),
logicalClientRect
.
GetLeft
(),
logicalClientRect
.
GetRight
(),
logicalClientRect
.
GetTop
(),
logicalClientRect
.
GetBottom
()
);
if
(
drawingRect
==
logicalClientRect
)
{
virtualSize
=
drawingRect
.
GetSize
();
}
else
{
if
(
drawingRect
.
GetLeft
()
<
logicalClientRect
.
GetLeft
()
&&
drawingRect
.
GetRight
()
>
logicalClientRect
.
GetRight
()
)
{
virtualSize
.
x
=
drawingRect
.
GetSize
().
x
;
}
else
{
int
drawingCenterX
=
drawingRect
.
x
+
(
drawingRect
.
width
/
2
);
int
clientCenterX
=
logicalClientRect
.
x
+
(
logicalClientRect
.
width
/
2
);
if
(
logicalClientRect
.
width
>
drawingRect
.
width
)
{
if
(
drawingCenterX
>
clientCenterX
)
virtualSize
.
x
=
(
drawingCenterX
-
logicalClientRect
.
GetLeft
()
)
*
2
;
else
if
(
drawingCenterX
<
clientCenterX
)
virtualSize
.
x
=
(
logicalClientRect
.
GetRight
()
-
drawingCenterX
)
*
2
;
else
virtualSize
.
x
=
logicalClientRect
.
width
;
}
else
{
if
(
drawingCenterX
>
clientCenterX
)
virtualSize
.
x
=
drawingRect
.
width
+
(
(
drawingRect
.
GetLeft
()
-
logicalClientRect
.
GetLeft
()
)
*
2
);
else
if
(
drawingCenterX
<
clientCenterX
)
virtualSize
.
x
=
drawingRect
.
width
+
(
(
logicalClientRect
.
GetRight
()
-
drawingRect
.
GetRight
()
)
*
2
);
else
virtualSize
.
x
=
drawingRect
.
width
;
}
}
if
(
drawingRect
.
GetTop
()
<
logicalClientRect
.
GetTop
()
&&
drawingRect
.
GetBottom
()
>
logicalClientRect
.
GetBottom
()
)
{
virtualSize
.
y
=
drawingRect
.
GetSize
().
y
;
}
else
{
int
drawingCenterY
=
drawingRect
.
y
+
(
drawingRect
.
height
/
2
);
int
clientCenterY
=
logicalClientRect
.
y
+
(
logicalClientRect
.
height
/
2
);
if
(
logicalClientRect
.
height
>
drawingRect
.
height
)
{
if
(
drawingCenterY
>
clientCenterY
)
virtualSize
.
y
=
(
drawingCenterY
-
logicalClientRect
.
GetTop
()
)
*
2
;
else
if
(
drawingCenterY
<
clientCenterY
)
virtualSize
.
y
=
(
logicalClientRect
.
GetBottom
()
-
drawingCenterY
)
*
2
;
else
virtualSize
.
y
=
logicalClientRect
.
height
;
}
else
{
if
(
drawingCenterY
>
clientCenterY
)
virtualSize
.
y
=
drawingRect
.
height
+
(
(
drawingRect
.
GetTop
()
-
logicalClientRect
.
GetTop
()
)
*
2
);
else
if
(
drawingCenterY
<
clientCenterY
)
virtualSize
.
y
=
drawingRect
.
height
+
(
(
logicalClientRect
.
GetBottom
()
-
drawingRect
.
GetBottom
()
)
*
2
);
else
virtualSize
.
y
=
drawingRect
.
height
;
}
}
}
if
(
screen
->
m_Center
)
{
screen
->
m_DrawOrg
.
x
=
-
(
KiROUND
(
(
double
)
virtualSize
.
x
/
2.0
)
);
screen
->
m_DrawOrg
.
y
=
-
(
KiROUND
(
(
double
)
virtualSize
.
y
/
2.0
)
);
}
else
{
screen
->
m_DrawOrg
.
x
=
-
(
KiROUND
(
(
double
)
(
virtualSize
.
x
-
drawingRect
.
width
)
/
2.0
)
);
screen
->
m_DrawOrg
.
y
=
-
(
KiROUND
(
(
double
)
(
virtualSize
.
y
-
drawingRect
.
height
)
/
2.0
)
);
}
/* Always set scrollbar pixels per unit to 1 unless you want the zoom
* around cursor to jump around. This reported problem occurs when the
* zoom point is not on a pixel per unit increment. If you set the
* pixels per unit to 10, you have potential for the zoom point to
* jump around +/-5 pixels from the nearest grid point.
*/
screen
->
m_ScrollPixelsPerUnitX
=
screen
->
m_ScrollPixelsPerUnitY
=
1
;
// Calculate the number of scroll bar units for the given zoom level in device units.
unitsX
=
KiROUND
(
(
double
)
virtualSize
.
x
*
scalar
);
unitsY
=
KiROUND
(
(
double
)
virtualSize
.
y
*
scalar
);
// Calculate the scroll bar position in logical units to place the center position at
// the center of client rectangle.
screen
->
SetScrollCenterPosition
(
aCenterPosition
);
posX
=
aCenterPosition
.
x
-
KiROUND
(
(
double
)
logicalClientRect
.
width
/
2.0
)
-
screen
->
m_DrawOrg
.
x
;
posY
=
aCenterPosition
.
y
-
KiROUND
(
(
double
)
logicalClientRect
.
height
/
2.0
)
-
screen
->
m_DrawOrg
.
y
;
// Convert scroll bar position to device units.
posX
=
KiROUND
(
(
double
)
posX
*
scalar
);
posY
=
KiROUND
(
(
double
)
posY
*
scalar
);
if
(
posX
<
0
)
{
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Required scroll bar X position %d"
),
posX
);
posX
=
0
;
}
if
(
posX
>
unitsX
)
{
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Required scroll bar X position %d"
),
posX
);
posX
=
unitsX
;
}
if
(
posY
<
0
)
{
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Required scroll bar Y position %d"
),
posY
);
posY
=
0
;
}
if
(
posY
>
unitsY
)
{
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Required scroll bar Y position %d"
),
posY
);
posY
=
unitsY
;
}
screen
->
m_ScrollbarPos
=
wxPoint
(
posX
,
posY
);
screen
->
m_ScrollbarNumber
=
wxSize
(
unitsX
,
unitsY
);
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Drawing = (%d, %d), Client = (%d, %d), Offset = (%d, %d), \
SetScrollbars(%d, %d, %d, %d, %d, %d)"
),
virtualSize
.
x
,
virtualSize
.
y
,
logicalClientSize
.
x
,
logicalClientSize
.
y
,
screen
->
m_DrawOrg
.
x
,
screen
->
m_DrawOrg
.
y
,
screen
->
m_ScrollPixelsPerUnitX
,
screen
->
m_ScrollPixelsPerUnitY
,
screen
->
m_ScrollbarNumber
.
x
,
screen
->
m_ScrollbarNumber
.
y
,
screen
->
m_ScrollbarPos
.
x
,
screen
->
m_ScrollbarPos
.
y
);
m_canvas
->
SetScrollbars
(
screen
->
m_ScrollPixelsPerUnitX
,
screen
->
m_ScrollPixelsPerUnitY
,
screen
->
m_ScrollbarNumber
.
x
,
screen
->
m_ScrollbarNumber
.
y
,
screen
->
m_ScrollbarPos
.
x
,
screen
->
m_ScrollbarPos
.
y
,
noRefresh
);
}
void
EDA_DRAW_FRAME
::
SetLanguage
(
wxCommandEvent
&
event
)
{
EDA_BASE_FRAME
::
SetLanguage
(
event
);
...
...
@@ -788,6 +584,11 @@ wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils )
return
::
CoordinateToString
(
aValue
,
aConvertToMils
);
}
wxString
EDA_DRAW_FRAME
::
LengthDoubleToString
(
double
aValue
,
bool
aConvertToMils
)
{
return
::
LengthDoubleToString
(
aValue
,
aConvertToMils
);
}
bool
EDA_DRAW_FRAME
::
HandleBlockBegin
(
wxDC
*
aDC
,
int
aKey
,
const
wxPoint
&
aPosition
)
{
...
...
@@ -858,3 +659,188 @@ bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosi
Block
->
SetMessageBlock
(
this
);
return
true
;
}
void
EDA_DRAW_FRAME
::
AdjustScrollBars
(
const
wxPoint
&
aCenterPositionIU
)
{
BASE_SCREEN
*
screen
=
GetScreen
();
if
(
screen
==
NULL
||
m_canvas
==
NULL
)
return
;
// There are no safety limits on these calculations, so in NANOMETRES build it
// still blows up. This is incomplete work.
double
scale
=
screen
->
GetScalingFactor
();
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Center Position = ( %d, %d ), scale = %.16g"
),
aCenterPositionIU
.
x
,
aCenterPositionIU
.
y
,
scale
);
// Calculate the portion of the drawing that can be displayed in the
// client area at the current zoom level.
// visible viewport in device units ~ pixels
wxSize
clientSizeDU
=
m_canvas
->
GetClientSize
();
// Size of the client window in IU
DSIZE
clientSizeIU
(
clientSizeDU
.
x
/
scale
,
clientSizeDU
.
y
/
scale
);
// Full drawing or "page" rectangle in internal units
DBOX
pageRectIU
(
0
,
0
,
GetPageSizeIU
().
x
,
GetPageSizeIU
().
y
);
// The upper left corner of the client rectangle in internal units.
double
xIU
=
aCenterPositionIU
.
x
-
clientSizeIU
.
x
/
2.0
;
double
yIU
=
aCenterPositionIU
.
y
-
clientSizeIU
.
y
/
2.0
;
// If drawn around the center, adjust the client rectangle accordingly.
if
(
screen
->
m_Center
)
{
// half page offset.
xIU
+=
pageRectIU
.
width
/
2.0
;
yIU
+=
pageRectIU
.
height
/
2.0
;
}
DBOX
clientRectIU
(
xIU
,
yIU
,
clientSizeIU
.
x
,
clientSizeIU
.
y
);
DSIZE
virtualSizeIU
;
if
(
pageRectIU
.
GetLeft
()
<
clientRectIU
.
GetLeft
()
&&
pageRectIU
.
GetRight
()
>
clientRectIU
.
GetRight
()
)
{
virtualSizeIU
.
x
=
pageRectIU
.
GetSize
().
x
;
}
else
{
double
drawingCenterX
=
pageRectIU
.
x
+
(
pageRectIU
.
width
/
2
);
double
clientCenterX
=
clientRectIU
.
x
+
(
clientRectIU
.
width
/
2
);
if
(
clientRectIU
.
width
>
pageRectIU
.
width
)
{
if
(
drawingCenterX
>
clientCenterX
)
virtualSizeIU
.
x
=
(
drawingCenterX
-
clientRectIU
.
GetLeft
()
)
*
2
;
else
if
(
drawingCenterX
<
clientCenterX
)
virtualSizeIU
.
x
=
(
clientRectIU
.
GetRight
()
-
drawingCenterX
)
*
2
;
else
virtualSizeIU
.
x
=
clientRectIU
.
width
;
}
else
{
if
(
drawingCenterX
>
clientCenterX
)
virtualSizeIU
.
x
=
pageRectIU
.
width
+
(
(
pageRectIU
.
GetLeft
()
-
clientRectIU
.
GetLeft
()
)
*
2
);
else
if
(
drawingCenterX
<
clientCenterX
)
virtualSizeIU
.
x
=
pageRectIU
.
width
+
(
(
clientRectIU
.
GetRight
()
-
pageRectIU
.
GetRight
()
)
*
2
);
else
virtualSizeIU
.
x
=
pageRectIU
.
width
;
}
}
if
(
pageRectIU
.
GetTop
()
<
clientRectIU
.
GetTop
()
&&
pageRectIU
.
GetBottom
()
>
clientRectIU
.
GetBottom
()
)
{
virtualSizeIU
.
y
=
pageRectIU
.
GetSize
().
y
;
}
else
{
int
drawingCenterY
=
pageRectIU
.
y
+
(
pageRectIU
.
height
/
2
);
int
clientCenterY
=
clientRectIU
.
y
+
(
clientRectIU
.
height
/
2
);
if
(
clientRectIU
.
height
>
pageRectIU
.
height
)
{
if
(
drawingCenterY
>
clientCenterY
)
virtualSizeIU
.
y
=
(
drawingCenterY
-
clientRectIU
.
GetTop
()
)
*
2
;
else
if
(
drawingCenterY
<
clientCenterY
)
virtualSizeIU
.
y
=
(
clientRectIU
.
GetBottom
()
-
drawingCenterY
)
*
2
;
else
virtualSizeIU
.
y
=
clientRectIU
.
height
;
}
else
{
if
(
drawingCenterY
>
clientCenterY
)
virtualSizeIU
.
y
=
pageRectIU
.
height
+
(
(
pageRectIU
.
GetTop
()
-
clientRectIU
.
GetTop
()
)
*
2
);
else
if
(
drawingCenterY
<
clientCenterY
)
virtualSizeIU
.
y
=
pageRectIU
.
height
+
(
(
clientRectIU
.
GetBottom
()
-
pageRectIU
.
GetBottom
()
)
*
2
);
else
virtualSizeIU
.
y
=
pageRectIU
.
height
;
}
}
if
(
screen
->
m_Center
)
{
screen
->
m_DrawOrg
.
x
=
-
KiROUND
(
virtualSizeIU
.
x
/
2.0
);
screen
->
m_DrawOrg
.
y
=
-
KiROUND
(
virtualSizeIU
.
y
/
2.0
);
}
else
{
screen
->
m_DrawOrg
.
x
=
-
KiROUND
(
(
virtualSizeIU
.
x
-
pageRectIU
.
width
)
/
2.0
);
screen
->
m_DrawOrg
.
y
=
-
KiROUND
(
(
virtualSizeIU
.
y
-
pageRectIU
.
height
)
/
2.0
);
}
/* Always set scrollbar pixels per unit to 1 unless you want the zoom
* around cursor to jump around. This reported problem occurs when the
* zoom point is not on a pixel per unit increment. If you set the
* pixels per unit to 10, you have potential for the zoom point to
* jump around +/-5 pixels from the nearest grid point.
*/
screen
->
m_ScrollPixelsPerUnitX
=
screen
->
m_ScrollPixelsPerUnitY
=
1
;
// Number of scroll bar units for the given zoom level in device units.
double
unitsX
=
virtualSizeIU
.
x
*
scale
;
double
unitsY
=
virtualSizeIU
.
y
*
scale
;
// Calculate the scroll bar position in internal units to place the
// center position at the center of client rectangle.
screen
->
SetScrollCenterPosition
(
aCenterPositionIU
);
double
posX
=
aCenterPositionIU
.
x
-
clientRectIU
.
width
/
2.0
-
screen
->
m_DrawOrg
.
x
;
double
posY
=
aCenterPositionIU
.
y
-
clientRectIU
.
height
/
2.0
-
screen
->
m_DrawOrg
.
y
;
// Convert scroll bar position to device units.
posX
=
KiROUND
(
posX
*
scale
);
posY
=
KiROUND
(
posY
*
scale
);
if
(
posX
<
0
)
{
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Required scroll bar X position %d"
),
posX
);
posX
=
0
;
}
if
(
posX
>
unitsX
)
{
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Required scroll bar X position %d"
),
posX
);
posX
=
unitsX
;
}
if
(
posY
<
0
)
{
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Required scroll bar Y position %d"
),
posY
);
posY
=
0
;
}
if
(
posY
>
unitsY
)
{
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Required scroll bar Y position %d"
),
posY
);
posY
=
unitsY
;
}
screen
->
m_ScrollbarPos
=
wxPoint
(
KiROUND
(
posX
),
KiROUND
(
posY
)
);
screen
->
m_ScrollbarNumber
=
wxSize
(
KiROUND
(
unitsX
),
KiROUND
(
unitsY
)
);
wxLogTrace
(
traceScrollSettings
,
wxT
(
"Drawing = (%.16g, %.16g), Client = (%.16g, %.16g), Offset = (%d, %d), SetScrollbars(%d, %d, %d, %d, %d, %d)"
),
virtualSizeIU
.
x
,
virtualSizeIU
.
y
,
clientSizeIU
.
x
,
clientSizeIU
.
y
,
screen
->
m_DrawOrg
.
x
,
screen
->
m_DrawOrg
.
y
,
screen
->
m_ScrollPixelsPerUnitX
,
screen
->
m_ScrollPixelsPerUnitY
,
screen
->
m_ScrollbarNumber
.
x
,
screen
->
m_ScrollbarNumber
.
y
,
screen
->
m_ScrollbarPos
.
x
,
screen
->
m_ScrollbarPos
.
y
);
bool
noRefresh
=
true
;
m_canvas
->
SetScrollbars
(
screen
->
m_ScrollPixelsPerUnitX
,
screen
->
m_ScrollPixelsPerUnitY
,
screen
->
m_ScrollbarNumber
.
x
,
screen
->
m_ScrollbarNumber
.
y
,
screen
->
m_ScrollbarPos
.
x
,
screen
->
m_ScrollbarPos
.
y
,
noRefresh
);
}
common/drawpanel.cpp
View file @
f3503723
...
...
@@ -158,28 +158,34 @@ void EDA_DRAW_PANEL::DrawCrossHair( wxDC* aDC, int aColor )
if
(
m_cursorLevel
!=
0
||
aDC
==
NULL
||
!
m_showCrossHair
)
return
;
wxPoint
C
ursor
=
GetScreen
()
->
GetCrossHairPosition
();
wxPoint
c
ursor
=
GetScreen
()
->
GetCrossHairPosition
();
GRSetDrawMode
(
aDC
,
GR_XOR
);
if
(
GetParent
()
->
m_cursorShape
!=
0
)
/
* Draws full screen crosshair. */
if
(
GetParent
()
->
m_cursorShape
!=
0
)
/
/ Draws full screen crosshair.
{
wxSize
clientSize
=
GetClientSize
();
wxPoint
lineStart
=
wxPoint
(
Cursor
.
x
,
aDC
->
DeviceToLogicalY
(
0
)
);
wxPoint
lineEnd
=
wxPoint
(
Cursor
.
x
,
aDC
->
DeviceToLogicalY
(
clientSize
.
y
)
);
GRLine
(
&
m_ClipBox
,
aDC
,
lineStart
,
lineEnd
,
0
,
aColor
);
// Y axis
lineStart
=
wxPoint
(
aDC
->
DeviceToLogicalX
(
0
),
Cursor
.
y
);
lineEnd
=
wxPoint
(
aDC
->
DeviceToLogicalX
(
clientSize
.
x
),
Cursor
.
y
);
GRLine
(
&
m_ClipBox
,
aDC
,
lineStart
,
lineEnd
,
0
,
aColor
);
// X axis
wxSize
clientSize
=
GetClientSize
();
// Y axis
wxPoint
lineStart
(
cursor
.
x
,
aDC
->
DeviceToLogicalY
(
0
)
);
wxPoint
lineEnd
(
cursor
.
x
,
aDC
->
DeviceToLogicalY
(
clientSize
.
y
)
);
GRLine
(
&
m_ClipBox
,
aDC
,
lineStart
,
lineEnd
,
0
,
aColor
);
// X axis
lineStart
=
wxPoint
(
aDC
->
DeviceToLogicalX
(
0
),
cursor
.
y
);
lineEnd
=
wxPoint
(
aDC
->
DeviceToLogicalX
(
clientSize
.
x
),
cursor
.
y
);
GRLine
(
&
m_ClipBox
,
aDC
,
lineStart
,
lineEnd
,
0
,
aColor
);
}
else
{
int
len
=
aDC
->
DeviceToLogicalXRel
(
CURSOR_SIZE
);
GRLine
(
&
m_ClipBox
,
aDC
,
Cursor
.
x
-
len
,
C
ursor
.
y
,
Cursor
.
x
+
len
,
C
ursor
.
y
,
0
,
aColor
);
GRLine
(
&
m_ClipBox
,
aDC
,
Cursor
.
x
,
C
ursor
.
y
-
len
,
Cursor
.
x
,
C
ursor
.
y
+
len
,
0
,
aColor
);
GRLine
(
&
m_ClipBox
,
aDC
,
cursor
.
x
-
len
,
c
ursor
.
y
,
cursor
.
x
+
len
,
c
ursor
.
y
,
0
,
aColor
);
GRLine
(
&
m_ClipBox
,
aDC
,
cursor
.
x
,
c
ursor
.
y
-
len
,
cursor
.
x
,
c
ursor
.
y
+
len
,
0
,
aColor
);
}
}
...
...
@@ -469,7 +475,7 @@ void EDA_DRAW_PANEL::EraseScreen( wxDC* DC )
m_ClipBox
.
GetRight
(),
m_ClipBox
.
GetBottom
(),
0
,
g_DrawBgColor
,
g_DrawBgColor
);
/
* Set to one (1) to draw bounding box validate bounding box calculation. */
/
/ Set to one (1) to draw bounding box validate bounding box calculation.
#if DEBUG_SHOW_CLIP_RECT
EDA_RECT
bBox
=
m_ClipBox
;
GRRect
(
NULL
,
DC
,
bBox
.
GetOrigin
().
x
,
bBox
.
GetOrigin
().
y
,
...
...
@@ -823,7 +829,7 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event )
wxRect
rect
=
wxRect
(
wxPoint
(
0
,
0
),
GetClientSize
()
);
/
* Ignore scroll events if the cursor is outside the drawing area. */
/
/ Ignore scroll events if the cursor is outside the drawing area.
if
(
event
.
GetWheelRotation
()
==
0
||
!
GetParent
()
->
IsEnabled
()
||
!
rect
.
Contains
(
event
.
GetPosition
()
)
)
{
...
...
@@ -937,12 +943,12 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if
(
event
.
MiddleDown
()
)
localbutt
=
GR_M_MIDDLE_DOWN
;
localrealbutt
|=
localbutt
;
/
* compensation default wxGTK */
localrealbutt
|=
localbutt
;
/
/ compensation default wxGTK
INSTALL_UNBUFFERED_DC
(
DC
,
this
);
DC
.
SetBackground
(
*
wxBLACK_BRUSH
);
/
* Compute the cursor position in drawing (logical) units. */
/
/ Compute the cursor position in drawing (logical) units.
screen
->
SetMousePosition
(
event
.
GetLogicalPosition
(
DC
)
);
int
kbstat
=
0
;
...
...
@@ -1101,7 +1107,7 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
GetEventHandler
()
->
ProcessEvent
(
cmd
);
}
/
* Calling the general function on mouse changes (and pseudo key commands) */
/
/ Calling the general function on mouse changes (and pseudo key commands)
GetParent
()
->
GeneralControl
(
&
DC
,
event
.
GetLogicalPosition
(
DC
),
0
);
/*******************************/
...
...
@@ -1165,17 +1171,16 @@ void EDA_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
if
(
!
m_enableMiddleButtonPan
&&
event
.
MiddleIsDown
()
)
cmd_type
|=
MOUSE_MIDDLE
;
/* A block command is started if the drag is enough. A small
* drag is ignored (it is certainly a little mouse move when
* clicking) not really a drag mouse
*/
// A block command is started if the drag is enough. A small
// drag is ignored (it is certainly a little mouse move when
// clicking) not really a drag mouse
if
(
MinDragEventCount
<
MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND
)
MinDragEventCount
++
;
else
{
if
(
!
GetParent
()
->
HandleBlockBegin
(
&
DC
,
cmd_type
,
m_CursorStartPos
)
)
{
// should not occur
s
: error
// should not occur: error
GetParent
()
->
DisplayToolMsg
(
wxT
(
"EDA_DRAW_PANEL::OnMouseEvent() Block Error"
)
);
}
...
...
@@ -1264,8 +1269,8 @@ void EDA_DRAW_PANEL::OnKeyEvent( wxKeyEvent& event )
switch
(
localkey
)
{
default
:
break
;
default
:
break
;
case
WXK_ESCAPE
:
m_abortRequest
=
true
;
...
...
common/eda_text.cpp
View file @
f3503723
...
...
@@ -37,11 +37,7 @@
// Conversion to application internal units defined at build time.
#if defined( PCBNEW )
#include <class_board_item.h>
#if defined( USE_PCBNEW_NANOMETRES )
#define MILS_TO_IU( x ) ( x * 25400 );
#else
#define MILS_TO_IU( x ) ( x * 10 )
#endif
#define MILS_TO_IU( x ) ( x * IU_PER_MILS );
#elif defined( EESCHEMA )
#include <sch_item_struct.h>
#define MILS_TO_IU( x ) ( x )
...
...
common/zoom.cpp
View file @
f3503723
...
...
@@ -52,15 +52,13 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
m_canvas
->
Refresh
();
m_canvas
->
Update
();
}
}
/** Redraw the screen with best zoom level and the best centering
* that shows all the page or the board
*/
void
EDA_DRAW_FRAME
::
Zoom_Automatique
(
bool
aWarpPointer
)
{
BASE_SCREEN
*
screen
=
GetScreen
();
BASE_SCREEN
*
screen
=
GetScreen
();
screen
->
SetZoom
(
BestZoom
()
);
// Set the best zoom and get center point.
if
(
screen
->
m_FirstRedraw
)
...
...
@@ -76,16 +74,15 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
*/
void
EDA_DRAW_FRAME
::
Window_Zoom
(
EDA_RECT
&
Rect
)
{
double
scalex
,
bestscale
;
wxSize
size
;
/* Compute the best zoom */
// Compute the best zoom
Rect
.
Normalize
();
size
=
m_canvas
->
GetClientSize
();
wxSize
size
=
m_canvas
->
GetClientSize
();
// Use ceil to at least show the full rect
scalex
=
(
double
)
Rect
.
GetSize
().
x
/
size
.
x
;
bestscale
=
(
double
)
Rect
.
GetSize
().
y
/
size
.
y
;
double
scalex
=
(
double
)
Rect
.
GetSize
().
x
/
size
.
x
;
double
bestscale
=
(
double
)
Rect
.
GetSize
().
y
/
size
.
y
;
bestscale
=
MAX
(
bestscale
,
scalex
);
GetScreen
()
->
SetScalingFactor
(
bestscale
);
...
...
@@ -102,7 +99,6 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
if
(
m_canvas
==
NULL
)
return
;
int
i
;
int
id
=
event
.
GetId
();
bool
zoom_at_cursor
=
false
;
BASE_SCREEN
*
screen
=
GetScreen
();
...
...
@@ -151,9 +147,11 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break
;
default
:
unsigned
i
;
i
=
id
-
ID_POPUP_ZOOM_LEVEL_START
;
if
(
(
i
<
0
)
||
(
(
size_t
)
i
>=
screen
->
m_ZoomList
.
GetCount
()
)
)
if
(
i
>=
screen
->
m_ZoomList
.
GetCount
(
)
)
{
wxLogDebug
(
wxT
(
"%s %d: index %d is outside the bounds of the zoom list."
),
__TFILE__
,
__LINE__
,
i
);
...
...
@@ -175,7 +173,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
int
maxZoomIds
;
int
zoom
;
wxString
msg
;
BASE_SCREEN
*
screen
=
m_canvas
->
GetScreen
();
BASE_SCREEN
*
screen
=
m_canvas
->
GetScreen
();
msg
=
AddHotkeyName
(
_
(
"Center"
),
m_HotkeysZoomAndGridList
,
HK_ZOOM_CENTER
);
AddMenuItem
(
MasterMenu
,
ID_POPUP_ZOOM_CENTER
,
msg
,
KiBitmap
(
zoom_center_on_screen_xpm
)
);
...
...
@@ -199,7 +197,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
maxZoomIds
=
(
(
size_t
)
maxZoomIds
<
screen
->
m_ZoomList
.
GetCount
()
)
?
maxZoomIds
:
screen
->
m_ZoomList
.
GetCount
();
/
* Populate zoom submenu. */
/
/ Populate zoom submenu.
for
(
int
i
=
0
;
i
<
maxZoomIds
;
i
++
)
{
msg
.
Printf
(
wxT
(
"%g"
),
screen
->
m_ZoomList
[
i
]
);
...
...
@@ -210,7 +208,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
zoom_choice
->
Check
(
ID_POPUP_ZOOM_LEVEL_START
+
i
,
true
);
}
/
* Create grid submenu as required. */
/
/ Create grid submenu as required.
if
(
screen
->
GetGridCount
()
)
{
wxMenu
*
gridMenu
=
new
wxMenu
;
...
...
cvpcb/CMakeLists.txt
View file @
f3503723
...
...
@@ -26,6 +26,7 @@ set(CVPCB_DIALOGS
)
set
(
CVPCB_SRCS
../common/base_units.cpp
../pcbnew/netlist_reader_common.cpp
../pcbnew/netlist_reader_kicad.cpp
../pcbnew/netlist_reader_firstformat.cpp
...
...
eeschema/class_drc_erc_item.cpp
View file @
f3503723
...
...
@@ -30,6 +30,7 @@
#include <class_drc_item.h>
#include <erc.h>
#include <base_units.h>
wxString
DRC_ITEM
::
GetErrorText
()
const
{
...
...
@@ -57,14 +58,9 @@ wxString DRC_ITEM::GetErrorText() const
}
}
wxString
DRC_ITEM
::
ShowCoord
(
const
wxPoint
&
aPos
)
{
wxString
ret
;
wxPoint
pos_in_pcb_units
=
aPos
;
pos_in_pcb_units
.
x
*=
10
;
pos_in_pcb_units
.
y
*=
10
;
ret
<<
pos_in_pcb_units
;
ret
<<
aPos
;
return
ret
;
}
eeschema/dialogs/dialog_SVG_print.cpp
View file @
f3503723
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eeschema/dialogs/dialog_SVG_print.cpp
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <gestfich.h>
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <dcsvg.h>
#include <base_units.h>
#include <general.h>
#include <libeditframe.h>
#include <sch_sheet_path.h>
#include <dialog_SVG_print.h>
// Keys for configuration
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
#define WIDTH_MAX_VALUE 100
#define WIDTH_MIN_VALUE 1
// Variables locales
static
bool
s_Print_Frame_Ref
=
true
;
static
int
s_PlotBlackAndWhite
=
0
;
/*!
* DIALOG_SVG_PRINT functions
*/
DIALOG_SVG_PRINT
::
DIALOG_SVG_PRINT
(
EDA_DRAW_FRAME
*
parent
)
:
DIALOG_SVG_PRINT_base
(
parent
)
{
m_Parent
=
parent
;
m_Config
=
wxGetApp
().
GetSettings
();
}
void
DIALOG_SVG_PRINT
::
OnInitDialog
(
wxInitDialogEvent
&
event
)
{
SetFocus
();
// Make ESC key working
if
(
m_Config
)
{
m_Config
->
Read
(
PLOTSVGMODECOLOR_KEY
,
&
s_PlotBlackAndWhite
);
}
m_ModeColorOption
->
SetSelection
(
s_PlotBlackAndWhite
);
AddUnitSymbol
(
*
m_TextPenWidth
,
g_UserUnit
);
m_DialogPenWidth
->
SetValue
(
ReturnStringFromValue
(
g_UserUnit
,
g_DrawDefaultLineThickness
)
);
m_Print_Sheet_Ref
->
SetValue
(
s_Print_Frame_Ref
);
if
(
GetSizer
()
)
{
GetSizer
()
->
SetSizeHints
(
this
);
}
}
void
DIALOG_SVG_PRINT
::
SetPenWidth
()
{
g_DrawDefaultLineThickness
=
ReturnValueFromTextCtrl
(
*
m_DialogPenWidth
);
if
(
g_DrawDefaultLineThickness
>
WIDTH_MAX_VALUE
)
{
g_DrawDefaultLineThickness
=
WIDTH_MAX_VALUE
;
}
if
(
g_DrawDefaultLineThickness
<
WIDTH_MIN_VALUE
)
{
g_DrawDefaultLineThickness
=
WIDTH_MIN_VALUE
;
}
m_DialogPenWidth
->
SetValue
(
ReturnStringFromValue
(
g_UserUnit
,
g_DrawDefaultLineThickness
)
);
}
void
DIALOG_SVG_PRINT
::
PrintSVGDoc
(
bool
aPrintAll
,
bool
aPrint_Sheet_Ref
)
{
wxString
msg
;
wxFileName
fn
;
SetPenWidth
();
g_DrawDefaultLineThickness
=
ReturnValueFromTextCtrl
(
*
m_DialogPenWidth
);
SCH_SCREEN
*
screen
=
(
SCH_SCREEN
*
)
m_Parent
->
GetScreen
();
if
(
aPrintAll
&&
m_Parent
->
IsType
(
SCHEMATIC_FRAME
)
)
{
SCH_EDIT_FRAME
*
schframe
=
(
SCH_EDIT_FRAME
*
)
m_Parent
;
SCH_SHEET_PATH
*
sheetpath
;
SCH_SHEET_PATH
oldsheetpath
=
schframe
->
GetCurrentSheet
();
SCH_SCREEN
*
schscreen
=
schframe
->
GetScreen
();
SCH_SHEET_LIST
SheetList
(
NULL
);
sheetpath
=
SheetList
.
GetFirst
();
SCH_SHEET_PATH
list
;
for
(
;
;
)
{
if
(
sheetpath
==
NULL
)
break
;
list
.
Clear
();
if
(
list
.
BuildSheetPathInfoFromSheetPathValue
(
sheetpath
->
Path
()
)
)
{
schframe
->
SetCurrentSheet
(
list
);
schframe
->
GetCurrentSheet
().
UpdateAllScreenReferences
();
schframe
->
SetSheetNumberAndCount
();
schscreen
=
schframe
->
GetCurrentSheet
().
LastScreen
();
}
else
// Should not happen
return
;
sheetpath
=
SheetList
.
GetNext
();
fn
=
schframe
->
GetUniqueFilenameForCurrentSheet
()
+
wxT
(
".svg"
);
bool
success
=
DrawSVGPage
(
m_Parent
,
fn
.
GetFullPath
(),
(
SCH_SCREEN
*
)
schscreen
,
m_ModeColorOption
->
GetSelection
()
==
0
?
false
:
true
,
aPrint_Sheet_Ref
);
msg
=
_
(
"Create file "
)
+
fn
.
GetFullPath
();
if
(
!
success
)
msg
+=
_
(
" error"
);
msg
+=
wxT
(
"
\n
"
);
m_MessagesBox
->
AppendText
(
msg
);
}
schframe
->
SetCurrentSheet
(
oldsheetpath
);
schframe
->
GetCurrentSheet
().
UpdateAllScreenReferences
();
schframe
->
SetSheetNumberAndCount
();
}
else
{
fn
=
m_FileNameCtrl
->
GetValue
();
if
(
!
fn
.
IsOk
()
)
fn
=
screen
->
GetFileName
();
fn
.
SetExt
(
wxT
(
"svg"
)
);
fn
.
MakeAbsolute
();
bool
success
=
DrawSVGPage
(
m_Parent
,
fn
.
GetFullPath
(),
(
SCH_SCREEN
*
)
screen
,
m_ModeColorOption
->
GetSelection
()
==
0
?
false
:
true
,
aPrint_Sheet_Ref
);
msg
=
_
(
"Create file "
)
+
fn
.
GetFullPath
();
if
(
!
success
)
msg
+=
_
(
" error"
);
msg
+=
wxT
(
"
\n
"
);
m_MessagesBox
->
AppendText
(
msg
);
}
}
bool
DIALOG_SVG_PRINT
::
DrawSVGPage
(
EDA_DRAW_FRAME
*
frame
,
const
wxString
&
FullFileName
,
SCH_SCREEN
*
screen
,
bool
aPrintBlackAndWhite
,
bool
aPrint_Sheet_Ref
)
{
int
tmpzoom
;
wxPoint
tmp_startvisu
;
wxSize
sheetSize
;
// Sheet size in internal units
wxPoint
old_org
;
bool
success
=
true
;
tmp_startvisu
=
screen
->
m_StartVisu
;
tmpzoom
=
screen
->
GetZoom
();
old_org
=
screen
->
m_DrawOrg
;
screen
->
m_DrawOrg
.
x
=
screen
->
m_DrawOrg
.
y
=
0
;
screen
->
m_StartVisu
.
x
=
screen
->
m_StartVisu
.
y
=
0
;
sheetSize
=
screen
->
GetPageSettings
().
GetSizeIU
();
// page size in 1/1000 inch, ie in internal units
screen
->
SetScalingFactor
(
1.0
);
EDA_DRAW_PANEL
*
panel
=
frame
->
GetCanvas
();
LOCALE_IO
toggle
;
float
dpi
=
1000.0
;
KicadSVGFileDC
dc
(
FullFileName
,
sheetSize
.
x
,
sheetSize
.
y
,
dpi
);
EDA_RECT
tmp
=
*
panel
->
GetClipBox
();
GRResetPenAndBrush
(
&
dc
);
GRForceBlackPen
(
aPrintBlackAndWhite
);
panel
->
SetClipBox
(
EDA_RECT
(
wxPoint
(
-
0x3FFFFF0
,
-
0x3FFFFF0
),
wxSize
(
0x7FFFFF0
,
0x7FFFFF0
)
)
);
screen
->
m_IsPrinting
=
true
;
if
(
frame
->
IsType
(
SCHEMATIC_FRAME
)
)
screen
->
Draw
(
panel
,
&
dc
,
GR_COPY
);
if
(
frame
->
IsType
(
LIBEDITOR_FRAME
)
)
((
LIB_EDIT_FRAME
*
)
frame
)
->
RedrawComponent
(
&
dc
,
wxPoint
(
sheetSize
.
x
/
2
,
sheetSize
.
y
/
2
)
);
if
(
aPrint_Sheet_Ref
)
frame
->
TraceWorkSheet
(
&
dc
,
screen
,
g_DrawDefaultLineThickness
,
MILS_TO_IU_SCALAR
);
screen
->
m_IsPrinting
=
false
;
panel
->
SetClipBox
(
tmp
);
GRForceBlackPen
(
false
);
screen
->
m_StartVisu
=
tmp_startvisu
;
screen
->
m_DrawOrg
=
old_org
;
screen
->
SetZoom
(
tmpzoom
);
return
success
;
}
void
DIALOG_SVG_PRINT
::
OnButtonPlotAllClick
(
wxCommandEvent
&
event
)
{
PrintSVGDoc
(
true
,
m_Print_Sheet_Ref
->
GetValue
()
);
}
void
DIALOG_SVG_PRINT
::
OnButtonPlotCurrentClick
(
wxCommandEvent
&
event
)
{
PrintSVGDoc
(
false
,
m_Print_Sheet_Ref
->
GetValue
()
);
}
void
DIALOG_SVG_PRINT
::
OnButtonCancelClick
(
wxCommandEvent
&
event
)
{
Close
();
}
void
DIALOG_SVG_PRINT
::
OnCloseWindow
(
wxCloseEvent
&
event
)
{
if
(
m_Config
)
{
s_PlotBlackAndWhite
=
m_ModeColorOption
->
GetSelection
();
m_Config
->
Write
(
PLOTSVGMODECOLOR_KEY
,
s_PlotBlackAndWhite
);
}
EndModal
(
0
);
}
/* called on radiobox color/black and white selection
*/
void
DIALOG_SVG_PRINT
::
OnSetColorModeSelected
(
wxCommandEvent
&
event
)
{
s_PlotBlackAndWhite
=
m_ModeColorOption
->
GetSelection
();
}
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eeschema/dialogs/dialog_SVG_print.cpp
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <gestfich.h>
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <dcsvg.h>
#include <base_units.h>
#include <general.h>
#include <libeditframe.h>
#include <sch_sheet_path.h>
#include <dialog_SVG_print.h>
// Keys for configuration
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
#define WIDTH_MAX_VALUE 100
#define WIDTH_MIN_VALUE 1
// Variables locales
static
bool
s_Print_Frame_Ref
=
true
;
static
int
s_PlotBlackAndWhite
=
0
;
/*!
* DIALOG_SVG_PRINT functions
*/
DIALOG_SVG_PRINT
::
DIALOG_SVG_PRINT
(
EDA_DRAW_FRAME
*
parent
)
:
DIALOG_SVG_PRINT_base
(
parent
)
{
m_Parent
=
parent
;
m_Config
=
wxGetApp
().
GetSettings
();
}
void
DIALOG_SVG_PRINT
::
OnInitDialog
(
wxInitDialogEvent
&
event
)
{
SetFocus
();
// Make ESC key working
if
(
m_Config
)
{
m_Config
->
Read
(
PLOTSVGMODECOLOR_KEY
,
&
s_PlotBlackAndWhite
);
}
m_ModeColorOption
->
SetSelection
(
s_PlotBlackAndWhite
);
AddUnitSymbol
(
*
m_TextPenWidth
,
g_UserUnit
);
m_DialogPenWidth
->
SetValue
(
ReturnStringFromValue
(
g_UserUnit
,
g_DrawDefaultLineThickness
)
);
m_Print_Sheet_Ref
->
SetValue
(
s_Print_Frame_Ref
);
if
(
GetSizer
()
)
{
GetSizer
()
->
SetSizeHints
(
this
);
}
}
void
DIALOG_SVG_PRINT
::
SetPenWidth
()
{
g_DrawDefaultLineThickness
=
ReturnValueFromTextCtrl
(
*
m_DialogPenWidth
);
if
(
g_DrawDefaultLineThickness
>
WIDTH_MAX_VALUE
)
{
g_DrawDefaultLineThickness
=
WIDTH_MAX_VALUE
;
}
if
(
g_DrawDefaultLineThickness
<
WIDTH_MIN_VALUE
)
{
g_DrawDefaultLineThickness
=
WIDTH_MIN_VALUE
;
}
m_DialogPenWidth
->
SetValue
(
ReturnStringFromValue
(
g_UserUnit
,
g_DrawDefaultLineThickness
)
);
}
void
DIALOG_SVG_PRINT
::
PrintSVGDoc
(
bool
aPrintAll
,
bool
aPrint_Sheet_Ref
)
{
wxString
msg
;
wxFileName
fn
;
SetPenWidth
();
g_DrawDefaultLineThickness
=
ReturnValueFromTextCtrl
(
*
m_DialogPenWidth
);
SCH_SCREEN
*
screen
=
(
SCH_SCREEN
*
)
m_Parent
->
GetScreen
();
if
(
aPrintAll
&&
m_Parent
->
IsType
(
SCHEMATIC_FRAME
)
)
{
SCH_EDIT_FRAME
*
schframe
=
(
SCH_EDIT_FRAME
*
)
m_Parent
;
SCH_SHEET_PATH
*
sheetpath
;
SCH_SHEET_PATH
oldsheetpath
=
schframe
->
GetCurrentSheet
();
SCH_SCREEN
*
schscreen
=
schframe
->
GetScreen
();
SCH_SHEET_LIST
SheetList
(
NULL
);
sheetpath
=
SheetList
.
GetFirst
();
SCH_SHEET_PATH
list
;
for
(
;
;
)
{
if
(
sheetpath
==
NULL
)
break
;
list
.
Clear
();
if
(
list
.
BuildSheetPathInfoFromSheetPathValue
(
sheetpath
->
Path
()
)
)
{
schframe
->
SetCurrentSheet
(
list
);
schframe
->
GetCurrentSheet
().
UpdateAllScreenReferences
();
schframe
->
SetSheetNumberAndCount
();
schscreen
=
schframe
->
GetCurrentSheet
().
LastScreen
();
}
else
// Should not happen
return
;
sheetpath
=
SheetList
.
GetNext
();
fn
=
schframe
->
GetUniqueFilenameForCurrentSheet
()
+
wxT
(
".svg"
);
bool
success
=
DrawSVGPage
(
m_Parent
,
fn
.
GetFullPath
(),
(
SCH_SCREEN
*
)
schscreen
,
m_ModeColorOption
->
GetSelection
()
==
0
?
false
:
true
,
aPrint_Sheet_Ref
);
msg
=
_
(
"Create file "
)
+
fn
.
GetFullPath
();
if
(
!
success
)
msg
+=
_
(
" error"
);
msg
+=
wxT
(
"
\n
"
);
m_MessagesBox
->
AppendText
(
msg
);
}
schframe
->
SetCurrentSheet
(
oldsheetpath
);
schframe
->
GetCurrentSheet
().
UpdateAllScreenReferences
();
schframe
->
SetSheetNumberAndCount
();
}
else
{
fn
=
m_FileNameCtrl
->
GetValue
();
if
(
!
fn
.
IsOk
()
)
fn
=
screen
->
GetFileName
();
fn
.
SetExt
(
wxT
(
"svg"
)
);
fn
.
MakeAbsolute
();
bool
success
=
DrawSVGPage
(
m_Parent
,
fn
.
GetFullPath
(),
(
SCH_SCREEN
*
)
screen
,
m_ModeColorOption
->
GetSelection
()
==
0
?
false
:
true
,
aPrint_Sheet_Ref
);
msg
=
_
(
"Create file "
)
+
fn
.
GetFullPath
();
if
(
!
success
)
msg
+=
_
(
" error"
);
msg
+=
wxT
(
"
\n
"
);
m_MessagesBox
->
AppendText
(
msg
);
}
}
bool
DIALOG_SVG_PRINT
::
DrawSVGPage
(
EDA_DRAW_FRAME
*
frame
,
const
wxString
&
FullFileName
,
SCH_SCREEN
*
screen
,
bool
aPrintBlackAndWhite
,
bool
aPrint_Sheet_Ref
)
{
int
tmpzoom
;
wxPoint
tmp_startvisu
;
wxSize
sheetSize
;
// Sheet size in internal units
wxPoint
old_org
;
bool
success
=
true
;
tmp_startvisu
=
screen
->
m_StartVisu
;
tmpzoom
=
screen
->
GetZoom
();
old_org
=
screen
->
m_DrawOrg
;
screen
->
m_DrawOrg
.
x
=
screen
->
m_DrawOrg
.
y
=
0
;
screen
->
m_StartVisu
.
x
=
screen
->
m_StartVisu
.
y
=
0
;
sheetSize
=
screen
->
GetPageSettings
().
GetSizeIU
();
// page size in 1/1000 inch, ie in internal units
screen
->
SetScalingFactor
(
1.0
);
EDA_DRAW_PANEL
*
panel
=
frame
->
GetCanvas
();
LOCALE_IO
toggle
;
float
dpi
=
1000.0
;
KicadSVGFileDC
dc
(
FullFileName
,
sheetSize
.
x
,
sheetSize
.
y
,
dpi
);
EDA_RECT
tmp
=
*
panel
->
GetClipBox
();
GRResetPenAndBrush
(
&
dc
);
GRForceBlackPen
(
aPrintBlackAndWhite
);
panel
->
SetClipBox
(
EDA_RECT
(
wxPoint
(
-
0x3FFFFF0
,
-
0x3FFFFF0
),
wxSize
(
0x7FFFFF0
,
0x7FFFFF0
)
)
);
screen
->
m_IsPrinting
=
true
;
if
(
frame
->
IsType
(
SCHEMATIC_FRAME
)
)
screen
->
Draw
(
panel
,
&
dc
,
GR_COPY
);
if
(
frame
->
IsType
(
LIBEDITOR_FRAME
)
)
((
LIB_EDIT_FRAME
*
)
frame
)
->
RedrawComponent
(
&
dc
,
wxPoint
(
sheetSize
.
x
/
2
,
sheetSize
.
y
/
2
)
);
if
(
aPrint_Sheet_Ref
)
frame
->
TraceWorkSheet
(
&
dc
,
screen
,
g_DrawDefaultLineThickness
,
IU_PER_MILS
);
screen
->
m_IsPrinting
=
false
;
panel
->
SetClipBox
(
tmp
);
GRForceBlackPen
(
false
);
screen
->
m_StartVisu
=
tmp_startvisu
;
screen
->
m_DrawOrg
=
old_org
;
screen
->
SetZoom
(
tmpzoom
);
return
success
;
}
void
DIALOG_SVG_PRINT
::
OnButtonPlotAllClick
(
wxCommandEvent
&
event
)
{
PrintSVGDoc
(
true
,
m_Print_Sheet_Ref
->
GetValue
()
);
}
void
DIALOG_SVG_PRINT
::
OnButtonPlotCurrentClick
(
wxCommandEvent
&
event
)
{
PrintSVGDoc
(
false
,
m_Print_Sheet_Ref
->
GetValue
()
);
}
void
DIALOG_SVG_PRINT
::
OnButtonCancelClick
(
wxCommandEvent
&
event
)
{
Close
();
}
void
DIALOG_SVG_PRINT
::
OnCloseWindow
(
wxCloseEvent
&
event
)
{
if
(
m_Config
)
{
s_PlotBlackAndWhite
=
m_ModeColorOption
->
GetSelection
();
m_Config
->
Write
(
PLOTSVGMODECOLOR_KEY
,
s_PlotBlackAndWhite
);
}
EndModal
(
0
);
}
/* called on radiobox color/black and white selection
*/
void
DIALOG_SVG_PRINT
::
OnSetColorModeSelected
(
wxCommandEvent
&
event
)
{
s_PlotBlackAndWhite
=
m_ModeColorOption
->
GetSelection
();
}
eeschema/dialogs/dialog_print_using_printer.cpp
View file @
f3503723
...
...
@@ -378,7 +378,7 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen
->
Draw
(
panel
,
dc
,
GR_DEFAULT_DRAWMODE
);
if
(
printReference
)
parent
->
TraceWorkSheet
(
dc
,
aScreen
,
g_DrawDefaultLineThickness
,
MILS_TO_IU_SCALAR
);
parent
->
TraceWorkSheet
(
dc
,
aScreen
,
g_DrawDefaultLineThickness
,
IU_PER_MILS
);
g_DrawBgColor
=
bg_color
;
aScreen
->
m_IsPrinting
=
false
;
...
...
eeschema/eeredraw.cpp
View file @
f3503723
...
...
@@ -71,7 +71,7 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GetScreen
()
->
Draw
(
m_canvas
,
DC
,
GR_DEFAULT_DRAWMODE
);
TraceWorkSheet
(
DC
,
GetScreen
(),
g_DrawDefaultLineThickness
,
MILS_TO_IU_SCALAR
);
TraceWorkSheet
(
DC
,
GetScreen
(),
g_DrawDefaultLineThickness
,
IU_PER_MILS
);
#ifdef USE_WX_OVERLAY
if
(
IsShown
()
)
...
...
eeschema/schframe.cpp
View file @
f3503723
...
...
@@ -863,7 +863,7 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
void
SCH_EDIT_FRAME
::
PrintPage
(
wxDC
*
aDC
,
int
aPrintMask
,
bool
aPrintMirrorMode
,
void
*
aData
)
{
GetScreen
()
->
Draw
(
m_canvas
,
aDC
,
GR_DEFAULT_DRAWMODE
);
TraceWorkSheet
(
aDC
,
GetScreen
(),
g_DrawDefaultLineThickness
,
MILS_TO_IU_SCALAR
);
TraceWorkSheet
(
aDC
,
GetScreen
(),
g_DrawDefaultLineThickness
,
IU_PER_MILS
);
}
...
...
gerbview/CMakeLists.txt
View file @
f3503723
...
...
@@ -33,6 +33,7 @@ set(GERBVIEW_SRCS
class_am_param.cpp
class_aperture_macro.cpp
class_DCodeSelectionbox.cpp
class_gbr_screen.cpp
class_GERBER.cpp
class_gerber_draw_item.cpp
class_gerbview_layer_widget.cpp
...
...
@@ -63,9 +64,10 @@ set(GERBVIEW_SRCS
)
###
# We need some extra sources from pcbnew
# We need some extra sources from
common and
pcbnew
###
set
(
GERBVIEW_EXTRA_SRCS
../common/base_units.cpp
../pcbnew/layer_widget.cpp
../pcbnew/printout_controler.cpp
../pcbnew/class_drc_item.cpp
...
...
gerbview/class_gbr_screen.cpp
0 → 100644
View file @
f3503723
/**
* @file classpcb.cpp
* @brief Member functions of classes used in Pcbnew (see pcbstruct.h)
* except for tracks (see class_track.cpp).
*/
#include <fctsys.h>
#include <common.h>
#include <macros.h>
#include <class_gbr_screen.h>
#include <base_units.h>
#include <pcbnew.h>
#include <class_board_design_settings.h>
#include <layers_id_colors_and_visibility.h>
#include <pcbnew_id.h>
#define DMIL_GRID( x ) wxRealPoint( x * IU_PER_DECIMILS,\
x * IU_PER_DECIMILS )
#define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\
x * IU_PER_MM )
/**
Default Pcbnew zoom values.
Limited to 19 values to keep a decent size to menus.
Roughly a 1.5 progression.
The last 2 values are handy when somebody uses a library import of a module
(or foreign data) which has a bad coordinate.
Also useful in GerbView for this reason.
Zoom 5 and 10 can create artefacts when drawing (integer overflow in low level graphic
functions )
*/
static
const
double
gbrZoomList
[]
=
{
ZOOM_FACTOR
(
0.5
),
ZOOM_FACTOR
(
1.0
),
ZOOM_FACTOR
(
1.5
),
ZOOM_FACTOR
(
2.0
),
ZOOM_FACTOR
(
3.0
),
ZOOM_FACTOR
(
4.5
),
ZOOM_FACTOR
(
7.0
),
ZOOM_FACTOR
(
10.0
),
ZOOM_FACTOR
(
15.0
),
ZOOM_FACTOR
(
22.0
),
ZOOM_FACTOR
(
35.0
),
ZOOM_FACTOR
(
50.0
),
ZOOM_FACTOR
(
80.0
),
ZOOM_FACTOR
(
120.0
),
ZOOM_FACTOR
(
200.0
),
ZOOM_FACTOR
(
350.0
),
ZOOM_FACTOR
(
500.0
),
ZOOM_FACTOR
(
1000.0
),
ZOOM_FACTOR
(
2000.0
)
};
// Default grid sizes for PCB editor screens.
static
GRID_TYPE
gbrGridList
[]
=
{
// predefined grid list in 0.0001 inches
{
ID_POPUP_GRID_LEVEL_1000
,
DMIL_GRID
(
1000
)
},
{
ID_POPUP_GRID_LEVEL_500
,
DMIL_GRID
(
500
)
},
{
ID_POPUP_GRID_LEVEL_250
,
DMIL_GRID
(
250
)
},
{
ID_POPUP_GRID_LEVEL_200
,
DMIL_GRID
(
200
)
},
{
ID_POPUP_GRID_LEVEL_100
,
DMIL_GRID
(
100
)
},
{
ID_POPUP_GRID_LEVEL_50
,
DMIL_GRID
(
50
)
},
{
ID_POPUP_GRID_LEVEL_25
,
DMIL_GRID
(
25
)
},
{
ID_POPUP_GRID_LEVEL_20
,
DMIL_GRID
(
20
)
},
{
ID_POPUP_GRID_LEVEL_10
,
DMIL_GRID
(
10
)
},
{
ID_POPUP_GRID_LEVEL_5
,
DMIL_GRID
(
5
)
},
{
ID_POPUP_GRID_LEVEL_2
,
DMIL_GRID
(
2
)
},
{
ID_POPUP_GRID_LEVEL_1
,
DMIL_GRID
(
1
)
},
// predefined grid list in mm
{
ID_POPUP_GRID_LEVEL_5MM
,
MM_GRID
(
5.0
)
},
{
ID_POPUP_GRID_LEVEL_2_5MM
,
MM_GRID
(
2.5
)
},
{
ID_POPUP_GRID_LEVEL_1MM
,
MM_GRID
(
1.0
)
},
{
ID_POPUP_GRID_LEVEL_0_5MM
,
MM_GRID
(
0.5
)
},
{
ID_POPUP_GRID_LEVEL_0_25MM
,
MM_GRID
(
0.25
)
},
{
ID_POPUP_GRID_LEVEL_0_2MM
,
MM_GRID
(
0.2
)
},
{
ID_POPUP_GRID_LEVEL_0_1MM
,
MM_GRID
(
0.1
)
},
{
ID_POPUP_GRID_LEVEL_0_0_5MM
,
MM_GRID
(
0.05
)
},
{
ID_POPUP_GRID_LEVEL_0_0_25MM
,
MM_GRID
(
0.025
)
},
{
ID_POPUP_GRID_LEVEL_0_0_1MM
,
MM_GRID
(
0.01
)
}
};
GBR_SCREEN
::
GBR_SCREEN
(
const
wxSize
&
aPageSizeIU
)
:
PCB_SCREEN
(
aPageSizeIU
)
{
// Replace zoom and grid lists already set by PCB_SCREEN ctor
m_ZoomList
.
Clear
();
for
(
unsigned
i
=
0
;
i
<
DIM
(
gbrZoomList
);
++
i
)
m_ZoomList
.
Add
(
gbrZoomList
[
i
]
);
GRIDS
gridlist
;
for
(
unsigned
i
=
0
;
i
<
DIM
(
gbrGridList
);
++
i
)
gridlist
.
push_back
(
gbrGridList
[
i
]
);
SetGridList
(
gridlist
);
// Set the working grid size to a reasonnable value (in 1/10000 inch)
SetGrid
(
DMIL_GRID
(
500
)
);
m_Active_Layer
=
LAYER_N_BACK
;
// default active layer = bottom layer
SetZoom
(
ZOOM_FACTOR
(
350
)
);
// a default value for zoom
}
GBR_SCREEN
::~
GBR_SCREEN
()
{
}
// virtual function
int
GBR_SCREEN
::
MilsToIuScalar
()
{
return
(
int
)
IU_PER_MILS
;
}
gerbview/class_gbr_screen.h
0 → 100644
View file @
f3503723
/**
* @file class_gbr_screen.h
*/
#ifndef CLASS_GBR_SCREEN_H_
#define CLASS_GBR_SCREEN_H_
#include <base_units.h>
#include <class_pcb_screen.h>
#define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS )
/* Handle info to display a board */
class
GBR_SCREEN
:
public
PCB_SCREEN
{
public
:
/**
* Constructor
* @param aPageSizeIU is the size of the initial paper page in internal units.
*/
GBR_SCREEN
(
const
wxSize
&
aPageSizeIU
);
~
GBR_SCREEN
();
GBR_SCREEN
*
Next
()
{
return
(
GBR_SCREEN
*
)
Pnext
;
}
virtual
int
MilsToIuScalar
();
};
#endif // CLASS_GBR_SCREEN_H_
gerbview/dcode.cpp
View file @
f3503723
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, j
aen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Jean-Pierre Charras, j
ean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
...
...
@@ -175,7 +175,8 @@ int GERBVIEW_FRAME::ReadDCodeDefinitionFile( const wxString& D_Code_FullFileName
/* Updating gerber scale: */
double
dcode_scale
=
MILS_TO_IU_SCALAR
;
// By uniting dCode = mil, internal unit = MILS_TO_IU_SCALAR
double
dcode_scale
=
IU_PER_MILS
;
// By uniting dCode = mil,
// internal unit = IU_PER_MILS
current_Dcode
=
0
;
if
(
D_Code_FullFileName
.
IsEmpty
()
)
...
...
gerbview/draw_gerber_screen.cpp
View file @
f3503723
...
...
@@ -107,7 +107,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if
(
IsElementVisible
(
DCODES_VISIBLE
)
)
DrawItemsDCodeID
(
DC
,
GR_COPY
);
TraceWorkSheet
(
DC
,
screen
,
0
,
MILS_TO_IU_SCALAR
);
TraceWorkSheet
(
DC
,
screen
,
0
,
IU_PER_MILS
);
if
(
m_canvas
->
IsMouseCaptured
()
)
m_canvas
->
CallMouseCapture
(
DC
,
wxDefaultPosition
,
false
);
...
...
gerbview/excellon_read_drill_file.cpp
View file @
f3503723
...
...
@@ -432,7 +432,7 @@ bool EXCELLON_IMAGE::Execute_HEADER_Command( char*& text )
if
(
dcode
==
NULL
)
break
;
// conv_scale = scaling factor from inch to Internal Unit
double
conv_scale
=
MILS_TO_IU_SCALAR
*
1000
;
double
conv_scale
=
IU_PER_MILS
*
1000
;
if
(
m_GerbMetric
)
conv_scale
/=
25.4
;
...
...
gerbview/gerbview_frame.cpp
View file @
f3503723
...
...
@@ -44,6 +44,7 @@
#include <dialog_helpers.h>
#include <class_DCodeSelectionbox.h>
#include <class_gerbview_layer_widget.h>
#include <class_gbr_screen.h>
...
...
@@ -93,7 +94,7 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( wxWindow* father,
PAGE_INFO
pageInfo
(
wxT
(
"GERBER"
)
);
GetBoard
()
->
SetPageSettings
(
pageInfo
);
SetScreen
(
new
PCB
_SCREEN
(
pageInfo
.
GetSizeIU
()
)
);
SetScreen
(
new
GBR
_SCREEN
(
pageInfo
.
GetSizeIU
()
)
);
// Create the PCB_LAYER_WIDGET *after* SetBoard():
wxFont
font
=
wxSystemSettings
::
GetFont
(
wxSYS_DEFAULT_GUI_FONT
);
...
...
@@ -179,7 +180,7 @@ double GERBVIEW_FRAME::BestZoom()
{
// gives a minimal value to zoom, if no item in list
if
(
GetBoard
()
->
m_Drawings
==
NULL
)
return
160.0
;
return
ZOOM_FACTOR
(
160.0
)
;
EDA_RECT
bbox
;
BOARD_ITEM
*
item
=
GetBoard
()
->
m_Drawings
;
...
...
@@ -210,7 +211,8 @@ void GERBVIEW_FRAME::LoadSettings()
if
(
config
==
NULL
)
return
;
PCB_BASE_FRAME
::
LoadSettings
();
// PCB_BASE_FRAME::LoadSettings();
EDA_DRAW_FRAME
::
LoadSettings
();
wxGetApp
().
ReadCurrentSetupValues
(
GetConfigurationSettings
()
);
...
...
@@ -255,7 +257,8 @@ void GERBVIEW_FRAME::SaveSettings()
if
(
config
==
NULL
)
return
;
PCB_BASE_FRAME
::
SaveSettings
();
// PCB_BASE_FRAME::SaveSettings();
EDA_DRAW_FRAME
::
SaveSettings
();
wxGetApp
().
SaveCurrentSetupValues
(
GetConfigurationSettings
()
);
...
...
@@ -408,7 +411,7 @@ void GERBVIEW_FRAME::Liste_D_Codes()
D_CODE
*
pt_D_code
;
wxString
Line
;
wxArrayString
list
;
double
scale
=
MILS_TO_IU_SCALAR
*
1000
;
double
scale
=
IU_PER_MILS
*
1000
;
int
curr_layer
=
getActiveLayer
();
for
(
int
layer
=
0
;
layer
<
32
;
layer
++
)
...
...
gerbview/gerbview_frame.h
View file @
f3503723
...
...
@@ -35,6 +35,7 @@
#include <wxBasePcbFrame.h>
#include <../pcbnew/class_board.h>
#include <class_gbr_screen.h>
class
DCODE_SELECTION_BOX
;
...
...
@@ -53,7 +54,6 @@ class GERBER_DRAW_ITEM;
class
GERBVIEW_FRAME
:
public
PCB_BASE_FRAME
{
friend
class
PCB_LAYER_WIDGET
;
protected
:
GERBER_LAYER_WIDGET
*
m_LayersManager
;
...
...
@@ -62,7 +62,7 @@ protected:
wxFileHistory
m_drillFileHistory
;
public
:
LAYER_BOX_SELECTOR
*
m_SelLayerBox
;
LAYER_BOX_SELECTOR
*
m_SelLayerBox
;
DCODE_SELECTION_BOX
*
m_DCodeSelector
;
// a list box to select the dcode Id to highlight.
wxTextCtrl
*
m_TextInfo
;
// a wxTextCtrl used to display some info about
// gerber data (format..)
...
...
@@ -84,7 +84,7 @@ private:
bool
m_show_layer_manager_tools
;
// An array st
ing to store warning messages when reag
ing a gerber file.
// An array st
ring to store warning messages when read
ing a gerber file.
wxArrayString
m_Messages
;
public
:
GERBVIEW_FRAME
(
wxWindow
*
father
,
const
wxString
&
title
,
...
...
@@ -226,7 +226,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
*/
void
setActiveLayer
(
int
aLayer
,
bool
doLayerWidgetUpdate
=
true
)
{
(
(
PCB
_SCREEN
*
)
GetScreen
()
)
->
m_Active_Layer
=
aLayer
;
(
(
GBR
_SCREEN
*
)
GetScreen
()
)
->
m_Active_Layer
=
aLayer
;
if
(
doLayerWidgetUpdate
)
syncLayerWidget
();
...
...
@@ -239,7 +239,7 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
*/
int
getActiveLayer
()
{
return
(
(
PCB
_SCREEN
*
)
GetScreen
()
)
->
m_Active_Layer
;
return
(
(
GBR
_SCREEN
*
)
GetScreen
()
)
->
m_Active_Layer
;
}
...
...
@@ -440,8 +440,6 @@ public: GERBVIEW_FRAME( wxWindow* father, const wxString& title,
*/
void
Block_Duplicate
(
wxDC
*
DC
);
void
ToPostProcess
(
wxCommandEvent
&
event
);
/**
* Function ToPlotter
* Open a dialog frame to create plot and drill files
...
...
gerbview/onleftclick.cpp
View file @
f3503723
...
...
@@ -21,7 +21,7 @@
*/
void
GERBVIEW_FRAME
::
OnLeftClick
(
wxDC
*
DC
,
const
wxPoint
&
aPosition
)
{
BOARD
_ITEM
*
DrawStruct
=
GetScreen
()
->
GetCurItem
();
EDA
_ITEM
*
DrawStruct
=
GetScreen
()
->
GetCurItem
();
wxString
msg
;
if
(
GetToolId
()
==
ID_NO_TOOL_SELECTED
)
...
...
@@ -36,7 +36,7 @@ void GERBVIEW_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition )
else
{
DrawStruct
=
Locate
(
aPosition
,
CURSEUR_OFF_GRILLE
);
GetScreen
()
->
SetCurItem
(
DrawStruct
);
GetScreen
()
->
SetCurItem
(
(
BOARD_ITEM
*
)
DrawStruct
);
if
(
DrawStruct
==
NULL
)
{
GERBER_IMAGE
*
gerber
=
g_GERBER_List
[
getActiveLayer
()
];
...
...
gerbview/onrightclick.cpp
View file @
f3503723
...
...
@@ -16,7 +16,7 @@
*/
bool
GERBVIEW_FRAME
::
OnRightClick
(
const
wxPoint
&
aPosition
,
wxMenu
*
PopMenu
)
{
BOARD
_ITEM
*
DrawStruct
=
GetScreen
()
->
GetCurItem
();
EDA
_ITEM
*
DrawStruct
=
GetScreen
()
->
GetCurItem
();
wxString
msg
;
bool
BlockActive
=
!
GetScreen
()
->
m_BlockLocate
.
IsIdle
();
bool
busy
=
DrawStruct
&&
DrawStruct
->
GetFlags
();
...
...
@@ -71,7 +71,7 @@ bool GERBVIEW_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return
true
;
if
(
DrawStruct
)
GetScreen
()
->
SetCurItem
(
DrawStruct
);
GetScreen
()
->
SetCurItem
(
(
BOARD_ITEM
*
)
DrawStruct
);
return
true
;
}
gerbview/options.cpp
View file @
f3503723
...
...
@@ -36,28 +36,20 @@ void GERBVIEW_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
case
ID_TB_OPTIONS_SHOW_FLASHED_ITEMS_SKETCH
:
if
(
state
)
{
DisplayOpt
.
DisplayPadFill
=
m_DisplayPadFill
=
false
;
}
DisplayOpt
.
DisplayPadFill
=
false
;
else
{
DisplayOpt
.
DisplayPadFill
=
m_DisplayPadFill
=
true
;
}
DisplayOpt
.
DisplayPadFill
=
true
;
m_DisplayPadFill
=
DisplayOpt
.
DisplayPadFill
;
m_canvas
->
Refresh
(
true
);
break
;
case
ID_TB_OPTIONS_SHOW_LINES_SKETCH
:
if
(
state
)
{
m_DisplayPcbTrackFill
=
false
;
DisplayOpt
.
DisplayPcbTrackFill
=
false
;
}
else
{
m_DisplayPcbTrackFill
=
true
;
DisplayOpt
.
DisplayPcbTrackFill
=
true
;
}
m_DisplayPcbTrackFill
=
DisplayOpt
.
DisplayPcbTrackFill
;
m_canvas
->
Refresh
(
true
);
break
;
...
...
gerbview/rs274_read_XY_and_IJ_coordinates.cpp
View file @
f3503723
...
...
@@ -21,16 +21,16 @@
// for metric gerber units, the imperial to metric conversion is made in read functions
static
double
scale_list
[
10
]
=
{
1000.0
*
MILS_TO_IU_SCALAR
,
100.0
*
MILS_TO_IU_SCALAR
,
10.0
*
MILS_TO_IU_SCALAR
,
1.0
*
MILS_TO_IU_SCALAR
,
0.1
*
MILS_TO_IU_SCALAR
,
0.01
*
MILS_TO_IU_SCALAR
,
0.001
*
MILS_TO_IU_SCALAR
,
0.0001
*
MILS_TO_IU_SCALAR
,
0.00001
*
MILS_TO_IU_SCALAR
,
0.000001
*
MILS_TO_IU_SCALAR
1000.0
*
IU_PER_MILS
,
100.0
*
IU_PER_MILS
,
10.0
*
IU_PER_MILS
,
1.0
*
IU_PER_MILS
,
0.1
*
IU_PER_MILS
,
0.01
*
IU_PER_MILS
,
0.001
*
IU_PER_MILS
,
0.0001
*
IU_PER_MILS
,
0.00001
*
IU_PER_MILS
,
0.000001
*
IU_PER_MILS
};
...
...
@@ -44,9 +44,9 @@ int scaletoIU( double aCoord, bool isMetric )
int
ret
;
if
(
isMetric
)
ret
=
KiROUND
(
aCoord
*
MILS_TO_IU_SCALAR
/
0.00254
);
ret
=
KiROUND
(
aCoord
*
IU_PER_MILS
/
0.00254
);
else
ret
=
KiROUND
(
aCoord
*
MILS_TO_IU_SCALAR
);
ret
=
KiROUND
(
aCoord
*
IU_PER_MILS
);
return
ret
;
}
...
...
@@ -94,9 +94,9 @@ wxPoint GERBER_IMAGE::ReadXYCoord( char*& Text )
{
// When X or Y values are float numbers, they are given in mm or inches
if
(
m_GerbMetric
)
// units are mm
current_coord
=
KiROUND
(
atof
(
line
)
*
MILS_TO_IU_SCALAR
/
0.0254
);
current_coord
=
KiROUND
(
atof
(
line
)
*
IU_PER_MILS
/
0.0254
);
else
// units are inches
current_coord
=
KiROUND
(
atof
(
line
)
*
MILS_TO_IU_SCALAR
*
1000
);
current_coord
=
KiROUND
(
atof
(
line
)
*
IU_PER_MILS
*
1000
);
}
else
{
...
...
@@ -185,9 +185,9 @@ wxPoint GERBER_IMAGE::ReadIJCoord( char*& Text )
{
// When X or Y values are float numbers, they are given in mm or inches
if
(
m_GerbMetric
)
// units are mm
current_coord
=
KiROUND
(
atof
(
line
)
*
MILS_TO_IU_SCALAR
/
0.0254
);
current_coord
=
KiROUND
(
atof
(
line
)
*
IU_PER_MILS
/
0.0254
);
else
// units are inches
current_coord
=
KiROUND
(
atof
(
line
)
*
MILS_TO_IU_SCALAR
*
1000
);
current_coord
=
KiROUND
(
atof
(
line
)
*
IU_PER_MILS
*
1000
);
}
else
{
...
...
gerbview/rs274x.cpp
View file @
f3503723
...
...
@@ -160,7 +160,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
double
fcoord
;
// conv_scale = scaling factor from inch to Internal Unit
double
conv_scale
=
MILS_TO_IU_SCALAR
*
1000
;
double
conv_scale
=
IU_PER_MILS
*
1000
;
if
(
m_GerbMetric
)
conv_scale
/=
25.4
;
...
...
@@ -294,7 +294,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
m_GerbMetric
=
false
;
else
if
(
code
==
MILLIMETER
)
m_GerbMetric
=
true
;
conv_scale
=
m_GerbMetric
?
PCB_INTERNAL_UNIT
/
25.4
:
PCB_INTERNAL_UNIT
;
conv_scale
=
m_GerbMetric
?
IU_PER_MILS
/
25.4
:
IU_PER_MILS
;
break
;
case
OFFSET
:
// command: OFAnnBnn (nn = float number) = layer Offset
...
...
@@ -579,8 +579,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
text
+=
2
;
// skip "C," for example
dcode
->
m_Size
.
x
=
dcode
->
m_Size
.
y
=
KiROUND
(
ReadDouble
(
text
)
*
conv_scale
)
;
dcode
->
m_Size
.
x
=
KiROUND
(
ReadDouble
(
text
)
*
conv_scale
);
dcode
->
m_Size
.
y
=
dcode
->
m_Size
.
x
;
switch
(
stdAperture
)
// Aperture desceiption has optional parameters. Read them
{
...
...
@@ -631,8 +631,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if
(
*
text
==
'X'
)
{
text
++
;
dcode
->
m_Drill
.
x
=
dcode
->
m_Drill
.
y
=
KiROUND
(
ReadDouble
(
text
)
*
conv_scale
)
;
dcode
->
m_Drill
.
x
=
KiROUND
(
ReadDouble
(
text
)
*
conv_scale
);
dcode
->
m_Drill
.
y
=
dcode
->
m_Drill
.
x
;
dcode
->
m_DrillShape
=
APT_DEF_ROUND_HOLE
;
}
...
...
@@ -679,8 +679,8 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if
(
*
text
==
'X'
)
{
text
++
;
dcode
->
m_Drill
.
x
=
dcode
->
m_Drill
.
y
=
KiROUND
(
ReadDouble
(
text
)
*
conv_scale
);
dcode
->
m_Drill
.
x
=
KiROUND
(
ReadDouble
(
text
)
*
conv_scale
);
dcode
->
m_Drill
.
y
=
dcode
->
m_Drill
.
x
=
dcode
->
m_DrillShape
=
APT_DEF_ROUND_HOLE
;
}
...
...
@@ -690,8 +690,7 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
if
(
*
text
==
'X'
)
{
text
++
;
dcode
->
m_Drill
.
y
=
KiROUND
(
ReadDouble
(
text
)
*
conv_scale
);
dcode
->
m_Drill
.
y
=
KiROUND
(
ReadDouble
(
text
)
*
conv_scale
);
dcode
->
m_DrillShape
=
APT_DEF_RECT_HOLE
;
}
dcode
->
m_Defined
=
true
;
...
...
include/base_units.h
View file @
f3503723
...
...
@@ -35,19 +35,7 @@
#include <common.h>
/// Scalar to convert mils to internal units.
#if defined( PCBNEW )
#if defined( USE_PCBNEW_NANOMETRES )
#define MILS_TO_IU_SCALAR 25.4e3 // Pcbnew in nanometers.
#else
#define MILS_TO_IU_SCALAR 10.0 // Pcbnew in deci-mils.
#endif
#else
#define MILS_TO_IU_SCALAR 1.0 // Eeschema and anything else.
#endif
#include <convert_to_biu.h>
/**
...
...
@@ -62,16 +50,27 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue );
/**
* Function CoordinateToString
* is a helper to convert the integer coordinate \a aValue to a string in inches,
* is a helper to convert the
\a
integer coordinate \a aValue to a string in inches,
* millimeters, or unscaled units according to the current user units setting.
*
* @param aValue The coordinate to convert.
* @param aValue The
integer
coordinate to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
* the current user unit is millimeters.
* @return The converted string for display in user interface elements.
*/
wxString
CoordinateToString
(
int
aValue
,
bool
aConvertToMils
=
false
);
/**
* Function LenghtDoubleToString
* is a helper to convert the \a double length \a aValue to a string in inches,
* millimeters, or unscaled units according to the current user units setting.
*
* @param aValue The double value to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
* the current user unit is millimeters.
* @return The converted string for display in user interface elements.
*/
wxString
LengthDoubleToString
(
double
aValue
,
bool
aConvertToMils
=
false
);
/**
* Function ReturnStringFromValue
...
...
@@ -84,6 +83,16 @@ wxString CoordinateToString( int aValue, bool aConvertToMils = false );
*/
wxString
ReturnStringFromValue
(
EDA_UNITS_T
aUnit
,
int
aValue
,
bool
aAddUnitSymbol
=
false
);
/**
* Operator << overload
* outputs a point to the argument string in a format resembling
* "@ (x,y)
* @param aString Where to put the text describing the point value
* @param aPoint The point to output.
* @return wxString& - the input string
*/
wxString
&
operator
<<
(
wxString
&
aString
,
const
wxPoint
&
aPoint
);
/**
* Function PutValueInLocalUnits
* converts \a aValue from internal units to user units and append the units notation
...
...
include/class_base_screen.h
View file @
f3503723
...
...
@@ -276,16 +276,22 @@ public:
/**
* Function SetScalingFactor
* @param aScale = the the current scale used to draw items on screen
* draw coordinates are user coordinates * GetScalingFactor()
* sets the scaling factor of "device units per logical unit".
* If the output device is a screen, then "device units" are pixels. The
* "logical unit" is wx terminology, and corresponds to KiCad's "Internal Unit (IU)".
*
* Another way of thinking of scaling factor, when applied to a screen,
* is "pixelsPerIU".
* @param aScale = the the current scale used to draw items onto the device context wxDC.
* device coordinates (pixels) = IU coordinates * GetScalingFactor()
*/
void
SetScalingFactor
(
double
aScale
);
/**
* Function GetZoom
* returns the
* @return the current zoom factor
* Note: the zoom factor is NOT the scaling factor
* the scaling factor is m_ZoomScalar * GetZoom()
*/
double
GetZoom
()
const
;
...
...
@@ -420,7 +426,7 @@ public:
void
ClearBlockCommand
()
{
m_BlockLocate
.
Clear
();
}
wxPoint
GetScrollCenterPosition
()
const
{
return
m_scrollCenter
;
}
const
wxPoint
&
GetScrollCenterPosition
()
const
{
return
m_scrollCenter
;
}
void
SetScrollCenterPosition
(
const
wxPoint
&
aCenterPosition
)
{
m_scrollCenter
=
aCenterPosition
;
...
...
include/common.h
View file @
f3503723
...
...
@@ -39,6 +39,7 @@
#include <wx/fileconf.h>
#include <richio.h>
#include <convert_to_biu.h>
#if !wxUSE_PRINTING_ARCHITECTURE && !SWIG
# error "You must use '--enable-printarch' in your wx library configuration."
...
...
@@ -127,11 +128,24 @@ enum pseudokeys {
* In Debug build an assert fires if will not fit into an int.
*/
#if defined( DEBUG )
#if
!
defined( DEBUG )
// DEBUG: a macro to capture line and file, then calls this inline
/// KiROUND: a function so v is not evaluated twice. Unfortunately, compiler
/// is unable to pre-compute constants using this.
static
inline
int
KiROUND
(
double
v
)
{
return
int
(
v
<
0
?
v
-
0
.
5
:
v
+
0
.
5
);
}
/// KIROUND: a macro so compiler can pre-compute constants. Use this with compile
/// time constants rather than the inline function above.
#define KIROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
#else
static
inline
int
KiRound
(
double
v
,
int
line
,
const
char
*
filename
)
// DEBUG: KiROUND() is a macro to capture line and file, then calls this inline
static
inline
int
kiRound_
(
double
v
,
int
line
,
const
char
*
filename
)
{
v
=
v
<
0
?
v
-
0
.
5
:
v
+
0
.
5
;
if
(
v
>
INT_MAX
+
0
.
5
)
...
...
@@ -145,13 +159,10 @@ static inline int KiRound( double v, int line, const char* filename )
return
int
(
v
);
}
#define KiROUND( v ) KiRound( v, __LINE__, __FILE__ )
#else
// RELEASE: a macro so compile can pre-compute constants.
#define KiROUND( v ) kiRound_( v, __LINE__, __FILE__ )
#define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 )
// in Debug build, use the overflow catcher since code size is immaterial
#define KIROUND( v ) KiROUND( v )
#endif
...
...
@@ -286,18 +297,9 @@ public:
// Accessors returning "Internal Units (IU)". IUs are mils in EESCHEMA,
// and either deci-mils or nanometers in PCBNew.
#if defined(PCBNEW)
# if defined(KICAD_NANOMETRE)
int
GetWidthIU
()
const
{
return
25400
*
GetWidthMils
();
}
int
GetHeightIU
()
const
{
return
25400
*
GetHeightMils
();
}
# else
int
GetWidthIU
()
const
{
return
10
*
GetWidthMils
();
}
int
GetHeightIU
()
const
{
return
10
*
GetHeightMils
();
}
# endif
const
wxSize
GetSizeIU
()
const
{
return
wxSize
(
GetWidthIU
(),
GetHeightIU
()
);
}
#elif defined(EESCHEMA)
int
GetWidthIU
()
const
{
return
GetWidthMils
();
}
int
GetHeightIU
()
const
{
return
GetHeightMils
();
}
#if defined(PCBNEW) || defined(EESCHEMA) || defined(GERBVIEW)
int
GetWidthIU
()
const
{
return
IU_PER_MILS
*
GetWidthMils
();
}
int
GetHeightIU
()
const
{
return
IU_PER_MILS
*
GetHeightMils
();
}
const
wxSize
GetSizeIU
()
const
{
return
wxSize
(
GetWidthIU
(),
GetHeightIU
()
);
}
#endif
...
...
@@ -539,17 +541,6 @@ private:
bool
EnsureTextCtrlWidth
(
wxTextCtrl
*
aCtrl
,
const
wxString
*
aString
=
NULL
);
/**
* Operator << overload
* outputs a point to the argument string in a format resembling
* "@ (x,y)
* @param aString Where to put the text describing the point value
* @param aPoint The point to output.
* @return wxString& - the input string
*/
wxString
&
operator
<<
(
wxString
&
aString
,
const
wxPoint
&
aPoint
);
/**
* Function ProcessExecute
* runs a child process.
...
...
@@ -581,14 +572,6 @@ int GetCommandOptions( const int argc, const char** argv,
const
char
*
stringtst
,
const
char
**
optarg
,
int
*
optind
);
/* Returns to display the value of a parameter, by type of units selected
* Input: value in mils, buffer text
* Returns to buffer: text: value expressed in inches or millimeters
* Followed by " or mm
*/
const
wxString
&
valeur_param
(
int
valeur
,
wxString
&
buf_texte
);
/**
* Returns the units symbol.
*
...
...
include/convert_to_biu.h
View file @
f3503723
...
...
@@ -9,20 +9,37 @@
/**
* @brief
inline convert functions to convert a value in decimils (or mils)
* to the internal unit used in pcbnew
or cvpcb
(nanometer or decimil)
* @brief
some define and functions to convert a value in mils, decimils or mm
* to the internal unit used in pcbnew
, cvpcb or gerbview
(nanometer or decimil)
* depending on compil option
*/
#if defined(PCBNEW) || defined(CVPCB)
/// Scaling factor to convert mils to internal units.
#if defined(PCBNEW) || defined(CVPCB) || defined(GERBVIEW)
#if defined( USE_PCBNEW_NANOMETRES )
#if defined(GERBVIEW)
#define IU_PER_MM 1e5 // Gerbview uses 10 micrometer.
#else
#define IU_PER_MM 1e6 // Pcbnew uses nanometers.
#endif
#define IU_PER_MILS ( IU_PER_MM * 0.0254 )
#define IU_PER_DECIMILS (IU_PER_MM * 0.00254 )
#else // Pcbnew in deci-mils.
#define IU_PER_DECIMILS 1
#define IU_PER_MILS 10.0
#define IU_PER_MM (1e4 / 25.4)
#endif
/// Convert mils to PCBNEW internal units (iu).
inline
int
Mils2iu
(
int
mils
)
{
#if defined( USE_PCBNEW_NANOMETRES )
double
x
=
mils
*
25.4e3
;
double
x
=
mils
*
IU_PER_MILS
;
return
int
(
x
<
0
?
x
-
0
.
5
:
x
+
0
.
5
);
#else
return
mils
*
10
;
return
mils
*
IU_PER_MILS
;
#endif
}
...
...
@@ -30,14 +47,17 @@ inline int Mils2iu( int mils )
inline
int
DMils2iu
(
int
dmils
)
{
#if defined( USE_PCBNEW_NANOMETRES )
double
x
=
dmils
*
25.4e2
;
double
x
=
dmils
*
IU_PER_DECIMILS
;
return
int
(
x
<
0
?
x
-
0
.
5
:
x
+
0
.
5
);
#else
return
dmils
;
#endif
}
#elif defined(EESCHEMA)
#else // Eeschema and anything else.
#define IU_PER_MILS 1.0
#define IU_PER_MM (IU_PER_MILS / 0.0254)
inline
int
Mils2iu
(
int
mils
)
{
return
mils
;
...
...
include/fctsys.h
View file @
f3503723
...
...
@@ -29,9 +29,6 @@
#define M_PI 3.141592653
#endif
#define PCB_INTERNAL_UNIT 10000 // PCBNEW internal unit = 1/10000 inch
#define EESCHEMA_INTERNAL_UNIT 1000 // EESCHEMA internal unit = 1/1000 inch
#ifdef __WINDOWS__
#define DIR_SEP '\\'
#define STRING_DIR_SEP wxT( "\\" )
...
...
include/vector2d.h
0 → 100644
View file @
f3503723
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2010 Virtenio GmbH, Torsten Hueter, torsten.hueter <at> virtenio.de
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef VECTOR2D_H_
#define VECTOR2D_H_
#include <cmath>
#include <wx/gdicmn.h>
/// Forward declaration for template friends
template
<
class
T
>
class
VECTOR2
;
/*
#include <iostream>
template<class T> ostream& operator<<( ostream &stream, const VECTOR2<T>& vector );
*/
/**
* Class VECTOR2
* defines a general 2D-vector.
*
* This class uses templates to be universal. Several operators are provided to help easy implementing
* of linear algebra equations.
*
*/
template
<
class
T
>
class
VECTOR2
{
public
:
T
x
,
y
;
// Constructors
/// Construct a 2D-vector with x, y = 0
VECTOR2
();
/// Copy constructor
VECTOR2
(
const
VECTOR2
<
T
>&
aVector
);
/// Constructor with a wxPoint as argument
VECTOR2
(
const
wxPoint
&
aPoint
);
/// Constructor with a wxSize as argument
VECTOR2
(
const
wxSize
&
aSize
);
/// Construct a vector with given components x, y
VECTOR2
(
T
x
,
T
y
);
/// Destructor
// virtual ~VECTOR2();
/**
* Function Euclidean Norm
* computes the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
* It is used to calculate the length of the vector.
* @return Scalar, the euclidean norm
*/
T
EuclideanNorm
();
/**
* Function Perpendicular
* computes the perpendicular vector
* @return Perpendicular vector
*/
VECTOR2
<
T
>
Perpendicular
();
/**
* Function Angle
* computes the angle of the vector
* @return vector angle
*/
T
Angle
();
// Operators
/// Assignment operator
VECTOR2
<
T
>&
operator
=
(
const
VECTOR2
<
T
>&
aVector
);
/// Vector addition operator
VECTOR2
<
T
>
operator
+
(
const
VECTOR2
<
T
>&
aVector
);
/// Compound assignment operator
VECTOR2
<
T
>&
operator
+=
(
const
VECTOR2
<
T
>&
aVector
);
/// Vector subtraction operator
VECTOR2
<
T
>
operator
-
(
const
VECTOR2
<
T
>&
aVector
);
/// Compound assignment operator
VECTOR2
<
T
>&
operator
-=
(
const
VECTOR2
<
T
>&
aVector
);
/// Negate Vector operator
VECTOR2
<
T
>
operator
-
();
/// Scalar product operator
T
operator
*
(
const
VECTOR2
<
T
>&
aVector
);
/// Multiplication with a factor
VECTOR2
<
T
>
operator
*
(
const
T
&
aFactor
);
/// Cross product operator
T
operator
^
(
const
VECTOR2
<
T
>&
aVector
);
/// Equality operator
const
bool
operator
==
(
const
VECTOR2
<
T
>&
aVector
);
/// Not equality operator
const
bool
operator
!=
(
const
VECTOR2
<
T
>&
aVector
);
/// Smaller than operator
bool
operator
<
(
const
VECTOR2
<
T
>&
aVector
);
bool
operator
<=
(
const
VECTOR2
<
T
>&
aVector
);
/// Greater than operator
bool
operator
>
(
const
VECTOR2
<
T
>&
aVector
);
bool
operator
>=
(
const
VECTOR2
<
T
>&
aVector
);
/// Casting to int vector
// operator VECTOR2<int>();
/// Type casting operator for the class wxPoint
//operator wxPoint();
// friend ostream& operator<< <T> ( ostream &stream, const VECTOR2<T>& vector );
};
// ----------------------
// --- Implementation ---
// ----------------------
template
<
class
T
>
VECTOR2
<
T
>::
VECTOR2
(
VECTOR2
<
T
>
const
&
aVector
)
:
x
(
aVector
.
x
),
y
(
aVector
.
y
)
{
}
template
<
class
T
>
VECTOR2
<
T
>::
VECTOR2
()
{
x
=
y
=
0
.
0
;
}
template
<
class
T
>
VECTOR2
<
T
>::
VECTOR2
(
wxPoint
const
&
aPoint
)
{
x
=
T
(
aPoint
.
x
);
y
=
T
(
aPoint
.
y
);
}
template
<
class
T
>
VECTOR2
<
T
>::
VECTOR2
(
wxSize
const
&
aSize
)
{
x
=
T
(
aSize
.
x
);
y
=
T
(
aSize
.
y
);
}
template
<
class
T
>
VECTOR2
<
T
>::
VECTOR2
(
T
aX
,
T
aY
)
{
x
=
aX
;
y
=
aY
;
}
// Not required at the moment for this class
//template<class T> VECTOR2<T>::~VECTOR2()
//{
// // TODO Auto-generated destructor stub
//}
template
<
class
T
>
T
VECTOR2
<
T
>::
EuclideanNorm
()
{
return
sqrt
(
(
*
this
)
*
(
*
this
)
);
}
template
<
class
T
>
T
VECTOR2
<
T
>::
Angle
()
{
return
atan2
(
y
,
x
);
}
template
<
class
T
>
VECTOR2
<
T
>
VECTOR2
<
T
>::
Perpendicular
(){
VECTOR2
<
T
>
perpendicular
(
-
y
,
x
);
return
perpendicular
;
}
/*
template<class T> ostream &operator<<( ostream &aStream, const VECTOR2<T>& aVector )
{
aStream << "[ " << aVector.x << " | " << aVector.y << " ]";
return aStream;
}
*/
template
<
class
T
>
VECTOR2
<
T
>
&
VECTOR2
<
T
>::
operator
=
(
const
VECTOR2
<
T
>&
aVector
)
{
x
=
aVector
.
x
;
y
=
aVector
.
y
;
return
*
this
;
}
template
<
class
T
>
VECTOR2
<
T
>
&
VECTOR2
<
T
>::
operator
+=
(
const
VECTOR2
<
T
>&
aVector
)
{
x
+=
aVector
.
x
;
y
+=
aVector
.
y
;
return
*
this
;
}
template
<
class
T
>
VECTOR2
<
T
>&
VECTOR2
<
T
>::
operator
-=
(
const
VECTOR2
<
T
>&
aVector
)
{
x
-=
aVector
.
x
;
y
-=
aVector
.
y
;
return
*
this
;
}
//template<class T> VECTOR2<T>::operator wxPoint()
//{
// wxPoint point;
// point.x = (int) x;
// point.y = (int) y;
// return point;
//}
//
//// Use correct rounding for casting to wxPoint
//template<> VECTOR2<double>::operator wxPoint()
//{
// wxPoint point;
// point.x = point.x >= 0 ? (int) ( x + 0.5 ) : (int) ( x - 0.5 );
// point.y = point.y >= 0 ? (int) ( y + 0.5 ) : (int) ( y - 0.5 );
// return point;
//}
// Use correct rounding for casting double->int
//template<> VECTOR2<double>::operator VECTOR2<int>()
//{
// VECTOR2<int> vector;
// vector.x = vector.x >= 0 ? (int) ( x + 0.5 ) : (int) ( x - 0.5 );
// vector.y = vector.y >= 0 ? (int) ( y + 0.5 ) : (int) ( y - 0.5 );
// return vector;
//}
template
<
class
T
>
VECTOR2
<
T
>
VECTOR2
<
T
>::
operator
+
(
const
VECTOR2
<
T
>&
aVector
)
{
return
VECTOR2
<
T
>
(
x
+
aVector
.
x
,
y
+
aVector
.
y
);
}
template
<
class
T
>
VECTOR2
<
T
>
VECTOR2
<
T
>::
operator
-
(
const
VECTOR2
<
T
>&
aVector
)
{
return
VECTOR2
<
T
>
(
x
-
aVector
.
x
,
y
-
aVector
.
y
);
}
template
<
class
T
>
VECTOR2
<
T
>
VECTOR2
<
T
>::
operator
-
()
{
return
VECTOR2
<
T
>
(
-
x
,
-
y
);
}
template
<
class
T
>
T
VECTOR2
<
T
>::
operator
*
(
const
VECTOR2
<
T
>&
aVector
)
{
return
aVector
.
x
*
x
+
aVector
.
y
*
y
;
}
template
<
class
T
>
VECTOR2
<
T
>
VECTOR2
<
T
>::
operator
*
(
const
T
&
aFactor
)
{
VECTOR2
<
T
>
vector
(
x
*
aFactor
,
y
*
aFactor
);
return
vector
;
}
template
<
class
T
>
VECTOR2
<
T
>
operator
*
(
const
T
&
aFactor
,
const
VECTOR2
<
T
>&
aVector
){
VECTOR2
<
T
>
vector
(
aVector
.
x
*
aFactor
,
aVector
.
y
*
aFactor
);
return
vector
;
}
template
<
class
T
>
T
VECTOR2
<
T
>::
operator
^
(
const
VECTOR2
<
T
>&
aVector
)
{
return
x
*
aVector
.
y
-
y
*
aVector
.
x
;
}
template
<
class
T
>
bool
VECTOR2
<
T
>::
operator
<
(
const
VECTOR2
<
T
>&
o
)
{
// VECTOR2<T> vector( aVector );
return
(
double
(
x
)
*
x
+
double
(
y
)
*
y
)
<
(
double
(
o
.
x
)
*
o
.
x
+
double
(
o
.
y
)
*
y
);
}
template
<
class
T
>
bool
VECTOR2
<
T
>::
operator
<=
(
const
VECTOR2
<
T
>&
aVector
)
{
VECTOR2
<
T
>
vector
(
aVector
);
return
(
*
this
*
*
this
)
<=
(
vector
*
vector
);
}
template
<
class
T
>
bool
VECTOR2
<
T
>::
operator
>
(
const
VECTOR2
<
T
>&
aVector
)
{
VECTOR2
<
T
>
vector
(
aVector
);
return
(
*
this
*
*
this
)
>
(
vector
*
vector
);
}
template
<
class
T
>
bool
VECTOR2
<
T
>::
operator
>=
(
const
VECTOR2
<
T
>&
aVector
)
{
VECTOR2
<
T
>
vector
(
aVector
);
return
(
*
this
*
*
this
)
>=
(
vector
*
vector
);
}
template
<
class
T
>
bool
const
VECTOR2
<
T
>::
operator
==
(
VECTOR2
<
T
>
const
&
aVector
)
{
return
(
aVector
.
x
==
x
)
&&
(
aVector
.
y
==
y
);
}
template
<
class
T
>
bool
const
VECTOR2
<
T
>::
operator
!=
(
VECTOR2
<
T
>
const
&
aVector
)
{
return
(
aVector
.
x
!=
x
)
||
(
aVector
.
y
!=
y
);
}
/**
* Class BOX2
* is a description of a rectangle in a cartesion coordinate system.
*/
template
<
class
T
>
class
BOX2
{
public
:
BOX2
()
:
x
(
0
),
y
(
0
),
width
(
0
),
height
(
0
)
{}
BOX2
(
T
aX
,
T
aY
,
T
aWidth
,
T
aHeight
)
:
x
(
aX
),
y
(
aY
),
width
(
aWidth
),
height
(
aHeight
)
{}
/// Copy constructor
BOX2
(
const
BOX2
<
T
>&
aRect
)
:
x
(
aRect
.
x
),
y
(
aRect
.
y
),
width
(
aRect
.
width
),
height
(
aRect
.
height
)
{}
/// Constructor with a wxPoint as argument?
VECTOR2
<
T
>
GetSize
()
const
{
return
VECTOR2
<
T
>
(
width
,
height
);
}
VECTOR2
<
T
>
GetPosition
()
const
{
return
VECTOR2
<
T
>
(
x
,
y
);
}
T
GetLeft
()
const
{
return
x
;
}
void
SetLeft
(
T
n
)
{
width
+=
x
-
n
;
x
=
n
;
}
void
MoveLeftTo
(
T
n
)
{
x
=
n
;
}
T
GetTop
()
const
{
return
y
;
}
void
SetTop
(
T
n
)
{
height
+=
y
-
n
;
y
=
n
;
}
void
MoveTopTo
(
T
n
)
{
y
=
n
;
}
T
GetBottom
()
const
{
return
y
+
height
;
}
void
SetBottom
(
T
n
)
{
height
+=
n
-
(
y
+
height
);
}
void
MoveBottomTo
(
T
n
)
{
y
=
n
-
height
;
}
T
GetRight
()
const
{
return
x
+
width
;
}
void
SetRight
(
T
n
)
{
width
+=
n
-
(
x
+
width
);
}
void
MoveRightTo
(
T
n
)
{
x
=
n
-
width
;
}
VECTOR2
<
T
>
GetLeftTop
()
const
{
return
VECTOR2
<
T
>
(
x
,
y
);
}
void
SetLeftTop
(
const
VECTOR2
<
T
>&
pt
)
{
width
+=
x
-
pt
.
x
;
height
+=
y
-
pt
.
y
;
x
=
pt
.
x
;
y
=
pt
.
y
;
}
void
MoveLeftTopTo
(
const
VECTOR2
<
T
>
&
pt
)
{
x
=
pt
.
x
;
y
=
pt
.
y
;
}
VECTOR2
<
T
>
GetLeftBottom
()
const
{
return
VECTOR2
<
T
>
(
x
,
y
+
height
);
}
void
SetLeftBottom
(
const
VECTOR2
<
T
>&
pt
)
{
width
+=
x
-
pt
.
x
;
height
+=
pt
.
y
-
(
y
+
height
);
x
=
pt
.
x
;
}
void
MoveLeftBottomTo
(
const
VECTOR2
<
T
>&
pt
)
{
x
=
pt
.
x
;
y
=
pt
.
y
-
height
;
}
VECTOR2
<
T
>
GetRightTop
()
const
{
return
VECTOR2
<
T
>
(
x
+
width
,
y
);
}
void
SetRightTop
(
const
VECTOR2
<
T
>&
pt
)
{
width
+=
pt
.
x
-
(
x
+
width
);
height
+=
y
-
pt
.
y
;
y
=
pt
.
y
;
}
void
MoveRightTopTo
(
const
VECTOR2
<
T
>&
pt
)
{
x
=
pt
.
x
-
width
;
y
=
pt
.
y
;
}
VECTOR2
<
T
>
GetRightBottom
()
const
{
return
VECTOR2
<
T
>
(
x
+
width
,
y
+
height
);
}
void
SetRightBottom
(
const
VECTOR2
<
T
>&
pt
)
{
width
+=
pt
.
x
-
(
x
+
width
);
height
+=
pt
.
y
-
(
y
+
height
);
}
void
MoveRightBottomTo
(
const
VECTOR2
<
T
>&
pt
)
{
x
=
pt
.
x
-
width
;
y
=
pt
.
y
-
height
;
}
VECTOR2
<
T
>
GetCentre
()
const
{
return
VECTOR2
<
T
>
(
x
+
width
/
2
,
y
+
height
/
2
);
}
void
SetCentre
(
const
VECTOR2
<
T
>&
pt
)
{
MoveCentreTo
(
pt
);
}
void
MoveCentreTo
(
const
VECTOR2
<
T
>&
pt
)
{
x
+=
pt
.
x
-
(
x
+
width
/
2
),
y
+=
pt
.
y
-
(
y
+
height
/
2
);
}
T
x
,
y
,
width
,
height
;
};
typedef
VECTOR2
<
double
>
DPOINT
;
typedef
DPOINT
DSIZE
;
typedef
BOX2
<
double
>
DBOX
;
#endif // VECTOR2D_H_
include/wxstruct.h
View file @
f3503723
...
...
@@ -647,6 +647,11 @@ public:
*/
void
RedrawScreen
(
const
wxPoint
&
aCenterPoint
,
bool
aWarpPointer
);
/**
* Function Zoom_Automatique
* redraws the screen with best zoom level and the best centering
* that shows all the page or the board
*/
void
Zoom_Automatique
(
bool
aWarpPointer
);
/* Set the zoom level to show the area Rect */
...
...
@@ -836,7 +841,7 @@ public:
/**
* Function CoordinateToString
* is a helper to convert the integer coordinate \a aValue to a string in inches or mm
* is a helper to convert the
\a
integer coordinate \a aValue to a string in inches or mm
* according to the current user units setting.
* @param aValue The coordinate to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
...
...
@@ -845,6 +850,17 @@ public:
*/
wxString
CoordinateToString
(
int
aValue
,
bool
aConvertToMils
=
false
);
/**
* Function LengthDoubleToString
* is a helper to convert the \a double value \a aValue to a string in inches or mm
* according to the current user units setting.
* @param aValue The coordinate to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
* the current user unit is millimeters.
* @return The converted string for display in user interface elements.
*/
wxString
LengthDoubleToString
(
double
aValue
,
bool
aConvertToMils
=
false
);
DECLARE_EVENT_TABLE
()
};
...
...
pcbnew/CMakeLists.txt
View file @
f3503723
...
...
@@ -222,7 +222,10 @@ set(PCBNEW_SRCS ${PCBNEW_CLASS_SRCS} ${PCBNEW_DIALOGS})
###
# We need some extra sources from common
###
#set(PCBNEW_COMMON_SRCS ../common/dialogs/dialog_page_settings.cpp )
set
(
PCBNEW_COMMON_SRCS
../common/dialogs/dialog_page_settings.cpp
../common/base_units.cpp
)
##
# Scripting sources
...
...
@@ -299,7 +302,7 @@ if (KICAD_SCRIPTING_MODULES)
SET
(
CMAKE_SWIG_FLAGS
${
SWIG_FLAGS
}
)
SET_SOURCE_FILES_PROPERTIES
(
scripting/pcbnew.i PROPERTIES CPLUSPLUS ON
)
SWIG_ADD_MODULE
(
pcbnew python scripting/pcbnew.i
${
PCBNEW_SCRIPTING_PYTHON_HELPERS
}
${
PCBNEW_SRCS
}
)
SWIG_ADD_MODULE
(
pcbnew python scripting/pcbnew.i
${
PCBNEW_SCRIPTING_PYTHON_HELPERS
}
${
PCBNEW_SRCS
}
${
PCBNEW_COMMON_SRCS
}
)
SWIG_LINK_LIBRARIES
(
pcbnew
3d-viewer
pcbcommon
...
...
pcbnew/basepcbframe.cpp
View file @
f3503723
...
...
@@ -810,8 +810,12 @@ void PCB_BASE_FRAME::updateZoomSelectBox()
{
msg
=
_
(
"Zoom "
);
wxString
value
;
value
.
Printf
(
wxT
(
"%g"
),
GetScreen
()
->
m_ZoomList
[
i
]);
wxString
value
=
wxString
::
Format
(
wxT
(
"%g"
),
// @todo could do scaling here and show a "percentage"
GetScreen
()
->
m_ZoomList
[
i
]
);
msg
+=
value
;
m_zoomSelectBox
->
Append
(
msg
);
...
...
@@ -821,6 +825,7 @@ void PCB_BASE_FRAME::updateZoomSelectBox()
}
}
/* Function GetActiveViewerFrame
* return a reference to the current Module Viewer Frame if exists
* if called from the PCB editor, this is the m_ModuleViewerFrame
...
...
pcbnew/class_dimension.cpp
View file @
f3503723
...
...
@@ -41,6 +41,7 @@
#include <class_board.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
#include <base_units.h>
DIMENSION
::
DIMENSION
(
BOARD_ITEM
*
aParent
)
:
...
...
@@ -344,7 +345,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
if
(
!
aDoNotChangeText
)
{
m_Value
=
mesure
;
valeur_param
(
m_Value
,
msg
);
msg
=
::
CoordinateToString
(
m_Value
);
SetText
(
msg
);
}
}
...
...
pcbnew/class_drawsegment.cpp
View file @
f3503723
...
...
@@ -47,6 +47,7 @@
#include <class_board.h>
#include <class_module.h>
#include <class_drawsegment.h>
#include <base_units.h>
DRAWSEGMENT
::
DRAWSEGMENT
(
BOARD_ITEM
*
aParent
,
KICAD_T
idtype
)
:
...
...
@@ -373,7 +374,7 @@ void DRAWSEGMENT::DisplayInfo( EDA_DRAW_FRAME* frame )
frame
->
AppendMsgPanel
(
_
(
"Layer"
),
board
->
GetLayerName
(
m_Layer
),
DARKBROWN
);
valeur_param
(
(
unsigned
)
m_Width
,
msg
);
msg
=
frame
->
CoordinateToString
(
m_Width
);
frame
->
AppendMsgPanel
(
_
(
"Width"
),
msg
,
DARKCYAN
);
}
...
...
@@ -527,12 +528,11 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect ) const
wxString
DRAWSEGMENT
::
GetSelectMenuText
()
const
{
wxString
text
;
wxString
temp
;
wxString
temp
=
::
LengthDoubleToString
(
GetLength
()
)
;
text
.
Printf
(
_
(
"Pcb Graphic: %s length: %s on %s"
),
GetChars
(
ShowShape
(
(
STROKE_T
)
m_Shape
)
),
GetChars
(
valeur_param
(
GetLength
(),
temp
)
),
GetChars
(
GetLayerName
()
)
);
GetChars
(
temp
),
GetChars
(
GetLayerName
()
)
);
return
text
;
}
...
...
pcbnew/class_drc_item.cpp
View file @
f3503723
...
...
@@ -32,6 +32,7 @@
#include <pcbnew.h>
#include <drc_stuff.h>
#include <class_drc_item.h>
#include <base_units.h>
wxString
DRC_ITEM
::
GetErrorText
()
const
...
...
pcbnew/class_edge_mod.cpp
View file @
f3503723
...
...
@@ -255,7 +255,7 @@ void EDGE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
frame
->
AppendMsgPanel
(
_
(
"Mod Layer"
),
board
->
GetLayerName
(
module
->
GetLayer
()
),
RED
);
frame
->
AppendMsgPanel
(
_
(
"Seg Layer"
),
board
->
GetLayerName
(
GetLayer
()
),
RED
);
valeur_param
(
m_Width
,
msg
);
msg
=
frame
->
CoordinateToString
(
m_Width
);
frame
->
AppendMsgPanel
(
_
(
"Width"
),
msg
,
BLUE
);
}
...
...
pcbnew/class_mire.cpp
View file @
f3503723
...
...
@@ -42,6 +42,7 @@
#include <class_board.h>
#include <class_mire.h>
#include <base_units.h>
PCB_TARGET
::
PCB_TARGET
(
BOARD_ITEM
*
aParent
)
:
...
...
@@ -210,7 +211,7 @@ wxString PCB_TARGET::GetSelectMenuText() const
wxString
text
;
wxString
msg
;
valeur_param
(
m_Size
,
msg
);
msg
=
::
CoordinateToString
(
m_Size
);
text
.
Printf
(
_
(
"Target on %s size %s"
),
GetChars
(
GetLayerName
()
),
GetChars
(
msg
)
);
...
...
pcbnew/class_pad.cpp
View file @
f3503723
...
...
@@ -612,13 +612,13 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
frame
->
AppendMsgPanel
(
ShowPadShape
(),
ShowPadAttr
(),
DARKGREEN
);
valeur_param
(
m_Size
.
x
,
Line
);
Line
=
frame
->
CoordinateToString
(
m_Size
.
x
);
frame
->
AppendMsgPanel
(
_
(
"H Size"
),
Line
,
RED
);
valeur_param
(
m_Size
.
y
,
Line
);
Line
=
frame
->
CoordinateToString
(
m_Size
.
y
);
frame
->
AppendMsgPanel
(
_
(
"V Size"
),
Line
,
RED
);
valeur_param
(
(
unsigned
)
m_Drill
.
x
,
Line
);
Line
=
frame
->
CoordinateToString
(
(
unsigned
)
m_Drill
.
x
);
if
(
m_DrillShape
==
PAD_CIRCLE
)
{
...
...
@@ -626,9 +626,9 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
}
else
{
valeur_param
(
(
unsigned
)
m_Drill
.
x
,
Line
);
Line
=
frame
->
CoordinateToString
(
(
unsigned
)
m_Drill
.
x
);
wxString
msg
;
valeur_param
(
(
unsigned
)
m_Drill
.
y
,
msg
);
Line
=
frame
->
CoordinateToString
(
(
unsigned
)
m_Drill
.
y
);
Line
+=
wxT
(
" / "
)
+
msg
;
frame
->
AppendMsgPanel
(
_
(
"Drill X / Y"
),
Line
,
RED
);
}
...
...
@@ -644,15 +644,15 @@ void D_PAD::DisplayInfo( EDA_DRAW_FRAME* frame )
frame
->
AppendMsgPanel
(
_
(
"Orient"
),
Line
,
LIGHTBLUE
);
valeur_param
(
m_Pos
.
x
,
Line
);
Line
=
frame
->
CoordinateToString
(
m_Pos
.
x
);
frame
->
AppendMsgPanel
(
_
(
"X Pos"
),
Line
,
LIGHTBLUE
);
valeur_param
(
m_Pos
.
y
,
Line
);
Line
=
frame
->
CoordinateToString
(
m_Pos
.
y
);
frame
->
AppendMsgPanel
(
_
(
"Y pos"
),
Line
,
LIGHTBLUE
);
if
(
GetDieLength
()
)
{
valeur_param
(
GetDieLength
(),
Line
);
Line
=
frame
->
CoordinateToString
(
GetDieLength
()
);
frame
->
AppendMsgPanel
(
_
(
"Length on die"
),
Line
,
CYAN
);
}
}
...
...
pcbnew/class_pcb_text.cpp
View file @
f3503723
...
...
@@ -138,13 +138,13 @@ void TEXTE_PCB::DisplayInfo( EDA_DRAW_FRAME* frame )
msg
.
Printf
(
wxT
(
"%.1f"
),
(
float
)
m_Orient
/
10
);
frame
->
AppendMsgPanel
(
_
(
"Orientation"
),
msg
,
DARKGREEN
);
valeur_param
(
m_Thickness
,
msg
);
msg
=
frame
->
CoordinateToString
(
m_Thickness
);
frame
->
AppendMsgPanel
(
_
(
"Thickness"
),
msg
,
MAGENTA
);
valeur_param
(
m_Size
.
x
,
msg
);
msg
=
frame
->
CoordinateToString
(
m_Size
.
x
);
frame
->
AppendMsgPanel
(
_
(
"Size X"
),
msg
,
RED
);
valeur_param
(
m_Size
.
y
,
msg
);
msg
=
frame
->
CoordinateToString
(
m_Size
.
y
);
frame
->
AppendMsgPanel
(
_
(
"Size Y"
),
msg
,
RED
);
}
...
...
pcbnew/class_text_mod.cpp
View file @
f3503723
...
...
@@ -405,13 +405,13 @@ void TEXTE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
msg
.
Printf
(
wxT
(
"%.1f"
),
(
float
)
m_Orient
/
10
);
frame
->
AppendMsgPanel
(
_
(
"Orient"
),
msg
,
DARKGREEN
);
valeur_param
(
m_Thickness
,
msg
);
msg
=
frame
->
CoordinateToString
(
m_Thickness
);
frame
->
AppendMsgPanel
(
_
(
"Thickness"
),
msg
,
DARKGREEN
);
valeur_param
(
m_Size
.
x
,
msg
);
msg
=
frame
->
CoordinateToString
(
m_Size
.
x
);
frame
->
AppendMsgPanel
(
_
(
"H Size"
),
msg
,
RED
);
valeur_param
(
m_Size
.
y
,
msg
);
msg
=
frame
->
CoordinateToString
(
m_Size
.
y
);
frame
->
AppendMsgPanel
(
_
(
"V Size"
),
msg
,
RED
);
}
...
...
pcbnew/class_track.cpp
View file @
f3503723
...
...
@@ -46,6 +46,7 @@
#include <pcbnew.h>
#include <protos.h>
#include <base_units.h>
/**
* Function ShowClearance
...
...
@@ -138,10 +139,7 @@ EDA_ITEM* TRACK::Clone() const
wxString
TRACK
::
ShowWidth
()
const
{
wxString
msg
;
valeur_param
(
m_Width
,
msg
);
wxString
msg
=
::
CoordinateToString
(
m_Width
);
return
msg
;
}
...
...
@@ -1173,7 +1171,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
// Display segment length
if
(
Type
()
!=
PCB_VIA_T
)
// Display Diam and Drill values
{
msg
=
frame
->
CoordinateToString
(
KiROUND
(
GetLength
()
)
);
msg
=
frame
->
LengthDoubleToString
(
GetLength
(
)
);
frame
->
AppendMsgPanel
(
_
(
"Segment Length"
),
msg
,
DARKCYAN
);
}
}
...
...
@@ -1553,7 +1551,7 @@ wxString TRACK::GetSelectMenuText() const
}
text
<<
_
(
" on "
)
<<
GetLayerName
()
<<
wxT
(
" "
)
<<
_
(
"Net:"
)
<<
GetNet
()
<<
wxT
(
" "
)
<<
_
(
"Length:"
)
<<
valeur_param
(
GetLength
(),
temp
);
<<
wxT
(
" "
)
<<
_
(
"Length:"
)
<<
::
LengthDoubleToString
(
GetLength
()
);
return
text
;
}
...
...
pcbnew/classpcb.cpp
View file @
f3503723
...
...
@@ -19,15 +19,11 @@
#include <pcbnew_id.h>
#if defined( USE_PCBNEW_NANOMETRES )
#define ZOOM_FACTOR( x ) ( x * 25.4e2 )
#define DMIL_GRID( x ) wxRealPoint( x * 25.4e2, x * 25.4e2 )
#define MM_GRID( x ) wxRealPoint( x * 1e6, x * 1e6 )
#else
#define ZOOM_FACTOR( x ) x
#define DMIL_GRID( x ) wxRealPoint( x , x )
#define MM_GRID( x ) wxRealPoint( x * 1e4 / 25.4, x * 1e4 / 25.4 )
#endif
#define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS )
#define DMIL_GRID( x ) wxRealPoint( x * IU_PER_DECIMILS,\
x * IU_PER_DECIMILS )
#define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\
x * IU_PER_MM )
/**
...
...
@@ -42,6 +38,12 @@
*/
static
const
double
pcbZoomList
[]
=
{
#if defined( USE_PCBNEW_NANOMETRES )
ZOOM_FACTOR
(
0.1
),
ZOOM_FACTOR
(
0.2
),
ZOOM_FACTOR
(
0.3
),
#endif
ZOOM_FACTOR
(
0.5
),
ZOOM_FACTOR
(
1.0
),
ZOOM_FACTOR
(
1.5
),
...
...
@@ -57,10 +59,14 @@ static const double pcbZoomList[] =
ZOOM_FACTOR
(
80.0
),
ZOOM_FACTOR
(
120.0
),
ZOOM_FACTOR
(
200.0
),
ZOOM_FACTOR
(
350.0
),
ZOOM_FACTOR
(
300.0
),
#if !defined( USE_PCBNEW_NANOMETRES )
ZOOM_FACTOR
(
500.0
),
ZOOM_FACTOR
(
1000.0
),
ZOOM_FACTOR
(
2000.0
)
#endif
};
...
...
@@ -98,6 +104,8 @@ static GRID_TYPE pcbGridList[] =
PCB_SCREEN
::
PCB_SCREEN
(
const
wxSize
&
aPageSizeIU
)
:
BASE_SCREEN
(
SCREEN_T
)
{
wxSize
displayz
=
wxGetDisplaySize
();
for
(
unsigned
i
=
0
;
i
<
DIM
(
pcbZoomList
);
++
i
)
m_ZoomList
.
Add
(
pcbZoomList
[
i
]
);
...
...
@@ -111,7 +119,7 @@ PCB_SCREEN::PCB_SCREEN( const wxSize& aPageSizeIU ) :
m_Route_Layer_TOP
=
LAYER_N_FRONT
;
// default layers pair for vias (bottom to top)
m_Route_Layer_BOTTOM
=
LAYER_N_BACK
;
SetZoom
(
ZOOM_FACTOR
(
1
50
)
);
// a default value for zoom
SetZoom
(
ZOOM_FACTOR
(
1
20
)
);
// a default value for zoom
InitDataPoints
(
aPageSizeIU
);
}
...
...
@@ -125,11 +133,7 @@ PCB_SCREEN::~PCB_SCREEN()
int
PCB_SCREEN
::
MilsToIuScalar
()
{
#if defined( USE_PCBNEW_NANOMETRES )
return
25400
;
#else
return
10
;
#endif
return
(
int
)
IU_PER_MILS
;
}
...
...
pcbnew/dialogs/dialog_SVG_print.cpp
View file @
f3503723
...
...
@@ -271,7 +271,7 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
g_DrawBgColor
=
WHITE
;
if
(
aPrint_Frame_Ref
)
m_Parent
->
TraceWorkSheet
(
&
dc
,
screen
,
s_Parameters
.
m_PenDefaultSize
,
MILS_TO_IU_SCALAR
);
m_Parent
->
TraceWorkSheet
(
&
dc
,
screen
,
s_Parameters
.
m_PenDefaultSize
,
IU_PER_MILS
);
m_Parent
->
PrintPage
(
&
dc
,
m_PrintMaskLayer
,
false
,
&
s_Parameters
);
g_DrawBgColor
=
bg_color
;
...
...
pcbnew/editrack.cpp
View file @
f3503723
...
...
@@ -789,13 +789,13 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
for
(
TRACK
*
track
=
g_FirstTrackSegment
;
track
;
track
=
track
->
Next
()
)
trackLen
+=
track
->
GetLength
();
valeur_param
(
KiROUND
(
trackLen
),
msg
);
msg
=
frame
->
LengthDoubleToString
(
trackLen
);
frame
->
AppendMsgPanel
(
_
(
"Track Len"
),
msg
,
DARKCYAN
);
if
(
lenDie
!=
0
)
// display the track len on board and the actual track len
{
frame
->
AppendMsgPanel
(
_
(
"Full Len"
),
msg
,
DARKCYAN
);
valeur_param
(
KiROUND
(
trackLen
+
lenDie
),
msg
);
msg
=
frame
->
LengthDoubleToString
(
trackLen
+
lenDie
);
frame
->
AppendMsgPanel
(
_
(
"On Die"
),
msg
,
DARKCYAN
);
}
...
...
pcbnew/legacy_plugin.cpp
View file @
f3503723
...
...
@@ -2682,7 +2682,7 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
// conversion factor for saving RAM BIUs to KICAD legacy file format.
#if defined( USE_PCBNEW_NANOMETRES )
biuToDisk
=
1
/
1000000.0
;
// BIUs are nanometers & file is mm
biuToDisk
=
1
/
IU_PER_MM
;
// BIUs are nanometers & file is mm
#else
biuToDisk
=
1.0
;
// BIUs are deci-mils
#endif
...
...
@@ -2694,11 +2694,8 @@ void LEGACY_PLUGIN::init( PROPERTIES* aProperties )
// then, during the file loading process, to start a conversion from
// mm to nanometers.
#if defined( USE_PCBNEW_NANOMETRES )
diskToBiu
=
2540.0
;
// BIUs are nanometers
#else
diskToBiu
=
1.0
;
// BIUs are deci-mils
#endif
diskToBiu
=
IU_PER_DECIMILS
;
// BIUs are nanometers if USE_PCBNEW_NANOMETRES
// or BIUs are deci-mils
}
...
...
pcbnew/printout_controler.cpp
View file @
f3503723
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2009 Jean-Pierre Charras, j
aen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2009 Jean-Pierre Charras, j
ean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
...
...
@@ -180,12 +180,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if
(
userscale
==
0
)
// fit in page
{
// Margin = 0.4 inch
#if defined(KICAD_NANOMETRE)
int
extra_margin
=
int
(
0.4
*
25400
);
// nanometers
#else
int
extra_margin
=
int
(
0.4
*
1000
);
// deci-mils
#endif
// Margin = 10mm
int
extra_margin
=
int
(
10
*
IU_PER_MM
);
// deci-mils
pageSizeIU
.
x
=
bbbox
.
GetWidth
()
+
extra_margin
*
2
;
pageSizeIU
.
y
=
bbbox
.
GetHeight
()
+
extra_margin
*
2
;
...
...
@@ -216,8 +212,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
MapScreenSizeToPaper
();
int
w
,
h
;
GetPPIPrinter
(
&
w
,
&
h
);
double
accurate_Xscale
=
(
(
double
)
(
DrawZoom
*
w
)
)
/
(
double
)
PCB_INTERNAL_UNIT
;
double
accurate_Yscale
=
(
(
double
)
(
DrawZoom
*
h
)
)
/
(
double
)
PCB_INTERNAL_UNIT
;
double
accurate_Xscale
=
(
(
double
)
(
DrawZoom
*
w
)
)
/
(
IU_PER_MILS
*
1000
)
;
double
accurate_Yscale
=
(
(
double
)
(
DrawZoom
*
h
)
)
/
(
IU_PER_MILS
*
1000
)
;
if
(
IsPreview
()
)
// Scale must take in account the DC size in Preview
{
...
...
@@ -278,7 +274,8 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
int
bg_color
=
g_DrawBgColor
;
if
(
m_PrintParams
.
m_Print_Sheet_Ref
)
m_Parent
->
TraceWorkSheet
(
dc
,
screen
,
m_PrintParams
.
m_PenDefaultSize
,
MILS_TO_IU_SCALAR
);
m_Parent
->
TraceWorkSheet
(
dc
,
screen
,
m_PrintParams
.
m_PenDefaultSize
,
IU_PER_MILS
);
if
(
printMirror
)
{
...
...
@@ -320,7 +317,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
/* when printing in color mode, we use the graphic OR mode that gives the same look as the screen
* But because the background is white when printing, we must use a trick:
* In order to plot on a white background in OR mode we must:
* 1 - Plot all items in black, this creates a local black backgroud
* 1 - Plot all items in black, this creates a local black backgrou
n
d
* 2 - Plot in OR mode on black "local" background
*/
if
(
!
m_PrintParams
.
m_Print_Black_and_White
)
...
...
pcbnew/scripting/module.i
View file @
f3503723
...
...
@@ -52,7 +52,7 @@
if type(itemC) is D_PAD:
item.thisown=0
self.m_Pads.PushBack(itemC)
elif type(itemC) in [ TEXTE_PCB, DIMENSION, TEXTE_MODULE, DRAWSEGMENT]:
elif type(itemC) in [ TEXTE_PCB, DIMENSION, TEXTE_MODULE, DRAWSEGMENT
,EDGE_MODULE
]:
item.thisown = 0
self.m_Drawings.PushBack(item)
}
...
...
pcbnew/scripting/pcbnew.i
View file @
f3503723
...
...
@@ -73,7 +73,9 @@
#include <class_board.h>
#include <class_module.h>
#include <class_track.h>
#include <layers_id_colors_and_visibility.h>
#include <class_pad.h>
#include <pad_shapes.h>
#include <class_netinfo.h>
#include <class_pcb_text.h>
#include <class_dimension.h>
...
...
@@ -85,7 +87,6 @@
#include <class_zone_settings.h>
#include <class_netclass.h>
#include <class_netinfo.h>
#include <layers_id_colors_and_visibility.h>
#include <pcbnew_scripting_helpers.h>
...
...
@@ -104,7 +105,9 @@
%include <class_board.h>
%include <class_module.h>
%include <class_track.h>
%include <layers_id_colors_and_visibility.h>
%include <class_pad.h>
%include <pad_shapes.h>
%include <class_netinfo.h>
%include <class_pcb_text.h>
%include <class_dimension.h>
...
...
@@ -116,7 +119,6 @@
%include <class_zone_settings.h>
%include <class_netclass.h>
%include <class_netinfo.h>
%include <layers_id_colors_and_visibility.h>
%include "board_item.i"
...
...
pcbnew/specctra_export.cpp
View file @
f3503723
...
...
@@ -48,6 +48,7 @@
#include <class_track.h>
#include <class_zone.h>
#include <class_drawsegment.h>
#include <base_units.h>
#include <collectors.h>
...
...
@@ -99,7 +100,7 @@ void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event )
wxString
errorText
;
BASE_SCREEN
*
screen
=
GetScreen
();
bool
wasModified
=
screen
->
IsModify
()
&&
!
screen
->
IsSave
()
;
bool
wasModified
=
screen
->
IsModify
();
db
.
SetPCB
(
SPECCTRA_DB
::
MakePCB
()
);
...
...
@@ -171,10 +172,10 @@ static inline double scale( int kicadDist )
#if defined(USE_PCBNEW_NANOMETRES)
// nanometers to um
return
kicadDist
/
1000.0
;
return
kicadDist
/
(
IU_PER_MM
/
1000.0
)
;
// nanometers to mils
// return kicadDist/
25400.0
;
// return kicadDist/
IU_PER_MILS
;
#else
// deci-mils to mils.
...
...
@@ -185,11 +186,7 @@ static inline double scale( int kicadDist )
/// Convert integer internal units to float um
static
inline
double
IU2um
(
int
kicadDist
)
{
#if defined(USE_PCBNEW_NANOMETRES)
return
kicadDist
/
1000.0
;
#else
return
kicadDist
*
25.4e-1
;
#endif
return
kicadDist
*
(
1000.0
/
IU_PER_MM
);
}
...
...
pcbnew/tracepcb.cpp
View file @
f3503723
...
...
@@ -67,7 +67,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GRSetDrawMode
(
DC
,
GR_COPY
);
m_canvas
->
DrawBackGround
(
DC
);
TraceWorkSheet
(
DC
,
screen
,
0
,
MILS_TO_IU_SCALAR
);
TraceWorkSheet
(
DC
,
screen
,
0
,
IU_PER_MILS
);
// Redraw the footprints
for
(
MODULE
*
module
=
GetBoard
()
->
m_Modules
;
module
;
module
=
module
->
Next
()
)
...
...
@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
m_canvas
->
DrawBackGround
(
DC
);
TraceWorkSheet
(
DC
,
GetScreen
(),
g_DrawDefaultLineThickness
,
MILS_TO_IU_SCALAR
);
TraceWorkSheet
(
DC
,
GetScreen
(),
g_DrawDefaultLineThickness
,
IU_PER_MILS
);
GetBoard
()
->
Draw
(
m_canvas
,
DC
,
GR_OR
|
GR_ALLOW_HIGHCONTRAST
);
...
...
polygon/PolyLine.cpp
View file @
f3503723
...
...
@@ -357,9 +357,7 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector<
else
{
// style is ARC_CW or ARC_CCW
int
n
;
// number of steps for arcs
n
=
(
abs
(
x2
-
x1
)
+
abs
(
y2
-
y1
)
)
/
(
CArc
::
MAX_STEP
);
n
=
MAX
(
n
,
CArc
::
MIN_STEPS
);
// or at most 5 degrees of arc
int
n
=
CArc
::
ARC_STEPS
;
n_vertices
+=
n
;
n_arcs
++
;
}
...
...
@@ -392,8 +390,7 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector<
{
// style is arc_cw or arc_ccw
int
n
;
// number of steps for arcs
n
=
(
abs
(
x2
-
x1
)
+
abs
(
y2
-
y1
)
)
/
(
CArc
::
MAX_STEP
);
n
=
MAX
(
n
,
CArc
::
MIN_STEPS
);
// or at most 5 degrees of arc
n
=
CArc
::
ARC_STEPS
;
double
xo
,
yo
,
theta1
,
theta2
,
a
,
b
;
a
=
fabs
(
(
double
)
(
x1
-
x2
)
);
b
=
fabs
(
(
double
)
(
y1
-
y2
)
);
...
...
polygon/PolyLine.h
View file @
f3503723
...
...
@@ -77,8 +77,7 @@ public:
class
CArc
{
public
:
enum
{
MAX_STEP
=
50
*
25400
};
// max step is 20 mils
enum
{
MIN_STEPS
=
18
};
// min step is 5 degrees
enum
{
ARC_STEPS
=
16
};
// arc approximation step is 16 segm / 90 degres
int
style
;
int
xi
,
yi
,
xf
,
yf
;
int
n_steps
;
// number of straight-line segments in gpc_poly
...
...
polygon/math_for_graphics.cpp
View file @
f3503723
...
...
@@ -12,6 +12,14 @@
#define NM_PER_MIL 25400
double
Distance
(
double
x1
,
double
y1
,
double
x2
,
double
y2
)
{
double
dx
=
x1
-
x2
;
double
dy
=
y1
-
y2
;
double
d
=
sqrt
(
dx
*
dx
+
dy
*
dy
);
return
d
;
}
/**
* Function TestLineHit
...
...
@@ -1031,7 +1039,7 @@ int GetClearanceBetweenSegments( int x1i, int y1i, int x1f, int y1f, int style1,
y2
=
el2
.
Center
.
Y
+
el2
.
yrad
*
sin
(
s2
);
}
double
d
=
Distance
(
(
int
)
x
,
(
int
)
y
,
(
int
)
x2
,
(
int
)
y2
);
double
d
=
Distance
(
x
,
y
,
x2
,
y2
);
if
(
d
<
dmin
)
{
...
...
@@ -1101,7 +1109,7 @@ double GetPointToLineDistance( double a, double b, int x, int y, double* xpp, do
}
// find distance
return
Distance
(
x
,
y
,
(
int
)
xp
,
(
int
)
yp
);
return
Distance
(
x
,
y
,
xp
,
yp
);
}
...
...
@@ -1151,7 +1159,7 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
// find distance
if
(
InRange
(
xp
,
xi
,
xf
)
&&
InRange
(
yp
,
yi
,
yf
)
)
return
Distance
(
x
,
y
,
(
int
)
xp
,
(
int
)
yp
);
return
Distance
(
x
,
y
,
xp
,
yp
);
else
return
min
(
Distance
(
x
,
y
,
xi
,
yi
),
Distance
(
x
,
y
,
xf
,
yf
)
);
}
...
...
@@ -1177,26 +1185,6 @@ bool InRange( double x, double xi, double xf )
}
// Get distance between 2 points
//
double
Distance
(
int
x1
,
int
y1
,
int
x2
,
int
y2
)
{
double
dx
=
x1
-
x2
;
double
dy
=
y1
-
y2
;
double
d
=
sqrt
(
dx
*
dx
+
dy
*
dy
);
if
(
d
>
INT_MAX
||
d
<
INT_MIN
)
{
wxASSERT
(
0
);
}
// wxASSERT( d <= INT_MAX && d >= INT_MIN );
return
int
(
d
);
}
// this finds approximate solutions
// note: this works best if el2 is smaller than el1
//
...
...
@@ -1368,7 +1356,7 @@ double GetArcClearance( EllipseKH* el1, EllipseKH* el2,
double
x2
=
el2
->
Center
.
X
+
el2
->
xrad
*
cos
(
theta2
);
double
y2
=
el2
->
Center
.
Y
+
el2
->
yrad
*
sin
(
theta2
);
double
d
=
Distance
(
(
int
)
x
,
(
int
)
y
,
(
int
)
x2
,
(
int
)
y2
);
double
d
=
Distance
(
x
,
y
,
x2
,
y2
);
if
(
d
<
dmin
)
{
...
...
polygon/math_for_graphics.h
View file @
f3503723
...
...
@@ -71,7 +71,9 @@ double GetPointToLineSegmentDistance( int x, int y, int xi, int yi, int xf, int
double
GetPointToLineDistance
(
double
a
,
double
b
,
int
x
,
int
y
,
double
*
xp
=
NULL
,
double
*
yp
=
NULL
);
bool
InRange
(
double
x
,
double
xi
,
double
xf
);
double
Distance
(
int
x1
,
int
y1
,
int
x2
,
int
y2
);
double
Distance
(
double
x1
,
double
y1
,
double
x2
,
double
y2
);
int
GetArcIntersections
(
EllipseKH
*
el1
,
EllipseKH
*
el2
,
double
*
x1
=
NULL
,
double
*
y1
=
NULL
,
double
*
x2
=
NULL
,
double
*
y2
=
NULL
);
...
...
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