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
ef865aab
Commit
ef865aab
authored
Jun 24, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Grid settings apply to GAL based rendering.
parent
322c71d2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
23 deletions
+66
-23
drawframe.cpp
common/drawframe.cpp
+45
-17
drawpanel_gal.cpp
common/drawpanel_gal.cpp
+0
-5
graphics_abstraction_layer.cpp
common/gal/graphics_abstraction_layer.cpp
+6
-0
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+2
-0
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+13
-1
No files found.
common/drawframe.cpp
View file @
ef865aab
...
...
@@ -236,6 +236,14 @@ void EDA_DRAW_FRAME::SkipNextLeftButtonReleaseEvent()
void
EDA_DRAW_FRAME
::
OnToggleGridState
(
wxCommandEvent
&
aEvent
)
{
SetGridVisibility
(
!
IsGridVisible
()
);
#ifdef KICAD_GAL
if
(
m_galCanvasActive
)
{
m_galCanvas
->
GetGAL
()
->
SetGridVisibility
(
IsGridVisible
()
);
m_galCanvas
->
Refresh
();
}
else
#endif
/* KICAD_GAL */
m_canvas
->
Refresh
();
}
...
...
@@ -388,6 +396,14 @@ void EDA_DRAW_FRAME::OnSelectGrid( wxCommandEvent& event )
m_LastGridSizeId
=
id
-
ID_POPUP_GRID_LEVEL_1000
;
screen
->
SetGrid
(
id
);
screen
->
SetCrossHairPosition
(
screen
->
RefPos
(
true
)
);
#ifdef KICAD_GAL
if
(
m_galCanvasActive
)
{
KiGfx
::
GAL
*
gal
=
m_galCanvas
->
GetGAL
();
gal
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGrid
().
m_Size
)
);
}
#endif
/* KICAD_GAL */
Refresh
();
}
...
...
@@ -945,33 +961,45 @@ void EDA_DRAW_FRAME::UseGalCanvas( bool aEnable )
KiGfx
::
VIEW
*
view
=
m_galCanvas
->
GetView
();
KiGfx
::
GAL
*
gal
=
m_galCanvas
->
GetGAL
();
if
(
aEnable
&&
m_galCanvasActive
)
{
// When we switch between GAL based canvases, all we need is a refresh
m_galCanvas
->
Refresh
();
}
if
(
!
(
aEnable
^
m_galCanvasActive
)
)
return
;
double
zoomFactor
=
gal
->
GetWorldScale
()
/
gal
->
GetZoomFactor
();
// Display the same view after canvas switching
if
(
aEnable
)
{
double
zoom
=
1
/
(
zoomFactor
*
m_canvas
->
GetZoom
()
);
view
->
SetScale
(
zoom
);
BASE_SCREEN
*
screen
=
GetScreen
();
// Switch to GAL rendering
if
(
!
m_galCanvasActive
)
{
// Change view settings only if GAL was not active previously
double
zoom
=
1.0
/
(
zoomFactor
*
m_canvas
->
GetZoom
()
);
view
->
SetScale
(
zoom
);
view
->
SetCenter
(
VECTOR2D
(
m_canvas
->
GetScreenCenterLogicalPosition
()
)
);
}
// Set up grid settings
gal
->
SetGridVisibility
(
IsGridVisible
()
);
// Default grid color - dark cyan does not look good
//gal->SetGridColor( KiGfx::COLOR4D( GetGridColor() ) );
gal
->
SetGridColor
(
KiGfx
::
COLOR4D
(
0.1
,
0.1
,
0.1
,
1.0
)
);
gal
->
SetGridSize
(
VECTOR2D
(
screen
->
GetGridSize
()
)
);
gal
->
SetGridOrigin
(
VECTOR2D
(
screen
->
GetGridOrigin
()
)
);
gal
->
SetGridOriginMarkerSize
(
15
);
gal
->
SetGridDrawThreshold
(
10
);
}
else
{
double
zoom
=
1
/
(
zoomFactor
*
view
->
GetScale
()
);
// Switch to standard rendering
if
(
m_galCanvasActive
)
{
// 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
);
}
}
m_canvas
->
SetEvtHandlerEnabled
(
!
aEnable
);
m_galCanvas
->
SetEvtHandlerEnabled
(
aEnable
);
...
...
common/drawpanel_gal.cpp
View file @
ef865aab
...
...
@@ -140,11 +140,6 @@ void EDA_DRAW_PANEL_GAL::Refresh( bool eraseBackground, const wxRect* rect )
m_gal
->
BeginDrawing
();
m_gal
->
SetBackgroundColor
(
KiGfx
::
COLOR4D
(
0
,
0
,
0
,
1.0
)
);
m_gal
->
ClearScreen
();
m_gal
->
SetGridOrigin
(
VECTOR2D
(
0
,
0
)
);
m_gal
->
SetGridOriginMarkerSize
(
15
);
m_gal
->
SetGridSize
(
VECTOR2D
(
METRIC_UNIT_LENGTH
/
10000.0
,
METRIC_UNIT_LENGTH
/
10000.0
)
);
m_gal
->
SetGridDrawThreshold
(
10
);
m_gal
->
SetLayerDepth
(
0
);
m_gal
->
DrawGrid
();
m_view
->
Redraw
();
...
...
common/gal/graphics_abstraction_layer.cpp
View file @
ef865aab
...
...
@@ -44,6 +44,7 @@ GAL::GAL()
SetZoomFactor
(
1.0
);
SetFillColor
(
COLOR4D
(
0.0
,
0.0
,
0.0
,
0.0
)
);
SetStrokeColor
(
COLOR4D
(
1.0
,
1.0
,
1.0
,
1.0
)
);
SetGridVisibility
(
true
);
SetGridColor
(
COLOR4D
(
1
,
1
,
1
,
0.1
)
);
SetCoarseGrid
(
5
);
SetLineWidth
(
1.0
);
...
...
@@ -58,6 +59,9 @@ GAL::~GAL()
void
GAL
::
DrawGrid
()
{
if
(
!
gridVisibility
)
return
;
// The grid consists of lines
// For the drawing the start points, end points and increments have to be calculated in world coordinates
VECTOR2D
screenStartPoint
(
0
,
0
);
...
...
@@ -98,6 +102,7 @@ void GAL::DrawGrid()
double
origSize
=
(
double
)
gridOriginMarkerSize
/
worldScale
;
// Draw the origin marker
SetStrokeColor
(
COLOR4D
(
1.0
,
1.0
,
1.0
,
1.0
)
);
SetIsFill
(
false
);
DrawLine
(
gridOrigin
+
VECTOR2D
(
-
origSize
,
-
origSize
),
gridOrigin
+
VECTOR2D
(
origSize
,
origSize
)
);
...
...
@@ -109,6 +114,7 @@ void GAL::DrawGrid()
if
(
std
::
max
(
gridScreenSizeDense
,
gridScreenSizeCoarse
)
<
gridDrawThreshold
)
return
;
SetLayerDepth
(
0.0
);
// Now draw the grid, every coarse grid line gets the double width
for
(
int
j
=
gridStartY
;
j
<
gridEndY
;
j
+=
1
)
{
...
...
common/gal/opengl/opengl_gal.cpp
View file @
ef865aab
...
...
@@ -1909,10 +1909,12 @@ void OPENGL_GAL::DrawGridLine( const VECTOR2D& aStartPoint, const VECTOR2D& aEnd
if
(
aStartPoint
.
x
==
aEndPoint
.
x
)
{
// Vertical grid line
perpendicularVector
=
VECTOR2D
(
0.5
*
lineWidth
,
0
);
}
else
{
// Horizontal grid line
perpendicularVector
=
VECTOR2D
(
0
,
0.5
*
lineWidth
);
}
...
...
include/gal/graphics_abstraction_layer.h
View file @
ef865aab
...
...
@@ -524,6 +524,16 @@ public:
// Grid methods
// -------------
/**
* @brief Sets the visibility setting of the grid.
*
* @param aVisibility is the new visibility setting of the grid.
*/
inline
void
SetGridVisibility
(
bool
aVisibility
)
{
gridVisibility
=
aVisibility
;
}
/**
* @brief Set the origin point for the grid.
*
...
...
@@ -698,6 +708,8 @@ protected:
double
layerDepth
;
///< The actual layer depth
VECTOR2D
depthRange
;
///< Range of the depth
// Grid settings
bool
gridVisibility
;
///< Should the grid be shown
VECTOR2D
gridSize
;
///< The grid size
VECTOR2D
gridOrigin
;
///< The grid origin
COLOR4D
gridColor
;
///< Color of the grid
...
...
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