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
7ef307e8
Commit
7ef307e8
authored
Jul 03, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start cleaning up gcview
parent
42dede1d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
16 deletions
+6
-16
gcview.py
printrun/gcview.py
+6
-16
No files found.
printrun/gcview.py
View file @
7ef307e8
...
@@ -52,8 +52,7 @@ class wxGLPanel(wx.Panel):
...
@@ -52,8 +52,7 @@ class wxGLPanel(wx.Panel):
self
.
canvas
=
glcanvas
.
GLCanvas
(
self
,
attribList
=
attribList
)
self
.
canvas
=
glcanvas
.
GLCanvas
(
self
,
attribList
=
attribList
)
self
.
context
=
glcanvas
.
GLContext
(
self
.
canvas
)
self
.
context
=
glcanvas
.
GLContext
(
self
.
canvas
)
self
.
sizer
.
Add
(
self
.
canvas
,
1
,
wx
.
EXPAND
)
self
.
sizer
.
Add
(
self
.
canvas
,
1
,
wx
.
EXPAND
)
self
.
SetSizer
(
self
.
sizer
)
self
.
SetSizerAndFit
(
self
.
sizer
)
self
.
sizer
.
Fit
(
self
)
# bind events
# bind events
self
.
canvas
.
Bind
(
wx
.
EVT_ERASE_BACKGROUND
,
self
.
processEraseBackgroundEvent
)
self
.
canvas
.
Bind
(
wx
.
EVT_ERASE_BACKGROUND
,
self
.
processEraseBackgroundEvent
)
...
@@ -74,7 +73,6 @@ class wxGLPanel(wx.Panel):
...
@@ -74,7 +73,6 @@ class wxGLPanel(wx.Panel):
self
.
OnReshape
(
size
.
width
,
size
.
height
)
self
.
OnReshape
(
size
.
width
,
size
.
height
)
self
.
canvas
.
Refresh
(
False
)
self
.
canvas
.
Refresh
(
False
)
event
.
Skip
()
event
.
Skip
()
#wx.CallAfter(self.Refresh)
def
processPaintEvent
(
self
,
event
):
def
processPaintEvent
(
self
,
event
):
'''Process the drawing event.'''
'''Process the drawing event.'''
...
@@ -164,19 +162,18 @@ class wxGLPanel(wx.Panel):
...
@@ -164,19 +162,18 @@ class wxGLPanel(wx.Panel):
'''called in the middle of ondraw after the buffer has been cleared'''
'''called in the middle of ondraw after the buffer has been cleared'''
pass
pass
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
):
def
trackball
(
p1x
,
p1y
,
p2x
,
p2y
,
r
):
TRACKBALLSIZE
=
r
TRACKBALLSIZE
=
r
#float a[3]; /* Axis of rotation */
#float phi; /* how much to rotate about axis */
#float p1[3], p2[3], d[3];
#float t;
if
(
p1x
==
p2x
and
p1y
==
p2y
)
:
if
p1x
==
p2x
and
p1y
==
p2y
:
return
[
0.0
,
0.0
,
0.0
,
1.0
]
return
[
0.0
,
0.0
,
0.0
,
1.0
]
p1
=
[
p1x
,
p1y
,
project_to_sphere
(
TRACKBALLSIZE
,
p1x
,
p1y
)]
p1
=
[
p1x
,
p1y
,
project_to_sphere
(
TRACKBALLSIZE
,
p1x
,
p1y
)]
p2
=
[
p2x
,
p2y
,
project_to_sphere
(
TRACKBALLSIZE
,
p2x
,
p2y
)]
p2
=
[
p2x
,
p2y
,
project_to_sphere
(
TRACKBALLSIZE
,
p2x
,
p2y
)]
a
=
stltool
.
cross
(
p2
,
p1
)
a
=
cross
(
p2
,
p1
)
d
=
map
(
lambda
x
,
y
:
x
-
y
,
p1
,
p2
)
d
=
map
(
lambda
x
,
y
:
x
-
y
,
p1
,
p2
)
t
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
d
)))
/
(
2.0
*
TRACKBALLSIZE
)
t
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
d
)))
/
(
2.0
*
TRACKBALLSIZE
)
...
@@ -189,20 +186,13 @@ def trackball(p1x, p1y, p2x, p2y, r):
...
@@ -189,20 +186,13 @@ def trackball(p1x, p1y, p2x, p2y, r):
return
axis_to_quat
(
a
,
phi
)
return
axis_to_quat
(
a
,
phi
)
def
vec
(
*
args
):
return
(
GLfloat
*
len
(
args
))(
*
args
)
def
axis_to_quat
(
a
,
phi
):
def
axis_to_quat
(
a
,
phi
):
#print a, phi
lena
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
a
)))
lena
=
math
.
sqrt
(
sum
(
map
(
lambda
x
:
x
*
x
,
a
)))
q
=
map
(
lambda
x
:
x
*
(
1
/
lena
),
a
)
q
=
map
(
lambda
x
:
x
*
(
1
/
lena
),
a
)
q
=
map
(
lambda
x
:
x
*
math
.
sin
(
phi
/
2.0
),
q
)
q
=
map
(
lambda
x
:
x
*
math
.
sin
(
phi
/
2.0
),
q
)
q
.
append
(
math
.
cos
(
phi
/
2.0
))
q
.
append
(
math
.
cos
(
phi
/
2.0
))
return
q
return
q
def
build_rotmatrix
(
q
):
def
build_rotmatrix
(
q
):
m
=
(
GLdouble
*
16
)()
m
=
(
GLdouble
*
16
)()
m
[
0
]
=
1.0
-
2.0
*
(
q
[
1
]
*
q
[
1
]
+
q
[
2
]
*
q
[
2
])
m
[
0
]
=
1.0
-
2.0
*
(
q
[
1
]
*
q
[
1
]
+
q
[
2
]
*
q
[
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