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
9b166516
Commit
9b166516
authored
Sep 18, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added limits for VIEW scale values & panning area.
parent
56c78d44
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
1 deletion
+53
-1
view.cpp
common/view/view.cpp
+23
-1
view.h
include/view/view.h
+29
-0
basepcbframe.cpp
pcbnew/basepcbframe.cpp
+1
-0
No files found.
common/view/view.cpp
View file @
9b166516
...
@@ -45,8 +45,11 @@ VIEW::VIEW( bool aIsDynamic ) :
...
@@ -45,8 +45,11 @@ VIEW::VIEW( bool aIsDynamic ) :
m_scale
(
1.0
),
m_scale
(
1.0
),
m_painter
(
NULL
),
m_painter
(
NULL
),
m_gal
(
NULL
),
m_gal
(
NULL
),
m_dynamic
(
aIsDynamic
)
m_dynamic
(
aIsDynamic
),
m_scaleLimits
(
15000.0
,
1.0
)
{
{
m_panBoundary
.
SetMaximum
();
// Redraw everything at the beginning
// Redraw everything at the beginning
for
(
int
i
=
0
;
i
<
TARGETS_NUMBER
;
++
i
)
for
(
int
i
=
0
;
i
<
TARGETS_NUMBER
;
++
i
)
MarkTargetDirty
(
i
);
MarkTargetDirty
(
i
);
...
@@ -290,6 +293,11 @@ void VIEW::SetScale( double aScale )
...
@@ -290,6 +293,11 @@ void VIEW::SetScale( double aScale )
void
VIEW
::
SetScale
(
double
aScale
,
const
VECTOR2D
&
aAnchor
)
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
);
VECTOR2D
a
=
ToScreen
(
aAnchor
);
m_gal
->
SetZoomFactor
(
aScale
);
m_gal
->
SetZoomFactor
(
aScale
);
...
@@ -308,6 +316,20 @@ void VIEW::SetScale( double aScale, const VECTOR2D& aAnchor )
...
@@ -308,6 +316,20 @@ void VIEW::SetScale( double aScale, const VECTOR2D& aAnchor )
void
VIEW
::
SetCenter
(
const
VECTOR2D
&
aCenter
)
void
VIEW
::
SetCenter
(
const
VECTOR2D
&
aCenter
)
{
{
m_center
=
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
->
SetLookAtPoint
(
m_center
);
m_gal
->
ComputeWorldScreenMatrix
();
m_gal
->
ComputeWorldScreenMatrix
();
...
...
include/view/view.h
View file @
9b166516
...
@@ -455,6 +455,29 @@ public:
...
@@ -455,6 +455,29 @@ public:
m_dirtyTargets
[
i
]
=
true
;
m_dirtyTargets
[
i
]
=
true
;
}
}
/**
* 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
static
const
int
VIEW_MAX_LAYERS
=
128
;
///* maximum number of layers that may be shown
private
:
private
:
...
@@ -588,6 +611,12 @@ private:
...
@@ -588,6 +611,12 @@ private:
/// Rendering order modifier for layers that are marked as top layers
/// Rendering order modifier for layers that are marked as top layers
static
const
int
TOP_LAYER_MODIFIER
=
-
VIEW_MAX_LAYERS
;
static
const
int
TOP_LAYER_MODIFIER
=
-
VIEW_MAX_LAYERS
;
/// Panning boundaries
BOX2I
m_panBoundary
;
/// Zoom limits
VECTOR2D
m_scaleLimits
;
};
};
}
// namespace KiGfx
}
// namespace KiGfx
...
...
pcbnew/basepcbframe.cpp
View file @
9b166516
...
@@ -217,6 +217,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
...
@@ -217,6 +217,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view
->
Add
(
worksheet
);
view
->
Add
(
worksheet
);
view
->
SetPanBoundary
(
worksheet
->
ViewBBox
()
);
view
->
RecacheAllItems
(
true
);
view
->
RecacheAllItems
(
true
);
if
(
m_galCanvasActive
)
if
(
m_galCanvasActive
)
...
...
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