Commit 59c2ea35ed9381ccb58d73323c53a3c49eafaf9f

Authored by Paulo Henrique Junqueira Amorim
1 parent 57af88d4

ENH: Decreased border size from cursor circle

Showing 1 changed file with 39 additions and 18 deletions   Show diff stats
invesalius/data/cursor_actors.py
... ... @@ -40,8 +40,8 @@ class CursorCircle:
40 40 self.spacing = (1, 1, 1)
41 41  
42 42 self.mapper = vtk.vtkPolyDataMapper()
43   - self.disk = vtk.vtkDiskSource()
44 43 self.actor = vtk.vtkActor()
  44 + self.property = vtk.vtkProperty()
45 45  
46 46 self.__build_actor()
47 47 self.__calculate_area_pixels()
... ... @@ -51,23 +51,41 @@ class CursorCircle:
51 51 Function to plot the circle
52 52 """
53 53  
54   - disk = self.disk
55   - disk.SetInnerRadius(self.radius-1) # filled = self.radius
56   - disk.SetOuterRadius(self.radius) # filled = 0x
57   - disk.SetRadialResolution(50)
58   - disk.SetCircumferentialResolution(50)
59   -
60   - mapper = self.mapper
61   - mapper.SetInput(disk.GetOutput())
  54 + r = self.radius
  55 + t = 0
  56 +
  57 + self.posc_a = 0
  58 + self.posc_b = 0
  59 +
  60 + self.segment = vtk.vtkAppendPolyData()
  61 +
  62 + self.xa = self.posc_a + r * cos(t)
  63 + self.ya = self.posc_a + r * sin(t)
  64 +
  65 + while(t <= 2 * pi):
  66 + self.GenerateCicleSegment(t)
  67 + t = t + 0.05
62 68  
63   - actor = self.actor
64   - actor.SetMapper(mapper)
65   - actor.GetProperty().SetOpacity(self.opacity)
66   - actor.GetProperty().SetColor(self.colour)
67   - #actor.SetPosition(self.position)
68   - actor.SetVisibility(0)
69   - actor.PickableOff()
  69 + self.GenerateCicleSegment(0)
  70 +
  71 + self.mapper.SetInputConnection(self.segment.GetOutputPort())
  72 + self.actor.SetMapper(self.mapper)
  73 + self.actor.PickableOff()
  74 +
  75 + def GenerateCicleSegment(self, t):
  76 + """
  77 + Generate cicle segment
  78 + """
  79 + x = self.posc_a + self.radius * cos(t)
  80 + y = self.posc_b + self.radius * sin(t)
  81 +
  82 + ls = vtk.vtkLineSource()
  83 + ls.SetPoint1(self.xa, self.ya, 0)
  84 + ls.SetPoint2(x, y, 0)
70 85  
  86 + self.segment.AddInput(ls.GetOutput())
  87 + self.xa, self.ya = x, y
  88 +
71 89 def __calculate_area_pixels(self):
72 90 """
73 91 Return the cursor's pixels.
... ... @@ -118,10 +136,13 @@ class CursorCircle:
118 136  
119 137 def SetSize(self, diameter):
120 138 radius = self.radius = diameter/2.0
121   - self.disk.SetInnerRadius(radius-1) # filled = self.radius
122   - self.disk.SetOuterRadius(radius) # filled = 0
  139 + #self.disk.SetInnerRadius(radius-1) # filled = self.radius
  140 + #self.disk.SetOuterRadius(radius) # filled = 0
  141 + self.__build_actor()
123 142 self.__calculate_area_pixels()
124 143  
  144 +
  145 +
125 146 def SetColour(self, colour):
126 147 self.colour = colour
127 148 self.actor.GetProperty().SetColor(colour)
... ...