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
9e8719d3
Commit
9e8719d3
authored
Mar 30, 2015
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed overlapping segment endings in OpenGL view.
parent
45d0448b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
38 deletions
+44
-38
graphics_abstraction_layer.cpp
common/gal/graphics_abstraction_layer.cpp
+4
-0
opengl_gal.cpp
common/gal/opengl/opengl_gal.cpp
+1
-1
shader.frag
common/gal/opengl/shader.frag
+5
-5
shader.vert
common/gal/opengl/shader.vert
+20
-23
view.cpp
common/view/view.cpp
+5
-2
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+7
-5
view.h
include/view/view.h
+1
-1
edit_points.cpp
pcbnew/tools/edit_points.cpp
+1
-1
No files found.
common/gal/graphics_abstraction_layer.cpp
View file @
9e8719d3
...
@@ -248,3 +248,7 @@ VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const
...
@@ -248,3 +248,7 @@ VECTOR2D GAL::GetGridPoint( const VECTOR2D& aPoint ) const
return
VECTOR2D
(
round
(
(
aPoint
.
x
-
gridOffset
.
x
)
/
gridSize
.
x
)
*
gridSize
.
x
+
gridOffset
.
x
,
return
VECTOR2D
(
round
(
(
aPoint
.
x
-
gridOffset
.
x
)
/
gridSize
.
x
)
*
gridSize
.
x
+
gridOffset
.
x
,
round
(
(
aPoint
.
y
-
gridOffset
.
y
)
/
gridSize
.
y
)
*
gridSize
.
y
+
gridOffset
.
y
);
round
(
(
aPoint
.
y
-
gridOffset
.
y
)
/
gridSize
.
y
)
*
gridSize
.
y
+
gridOffset
.
y
);
}
}
const
int
GAL
::
MIN_DEPTH
=
-
256
;
const
int
GAL
::
MAX_DEPTH
=
255
;
const
int
GAL
::
GRID_DEPTH
=
MAX_DEPTH
-
1
;
common/gal/opengl/opengl_gal.cpp
View file @
9e8719d3
...
@@ -42,7 +42,7 @@ using namespace KIGFX;
...
@@ -42,7 +42,7 @@ using namespace KIGFX;
// Prototypes
// Prototypes
void
InitTesselatorCallbacks
(
GLUtesselator
*
aTesselator
);
void
InitTesselatorCallbacks
(
GLUtesselator
*
aTesselator
);
const
int
glAttributes
[]
=
{
WX_GL_RGBA
,
WX_GL_DOUBLEBUFFER
,
WX_GL_DEPTH_SIZE
,
16
,
0
};
const
int
glAttributes
[]
=
{
WX_GL_RGBA
,
WX_GL_DOUBLEBUFFER
,
WX_GL_DEPTH_SIZE
,
8
,
0
};
wxGLContext
*
OPENGL_GAL
::
glContext
=
NULL
;
wxGLContext
*
OPENGL_GAL
::
glContext
=
NULL
;
...
...
common/gal/opengl/shader.frag
View file @
9e8719d3
...
@@ -27,16 +27,16 @@
...
@@ -27,16 +27,16 @@
#version 120
#version 120
// Shader types
// Shader types
const
float
SHADER_LINE
=
1
.
0
f
;
const
float
SHADER_LINE
=
1
.
0
;
const
float
SHADER_FILLED_CIRCLE
=
2
.
0
f
;
const
float
SHADER_FILLED_CIRCLE
=
2
.
0
;
const
float
SHADER_STROKED_CIRCLE
=
3
.
0
f
;
const
float
SHADER_STROKED_CIRCLE
=
3
.
0
;
varying
vec4
shaderParams
;
varying
vec4
shaderParams
;
varying
vec2
circleCoords
;
varying
vec2
circleCoords
;
void
filledCircle
(
vec2
aCoord
)
void
filledCircle
(
vec2
aCoord
)
{
{
if
(
dot
(
aCoord
,
aCoord
)
<
1
.
0
f
)
if
(
dot
(
aCoord
,
aCoord
)
<
1
.
0
)
gl_FragColor
=
gl_Color
;
gl_FragColor
=
gl_Color
;
else
else
discard
;
discard
;
...
@@ -49,7 +49,7 @@ void strokedCircle( vec2 aCoord, float aRadius, float aWidth )
...
@@ -49,7 +49,7 @@ void strokedCircle( vec2 aCoord, float aRadius, float aWidth )
float
innerRadius
=
aRadius
-
(
aWidth
/
2
);
float
innerRadius
=
aRadius
-
(
aWidth
/
2
);
float
relWidth
=
innerRadius
/
outerRadius
;
float
relWidth
=
innerRadius
/
outerRadius
;
if
(
(
dot
(
aCoord
,
aCoord
)
<
1
.
0
f
)
&&
if
(
(
dot
(
aCoord
,
aCoord
)
<
1
.
0
)
&&
(
dot
(
aCoord
,
aCoord
)
>
relWidth
*
relWidth
)
)
(
dot
(
aCoord
,
aCoord
)
>
relWidth
*
relWidth
)
)
gl_FragColor
=
gl_Color
;
gl_FragColor
=
gl_Color
;
else
else
...
...
common/gal/opengl/shader.vert
View file @
9e8719d3
...
@@ -27,12 +27,12 @@
...
@@ -27,12 +27,12 @@
#version 120
#version 120
// Shader types
// Shader types
const
float
SHADER_LINE
=
1
.
0
f
;
const
float
SHADER_LINE
=
1
.
0
;
const
float
SHADER_FILLED_CIRCLE
=
2
.
0
f
;
const
float
SHADER_FILLED_CIRCLE
=
2
.
0
;
const
float
SHADER_STROKED_CIRCLE
=
3
.
0
f
;
const
float
SHADER_STROKED_CIRCLE
=
3
.
0
;
// Minimum line width
// Minimum line width
const
float
MIN_WIDTH
=
1
.
0
f
;
const
float
MIN_WIDTH
=
1
.
0
;
attribute
vec4
attrShaderParams
;
attribute
vec4
attrShaderParams
;
varying
vec4
shaderParams
;
varying
vec4
shaderParams
;
...
@@ -47,42 +47,39 @@ void main()
...
@@ -47,42 +47,39 @@ void main()
{
{
float
lineWidth
=
shaderParams
[
3
];
float
lineWidth
=
shaderParams
[
3
];
float
worldScale
=
gl_ModelViewMatrix
[
0
][
0
];
float
worldScale
=
gl_ModelViewMatrix
[
0
][
0
];
float
scale
;
// Make lines appear to be at least 1 pixel wide
// Make lines appear to be at least 1 pixel wide
if
(
worldScale
*
lineWidth
<
MIN_WIDTH
)
if
(
worldScale
*
lineWidth
<
MIN_WIDTH
)
scale
=
MIN_WIDTH
/
(
worldScale
*
lineWidth
);
gl_Position
=
gl_ModelViewProjectionMatrix
*
(
gl_Vertex
+
vec4
(
shaderParams
.
yz
*
MIN_WIDTH
/
(
worldScale
*
lineWidth
),
0
.
0
,
0
.
0
)
);
else
else
scale
=
1
.
0
f
;
gl_Position
=
gl_ModelViewProjectionMatrix
*
gl_Position
=
gl_ModelViewProjectionMatrix
*
(
gl_Vertex
+
vec4
(
shaderParams
.
yz
*
scale
,
0
.
0
,
0
.
0
)
);
(
gl_Vertex
+
vec4
(
shaderParams
.
yz
,
0
.
0
,
0
.
0
)
);
}
}
else
if
(
(
shaderParams
[
0
]
==
SHADER_STROKED_CIRCLE
)
||
else
if
(
(
shaderParams
[
0
]
==
SHADER_STROKED_CIRCLE
)
||
(
shaderParams
[
0
]
==
SHADER_FILLED_CIRCLE
)
)
(
shaderParams
[
0
]
==
SHADER_FILLED_CIRCLE
)
)
{
{
// Compute relative circle coordinates basing on indices
// Compute relative circle coordinates basing on indices
// Circle
// Circle
if
(
shaderParams
[
1
]
==
1
.
0
f
)
if
(
shaderParams
[
1
]
==
1
.
0
)
circleCoords
=
vec2
(
-
sqrt
(
3
.
0
f
),
-
1
.
0
f
);
circleCoords
=
vec2
(
-
sqrt
(
3
.
0
),
-
1
.
0
);
else
if
(
shaderParams
[
1
]
==
2
.
0
f
)
else
if
(
shaderParams
[
1
]
==
2
.
0
)
circleCoords
=
vec2
(
sqrt
(
3
.
0
f
),
-
1
.
0
f
);
circleCoords
=
vec2
(
sqrt
(
3
.
0
),
-
1
.
0
);
else
if
(
shaderParams
[
1
]
==
3
.
0
f
)
else
if
(
shaderParams
[
1
]
==
3
.
0
)
circleCoords
=
vec2
(
0
.
0
f
,
2
.
0
f
);
circleCoords
=
vec2
(
0
.
0
,
2
.
0
);
// Semicircle
// Semicircle
else
if
(
shaderParams
[
1
]
==
4
.
0
f
)
else
if
(
shaderParams
[
1
]
==
4
.
0
)
circleCoords
=
vec2
(
-
3
.
0
f
/
sqrt
(
3
.
0
f
),
0
.
0
f
);
circleCoords
=
vec2
(
-
3
.
0
/
sqrt
(
3
.
0
),
0
.
0
);
else
if
(
shaderParams
[
1
]
==
5
.
0
f
)
else
if
(
shaderParams
[
1
]
==
5
.
0
)
circleCoords
=
vec2
(
3
.
0
f
/
sqrt
(
3
.
0
f
),
0
.
0
f
);
circleCoords
=
vec2
(
3
.
0
/
sqrt
(
3
.
0
),
0
.
0
);
else
if
(
shaderParams
[
1
]
==
6
.
0
f
)
else
if
(
shaderParams
[
1
]
==
6
.
0
)
circleCoords
=
vec2
(
0
.
0
f
,
2
.
0
f
);
circleCoords
=
vec2
(
0
.
0
,
2
.
0
);
// Make the line appear to be at least 1 pixel wide
// Make the line appear to be at least 1 pixel wide
float
lineWidth
=
shaderParams
[
3
];
float
lineWidth
=
shaderParams
[
3
];
float
worldScale
=
gl_ModelViewMatrix
[
0
][
0
];
float
worldScale
=
gl_ModelViewMatrix
[
0
][
0
];
// Make lines appear to be at least 1 pixel width
if
(
worldScale
*
lineWidth
<
MIN_WIDTH
)
if
(
worldScale
*
lineWidth
<
MIN_WIDTH
)
shaderParams
[
3
]
=
shaderParams
[
3
]
/
(
worldScale
*
lineWidth
);
shaderParams
[
3
]
=
shaderParams
[
3
]
/
(
worldScale
*
lineWidth
);
...
...
common/view/view.cpp
View file @
9e8719d3
...
@@ -1054,3 +1054,6 @@ const BOX2I VIEW::CalculateExtents()
...
@@ -1054,3 +1054,6 @@ const BOX2I VIEW::CalculateExtents()
return
v
.
extents
;
return
v
.
extents
;
}
}
const
int
VIEW
::
TOP_LAYER_MODIFIER
=
-
VIEW_MAX_LAYERS
;
include/gal/graphics_abstraction_layer.h
View file @
9e8719d3
...
@@ -836,9 +836,6 @@ public:
...
@@ -836,9 +836,6 @@ public:
depthStack
.
pop
();
depthStack
.
pop
();
}
}
/// Depth level on which the grid is drawn
static
const
int
GRID_DEPTH
=
1024
;
static
const
double
METRIC_UNIT_LENGTH
;
static
const
double
METRIC_UNIT_LENGTH
;
protected
:
protected
:
...
@@ -903,8 +900,13 @@ protected:
...
@@ -903,8 +900,13 @@ protected:
*/
*/
virtual
void
drawGridLine
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
)
=
0
;
virtual
void
drawGridLine
(
const
VECTOR2D
&
aStartPoint
,
const
VECTOR2D
&
aEndPoint
)
=
0
;
static
const
int
MIN_DEPTH
=
-
2048
;
/// Possible depth range
static
const
int
MAX_DEPTH
=
2047
;
static
const
int
MIN_DEPTH
;
static
const
int
MAX_DEPTH
;
/// Depth level on which the grid is drawn
static
const
int
GRID_DEPTH
;
};
};
}
// namespace KIGFX
}
// namespace KIGFX
...
...
include/view/view.h
View file @
9e8719d3
...
@@ -670,7 +670,7 @@ private:
...
@@ -670,7 +670,7 @@ private:
bool
m_dirtyTargets
[
TARGETS_NUMBER
];
bool
m_dirtyTargets
[
TARGETS_NUMBER
];
/// 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
;
/// Items to be updated
/// Items to be updated
std
::
vector
<
VIEW_ITEM
*>
m_needsUpdate
;
std
::
vector
<
VIEW_ITEM
*>
m_needsUpdate
;
...
...
pcbnew/tools/edit_points.cpp
View file @
9e8719d3
...
@@ -211,7 +211,7 @@ void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
...
@@ -211,7 +211,7 @@ void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::GAL* aGal ) const
aGal
->
SetIsFill
(
true
);
aGal
->
SetIsFill
(
true
);
aGal
->
SetIsStroke
(
false
);
aGal
->
SetIsStroke
(
false
);
aGal
->
PushDepth
();
aGal
->
PushDepth
();
aGal
->
SetLayerDepth
(
-
512.0
);
// TODO no hardcoded depths?
aGal
->
SetLayerDepth
(
aGal
->
GetMinDepth
()
);
float
size
=
m_view
->
ToWorld
(
EDIT_POINT
::
POINT_SIZE
);
float
size
=
m_view
->
ToWorld
(
EDIT_POINT
::
POINT_SIZE
);
...
...
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