Commit 7a7575246daf1e9608d1941c08b678de48907fbe

Authored by Thiago Franco de Moraes
1 parent dc6f1c9a

Drawing the arc

Showing 1 changed file with 37 additions and 4 deletions   Show diff stats
invesalius/data/viewer_slice.py
@@ -225,7 +225,7 @@ class CanvasRendererCTX: @@ -225,7 +225,7 @@ class CanvasRendererCTX:
225 gc.SetAntialiasMode(0) 225 gc.SetAntialiasMode(0)
226 226
227 font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) 227 font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
228 - font.SetWeight(wx.BOLD) 228 + # font.SetWeight(wx.BOLD)
229 font = gc.CreateFont(font, (0, 0, 255)) 229 font = gc.CreateFont(font, (0, 0, 255))
230 gc.SetFont(font) 230 gc.SetFont(font)
231 231
@@ -240,16 +240,49 @@ class CanvasRendererCTX: @@ -240,16 +240,49 @@ class CanvasRendererCTX:
240 for p in m.points: 240 for p in m.points:
241 coord.SetValue(p) 241 coord.SetValue(p)
242 cx, cy = coord.GetComputedDisplayValue(self.viewer.slice_data.renderer) 242 cx, cy = coord.GetComputedDisplayValue(self.viewer.slice_data.renderer)
  243 + print (p, cx, cy)
243 cy = -cy 244 cy = -cy
244 lines.append((cx, cy)) 245 lines.append((cx, cy))
245 path = gc.CreatePath() 246 path = gc.CreatePath()
246 - path.AddArc(cx, cy, 5, 0, np.pi * 2) 247 + path.AddCircle(cx, cy, 2.5)
247 gc.StrokePath(path) 248 gc.StrokePath(path)
248 gc.FillPath(path) 249 gc.FillPath(path)
249 250
250 if len(lines) > 1: 251 if len(lines) > 1:
251 - gc.DrawLines(lines)  
252 - txt = u"%.3f" % m.value 252 + path = gc.CreatePath()
  253 +
  254 + path.MoveToPoint(*lines[0])
  255 + for p in lines[1::]:
  256 + path.AddLineToPoint(*p)
  257 + gc.StrokePath(path)
  258 + if m.type == const.ANGULAR:
  259 + txt = u"%.3f°" % m.value
  260 +
  261 + if len(lines) == 3:
  262 + path = gc.CreatePath()
  263 +
  264 + c = np.array(lines[1])
  265 + v0 = np.array(lines[0]) - c
  266 + v1 = np.array(lines[2]) - c
  267 +
  268 + s0 = np.linalg.norm(v0)
  269 + s1 = np.linalg.norm(v1)
  270 +
  271 + a0 = np.arctan2(v0[1] , v0[0])
  272 + a1 = np.arctan2(v1[1] , v1[0])
  273 +
  274 + if (a1 - a0) % (np.pi*2) < (a0 - a1) % (np.pi*2):
  275 + sa = a0
  276 + ea = a1
  277 + else:
  278 + sa = a1
  279 + ea = a0
  280 +
  281 + path.AddArc((c[0], c[1]), min(s0, s1), sa, ea)
  282 + gc.StrokePath(path)
  283 +
  284 + else:
  285 + txt = u"%.3f mm ひらがな - Hiragana, 히라가나" % m.value
253 gc.DrawText(txt, *lines[0]) 286 gc.DrawText(txt, *lines[0])
254 287
255 gc.Destroy() 288 gc.Destroy()