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
afc56d3f
Commit
afc56d3f
authored
Mar 12, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved panning boundaries and scale limits from VIEW to VIEW_CONTROL.
parent
c7fa57fa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
61 deletions
+87
-61
view.cpp
common/view/view.cpp
+1
-21
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+40
-4
view.h
include/view/view.h
+0
-29
view_controls.h
include/view/view_controls.h
+44
-6
pcbframe.cpp
pcbnew/pcbframe.cpp
+2
-1
No files found.
common/view/view.cpp
View file @
afc56d3f
...
...
@@ -45,10 +45,8 @@ VIEW::VIEW( bool aIsDynamic ) :
m_scale
(
1.0
),
m_painter
(
NULL
),
m_gal
(
NULL
),
m_dynamic
(
aIsDynamic
),
m_scaleLimits
(
15000.0
,
1.0
)
m_dynamic
(
aIsDynamic
)
{
m_panBoundary
.
SetMaximum
();
m_needsUpdate
.
reserve
(
32768
);
// Redraw everything at the beginning
...
...
@@ -295,11 +293,6 @@ void VIEW::SetMirror( bool aMirrorX, bool aMirrorY )
void
VIEW
::
SetScale
(
double
aScale
,
const
VECTOR2D
&
aAnchor
)
{
if
(
aScale
>
m_scaleLimits
.
x
)
aScale
=
m_scaleLimits
.
x
;
else
if
(
aScale
<
m_scaleLimits
.
y
)
aScale
=
m_scaleLimits
.
y
;
VECTOR2D
a
=
ToScreen
(
aAnchor
);
m_gal
->
SetZoomFactor
(
aScale
);
...
...
@@ -319,19 +312,6 @@ void VIEW::SetCenter( const VECTOR2D& aCenter )
{
m_center
=
aCenter
;
if
(
!
m_panBoundary
.
Contains
(
aCenter
)
)
{
if
(
aCenter
.
x
<
m_panBoundary
.
GetLeft
()
)
m_center
.
x
=
m_panBoundary
.
GetLeft
();
else
if
(
aCenter
.
x
>
m_panBoundary
.
GetRight
()
)
m_center
.
x
=
m_panBoundary
.
GetRight
();
if
(
aCenter
.
y
<
m_panBoundary
.
GetTop
()
)
m_center
.
y
=
m_panBoundary
.
GetTop
();
else
if
(
aCenter
.
y
>
m_panBoundary
.
GetBottom
()
)
m_center
.
y
=
m_panBoundary
.
GetBottom
();
}
m_gal
->
SetLookAtPoint
(
m_center
);
m_gal
->
ComputeWorldScreenMatrix
();
...
...
common/view/wx_view_controls.cpp
View file @
afc56d3f
...
...
@@ -66,6 +66,42 @@ void VIEW_CONTROLS::ShowCursor( bool aEnabled )
}
void
VIEW_CONTROLS
::
setCenter
(
const
VECTOR2D
&
aCenter
)
{
if
(
!
m_panBoundary
.
Contains
(
aCenter
)
)
{
VECTOR2D
newCenter
(
aCenter
);
if
(
aCenter
.
x
<
m_panBoundary
.
GetLeft
()
)
newCenter
.
x
=
m_panBoundary
.
GetLeft
();
else
if
(
aCenter
.
x
>
m_panBoundary
.
GetRight
()
)
newCenter
.
x
=
m_panBoundary
.
GetRight
();
if
(
aCenter
.
y
<
m_panBoundary
.
GetTop
()
)
newCenter
.
y
=
m_panBoundary
.
GetTop
();
else
if
(
aCenter
.
y
>
m_panBoundary
.
GetBottom
()
)
newCenter
.
y
=
m_panBoundary
.
GetBottom
();
m_view
->
SetCenter
(
newCenter
);
}
else
{
m_view
->
SetCenter
(
aCenter
);
}
}
void
VIEW_CONTROLS
::
setScale
(
double
aScale
,
const
VECTOR2D
&
aAnchor
)
{
if
(
aScale
<
m_minScale
)
aScale
=
m_minScale
;
else
if
(
aScale
>
m_maxScale
)
aScale
=
m_maxScale
;
m_view
->
SetScale
(
aScale
,
aAnchor
);
}
void
WX_VIEW_CONTROLS
::
onMotion
(
wxMouseEvent
&
aEvent
)
{
bool
isAutoPanning
=
false
;
...
...
@@ -80,7 +116,7 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
VECTOR2D
d
=
m_dragStartPoint
-
VECTOR2D
(
aEvent
.
GetX
(),
aEvent
.
GetY
()
);
VECTOR2D
delta
=
m_view
->
ToWorld
(
d
,
false
);
m_view
->
S
etCenter
(
m_lookStartPoint
+
delta
);
s
etCenter
(
m_lookStartPoint
+
delta
);
aEvent
.
StopPropagation
();
}
else
...
...
@@ -110,7 +146,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
VECTOR2D
delta
(
aEvent
.
ControlDown
()
?
-
scrollSpeed
:
0.0
,
aEvent
.
ShiftDown
()
?
-
scrollSpeed
:
0.0
);
m_view
->
S
etCenter
(
m_view
->
GetCenter
()
+
delta
);
s
etCenter
(
m_view
->
GetCenter
()
+
delta
);
}
else
{
...
...
@@ -133,7 +169,7 @@ void WX_VIEW_CONTROLS::onWheel( wxMouseEvent& aEvent )
}
VECTOR2D
anchor
=
m_view
->
ToWorld
(
VECTOR2D
(
aEvent
.
GetX
(),
aEvent
.
GetY
()
)
);
m_view
->
S
etScale
(
m_view
->
GetScale
()
*
zoomScale
,
anchor
);
s
etScale
(
m_view
->
GetScale
()
*
zoomScale
,
anchor
);
}
aEvent
.
Skip
();
...
...
@@ -190,7 +226,7 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
dir
=
dir
.
Resize
(
borderSize
);
dir
=
m_view
->
ToWorld
(
dir
,
false
);
m_view
->
S
etCenter
(
m_view
->
GetCenter
()
+
dir
*
m_autoPanSpeed
);
s
etCenter
(
m_view
->
GetCenter
()
+
dir
*
m_autoPanSpeed
);
// Notify tools that the cursor position has changed in the world coordinates
wxMouseEvent
moveEvent
(
EVT_REFRESH_MOUSE
);
...
...
include/view/view.h
View file @
afc56d3f
...
...
@@ -507,29 +507,6 @@ public:
*/
void
UpdateItems
();
/**
* Function SetPanBoundary()
* Sets limits for panning area.
* @param aBoundary is the box that limits panning area.
*/
void
SetPanBoundary
(
const
BOX2I
&
aBoundary
)
{
m_panBoundary
=
aBoundary
;
}
/**
* Function SetScaleLimits()
* Sets minimum and maximum values for scale.
* @param aMaximum is the maximum value for scale..
* @param aMinimum is the minimum value for scale.
*/
void
SetScaleLimits
(
double
aMaximum
,
double
aMinimum
)
{
wxASSERT_MSG
(
aMaximum
>
aMinimum
,
wxT
(
"I guess you passed parameters in wrong order"
)
);
m_scaleLimits
=
VECTOR2D
(
aMaximum
,
aMinimum
);
}
static
const
int
VIEW_MAX_LAYERS
=
128
;
///< maximum number of layers that may be shown
private
:
...
...
@@ -670,12 +647,6 @@ private:
/// Rendering order modifier for layers that are marked as top layers
static
const
int
TOP_LAYER_MODIFIER
=
-
VIEW_MAX_LAYERS
;
/// Panning boundaries
BOX2I
m_panBoundary
;
/// Zoom limits
VECTOR2D
m_scaleLimits
;
/// Items to be updated
std
::
vector
<
VIEW_ITEM
*>
m_needsUpdate
;
};
...
...
include/view/view_controls.h
View file @
afc56d3f
...
...
@@ -46,14 +46,40 @@ class VIEW;
class
VIEW_CONTROLS
{
public
:
VIEW_CONTROLS
(
VIEW
*
aView
)
:
m_view
(
aView
),
m_forceCursorPosition
(
false
),
m_snappingEnabled
(
false
),
m_grabMouse
(
false
),
m_autoPanEnabled
(
false
),
m_autoPanMargin
(
0
.
1
),
m_autoPanSpeed
(
0
.
15
)
{}
VIEW_CONTROLS
(
VIEW
*
aView
)
:
m_view
(
aView
),
m_minScale
(
4
.
0
),
m_maxScale
(
15000
),
m_forceCursorPosition
(
false
),
m_snappingEnabled
(
false
),
m_grabMouse
(
false
),
m_autoPanEnabled
(
false
),
m_autoPanMargin
(
0
.
1
),
m_autoPanSpeed
(
0
.
15
)
{
m_panBoundary
.
SetMaximum
();
}
virtual
~
VIEW_CONTROLS
()
{}
/**
* Function SetPanBoundary()
* Sets limits for panning area.
* @param aBoundary is the box that limits panning area.
*/
void
SetPanBoundary
(
const
BOX2I
&
aBoundary
)
{
m_panBoundary
=
aBoundary
;
}
/**
* Function SetScaleLimits()
* Sets minimum and maximum values for scale.
* @param aMaximum is the maximum value for scale.
* @param aMinimum is the minimum value for scale.
*/
void
SetScaleLimits
(
double
aMaximum
,
double
aMinimum
)
{
wxASSERT_MSG
(
aMaximum
>
aMinimum
,
wxT
(
"I guess you passed parameters in wrong order"
)
);
m_minScale
=
aMinimum
;
m_maxScale
=
aMaximum
;
}
/**
* Function SetSnapping()
* Enables/disables snapping cursor to grid.
...
...
@@ -146,11 +172,23 @@ public:
virtual
void
ShowCursor
(
bool
aEnabled
);
protected
:
/// Sets center for VIEW, takes into account panning boundaries.
void
setCenter
(
const
VECTOR2D
&
aCenter
);
/// Sets scale for VIEW, takes into account scale limits.
void
setScale
(
double
aScale
,
const
VECTOR2D
&
aAnchor
);
/// Pointer to controlled VIEW.
VIEW
*
m_view
;
/// Current mouse position
VECTOR2D
m_mousePosition
;
/// Panning boundaries.
BOX2I
m_panBoundary
;
/// Scale lower limit.
double
m_minScale
;
/// Scale upper limit.
double
m_maxScale
;
/// Current cursor position
VECTOR2D
m_cursorPosition
;
...
...
pcbnew/pcbframe.cpp
View file @
afc56d3f
...
...
@@ -56,6 +56,7 @@
#include <dialog_plot.h>
#include <convert_from_iu.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <painter.h>
#include <class_track.h>
...
...
@@ -583,7 +584,7 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view
->
Add
(
aBoard
->
GetRatsnestViewItem
()
);
// Limit panning to the size of worksheet frame
view
->
SetPanBoundary
(
aBoard
->
GetWorksheetViewItem
()
->
ViewBBox
()
);
GetGalCanvas
()
->
GetViewControls
()
->
SetPanBoundary
(
aBoard
->
GetWorksheetViewItem
()
->
ViewBBox
()
);
view
->
RecacheAllItems
(
true
);
if
(
IsGalCanvasActive
()
)
...
...
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