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
f59e30bc
Commit
f59e30bc
authored
Sep 23, 2010
by
jean-pierre charras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a minor artefact when redraw the grid after a scrool.
parent
148baffd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
40 deletions
+53
-40
base_screen.cpp
common/base_screen.cpp
+0
-1
drawpanel.cpp
common/drawpanel.cpp
+34
-25
zoom.cpp
common/zoom.cpp
+12
-10
class_base_screen.h
include/class_base_screen.h
+0
-1
wxstruct.h
include/wxstruct.h
+7
-3
No files found.
common/base_screen.cpp
View file @
f59e30bc
...
...
@@ -34,7 +34,6 @@ BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) : EDA_BaseStruct( aType )
m_Zoom
=
32
*
m_ZoomScalar
;
m_Grid
.
m_Size
=
wxRealPoint
(
50
,
50
);
/* Default grid size */
m_Grid
.
m_Id
=
ID_POPUP_GRID_LEVEL_50
;
m_UserGridIsON
=
FALSE
;
m_Center
=
true
;
m_CurrentSheetDesc
=
&
g_Sheet_A4
;
m_IsPrinting
=
false
;
...
...
common/drawpanel.cpp
View file @
f59e30bc
...
...
@@ -758,11 +758,13 @@ void WinEDA_DrawPanel::DrawBackGround( wxDC* DC )
*/
void
WinEDA_DrawPanel
::
DrawGrid
(
wxDC
*
DC
)
{
#define MIN_GRID_SIZE 10 // min grid size in pixels to allow drawing
BASE_SCREEN
*
screen
=
GetScreen
();
int
ii
,
jj
,
xg
,
yg
;
wxRealPoint
screen_grid_size
;
wxSize
size
;
wxPoint
org
;
wxRealPoint
dgrid
;
/* The grid must be visible. this is possible only is grid value
* and zoom value are sufficient
...
...
@@ -773,43 +775,50 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
size
=
GetClientSize
();
#ifdef USE_WX_ZOOM
if
(
DC
->
LogicalToDeviceXRel
(
wxRound
(
screen_grid_size
.
x
)
)
<
5
||
DC
->
LogicalToDeviceXRel
(
wxRound
(
screen_grid_size
.
y
)
)
<
5
)
return
;
dgrid
.
x
=
DC
->
LogicalToDeviceXRel
(
wxRound
(
screen_grid_size
.
x
)
);
dgrid
.
y
=
DC
->
LogicalToDeviceXRel
(
wxRound
(
screen_grid_size
.
y
)
);
org
=
m_ClipBox
.
m_Pos
;
size
=
m_ClipBox
.
m_Size
;
#else
wxRealPoint
dgrid
=
screen_grid_size
;
dgrid
=
screen_grid_size
;
screen
->
Scale
(
dgrid
);
// dgrid = grid size in pixels
screen
->
Unscale
(
size
);
screen
->
Unscale
(
org
);
org
+=
screen
->
m_DrawOrg
;
#endif
// if the grid size is small ( < 5 pixels) do not display all points
if
(
dgrid
.
x
<
5
)
// if the grid size is small ( < MIN_GRID_SIZE pixels ) do not display all points
bool
double_size
=
false
;
if
(
dgrid
.
x
<
MIN_GRID_SIZE
)
{
screen_grid_size
.
x
*=
2
;
double_size
=
true
;
dgrid
.
x
*=
2
;
}
if
(
dgrid
.
x
<
5
)
return
;
// The grid is too small: do not show it
if
(
dgrid
.
x
<
MIN_GRID_SIZE
)
return
;
// The
X
grid is too small: do not show it
if
(
dgrid
.
y
<
5
)
if
(
dgrid
.
y
<
MIN_GRID_SIZE
)
{
screen_grid_size
.
y
*=
2
;
double_size
=
true
;
dgrid
.
y
*=
2
;
}
if
(
dgrid
.
y
<
5
)
return
;
// The
grid is too small
if
(
dgrid
.
y
<
MIN_GRID_SIZE
)
return
;
// The
Y grid is too small: do not show it
screen
->
Unscale
(
size
);
screen
->
Unscale
(
org
);
org
+=
screen
->
m_DrawOrg
;
#endif
m_Parent
->
PutOnGrid
(
&
org
);
GRSetColorPen
(
DC
,
m_Parent
->
GetGridColor
()
);
int
xpos
,
ypos
;
/* When we use an double_size grid, we must align grid ord on double grid
*/
int
increment
=
double_size
?
2
:
1
;
if
(
double_size
)
{
wxRealPoint
dblgrid
=
screen_grid_size
*
2
;
m_Parent
->
PutOnGrid
(
&
org
,
&
dblgrid
);
}
// Draw grid: the best algorithm depend on the platform.
// under macOSX, the first method is better
...
...
@@ -824,14 +833,14 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
#if defined( __WXMAC__ ) && !defined( USE_WX_ZOOM )
// Use a pixel based draw to display grid
// When is not used USE_WX_ZOOM
for
(
ii
=
0
;
;
ii
++
)
for
(
ii
=
0
;
;
ii
+=
increment
)
{
xg
=
wxRound
(
ii
*
screen_grid_size
.
x
);
if
(
xg
>
size
.
x
)
break
;
xpos
=
org
.
x
+
xg
;
xpos
=
GRMapX
(
xpos
);
for
(
jj
=
0
;
;
jj
++
)
for
(
jj
=
0
;
;
jj
+=
increment
)
{
yg
=
wxRound
(
jj
*
screen_grid_size
.
y
);
if
(
yg
>
size
.
y
)
...
...
@@ -846,7 +855,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
// Use a pixel based draw to display grid
// There is a lot of calls, so the cost is hight
// and grid is slowly drawn on some platforms
for
(
ii
=
0
;
;
ii
++
)
for
(
ii
=
0
;
;
ii
+=
increment
)
{
xg
=
wxRound
(
ii
*
screen_grid_size
.
x
);
if
(
xg
>
size
.
x
)
...
...
@@ -857,7 +866,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
continue
;
if
(
xpos
>
m_ClipBox
.
GetEnd
().
x
)
// end of active area reached.
break
;
for
(
jj
=
0
;
;
jj
++
)
for
(
jj
=
0
;
;
jj
+=
increment
)
{
yg
=
wxRound
(
jj
*
screen_grid_size
.
y
);
if
(
yg
>
size
.
y
)
...
...
@@ -890,7 +899,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
GRSetColorPen
(
&
tmpDC
,
g_DrawBgColor
);
tmpDC
.
DrawLine
(
0
,
0
,
0
,
screenSize
.
y
-
1
);
// init background
GRSetColorPen
(
&
tmpDC
,
m_Parent
->
GetGridColor
()
);
for
(
jj
=
0
;
;
jj
++
)
// draw grid points
for
(
jj
=
0
;
;
jj
+=
increment
)
// draw grid points
{
yg
=
wxRound
(
jj
*
screen_grid_size
.
y
);
ypos
=
screen
->
Scale
(
yg
);
...
...
@@ -900,7 +909,7 @@ void WinEDA_DrawPanel::DrawGrid( wxDC* DC )
}
ypos
=
GRMapY
(
org
.
y
);
for
(
ii
=
0
;
;
ii
++
)
for
(
ii
=
0
;
;
ii
+=
increment
)
{
xg
=
wxRound
(
ii
*
screen_grid_size
.
x
);
if
(
xg
>
size
.
x
)
...
...
@@ -1107,7 +1116,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxMouseEvent& event )
* in order to avoid spurious block commands.
*/
static
int
MinDragEventCount
;
if
(
event
.
Leaving
()
/*|| event.Entering()*/
)
if
(
event
.
Leaving
()
)
{
m_CanStartBlock
=
-
1
;
}
...
...
common/zoom.cpp
View file @
f59e30bc
...
...
@@ -46,23 +46,25 @@ void WinEDA_DrawFrame::Recadre_Trace( bool ToMouse )
/** Adjust the coordinate to the nearest grid value
* @param coord = coordinate to adjust
* @param aCoord = coordinate to adjust
* @param aGridSize = pointer to a grid value. if NULL uses the current grid size
*/
void
WinEDA_DrawFrame
::
PutOnGrid
(
wxPoint
*
coord
)
void
WinEDA_DrawFrame
::
PutOnGrid
(
wxPoint
*
aCoord
,
wxRealPoint
*
aGridSize
)
{
wxRealPoint
grid_size
=
GetBaseScreen
()
->
GetGridSize
();
wxRealPoint
grid_size
;
if
(
aGridSize
)
grid_size
=
*
aGridSize
;
else
grid_size
=
GetBaseScreen
()
->
GetGridSize
();
if
(
!
GetBaseScreen
()
->
m_UserGridIsON
)
// XXX UNUSED VARIABLE???
{
const
wxPoint
&
grid_origin
=
GetBaseScreen
()
->
GetGridOrigin
();
double
offset
=
fmod
(
grid_origin
.
x
,
grid_size
.
x
);
int
tmp
=
wxRound
(
(
c
oord
->
x
-
offset
)
/
grid_size
.
x
);
c
oord
->
x
=
wxRound
(
tmp
*
grid_size
.
x
+
offset
);
int
tmp
=
wxRound
(
(
aC
oord
->
x
-
offset
)
/
grid_size
.
x
);
aC
oord
->
x
=
wxRound
(
tmp
*
grid_size
.
x
+
offset
);
offset
=
fmod
(
grid_origin
.
y
,
grid_size
.
y
);
tmp
=
wxRound
(
(
coord
->
y
-
offset
)
/
grid_size
.
y
);
coord
->
y
=
wxRound
(
tmp
*
grid_size
.
y
+
offset
);
}
tmp
=
wxRound
(
(
aCoord
->
y
-
offset
)
/
grid_size
.
y
);
aCoord
->
y
=
wxRound
(
tmp
*
grid_size
.
y
+
offset
);
}
...
...
include/class_base_screen.h
View file @
f59e30bc
...
...
@@ -132,7 +132,6 @@ private:
public
:
wxPoint
m_GridOrigin
;
GridArray
m_GridList
;
bool
m_UserGridIsON
;
wxArrayInt
m_ZoomList
;
/* Array of standard zoom coefficients. */
int
m_Zoom
;
/* Current zoom coefficient. */
...
...
include/wxstruct.h
View file @
f59e30bc
...
...
@@ -361,9 +361,13 @@ public:
virtual
void
OnZoom
(
wxCommandEvent
&
event
);
void
OnGrid
(
int
grid_type
);
void
Recadre_Trace
(
bool
ToMouse
);
void
PutOnGrid
(
wxPoint
*
coord
);
/* set the coordinate to
* the nearest grid
* coordinate */
/** Adjust the coordinate to the nearest grid value
* @param aCoord = coordinate to adjust
* @param aGridSize = pointer to a grid value. if NULL uses the current grid size
*/
void
PutOnGrid
(
wxPoint
*
aCoord
,
wxRealPoint
*
aGridSize
=
NULL
);
void
Zoom_Automatique
(
bool
move_mouse_cursor
);
/* Set the zoom level to show the area Rect */
...
...
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