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
0bba2c17
Commit
0bba2c17
authored
Apr 05, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow up on
c3799528
: implement get_modelview_mat in gcview/stlview
parent
1289d3c2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
18 deletions
+50
-18
gcview.py
printrun/gcview.py
+21
-1
panel.py
printrun/gl/panel.py
+8
-15
stlview.py
printrun/stlview.py
+21
-2
No files found.
printrun/gcview.py
View file @
0bba2c17
...
...
@@ -24,7 +24,8 @@ from .gl.libtatlin import actors
from
.injectgcode
import
injector
,
injector_edit
from
pyglet.gl
import
glPushMatrix
,
glPopMatrix
,
\
glTranslatef
,
glRotatef
,
glScalef
,
glMultMatrixd
glTranslatef
,
glRotatef
,
glScalef
,
glMultMatrixd
,
\
glGetDoublev
,
GL_MODELVIEW_MATRIX
,
GLdouble
from
.gviz
import
GvizBaseFrame
...
...
@@ -153,6 +154,25 @@ class GcodeViewPanel(wxGLPanel):
glPopMatrix
()
glPopMatrix
()
# ==========================================================================
# Utils
# ==========================================================================
def
get_modelview_mat
(
self
,
local_transform
):
mvmat
=
(
GLdouble
*
16
)()
if
local_transform
:
glPushMatrix
()
# Rotate according to trackball
glMultMatrixd
(
build_rotmatrix
(
self
.
basequat
))
# Move origin to bottom left of platform
platformx0
=
-
self
.
build_dimensions
[
3
]
-
self
.
parent
.
platform
.
width
/
2
platformy0
=
-
self
.
build_dimensions
[
4
]
-
self
.
parent
.
platform
.
depth
/
2
glTranslatef
(
platformx0
,
platformy0
,
0
)
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
glPopMatrix
()
else
:
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
return
mvmat
def
double
(
self
,
event
):
if
hasattr
(
self
.
parent
,
"clickcb"
)
and
self
.
parent
.
clickcb
:
self
.
parent
.
clickcb
(
event
)
...
...
printrun/gl/panel.py
View file @
0bba2c17
...
...
@@ -38,9 +38,9 @@ from pyglet.gl import glEnable, glDisable, GL_LIGHTING, glLightfv, \
GL_MODELVIEW_MATRIX
,
GL_ONE_MINUS_SRC_ALPHA
,
glOrtho
,
\
GL_PROJECTION
,
GL_PROJECTION_MATRIX
,
glScalef
,
\
GL_SRC_ALPHA
,
glTranslatef
,
gluPerspective
,
gluUnProject
,
\
glViewport
,
GL_VIEWPORT
,
glPushMatrix
,
glPopMatrix
,
glMultMatrixd
glViewport
,
GL_VIEWPORT
from
pyglet
import
gl
from
.trackball
import
trackball
,
mulquat
,
build_rotmatrix
from
.trackball
import
trackball
,
mulquat
from
.libtatlin.actors
import
vec
class
wxGLPanel
(
wx
.
Panel
):
...
...
@@ -248,19 +248,12 @@ class wxGLPanel(wx.Panel):
# ==========================================================================
# Utils
# ==========================================================================
def
get_modelview_mat
(
self
,
mult_rot
):
def
get_modelview_mat
(
self
,
local_transform
):
mvmat
=
(
GLdouble
*
16
)()
if
mult_rot
:
glPushMatrix
()
# Rotate according to trackball
glMultMatrixd
(
build_rotmatrix
(
self
.
basequat
))
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
glPopMatrix
()
else
:
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
return
mvmat
def
mouse_to_3d
(
self
,
x
,
y
,
z
=
1.0
,
mult_rot
=
False
):
def
mouse_to_3d
(
self
,
x
,
y
,
z
=
1.0
,
local_transform
=
False
):
x
=
float
(
x
)
y
=
self
.
height
-
float
(
y
)
# The following could work if we were not initially scaling to zoom on
...
...
@@ -268,7 +261,7 @@ class wxGLPanel(wx.Panel):
# if self.orthographic:
# return (x - self.width / 2, y - self.height / 2, 0)
pmat
=
(
GLdouble
*
16
)()
mvmat
=
self
.
get_modelview_mat
(
mult_rot
)
mvmat
=
self
.
get_modelview_mat
(
local_transform
)
viewport
=
(
GLint
*
4
)()
px
=
(
GLdouble
)()
py
=
(
GLdouble
)()
...
...
@@ -279,7 +272,7 @@ class wxGLPanel(wx.Panel):
gluUnProject
(
x
,
y
,
z
,
mvmat
,
pmat
,
viewport
,
px
,
py
,
pz
)
return
(
px
.
value
,
py
.
value
,
pz
.
value
)
def
mouse_to_ray
(
self
,
x
,
y
,
mult_rot
=
False
):
def
mouse_to_ray
(
self
,
x
,
y
,
local_transform
=
False
):
x
=
float
(
x
)
y
=
self
.
height
-
float
(
y
)
pmat
=
(
GLdouble
*
16
)()
...
...
@@ -290,7 +283,7 @@ class wxGLPanel(wx.Panel):
pz
=
(
GLdouble
)()
glGetIntegerv
(
GL_VIEWPORT
,
viewport
)
glGetDoublev
(
GL_PROJECTION_MATRIX
,
pmat
)
mvmat
=
self
.
get_modelview_mat
(
mult_rot
)
mvmat
=
self
.
get_modelview_mat
(
local_transform
)
gluUnProject
(
x
,
y
,
0
,
mvmat
,
pmat
,
viewport
,
px
,
py
,
pz
)
ray_far
=
(
px
.
value
,
py
.
value
,
pz
.
value
)
gluUnProject
(
x
,
y
,
1.
,
mvmat
,
pmat
,
viewport
,
px
,
py
,
pz
)
...
...
printrun/stlview.py
View file @
0bba2c17
...
...
@@ -27,7 +27,8 @@ from pyglet.gl import GL_AMBIENT_AND_DIFFUSE, glBegin, glClearColor, \
GL_LIGHT1
,
glLightfv
,
GL_LIGHTING
,
GL_LINE
,
glMaterialf
,
glMaterialfv
,
\
glMultMatrixd
,
glNormal3f
,
glPolygonMode
,
glPopMatrix
,
GL_POSITION
,
\
glPushMatrix
,
glRotatef
,
glScalef
,
glShadeModel
,
GL_SHININESS
,
\
GL_SMOOTH
,
GL_SPECULAR
,
glTranslatef
,
GL_TRIANGLES
,
glVertex3f
GL_SMOOTH
,
GL_SPECULAR
,
glTranslatef
,
GL_TRIANGLES
,
glVertex3f
,
\
glGetDoublev
,
GL_MODELVIEW_MATRIX
,
GLdouble
from
pyglet
import
gl
from
.gl.panel
import
wxGLPanel
...
...
@@ -180,7 +181,7 @@ class StlViewPanel(wxGLPanel):
delta
=
event
.
GetWheelRotation
()
factor
=
1.05
x
,
y
=
event
.
GetPositionTuple
()
x
,
y
,
_
=
self
.
mouse_to_3d
(
x
,
y
)
x
,
y
,
_
=
self
.
mouse_to_3d
(
x
,
y
,
local_transform
=
True
)
if
delta
>
0
:
self
.
zoom
(
factor
,
(
x
,
y
))
else
:
...
...
@@ -310,6 +311,24 @@ class StlViewPanel(wxGLPanel):
glPopMatrix
()
glPopMatrix
()
# ==========================================================================
# Utils
# ==========================================================================
def
get_modelview_mat
(
self
,
local_transform
):
mvmat
=
(
GLdouble
*
16
)()
if
local_transform
:
glPushMatrix
()
# Rotate according to trackball
glTranslatef
(
0
,
0
,
-
self
.
dist
)
glMultMatrixd
(
build_rotmatrix
(
self
.
basequat
))
# Rotate according to trackball
glTranslatef
(
-
self
.
build_dimensions
[
3
]
-
self
.
platform
.
width
/
2
,
-
self
.
build_dimensions
[
4
]
-
self
.
platform
.
depth
/
2
,
0
)
# Move origin to bottom left of platform
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
glPopMatrix
()
else
:
glGetDoublev
(
GL_MODELVIEW_MATRIX
,
mvmat
)
return
mvmat
def
main
():
app
=
wx
.
App
(
redirect
=
False
)
frame
=
wx
.
Frame
(
None
,
-
1
,
"GL Window"
,
size
=
(
400
,
400
))
...
...
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