コード例 #1
0
ファイル: spline_by_hand.py プロジェクト: almarklein/pirt
    def on_doubleclick_line(self, event):  # On axes

        # Get closest point
        dists = Point(event.x2d, event.y2d).distance(self._pp)
        I, = np.where(dists == dists.min())
        if not len(I):
            return False

        # Remove from pointset
        self._pp.Pop(I[0])
        self._line1.SetPoints(self._pp)

        # Apply
        self._a1.Draw()
        self.apply()
コード例 #2
0
ファイル: deform_by_hand.py プロジェクト: almarklein/pirt
 def on_down(self, event):
     
     if event.button != 1:
         return False        
     if not vv.KEY_SHIFT in event.modifiers:
         return False
     
     # Store location
     self._active = Point(event.x2d, event.y2d)
     
     # Clear any line object
     for l in self._lines:
         l.Destroy()
     
     # Create line objects
     tmp = Pointset(2)
     tmp.append(self._active)
     tmp.append(self._active)
     l1 = vv.plot(tmp, lc='g', lw='3', axes=self._a2, axesAdjust=0)
     l2 = vv.plot(tmp[:1], ls='', ms='.', mc='g', axes=self._a2, axesAdjust=0)
     self._lines = [l1, l2]
     
     # Draw
     self._a2.Draw()
     
     # Prevent dragging by indicating the event needs no further handling
     return True
コード例 #3
0
 def OnUp(self, event):
     """ Called when the mouse is released (when first pressed down 
     in the axes).
     """
     
     # Only if a point is active
     if self._active is None:
         return False
     
     # Get points
     p1 = self._active
     p2 = Point(event.x2d, event.y2d)
     
     # Add!
     self._pp.append(p1)
     self._pp.append(p2)
     
     # We're done with this one
     self._active = None
     
     # Clear temp line object
     if self._line1:
         self._line1.Destroy()
         self._line1 = None
     
     # Update lines
     self._line2.SetPoints(self._pp)
     
     # Draw
     self._a.Draw()
コード例 #4
0
 def OnDown(self, event):
     """ Called when the mouse is pressed down in the axes.
     """
     
     # Only process left mouse button
     if event.button != 1:
         return False
     
     # Store location
     self._active = Point(event.x2d, event.y2d)
     
     # Clear temp line object
     if self._line1:
         self._line1.Destroy()
     
     # Create line objects
     tmp = Pointset(2)
     tmp.append(self._active)
     tmp.append(self._active)
     self._line1 = vv.plot(tmp, lc='r', lw='1', axes=self._a, axesAdjust=0)
     
     # Draw
     self._a.Draw()
     
     # Prevent dragging by indicating the event needs no further handling
     return True
コード例 #5
0
ファイル: spline_by_hand.py プロジェクト: almarklein/pirt
    def on_down_line(self, event):  # On line instance

        if event.button != 1:
            return False

        # Get closest point
        dists = Point(event.x2d, event.y2d).distance(self._pp)
        I, = np.where(dists == dists.min())
        if not len(I):
            return False

        # Store
        self._active = I[0]

        # Prevent dragging by indicating the event needs no further handling
        return True
コード例 #6
0
ファイル: spline_by_hand.py プロジェクト: almarklein/pirt
    def on_motion(self, event):

        if self._active is None:
            return False

        # Update line
        self._pp[self._active] = Point(event.x2d, event.y2d)
        self._line1.SetPoints(self._pp)
        # Draw
        self._a1.Draw()
コード例 #7
0
ファイル: spline_by_hand.py プロジェクト: almarklein/pirt
    def on_doubleclick(self, event):  # On axes

        # Get new point
        p = Point(event.x2d, event.y2d)

        # Add to pointset
        self._pp.append(p)
        self._line1.SetPoints(self._pp)

        # Apply
        self.apply()
コード例 #8
0
ファイル: deform_by_hand.py プロジェクト: almarklein/pirt
 def on_up(self, event):
     
     if self._active is None:
         return False
     
     # Get points
     p1 = self._active
     p2 = Point(event.x2d, event.y2d)
     
     # Add!
     self._pp1.append(p1)
     self._pp2.append(p2)
     
     # We're done with this one
     self._active = None
     
     # Clear any line object
     for l in self._lines:
         l.Destroy()
     
     # Apply
     self.apply()
コード例 #9
0
vv.figure()
a = vv.gca()

# Define points for the line
pp = Pointset(3)
pp.append(0,0,0); pp.append(0,1,0); pp.append(1,2,0); pp.append(0,2,1)

# Create all solids
box = vv.solidBox((0,0,0))
sphere = vv.solidSphere((3,0,0))
cone = vv.solidCone((6,0,0))
pyramid = vv.solidCone((9,0,0), N=4) # a cone with 4 faces is a pyramid
cylinder = vv.solidCylinder((0,3,0),(1,1,2))
ring = vv.solidRing((3,3,0))
teapot = vv.solidTeapot((6,3,0))
line = vv.solidLine(pp+Point(9,3,0), radius = 0.2)

# Let's put a face on that cylinder
# This works because 2D texture coordinates are automatically generated for
# the sphere, cone, cylinder and ring.
im = vv.imread('astronaut.png')
cylinder.SetTexture(im)

# Make the ring green
ring.faceColor = 'g'

# Make the sphere dull
sphere.specular = 0
sphere.diffuse = 0.4

# Show lines in yellow pyramid
コード例 #10
0
ファイル: graph.py プロジェクト: turapeach/TOAK
 def __init__(self, *args, **kwargs):
     Point.__init__(self, *args, **kwargs)
     self._edges = []
コード例 #11
0
ファイル: graph.py プロジェクト: turapeach/TOAK
 def __str__(self):
     """ Make string representation. 
     """
     s = Point.__str__(self)
     s.replace('point', 'node')
コード例 #12
0
#!/usr/bin/env python

import numpy as np
import visvis as vv
from visvis import Point, Pointset
app = vv.use()

# create random points
a = np.random.normal(size=(1000, 3))
pp = Pointset(a)
pp *= Point(2, 5, 1)

# prepare axes
a = vv.gca()
a.cameraType = '3d'
a.daspectAuto = False

# draw points
l = vv.plot(pp, ms='.', mc='r', mw='9', ls='', mew=0)
l.alpha = 0.1

app.Run()
コード例 #13
0
ファイル: graph.py プロジェクト: chiluf/visvis
 def __init__(self, *args, **kwargs):
     Point.__init__(self, *args, **kwargs)
     self._edges = []
コード例 #14
0
ファイル: graph.py プロジェクト: chiluf/visvis
 def __str__(self):
     """ Make string representation. 
     """
     s = Point.__str__(self)
     s.replace('point', 'node')