Commit 469c97a9 authored by lode_leroy's avatar lode_leroy

remove MGED exporter

git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@40 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 1a77f369
BRLCAD=/opt/brlcad/bin
BRLCAD=c:/Software/BRL-CAD/bin
MGED=$(BRLCAD)/mged
G-STL=$(BRLCAD)/g-stl
VER=0.1.6
VER=0.1.7
all:
......@@ -13,26 +8,5 @@ dist:
(cd ..; tar zcf pycam/pycam.tgz pycam/*{Makefile,TXT} pycam/*.py pycam/tests/*.py pycam/pycam/*/*.py pycam/pycam/*.py pycam/Samples/*/*.stl)
dist-ver:
(cd ..; tar zcf pycam-$(VER)/pycam-$(VER).tgz pycam-$(VER)/*{Makefile,TXT} pycam-$(VER)/*.py pycam-$(VER)/tests/*.py pycam-$(VER)/pycam/*/*.py pycam-$(VER)/pycam/*.py pycam-$(VER)/Samples/*/*.stl)
test:
rm -f test.g; $(MGED) test.g < test.txt; $(MGED) test.g
test0:
rm -f test.g; $(MGED) test.g < cutter0.txt; $(MGED) test.g
test1:
rm -f test.g; $(MGED) test.g < cutter1.txt; $(MGED) test.g
test2:
rm -f test.g; $(MGED) test.g < cutter2.txt; $(MGED) test.g
test3:
rm -f test.g; $(MGED) test.g < cutter3.txt; $(MGED) test.g
(cd ..; tar zcf pycam-$(VER).tgz pycam-$(VER)/*{Makefile,TXT} pycam-$(VER)/*.py pycam-$(VER)/tests/*.py pycam-$(VER)/pycam/*/*.py pycam-$(VER)/pycam/*.py pycam-$(VER)/Samples/*/*.{stl,cfg})
TestModel.stl:
./Tests/MGEDExporterTest.py
rm -f TestModel.g
$(MGED) TestModel.g < TestModel.txt
$(G-STL) -o TestModel.stl TestModel.g model0
......@@ -38,7 +38,9 @@ INSTALL:
(requires TOGL)
TOGL: http://downloads.sourceforge.net/togl/Togl2.0-8.4-Windows.zip
(just copy Togl2.0 into Python25/tcl)
http://downloads.sourceforge.net/togl/Togl2.0-src.tar.gz
(download tcl-8.4-src.tgz and tk-8.4-src.tgz and compile and install togl)
(on windows, this also requires GLUT)
GLUT : http://www.cip.physik.uni-muenchen.de/~georg.hennig/downloads/glut-3.7.6-wheel_mingw.zip
......
......@@ -13,5 +13,5 @@ Layers=4
Samples=50
Lines=20
Cutter=SphericalCutter
PathGenerator=DropCutter
PathGenerator=PushCutter
PathProcessor=ZigZagCutter
......@@ -46,6 +46,7 @@ if __name__ == "__main__":
t = Triangle(Point(-2,0,2), Point(2,1,3), Point(2,-1,4))
#t = Triangle(Point(-2,0,2), Point(2,-1,4), Point(2,1,3))
#t = Triangle(Point(2,0,4), Point(2,-1,2), Point(2,1,2))
#t = Triangle(Point(2,0,2), Point(-2,1,2), Point(-2,-1,2))
print "t=", t
if False:
......
......@@ -6,18 +6,6 @@ from pycam.Geometry.TriangleKdtree import *
from pycam.Geometry.Model import Model
from pycam.Importers.TestModel import TestModel
def comb_tomged(f, triangles, name, color):
comb = ""
for t in triangles:
comb += " u triangle%d" % t.id
if len(comb)>512:
f.write("comb "+name+comb+"\n")
comb = ""
if len(comb)>0:
f.write("comb "+name+comb+"\n")
f.write("mater " + name + " del " + color + " 1\n")
print "# get model"
testmodel = TestModel()
print "# subdivide"
......@@ -45,27 +33,3 @@ hits = SearchKdtree2d(kdtree, minx, maxx, miny, maxy)
#print "# hits=%d / tests=%d" % GetKdtree2dStats(), "/ triangles=%d" % len(model.triangles())
print "# hits=%d " % len(hits), "/ tests=%d" % len(tests), "/ triangles=%d" % len(model.triangles())
print "# write mged"
f = file("test.txt","w")
f.write("in query.s arb8 %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f\n" %
(minx, miny, 0, maxx, miny, 0, minx, maxy, 0, maxx, maxy, 0, minx, miny, 10, maxx, miny, 10, minx, maxy, 10, maxx, maxy, 10))
f.write("comb query.c u query.s\n")
f.write("mater query.c del 255 255 255 0\n")
if False:
for t in model.triangles():
f.write(t.to_mged())
comb_tomged(f, model.triangles(), "model.c", "255 0 0")
else:
for t in tests:
f.write(t.to_mged())
comb_tomged(f, tests, "tests.c", "0 255 0")
comb_tomged(f, hits, "hits.c", "0 0 255")
#print kdtree
#f.write(kdtree.to_mged(-7,-7,7,7))
f.write(SearchKdtree2d_mged(kdtree, minx, maxx, miny, maxy,-7,-7,+7,+7))
f.close()
......@@ -33,7 +33,4 @@ if __name__ == "__main__":
t.calc_circumcircle()
print "circ(t) = %s@%s" % (t.radius,t.center())
f = file("triangle0.txt","w")
f.write(t.to_mged(sphere=True))
f.close()
......@@ -22,9 +22,6 @@ class BaseCutter:
def __repr__(self):
return "BaseCutter"
def to_mged(self):
return ""
def moveto(self, location):
self.location = location
self.minx = location.x-self.radius
......
......@@ -25,15 +25,6 @@ class CylindricalCutter(BaseCutter):
def __repr__(self):
return "CylindricalCutter<%s,%s>" % (self.location,self.radius)
def to_mged(self):
s = ""
s += "in cutter%d_cyl.s rcc"% (self.id)
s += " %f %f %f 0 0 %f %f" % (self.location.x, self.location.y, self.location.z, self.height, self.radius)
s += "\n"
s += "comb cutter%d_cyl.c u cutter%d_cyl.s\n" % (self.id, self.id)
s += "r cutter%d.r u cutter%d_cyl.c\n" % (self.id, self.id)
return s
def to_OpenGL(self):
glPushMatrix()
glTranslate(self.center.x, self.center.y, self.center.z)
......
......@@ -25,19 +25,6 @@ class SphericalCutter(BaseCutter):
def __repr__(self):
return "SphericalCutter<%s,%s>" % (self.location,self.radius)
def to_mged(self):
s = ""
s += "in cutter%d_sph.s sph" % (self.id)
s += " %f %f %f %f" % (self.center.x, self.center.y, self.center.z, self.radius)
s += "\n"
s += "in cutter%d_cyl.s rcc"% (self.id)
s += " %f %f %f 0 0 %f %f" % (self.center.x, self.center.y, self.center.z, self.height, self.radius)
s += "\n"
s += "comb cutter%d_sph.c u cutter%d_sph.s\n" % (self.id, self.id)
s += "comb cutter%d_cyl.c u cutter%d_cyl.s - cutter%d_sph.s\n" % (self.id, self.id, self.id)
s += "r cutter%d.r u cutter%d_cyl.c u cutter%d_sph.c\n" % (self.id, self.id, self.id)
return s
def to_OpenGL(self):
glPushMatrix()
glTranslate(self.center.x, self.center.y, self.center.z)
......
......@@ -29,25 +29,6 @@ class ToroidalCutter(BaseCutter):
def __repr__(self):
return "ToroidalCutter<%s,%f,R=%f,r=%f>" % (self.location,self.radius,self.majorradius,self.minorradius)
def to_mged(self):
s = ""
s += "in cutter%d_tor.s tor" % (self.id)
s += " %f %f %f" % (self.center.x, self.center.y, self.center.z)
s += " %f %f %f" % (0, 0, 1)
s += " %f %f" % (self.majorradius, self.minorradius)
s += "\n"
s += "in cutter%d_cyl.s rcc"% (self.id)
s += " %f %f %f 0 0 %f %f" % (self.center.x, self.center.y, self.center.z, self.height, self.radius)
s += "\n"
s += "in cutter%d_bot.s rcc"% (self.id)
s += " %f %f %f 0 0 %f %f" % (self.center.x, self.center.y, self.center.z, -self.minorradius, self.majorradius)
s += "\n"
s += "comb cutter%d_tor.c u cutter%d_tor.s - cutter%d_cyl.s - cutter%d_bot.s\n" % (self.id, self.id, self.id, self.id)
s += "comb cutter%d_cyl.c u cutter%d_cyl.s\n" % (self.id, self.id)
s += "comb cutter%d_bot.c u cutter%d_bot.s\n" % (self.id, self.id)
s += "r cutter%d.r u cutter%d_tor.c u cutter%d_cyl.c u cutter%d_bot.c\n" % (self.id, self.id, self.id, self.id)
return s
def to_OpenGL(self):
glPushMatrix()
glTranslate(self.center.x, self.center.y, self.center.z)
......
from pycam.Geometry import *
class MGEDExporter:
def __init__(self, filename):
self.file = file(filename,"w")
def close(self):
self.file.close()
def AddCutter(self, cutter):
self.file.write(cutter.to_mged())
def AddModel(self, model):
self.file.write(model.to_mged())
def AddPath(self, path):
prev = path.points[0]
for i in range(1, len(path.points)):
next = path.points[i]
self.file.write(Line(prev,next).to_mged())
prev = next
def AddPathList(self, pathlist):
for path in pathlist:
self.AddPath(path)
......@@ -5,8 +5,8 @@ class SVGExporter:
def __init__(self, filename):
self.file = file(filename,"w")
self.file.write("""<?xml version='1.0'?>
<svg xmlns='http://www.w3.org/2000/svg' width='640' height='480'>
<g transform='translate(320,240) scale(20)' stroke-width='0.01'>
<svg xmlns='http://www.w3.org/2000/svg' width='640' height='800'>
<g transform='translate(320,320) scale(30)' stroke-width='0.01' font-size='0.4'>
""")
self._fill = 'none'
self._stroke = 'black'
......@@ -32,7 +32,16 @@ class SVGExporter:
l = "<circle fill='" + self._fill +"'" + (" cx='%g'" % x) + (" cy='%g'" % -y) + " r='0.1'/>\n"
self.file.write(l)
def AddText(self, x, y, text):
l = "<text fill='" + self._fill +"'" + (" x='%g'" % x) + (" y='%g'" % -y) + ">" + text + "</text>\n"
self.file.write(l)
def AddLine(self, x1, y1, x2, y2):
if y1 < -1000:
y1 = -7
if y2 < -1000:
y2 = -7
l = "<line fill='" + self._fill +"' stroke='" + self._stroke + "'" + (" x1='%g'" % x1) + (" y1='%g'" % -y1) + (" x2='%g'" % x2) + (" y2='%g'" % -y2) + " />\n"
self.file.write(l)
......
......@@ -16,8 +16,8 @@ class SimpleGCodeExporter:
self.gcode = gcode(x,y,z)
gc = self.gcode
self.file.write(gc.begin()+"\n")
self.file.write("F"+feedrate+"\n")
self.file.write("S"+speed+"\n")
self.file.write("F"+str(feedrate)+"\n")
self.file.write("S"+str(speed)+"\n")
self.file.write(gc.safety()+"\n")
def close(self):
......@@ -29,10 +29,10 @@ class SimpleGCodeExporter:
def AddPath(self, path):
gc = self.gcode
point = path.points[0]
# self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n")
self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n")
for point in path.points:
self.file.write(gc.cut(point.x,point.y,point.z)+"\n")
# self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n")
self.file.write(gc.rapid(point.x,point.y,gc.safetyheight)+"\n")
def AddPathList(self, pathlist):
for path in pathlist:
......
list = ["MGEDExporter", "SimpleGCodeExporter"]
list = [ "SimpleGCodeExporter"]
__all__ = list
......@@ -12,12 +12,6 @@ class Line:
def __repr__(self):
return "Line<%g,%g,%g>-<%g,%g,%g>" % (self.p1.x,self.p1.y,self.p1.z,
self.p2.x,self.p2.y,self.p2.z)
def to_mged(self):
s = ""
s += "in line%d rcc %f %f %f %f %f %f 0.01\n" % (self.id,
self.p1.x,self.p1.y,self.p1.z,
self.p2.x-self.p1.x,self.p2.y-self.p1.y,self.p2.z-self.p1.z)
return s
def dir(self):
if not hasattr(self,"_dir"):
......
......@@ -19,22 +19,6 @@ class Model:
self._triangles = []
self.name = "model%d" % self.id
def to_mged(self): # TODO: optimize to not export points multiple times
s = "in %s bot" % self.name
s += " %d" % (len(self._triangles)*3)
s += " %d" % len(self._triangles)
s += " 1 3"
for t in self._triangles:
s += " %g %g %g" % (t.p1.x,t.p1.y,t.p1.z)
s += " %g %g %g" % (t.p2.x,t.p2.y,t.p2.z)
s += " %g %g %g" % (t.p3.x,t.p3.y,t.p3.z)
i = 0
for t in self._triangles:
s += " %d %d %d" % (i, i+1, i+2)
i += 3
s += "\n"
return s
def to_OpenGL(self):
if True:
glBegin(GL_TRIANGLES)
......
......@@ -11,11 +11,3 @@ class Plane:
def __repr__(self):
return "Plane<%s,%s>" % (self.p,self.n)
def to_mged(self):
s = ""
s += "in plane%d half"%(self.id)
s += " %f %f %f"% (self.n.x, self.n.y, self.n.z)
s += " %f "% (self.p.dot(self.n))
s += "\n"
return s
......@@ -10,10 +10,6 @@ class Point:
self.z = float(z)
def __repr__(self):
return "Point<%g,%g,%g>" % (self.x,self.y,self.z)
def to_mged(self):
s = ""
s += "in point%d sph %f %f %f 0.03\n" % (self.id,self.x,self.y,self.z)
return s
def mul(self, c):
return Point(self.x*c,self.y*c,self.z*c)
def div(self, c):
......@@ -41,4 +37,5 @@ class Point:
self.z /= n
self._norm = 1.0
self._normsq = 1.0
return self
......@@ -28,28 +28,13 @@ class Triangle:
def name(self):
return "triangle%d" % self.id
def to_mged(self, sphere=False):
s = "in %s bot 3 1" % self.name()
s += " 1 3"
s += " %f %f %f" % (self.p1.x,self.p1.y,self.p1.z)
s += " %f %f %f" % (self.p2.x,self.p2.y,self.p2.z)
s += " %f %f %f" % (self.p3.x,self.p3.y,self.p3.z)
s += " 0 1 2"
s += "\n"
if sphere and hasattr(self, "_middle"):
s += "in %s_sph sph " % self.name()
s += " %f %f %f" % (self._middle.x, self._middle.y, self._middle.z)
s += " %f" % self._radius
s += "\n"
return s
def to_OpenGL(self):
glBegin(GL_TRIANGLES)
glVertex3f(self.p1.x, self.p1.y, self.p1.z)
glVertex3f(self.p2.x, self.p2.y, self.p2.z)
glVertex3f(self.p3.x, self.p3.y, self.p3.z)
glEnd()
if False:
if False: # display surface normals
n = self.normal()
c = self.center()
d = 0.5
......@@ -57,16 +42,64 @@ class Triangle:
glVertex3f(c.x, c.y, c.z)
glVertex3f(c.x+n.x*d, c.y+n.y*d, c.z+n.z*d)
glEnd()
if False and hasattr(self, "_middle"):
if False and hasattr(self, "_middle"): # display bounding sphere
glPushMatrix()
glTranslate(self._middle.x, self._middle.y, self._middle.z)
if not hasattr(self,"_sphere"):
self._sphere = gluNewQuadric()
gluSphere(self._sphere, self._radius, 10, 10)
glPopMatrix()
if False: # draw triangle id on triangle face
glPushMatrix()
cc = glGetFloatv(GL_CURRENT_COLOR)
c = self.center()
glTranslate(c.x,c.y,c.z)
p12=self.p1.add(self.p2).mul(0.5)
p3_12=self.p3.sub(p12).normalize()
p2_1=self.p1.sub(self.p2).normalize()
pn=p2_1.cross(p3_12)
glMultMatrixf((p2_1.x, p2_1.y, p2_1.z, 0, p3_12.x, p3_12.y, p3_12.z, 0, pn.x, pn.y, pn.z, 0, 0,0,0,1))
n = self.normal().mul(0.01)
glTranslatef(n.x,n.y,n.z)
glScalef(0.003,0.003,0.003)
w = 0
for ch in str(self.id):
w += glutStrokeWidth(GLUT_STROKE_ROMAN, ord(ch))
glTranslate(-w/2,0,0)
glColor4f(1,1,1,0)
for ch in str(self.id):
glutStrokeCharacter(GLUT_STROKE_ROMAN, ord(ch))
glPopMatrix()
glColor4f(cc[0],cc[1],cc[2],cc[3])
if False: # draw point id on triangle face
cc = glGetFloatv(GL_CURRENT_COLOR)
c = self.center()
p12=self.p1.add(self.p2).mul(0.5)
p3_12=self.p3.sub(p12).normalize()
p2_1=self.p1.sub(self.p2).normalize()
pn=p2_1.cross(p3_12)
n = self.normal().mul(0.01)
for p in (self.p1,self.p2,self.p3):
glPushMatrix()
pp = p.sub(p.sub(c).mul(0.3))
glTranslate(pp.x,pp.y,pp.z)
glMultMatrixf((p2_1.x, p2_1.y, p2_1.z, 0, p3_12.x, p3_12.y, p3_12.z, 0, pn.x, pn.y, pn.z, 0, 0,0,0,1))
glTranslatef(n.x,n.y,n.z)
glScalef(0.001,0.001,0.001)
w = 0
for ch in str(p.id):
w += glutStrokeWidth(GLUT_STROKE_ROMAN, ord(ch))
glTranslate(-w/2,0,0)
glColor4f(0.5,1,0.5,0)
for ch in str(p.id):
glutStrokeCharacter(GLUT_STROKE_ROMAN, ord(ch))
glPopMatrix()
glColor4f(cc[0],cc[1],cc[2],cc[3])
def normal(self):
if not hasattr(self, '_normal'):
# calculate normal, if p1-p2-pe are in clockwise order
self._normal = self.p3.sub(self.p1).cross(self.p2.sub(self.p1))
denom = self._normal.norm()
# # TODO: fix kludge: make surface normal point up for now
......
......@@ -22,14 +22,12 @@ def BuildKdtree2d(triangles, cutoff=3, cutoff_distance=1.0):
tests = 0
hits = 0
overlaptest=True
mged = ""
def ResetKdtree2dStats(overlap=True):
global tests, hits, overlaptest
hits = 0
tests = 0
overlaptest = overlap
mged = ""
def GetKdtree2dStats():
global tests, hits
......@@ -85,48 +83,3 @@ def SearchKdtree2d(kdtree, minx, maxx, miny, maxy):
return SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
else:
return SearchKdtree2d(kdtree.lo, minx, maxx, miny, maxy)+SearchKdtree2d(kdtree.hi, minx, maxx, miny, maxy)
def SearchKdtree2d_mged(kdtree, minx, maxx, miny, maxy, _minx, _maxx, _miny, _maxy):
if kdtree.bucket:
s = ""
s += "in kdtree_%d arb8 " % kdtree.id
s += " %f %f %f " % (_minx, _miny, 0)
s += " %f %f %f " % (_maxx, _miny, 0)
s += " %f %f %f " % (_maxx, _maxy, 0)
s += " %f %f %f " % (_minx, _maxy, 0)
s += " %f %f %f " % (_minx, _miny, 10)
s += " %f %f %f " % (_maxx, _miny, 10)
s += " %f %f %f " % (_maxx, _maxy, 10)
s += " %f %f %f" % (_minx, _maxy, 10)
s += "\n"
return s
else:
if kdtree.cutdim==0:
if maxx<kdtree.minval:
return ""
elif maxx<=kdtree.cutval:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, kdtree.minval, kdtree.cutval, _miny, _maxy)
else:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, kdtree.minval, kdtree.cutval, _miny, _maxy)+SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, kdtree.cutval, kdtree.maxval, _miny, _maxy)
elif kdtree.cutdim==1:
if maxy<kdtree.minval:
return ""
elif maxy<=kdtree.cutval:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, _minx, _maxx, kdtree.minval, kdtree.cutval)
else:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, _minx, _maxx, kdtree.minval, kdtree.cutval)+SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, _minx, _maxx, kdtree.cutval, kdtree.maxval)
elif kdtree.cutdim==2:
if minx>kdtree.maxval:
return ""
elif minx>kdtree.cutval:
return SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, kdtree.minval, kdtree.cutval, _miny, _maxy)
else:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, kdtree.minval, kdtree.cutval, _miny, _maxy)+SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, kdtree.cutval, kdtree.maxval, _miny, _maxy)
elif kdtree.cutdim==3:
if miny>kdtree.maxval:
return ""
elif miny>kdtree.cutval:
return SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, _minx, _maxx, kdtree.minval, kdtree.cutval)
else:
return SearchKdtree2d_mged(kdtree.lo, minx, maxx, miny, maxy, _minx, _maxx, kdtree.minval, kdtree.cutval)+SearchKdtree2d_mged(kdtree.hi, minx, maxx, miny, maxy, _minx, _maxx, kdtree.cutval, kdtree.maxval)
......@@ -40,36 +40,6 @@ class kd_tree:
else:
return "(%f<=%s,%d:%f,%s<=%f)" % (self.minval,self.lo, self.cutdim,self.cutval,self.hi,self.maxval)
def to_mged(self, minx, maxx, miny, maxy):
s = ""
if self.bucket:
s += "in kdtree_%d arb8 " % self.id
s += " %f %f %f " % (minx, miny, 0)
s += " %f %f %f " % (maxx, miny, 0)
s += " %f %f %f " % (maxx, maxy, 0)
s += " %f %f %f " % (minx, maxy, 0)
s += " %f %f %f " % (minx, miny, 10)
s += " %f %f %f " % (maxx, miny, 10)
s += " %f %f %f " % (maxx, maxy, 10)
s += " %f %f %f" % (minx, maxy, 10)
s += "\n"
else:
if True: # show bounding box
if self.cutdim == 0 or self.cutdim == 2:
s += self.lo.to_mged(self.minval,self.cutval,miny,maxy)
s += self.hi.to_mged(self.cutval,self.maxval,miny,maxy)
elif self.cutdim == 1 or self.cutdim == 3:
s += self.lo.to_mged(minx,maxx,self.minval,self.cutval)
s += self.hi.to_mged(minx,maxx,self.cutval,self.maxval)
else: # show partitions
if self.cutdim == 0 or self.cutdim == 2:
s += self.lo.to_mged(minx,self.cutval,miny,maxy)
s += self.hi.to_mged(self.cutval,maxx,miny,maxy)
elif self.cutdim == 1 or self.cutdim == 3:
s += self.lo.to_mged(minx,maxx,miny,self.cutval)
s += self.hi.to_mged(minx,maxx,self.cutval,maxy)
return s
def __init__(self, nodes, cutoff, cutoff_distance):
self.id = kd_tree.id
kd_tree.id += 1
......
#!/usr/bin/python
import sys
sys.path.insert(0,'.')
......@@ -47,6 +48,22 @@ class OpenglWidget(Opengl):
self.master.resetView()
class SimpleGui(Frame):
def draw_string(self, x, y, z, p, s, scale=.01):
glPushMatrix()
glTranslatef(x,y,z)
if p == 'xy':
pass
elif p == 'yz':
glRotatef(90, 0, 1, 0)
glRotatef(90, 0, 0, 1)
elif p == 'xz':
glRotatef(90, 0, 1, 0)
glRotatef(90, 0, 0, 1)
glRotatef(-90, 0, 1, 0)
glScalef(scale,scale,scale)
for c in str(s):
glutStrokeCharacter(GLUT_STROKE_ROMAN, ord(c))
glPopMatrix()
def Redraw(self, event=None):
# default scale and orientation
......@@ -63,16 +80,19 @@ class SimpleGui(Frame):
glVertex3f(0,0,0)
glVertex3f(size,0,0)
glEnd()
self.draw_string(size,0,0,'xy',"X")
glBegin(GL_LINES)
glColor3f(0,1,0)
glVertex3f(0,0,0)
glVertex3f(0,size,0)
glEnd()
self.draw_string(0,size,0,'yz',"Y")
glBegin(GL_LINES)
glColor3f(0,0,1)
glVertex3f(0,0,0)
glVertex3f(0,0,size)
glEnd()
self.draw_string(0,0,size,'xz',"Z")
if True:
# stock model
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment