Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
d23b511e
Commit
d23b511e
authored
Jul 03, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor our trackball into its own module, move things to printrun.gl
parent
f9e9a074
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
76 deletions
+91
-76
gcview.py
printrun/gcview.py
+3
-73
__init__.py
printrun/gl/__init__.py
+0
-0
__init__.py
printrun/gl/libtatlin/__init__.py
+0
-0
actors.py
printrun/gl/libtatlin/actors.py
+0
-0
panel.py
printrun/gl/panel.py
+0
-3
trackball.py
printrun/gl/trackball.py
+88
-0
No files found.
printrun/gcview.py
View file @
d23b511e
...
...
@@ -28,79 +28,9 @@ from pyglet.gl import *
from
pyglet
import
gl
from
.
import
gcoder
from
.glpanel
import
wxGLPanel
from
.libtatlin
import
actors
def
cross
(
v1
,
v2
):
return
[
v1
[
1
]
*
v2
[
2
]
-
v1
[
2
]
*
v2
[
1
],
v1
[
2
]
*
v2
[
0
]
-
v1
[
0
]
*
v2
[
2
],
v1
[
0
]
*
v2
[
1
]
-
v1
[
1
]
*
v2
[
0
]]
def
trackball
(
p1x
,
p1y
,
p2x
,
p2y
,
r
):
TRACKBALLSIZE
=
r
if
p1x
==
p2x
and
p1y
==
p2y
:
return
[
0.0
,
0.0
,
0.0
,
1.0
]
p1
=
[
p1x
,
p1y
,
project_to_sphere
(
TRACKBALLSIZE
,
p1x
,
p1y
)]
p2
=
[
p2x
,
p2y
,
project_to_sphere
(
TRACKBALLSIZE
,
p2x
,
p2y
)]
a
=
cross
(
p2
,
p1
)
d
=
map
(
lambda
x
,
y
:
x
-
y
,
p1
,
p2
)
t
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
d
)))
/
(
2.0
*
TRACKBALLSIZE
)
if
(
t
>
1.0
):
t
=
1.0
if
(
t
<
-
1.0
):
t
=
-
1.0
phi
=
2.0
*
math
.
asin
(
t
)
return
axis_to_quat
(
a
,
phi
)
def
axis_to_quat
(
a
,
phi
):
lena
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
a
)))
q
=
map
(
lambda
x
:
x
*
(
1
/
lena
),
a
)
q
=
map
(
lambda
x
:
x
*
math
.
sin
(
phi
/
2.0
),
q
)
q
.
append
(
math
.
cos
(
phi
/
2.0
))
return
q
def
build_rotmatrix
(
q
):
m
=
(
GLdouble
*
16
)()
m
[
0
]
=
1.0
-
2.0
*
(
q
[
1
]
*
q
[
1
]
+
q
[
2
]
*
q
[
2
])
m
[
1
]
=
2.0
*
(
q
[
0
]
*
q
[
1
]
-
q
[
2
]
*
q
[
3
])
m
[
2
]
=
2.0
*
(
q
[
2
]
*
q
[
0
]
+
q
[
1
]
*
q
[
3
])
m
[
3
]
=
0.0
m
[
4
]
=
2.0
*
(
q
[
0
]
*
q
[
1
]
+
q
[
2
]
*
q
[
3
])
m
[
5
]
=
1.0
-
2.0
*
(
q
[
2
]
*
q
[
2
]
+
q
[
0
]
*
q
[
0
])
m
[
6
]
=
2.0
*
(
q
[
1
]
*
q
[
2
]
-
q
[
0
]
*
q
[
3
])
m
[
7
]
=
0.0
m
[
8
]
=
2.0
*
(
q
[
2
]
*
q
[
0
]
-
q
[
1
]
*
q
[
3
])
m
[
9
]
=
2.0
*
(
q
[
1
]
*
q
[
2
]
+
q
[
0
]
*
q
[
3
])
m
[
10
]
=
1.0
-
2.0
*
(
q
[
1
]
*
q
[
1
]
+
q
[
0
]
*
q
[
0
])
m
[
11
]
=
0.0
m
[
12
]
=
0.0
m
[
13
]
=
0.0
m
[
14
]
=
0.0
m
[
15
]
=
1.0
return
m
def
project_to_sphere
(
r
,
x
,
y
):
d
=
math
.
sqrt
(
x
*
x
+
y
*
y
)
if
(
d
<
r
*
0.70710678118654752440
):
return
math
.
sqrt
(
r
*
r
-
d
*
d
)
else
:
t
=
r
/
1.41421356237309504880
return
t
*
t
/
d
def
mulquat
(
q1
,
rq
):
return
[
q1
[
3
]
*
rq
[
0
]
+
q1
[
0
]
*
rq
[
3
]
+
q1
[
1
]
*
rq
[
2
]
-
q1
[
2
]
*
rq
[
1
],
q1
[
3
]
*
rq
[
1
]
+
q1
[
1
]
*
rq
[
3
]
+
q1
[
2
]
*
rq
[
0
]
-
q1
[
0
]
*
rq
[
2
],
q1
[
3
]
*
rq
[
2
]
+
q1
[
2
]
*
rq
[
3
]
+
q1
[
0
]
*
rq
[
1
]
-
q1
[
1
]
*
rq
[
0
],
q1
[
3
]
*
rq
[
3
]
-
q1
[
0
]
*
rq
[
0
]
-
q1
[
1
]
*
rq
[
1
]
-
q1
[
2
]
*
rq
[
2
]]
from
.gl.panel
import
wxGLPanel
from
.gl.trackball
import
trackball
,
mulquat
,
build_rotmatrix
from
.gl.libtatlin
import
actors
class
GcodeViewPanel
(
wxGLPanel
):
...
...
printrun/
libtatlin
/__init__.py
→
printrun/
gl
/__init__.py
View file @
d23b511e
File moved
printrun/gl/libtatlin/__init__.py
0 → 100644
View file @
d23b511e
printrun/libtatlin/actors.py
→
printrun/
gl/
libtatlin/actors.py
View file @
d23b511e
File moved
printrun/glpanel.py
→
printrun/gl
/
panel.py
View file @
d23b511e
#!/usr/bin/env python
# This file is part of the Printrun suite.
...
...
@@ -28,8 +27,6 @@ pyglet.options['debug_gl'] = True
from
pyglet.gl
import
*
from
pyglet
import
gl
from
.
import
gcoder
class
wxGLPanel
(
wx
.
Panel
):
'''A simple class for using OpenGL with wxPython.'''
...
...
printrun/gl/trackball.py
0 → 100644
View file @
d23b511e
#!/usr/bin/env python
# This file is part of the Printrun suite.
#
# Printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Printrun is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Printrun. If not, see <http://www.gnu.org/licenses/>.
from
pyglet.gl
import
*
def
cross
(
v1
,
v2
):
return
[
v1
[
1
]
*
v2
[
2
]
-
v1
[
2
]
*
v2
[
1
],
v1
[
2
]
*
v2
[
0
]
-
v1
[
0
]
*
v2
[
2
],
v1
[
0
]
*
v2
[
1
]
-
v1
[
1
]
*
v2
[
0
]]
def
trackball
(
p1x
,
p1y
,
p2x
,
p2y
,
r
):
TRACKBALLSIZE
=
r
if
p1x
==
p2x
and
p1y
==
p2y
:
return
[
0.0
,
0.0
,
0.0
,
1.0
]
p1
=
[
p1x
,
p1y
,
project_to_sphere
(
TRACKBALLSIZE
,
p1x
,
p1y
)]
p2
=
[
p2x
,
p2y
,
project_to_sphere
(
TRACKBALLSIZE
,
p2x
,
p2y
)]
a
=
cross
(
p2
,
p1
)
d
=
map
(
lambda
x
,
y
:
x
-
y
,
p1
,
p2
)
t
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
d
)))
/
(
2.0
*
TRACKBALLSIZE
)
if
(
t
>
1.0
):
t
=
1.0
if
(
t
<
-
1.0
):
t
=
-
1.0
phi
=
2.0
*
math
.
asin
(
t
)
return
axis_to_quat
(
a
,
phi
)
def
axis_to_quat
(
a
,
phi
):
lena
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
a
)))
q
=
map
(
lambda
x
:
x
*
(
1
/
lena
),
a
)
q
=
map
(
lambda
x
:
x
*
math
.
sin
(
phi
/
2.0
),
q
)
q
.
append
(
math
.
cos
(
phi
/
2.0
))
return
q
def
build_rotmatrix
(
q
):
m
=
(
GLdouble
*
16
)()
m
[
0
]
=
1.0
-
2.0
*
(
q
[
1
]
*
q
[
1
]
+
q
[
2
]
*
q
[
2
])
m
[
1
]
=
2.0
*
(
q
[
0
]
*
q
[
1
]
-
q
[
2
]
*
q
[
3
])
m
[
2
]
=
2.0
*
(
q
[
2
]
*
q
[
0
]
+
q
[
1
]
*
q
[
3
])
m
[
3
]
=
0.0
m
[
4
]
=
2.0
*
(
q
[
0
]
*
q
[
1
]
+
q
[
2
]
*
q
[
3
])
m
[
5
]
=
1.0
-
2.0
*
(
q
[
2
]
*
q
[
2
]
+
q
[
0
]
*
q
[
0
])
m
[
6
]
=
2.0
*
(
q
[
1
]
*
q
[
2
]
-
q
[
0
]
*
q
[
3
])
m
[
7
]
=
0.0
m
[
8
]
=
2.0
*
(
q
[
2
]
*
q
[
0
]
-
q
[
1
]
*
q
[
3
])
m
[
9
]
=
2.0
*
(
q
[
1
]
*
q
[
2
]
+
q
[
0
]
*
q
[
3
])
m
[
10
]
=
1.0
-
2.0
*
(
q
[
1
]
*
q
[
1
]
+
q
[
0
]
*
q
[
0
])
m
[
11
]
=
0.0
m
[
12
]
=
0.0
m
[
13
]
=
0.0
m
[
14
]
=
0.0
m
[
15
]
=
1.0
return
m
def
project_to_sphere
(
r
,
x
,
y
):
d
=
math
.
sqrt
(
x
*
x
+
y
*
y
)
if
(
d
<
r
*
0.70710678118654752440
):
return
math
.
sqrt
(
r
*
r
-
d
*
d
)
else
:
t
=
r
/
1.41421356237309504880
return
t
*
t
/
d
def
mulquat
(
q1
,
rq
):
return
[
q1
[
3
]
*
rq
[
0
]
+
q1
[
0
]
*
rq
[
3
]
+
q1
[
1
]
*
rq
[
2
]
-
q1
[
2
]
*
rq
[
1
],
q1
[
3
]
*
rq
[
1
]
+
q1
[
1
]
*
rq
[
3
]
+
q1
[
2
]
*
rq
[
0
]
-
q1
[
0
]
*
rq
[
2
],
q1
[
3
]
*
rq
[
2
]
+
q1
[
2
]
*
rq
[
3
]
+
q1
[
0
]
*
rq
[
1
]
-
q1
[
1
]
*
rq
[
0
],
q1
[
3
]
*
rq
[
3
]
-
q1
[
0
]
*
rq
[
0
]
-
q1
[
1
]
*
rq
[
1
]
-
q1
[
2
]
*
rq
[
2
]]
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