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
87487632
Commit
87487632
authored
Jul 25, 2013
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move handle_translation|rotation to wxGLPanel
parent
1932c52b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
30 deletions
+31
-30
gcview.py
printrun/gcview.py
+1
-30
panel.py
printrun/gl/panel.py
+30
-0
No files found.
printrun/gcview.py
View file @
87487632
...
...
@@ -20,7 +20,7 @@ import wx
from
.
import
gcoder
from
.gl.panel
import
wxGLPanel
from
.gl.trackball
import
trackball
,
mulquat
,
build_rotmatrix
from
.gl.trackball
import
build_rotmatrix
from
.gl.libtatlin
import
actors
from
pyglet.gl
import
glPushMatrix
,
glPopMatrix
,
\
...
...
@@ -108,35 +108,6 @@ class GcodeViewPanel(wxGLPanel):
if
self
.
parent
.
clickcb
:
self
.
parent
.
clickcb
(
event
)
def
handle_rotation
(
self
,
event
):
if
self
.
initpos
is
None
:
self
.
initpos
=
event
.
GetPositionTuple
()
else
:
p1
=
self
.
initpos
p2
=
event
.
GetPositionTuple
()
sz
=
self
.
GetClientSize
()
p1x
=
float
(
p1
[
0
])
/
(
sz
[
0
]
/
2
)
-
1
p1y
=
1
-
float
(
p1
[
1
])
/
(
sz
[
1
]
/
2
)
p2x
=
float
(
p2
[
0
])
/
(
sz
[
0
]
/
2
)
-
1
p2y
=
1
-
float
(
p2
[
1
])
/
(
sz
[
1
]
/
2
)
quat
=
trackball
(
p1x
,
p1y
,
p2x
,
p2y
,
self
.
dist
/
250.0
)
self
.
basequat
=
mulquat
(
self
.
basequat
,
quat
)
self
.
initpos
=
p2
def
handle_translation
(
self
,
event
):
if
self
.
initpos
is
None
:
self
.
initpos
=
event
.
GetPositionTuple
()
else
:
p1
=
self
.
initpos
p2
=
event
.
GetPositionTuple
()
if
self
.
orthographic
:
x1
,
y1
,
_
=
self
.
mouse_to_3d
(
p1
[
0
],
p1
[
1
])
x2
,
y2
,
_
=
self
.
mouse_to_3d
(
p2
[
0
],
p2
[
1
])
glTranslatef
(
x2
-
x1
,
y2
-
y1
,
0
)
else
:
glTranslatef
(
p2
[
0
]
-
p1
[
0
],
-
(
p2
[
1
]
-
p1
[
1
]),
0
)
self
.
initpos
=
p2
def
move
(
self
,
event
):
"""react to mouse actions:
no mouse: show red mousedrop
...
...
printrun/gl/panel.py
View file @
87487632
...
...
@@ -23,6 +23,7 @@ pyglet.options['debug_gl'] = True
from
pyglet.gl
import
*
from
pyglet
import
gl
from
.trackball
import
trackball
,
mulquat
class
wxGLPanel
(
wx
.
Panel
):
'''A simple class for using OpenGL with wxPython.'''
...
...
@@ -202,3 +203,32 @@ class wxGLPanel(wx.Panel):
self
.
canvas
.
SetCurrent
(
self
.
context
)
x
,
y
,
_
=
self
.
mouse_to_3d
(
self
.
width
/
2
,
self
.
height
/
2
)
self
.
zoom
(
factor
,
(
x
,
y
))
def
handle_rotation
(
self
,
event
):
if
self
.
initpos
is
None
:
self
.
initpos
=
event
.
GetPositionTuple
()
else
:
p1
=
self
.
initpos
p2
=
event
.
GetPositionTuple
()
sz
=
self
.
GetClientSize
()
p1x
=
float
(
p1
[
0
])
/
(
sz
[
0
]
/
2
)
-
1
p1y
=
1
-
float
(
p1
[
1
])
/
(
sz
[
1
]
/
2
)
p2x
=
float
(
p2
[
0
])
/
(
sz
[
0
]
/
2
)
-
1
p2y
=
1
-
float
(
p2
[
1
])
/
(
sz
[
1
]
/
2
)
quat
=
trackball
(
p1x
,
p1y
,
p2x
,
p2y
,
self
.
dist
/
250.0
)
self
.
basequat
=
mulquat
(
self
.
basequat
,
quat
)
self
.
initpos
=
p2
def
handle_translation
(
self
,
event
):
if
self
.
initpos
is
None
:
self
.
initpos
=
event
.
GetPositionTuple
()
else
:
p1
=
self
.
initpos
p2
=
event
.
GetPositionTuple
()
if
self
.
orthographic
:
x1
,
y1
,
_
=
self
.
mouse_to_3d
(
p1
[
0
],
p1
[
1
])
x2
,
y2
,
_
=
self
.
mouse_to_3d
(
p2
[
0
],
p2
[
1
])
glTranslatef
(
x2
-
x1
,
y2
-
y1
,
0
)
else
:
glTranslatef
(
p2
[
0
]
-
p1
[
0
],
-
(
p2
[
1
]
-
p1
[
1
]),
0
)
self
.
initpos
=
p2
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