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
c4888afb
Commit
c4888afb
authored
Apr 30, 2015
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the way GAL handles zoom settings.
parent
74a902da
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
59 deletions
+103
-59
draw_frame.cpp
common/draw_frame.cpp
+20
-38
zoom.cpp
common/zoom.cpp
+27
-14
class_base_screen.h
include/class_base_screen.h
+1
-1
draw_frame.h
include/draw_frame.h
+13
-0
common_actions.cpp
pcbnew/tools/common_actions.cpp
+10
-6
common_actions.h
pcbnew/tools/common_actions.h
+1
-0
pcbnew_control.cpp
pcbnew/tools/pcbnew_control.cpp
+30
-0
pcbnew_control.h
pcbnew/tools/pcbnew_control.h
+1
-0
No files found.
common/draw_frame.cpp
View file @
c4888afb
...
...
@@ -424,8 +424,7 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
if
(
IsGalCanvasActive
()
)
{
GetGalCanvas
()
->
GetGAL
()
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGrid
().
m_Size
.
x
,
screen
->
GetGrid
().
m_Size
.
y
)
);
GetGalCanvas
()
->
GetGAL
()
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGrid
().
m_Size
)
);
GetGalCanvas
()
->
GetView
()
->
MarkTargetDirty
(
KIGFX
::
TARGET_NONCACHED
);
}
...
...
@@ -456,22 +455,14 @@ void EDA_DRAW_FRAME::OnSelectZoom( wxCommandEvent& event )
return
;
GetScreen
()
->
SetZoom
(
selectedZoom
);
RedrawScreen
(
GetScrollCenterPosition
(),
false
);
}
if
(
IsGalCanvasActive
()
)
{
// Apply computed view settings to GAL
KIGFX
::
VIEW
*
view
=
GetGalCanvas
()
->
GetView
();
KIGFX
::
GAL
*
gal
=
GetGalCanvas
()
->
GetGAL
();
double
zoomFactor
=
gal
->
GetWorldScale
()
/
gal
->
GetZoomFactor
();
double
zoom
=
1.0
/
(
zoomFactor
*
GetZoom
()
);
// Notify GAL
TOOL_MANAGER
*
mgr
=
GetToolManager
();
view
->
SetScale
(
zoom
);
GetGalCanvas
()
->
Refresh
();
}
else
RedrawScreen
(
GetScrollCenterPosition
(),
false
);
}
if
(
mgr
&&
IsGalCanvasActive
()
)
mgr
->
RunAction
(
"common.Control.zoomPreset"
,
true
,
id
);
}
...
...
@@ -1026,38 +1017,29 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
KIGFX
::
GAL
*
gal
=
GetGalCanvas
()
->
GetGAL
();
double
zoomFactor
=
gal
->
GetWorldScale
()
/
gal
->
GetZoomFactor
();
BASE_SCREEN
*
screen
=
GetScreen
();
// Display the same view after canvas switching
if
(
aEnable
)
if
(
aEnable
)
// Switch to GAL rendering
{
BASE_SCREEN
*
screen
=
GetScreen
();
// Switch to GAL rendering
if
(
!
IsGalCanvasActive
()
)
{
// Set up viewport
double
zoom
=
1.0
/
(
zoomFactor
*
m_canvas
->
GetZoom
()
);
view
->
SetScale
(
zoom
);
view
->
SetCenter
(
VECTOR2D
(
m_canvas
->
GetScreenCenterLogicalPosition
()
)
);
}
// Set up viewport
double
zoom
=
1.0
/
(
zoomFactor
*
m_canvas
->
GetZoom
()
);
view
->
SetScale
(
zoom
);
view
->
SetCenter
(
VECTOR2D
(
m_canvas
->
GetScreenCenterLogicalPosition
()
)
);
// Set up grid settings
gal
->
SetGridVisibility
(
IsGridVisible
()
);
gal
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGridSize
()
.
x
,
screen
->
GetGridSize
().
y
)
);
gal
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGridSize
()
)
);
gal
->
SetGridOrigin
(
VECTOR2D
(
GetGridOrigin
()
)
);
}
else
else
// Switch to standard rendering
{
// Switch to standard rendering
if
(
IsGalCanvasActive
()
)
{
// Change view settings only if GAL was active previously
double
zoom
=
1.0
/
(
zoomFactor
*
view
->
GetScale
()
);
m_canvas
->
SetZoom
(
zoom
);
// Change view settings only if GAL was active previously
double
zoom
=
1.0
/
(
zoomFactor
*
view
->
GetScale
()
);
m_canvas
->
SetZoom
(
zoom
);
VECTOR2D
center
=
view
->
GetCenter
();
RedrawScreen
(
wxPoint
(
center
.
x
,
center
.
y
),
false
);
}
VECTOR2D
center
=
view
->
GetCenter
();
AdjustScrollBars
(
wxPoint
(
center
.
x
,
center
.
y
)
);
}
m_canvas
->
SetEvtHandlerEnabled
(
!
aEnable
);
...
...
common/zoom.cpp
View file @
c4888afb
...
...
@@ -33,8 +33,6 @@
#include <fctsys.h>
#include <id.h>
#include <class_drawpanel.h>
#include <class_draw_panel_gal.h>
#include <gal/graphics_abstraction_layer.h>
#include <view/view.h>
#include <class_base_screen.h>
#include <draw_frame.h>
...
...
@@ -46,6 +44,9 @@
void
EDA_DRAW_FRAME
::
RedrawScreen
(
const
wxPoint
&
aCenterPoint
,
bool
aWarpPointer
)
{
if
(
IsGalCanvasActive
()
)
return
;
AdjustScrollBars
(
aCenterPoint
);
// Move the mouse cursor to the on grid graphic cursor position
...
...
@@ -58,6 +59,9 @@ void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
void
EDA_DRAW_FRAME
::
RedrawScreen2
(
const
wxPoint
&
posBefore
)
{
if
(
IsGalCanvasActive
()
)
return
;
wxPoint
dPos
=
posBefore
-
m_canvas
->
GetClientSize
()
/
2
;
// relative screen position to center before zoom
wxPoint
newScreenPos
=
m_canvas
->
ToDeviceXY
(
GetCrossHairPosition
()
);
// screen position of crosshair after zoom
wxPoint
newCenter
=
m_canvas
->
ToLogicalXY
(
newScreenPos
-
dPos
);
...
...
@@ -186,18 +190,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
break
;
default
:
unsigned
i
;
i
=
id
-
ID_POPUP_ZOOM_LEVEL_START
;
if
(
i
>=
screen
->
m_ZoomList
.
size
()
)
{
wxLogDebug
(
wxT
(
"%s %d: index %d is outside the bounds of the zoom list."
),
__TFILE__
,
__LINE__
,
i
);
return
;
}
if
(
screen
->
SetZoom
(
screen
->
m_ZoomList
[
i
]
)
)
RedrawScreen
(
center
,
true
);
SetPresetZoom
(
id
-
ID_POPUP_ZOOM_LEVEL_START
);
}
UpdateStatusBar
();
...
...
@@ -216,6 +209,26 @@ void EDA_DRAW_FRAME::SetPrevZoom()
}
void
EDA_DRAW_FRAME
::
SetPresetZoom
(
int
aIndex
)
{
BASE_SCREEN
*
screen
=
GetScreen
();
if
(
aIndex
>=
(
int
)
screen
->
m_ZoomList
.
size
()
)
{
wxLogDebug
(
wxT
(
"%s %d: index %d is outside the bounds of the zoom list."
),
__TFILE__
,
__LINE__
,
aIndex
);
return
;
}
m_zoomSelectBox
->
SetSelection
(
aIndex
);
if
(
screen
->
SetZoom
(
screen
->
m_ZoomList
[
aIndex
]
)
)
RedrawScreen
(
GetScrollCenterPosition
(),
true
);
UpdateStatusBar
();
}
/* add the zoom list menu the the MasterMenu.
* used in OnRightClick(wxMouseEvent& event)
*/
...
...
include/class_base_screen.h
View file @
c4888afb
...
...
@@ -215,7 +215,7 @@ public:
int
m_ScreenNumber
;
int
m_NumberOfScreens
;
std
::
vector
<
double
>
m_ZoomList
;
///< standard zoom (i.e. scale) coefficients.
std
::
vector
<
int
>
m_ZoomList
;
///< standard zoom (i.e. scale) coefficients.
bool
m_IsPrinting
;
public
:
...
...
include/draw_frame.h
View file @
c4888afb
...
...
@@ -346,6 +346,12 @@ public:
*/
virtual
const
wxString
GetZoomLevelIndicator
()
const
;
/**
* Function GetZoomLevelCoeff
* returns the coefficient to convert internal display scale factor to zoom level.
*/
inline
double
GetZoomLevelCoeff
()
const
{
return
m_zoomLevelCoeff
;
}
void
EraseMsgBox
();
void
Process_PageSettings
(
wxCommandEvent
&
event
);
...
...
@@ -505,6 +511,13 @@ public:
*/
void
SetPrevZoom
();
/**
* Function SetPresetZoom()
* changes zoom to one of the preset values.
* @param aIndex is the zoom index from the list.
*/
void
SetPresetZoom
(
int
aIndex
);
/**
* Function RedrawScreen
* redraws the entire screen area by updating the scroll bars and mouse pointer in
...
...
pcbnew/tools/common_actions.cpp
View file @
c4888afb
...
...
@@ -181,30 +181,34 @@ TOOL_ACTION COMMON_ACTIONS::arcPosture( "pcbnew.InteractiveDrawing.arcPosture",
// View Controls
TOOL_ACTION
COMMON_ACTIONS
::
zoomIn
(
"
pcbnew
.Control.zoomIn"
,
TOOL_ACTION
COMMON_ACTIONS
::
zoomIn
(
"
common
.Control.zoomIn"
,
AS_GLOBAL
,
WXK_F1
,
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
zoomOut
(
"
pcbnew
.Control.zoomOut"
,
TOOL_ACTION
COMMON_ACTIONS
::
zoomOut
(
"
common
.Control.zoomOut"
,
AS_GLOBAL
,
WXK_F2
,
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
zoomInCenter
(
"
pcbnew
.Control.zoomInCenter"
,
TOOL_ACTION
COMMON_ACTIONS
::
zoomInCenter
(
"
common
.Control.zoomInCenter"
,
AS_GLOBAL
,
0
,
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
zoomOutCenter
(
"
pcbnew
.Control.zoomOutCenter"
,
TOOL_ACTION
COMMON_ACTIONS
::
zoomOutCenter
(
"
common
.Control.zoomOutCenter"
,
AS_GLOBAL
,
0
,
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
zoomCenter
(
"
pcbnew
.Control.zoomCenter"
,
TOOL_ACTION
COMMON_ACTIONS
::
zoomCenter
(
"
common
.Control.zoomCenter"
,
AS_GLOBAL
,
WXK_F4
,
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
zoomFitScreen
(
"
pcbnew
.Control.zoomFitScreen"
,
TOOL_ACTION
COMMON_ACTIONS
::
zoomFitScreen
(
"
common
.Control.zoomFitScreen"
,
AS_GLOBAL
,
WXK_HOME
,
""
,
""
);
TOOL_ACTION
COMMON_ACTIONS
::
zoomPreset
(
"common.Control.zoomPreset"
,
AS_GLOBAL
,
0
,
""
,
""
);
// Display modes
TOOL_ACTION
COMMON_ACTIONS
::
trackDisplayMode
(
"pcbnew.Control.trackDisplayMode"
,
...
...
pcbnew/tools/common_actions.h
View file @
c4888afb
...
...
@@ -188,6 +188,7 @@ public:
static
TOOL_ACTION
zoomOutCenter
;
static
TOOL_ACTION
zoomCenter
;
static
TOOL_ACTION
zoomFitScreen
;
static
TOOL_ACTION
zoomPreset
;
// Display modes
static
TOOL_ACTION
trackDisplayMode
;
...
...
pcbnew/tools/pcbnew_control.cpp
View file @
c4888afb
...
...
@@ -140,6 +140,35 @@ int PCBNEW_CONTROL::ZoomFitScreen( const TOOL_EVENT& aEvent )
}
int
PCBNEW_CONTROL
::
ZoomPreset
(
const
TOOL_EVENT
&
aEvent
)
{
unsigned
int
idx
=
aEvent
.
Parameter
<
long
>
();
std
::
vector
<
int
>&
zoomList
=
m_frame
->
GetScreen
()
->
m_ZoomList
;
KIGFX
::
VIEW
*
view
=
m_frame
->
GetGalCanvas
()
->
GetView
();
KIGFX
::
GAL
*
gal
=
m_frame
->
GetGalCanvas
()
->
GetGAL
();
m_frame
->
SetPresetZoom
(
idx
);
if
(
idx
==
0
)
{
return
ZoomFitScreen
(
aEvent
);
}
else
if
(
idx
<
0
||
idx
>=
zoomList
.
size
()
)
{
setTransitions
();
return
0
;
}
double
selectedZoom
=
zoomList
[
idx
];
double
zoomFactor
=
gal
->
GetWorldScale
()
/
gal
->
GetZoomFactor
();
view
->
SetScale
(
1.0
/
(
zoomFactor
*
selectedZoom
)
);
setTransitions
();
return
0
;
}
int
PCBNEW_CONTROL
::
TrackDisplayMode
(
const
TOOL_EVENT
&
aEvent
)
{
KIGFX
::
PCB_PAINTER
*
painter
=
...
...
@@ -539,6 +568,7 @@ void PCBNEW_CONTROL::setTransitions()
Go
(
&
PCBNEW_CONTROL
::
ZoomInOutCenter
,
COMMON_ACTIONS
::
zoomOutCenter
.
MakeEvent
()
);
Go
(
&
PCBNEW_CONTROL
::
ZoomCenter
,
COMMON_ACTIONS
::
zoomCenter
.
MakeEvent
()
);
Go
(
&
PCBNEW_CONTROL
::
ZoomFitScreen
,
COMMON_ACTIONS
::
zoomFitScreen
.
MakeEvent
()
);
Go
(
&
PCBNEW_CONTROL
::
ZoomPreset
,
COMMON_ACTIONS
::
zoomPreset
.
MakeEvent
()
);
// Display modes
Go
(
&
PCBNEW_CONTROL
::
TrackDisplayMode
,
COMMON_ACTIONS
::
trackDisplayMode
.
MakeEvent
()
);
...
...
pcbnew/tools/pcbnew_control.h
View file @
c4888afb
...
...
@@ -51,6 +51,7 @@ public:
int
ZoomInOutCenter
(
const
TOOL_EVENT
&
aEvent
);
int
ZoomCenter
(
const
TOOL_EVENT
&
aEvent
);
int
ZoomFitScreen
(
const
TOOL_EVENT
&
aEvent
);
int
ZoomPreset
(
const
TOOL_EVENT
&
aEvent
);
// Display modes
int
TrackDisplayMode
(
const
TOOL_EVENT
&
aEvent
);
...
...
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