Commit 4fa55237998a2e57c25e8624af5500063acd8d19
Committed by
GitHub
1 parent
5e3adf0d
Exists in
master
Coil projection enhancement (#320)
* modify arrow properties, replace orientation disk with torus * Remove ball actor * Change coil angle arrow projection constant to 5 degrees * Add removing arrow and disk used for coil projection when removing the peel * Modify Add_Torus function to be able to modify the color, Modify colors for arrow and torus, Modify size of coil projected arrow * Modify torus color * Modify arrow color * Undo changes done in commit 5fc6fd12b56e42a22571246c025256c30600deaf
Showing
3 changed files
with
55 additions
and
19 deletions
Show diff stats
invesalius/constants.py
invesalius/data/viewer_volume.py
... | ... | @@ -174,7 +174,7 @@ class Viewer(wx.Panel): |
174 | 174 | self.z_actor = None |
175 | 175 | self.mark_actor = None |
176 | 176 | self.obj_projection_arrow_actor = None |
177 | - self.object_orientation_disk_actor = None | |
177 | + self.object_orientation_torus_actor = None | |
178 | 178 | |
179 | 179 | self._mode_cross = False |
180 | 180 | self._to_show_ball = 0 |
... | ... | @@ -1316,17 +1316,18 @@ class Viewer(wx.Panel): |
1316 | 1316 | self.z_actor = self.add_line([0., 0., 0.], [0., 0., 1.], color=[1.0, .0, .0]) |
1317 | 1317 | |
1318 | 1318 | self.obj_projection_arrow_actor = self.Add_ObjectArrow([0., 0., 0.], [0., 0., 0.], vtk_colors.GetColor3d('Red'), |
1319 | - 15) | |
1320 | - self.object_orientation_disk_actor = self.Add_Object_Orientation_Disk([0., 0., 0.], [0., 0., 0.], | |
1321 | - vtk_colors.GetColor3d('Red')) | |
1319 | + 8) | |
1320 | + self.object_orientation_torus_actor = self.Add_Torus([0., 0., 0.], [0., 0., 0.], | |
1321 | + vtk_colors.GetColor3d('Red')) | |
1322 | + | |
1322 | 1323 | #self.obj_projection_arrow_actor.SetVisibility(False) |
1323 | - #self.object_orientation_disk_actor.SetVisibility(False) | |
1324 | + #self.object_orientation_torus_actor.SetVisibility(False) | |
1324 | 1325 | self.ren.AddActor(self.obj_actor) |
1325 | 1326 | self.ren.AddActor(self.x_actor) |
1326 | 1327 | self.ren.AddActor(self.y_actor) |
1327 | 1328 | self.ren.AddActor(self.z_actor) |
1328 | 1329 | #self.ren.AddActor(self.obj_projection_arrow_actor) |
1329 | - #self.ren.AddActor(self.object_orientation_disk_actor) | |
1330 | + #self.ren.AddActor(self.object_orientation_torus_actor) | |
1330 | 1331 | # self.obj_axes = vtk.vtkAxesActor() |
1331 | 1332 | # self.obj_axes.SetShaftTypeToCylinder() |
1332 | 1333 | # self.obj_axes.SetXAxisLabelText("x") |
... | ... | @@ -1356,10 +1357,36 @@ class Viewer(wx.Panel): |
1356 | 1357 | |
1357 | 1358 | return disk_actor |
1358 | 1359 | |
1360 | + def Add_Torus(self, position, orientation, color=[0.0, 0.0, 1.0]): | |
1361 | + torus = vtk.vtkParametricTorus() | |
1362 | + torus.SetRingRadius(2) | |
1363 | + torus.SetCrossSectionRadius(1) | |
1364 | + | |
1365 | + torusSource = vtk.vtkParametricFunctionSource() | |
1366 | + torusSource.SetParametricFunction(torus) | |
1367 | + torusSource.Update() | |
1368 | + | |
1369 | + torusMapper = vtk.vtkPolyDataMapper() | |
1370 | + torusMapper.SetInputConnection(torusSource.GetOutputPort()) | |
1371 | + torusMapper.SetScalarRange(0, 360) | |
1372 | + | |
1373 | + torusActor = vtk.vtkActor() | |
1374 | + torusActor.SetMapper(torusMapper) | |
1375 | + torusActor.GetProperty().SetDiffuseColor(color) | |
1376 | + torusActor.SetPosition(position) | |
1377 | + torusActor.SetOrientation(orientation) | |
1378 | + | |
1379 | + return torusActor | |
1380 | + | |
1359 | 1381 | def Add_ObjectArrow(self, direction, orientation, color=[0.0, 0.0, 1.0], size=2): |
1360 | 1382 | vtk_colors = vtk.vtkNamedColors() |
1361 | 1383 | |
1362 | 1384 | arrow = vtk.vtkArrowSource() |
1385 | + arrow.SetTipResolution(40) | |
1386 | + arrow.SetShaftResolution(40) | |
1387 | + arrow.SetShaftRadius(0.05) | |
1388 | + arrow.SetTipRadius(0.15) | |
1389 | + arrow.SetTipLength(0.35) | |
1363 | 1390 | |
1364 | 1391 | mapper = vtk.vtkPolyDataMapper() |
1365 | 1392 | mapper.SetInputConnection(arrow.GetOutputPort()) |
... | ... | @@ -1410,10 +1437,14 @@ class Viewer(wx.Panel): |
1410 | 1437 | def AddPeeledSurface(self, flag, actor): |
1411 | 1438 | if self.actor_peel: |
1412 | 1439 | self.ren.RemoveActor(self.actor_peel) |
1440 | + self.ren.RemoveActor(self.object_orientation_torus_actor) | |
1441 | + self.ren.RemoveActor(self.obj_projection_arrow_actor) | |
1413 | 1442 | self.actor_peel = None |
1414 | 1443 | if flag and actor: |
1415 | 1444 | self.ren.AddActor(actor) |
1416 | 1445 | self.actor_peel = actor |
1446 | + self.ren.AddActor(self.object_orientation_torus_actor) | |
1447 | + self.ren.AddActor(self.obj_projection_arrow_actor) | |
1417 | 1448 | self.Refresh() |
1418 | 1449 | |
1419 | 1450 | def GetPeelCenters(self, centers, normals): |
... | ... | @@ -1465,27 +1496,27 @@ class Viewer(wx.Panel): |
1465 | 1496 | |
1466 | 1497 | |
1467 | 1498 | self.ren.AddActor(self.obj_projection_arrow_actor) |
1468 | - self.ren.AddActor(self.object_orientation_disk_actor) | |
1499 | + self.ren.AddActor(self.object_orientation_torus_actor) | |
1469 | 1500 | |
1470 | 1501 | self.obj_projection_arrow_actor.SetPosition(closestPoint) |
1471 | 1502 | self.obj_projection_arrow_actor.SetOrientation(coil_dir) |
1472 | 1503 | |
1473 | - self.object_orientation_disk_actor.SetPosition(closestPoint) | |
1474 | - self.object_orientation_disk_actor.SetOrientation(coil_dir) | |
1504 | + self.object_orientation_torus_actor.SetPosition(closestPoint) | |
1505 | + self.object_orientation_torus_actor.SetOrientation(coil_dir) | |
1475 | 1506 | |
1476 | 1507 | # change color of arrow and disk according to angle |
1477 | 1508 | if angle < self.angle_arrow_projection_threshold: |
1478 | - self.object_orientation_disk_actor.GetProperty().SetColor(vtk_colors.GetColor3d('Green')) | |
1479 | - self.obj_projection_arrow_actor.GetProperty().SetColor(vtk_colors.GetColor3d('Green')) | |
1509 | + self.object_orientation_torus_actor.GetProperty().SetDiffuseColor([51/255,176/255,102/255]) | |
1510 | + self.obj_projection_arrow_actor.GetProperty().SetColor([55/255,120/255,163/255]) | |
1480 | 1511 | else: |
1481 | - self.object_orientation_disk_actor.GetProperty().SetColor(vtk_colors.GetColor3d('indian_red')) | |
1482 | - self.obj_projection_arrow_actor.GetProperty().SetColor(vtk_colors.GetColor3d('indian_red')) | |
1512 | + self.object_orientation_torus_actor.GetProperty().SetDiffuseColor([240/255,146/255,105/255]) | |
1513 | + self.obj_projection_arrow_actor.GetProperty().SetColor([240/255,146/255,105/255]) | |
1483 | 1514 | else: |
1484 | 1515 | self.ren.RemoveActor(self.y_actor) |
1485 | 1516 | |
1486 | 1517 | else: |
1487 | 1518 | self.ren.RemoveActor(self.obj_projection_arrow_actor) |
1488 | - self.ren.RemoveActor(self.object_orientation_disk_actor) | |
1519 | + self.ren.RemoveActor(self.object_orientation_torus_actor) | |
1489 | 1520 | self.ren.RemoveActor(self.x_actor) |
1490 | 1521 | #self.ren.RemoveActor(self.y_actor) |
1491 | 1522 | self.Refresh() |
... | ... | @@ -1501,7 +1532,7 @@ class Viewer(wx.Panel): |
1501 | 1532 | self.x_actor.SetVisibility(self.obj_state) |
1502 | 1533 | self.y_actor.SetVisibility(self.obj_state) |
1503 | 1534 | self.z_actor.SetVisibility(self.obj_state) |
1504 | - #self.object_orientation_disk_actor.SetVisibility(self.obj_state) | |
1535 | + #self.object_orientation_torus_actor.SetVisibility(self.obj_state) | |
1505 | 1536 | #self.obj_projection_arrow_actor.SetVisibility(self.obj_state) |
1506 | 1537 | self.Refresh() |
1507 | 1538 | |
... | ... | @@ -1562,7 +1593,7 @@ class Viewer(wx.Panel): |
1562 | 1593 | self.ren.RemoveActor(self.x_actor) |
1563 | 1594 | #self.ren.RemoveActor(self.y_actor) |
1564 | 1595 | self.ren.RemoveActor(self.obj_projection_arrow_actor) |
1565 | - self.ren.RemoveActor(self.object_orientation_disk_actor) | |
1596 | + self.ren.RemoveActor(self.object_orientation_torus_actor) | |
1566 | 1597 | self.GetCellIntersection(p1, norm, coil_norm, coil_dir) |
1567 | 1598 | self.Refresh() |
1568 | 1599 | |
... | ... | @@ -1580,14 +1611,14 @@ class Viewer(wx.Panel): |
1580 | 1611 | self.ren.RemoveActor(self.z_actor) |
1581 | 1612 | self.ren.RemoveActor(self.mark_actor) |
1582 | 1613 | self.ren.RemoveActor(self.obj_projection_arrow_actor) |
1583 | - self.ren.RemoveActor(self.object_orientation_disk_actor) | |
1614 | + self.ren.RemoveActor(self.object_orientation_torus_actor) | |
1584 | 1615 | self.obj_actor = None |
1585 | 1616 | self.x_actor = None |
1586 | 1617 | self.y_actor = None |
1587 | 1618 | self.z_actor = None |
1588 | 1619 | self.mark_actor = None |
1589 | 1620 | self.obj_projection_arrow_actor = None |
1590 | - self.object_orientation_disk_actor=None | |
1621 | + self.object_orientation_torus_actor=None | |
1591 | 1622 | self.Refresh() |
1592 | 1623 | |
1593 | 1624 | def UpdateShowObjectState(self, state): | ... | ... |
invesalius/gui/task_navigator.py
... | ... | @@ -2022,8 +2022,13 @@ class TractographyPanel(wx.Panel): |
2022 | 2022 | # self.view_peeling = ctrl.GetValue() |
2023 | 2023 | if ctrl.GetValue(): |
2024 | 2024 | actor = self.brain_peel.get_actor(self.peel_depth, self.affine_vtk) |
2025 | + self.peel_loaded = True | |
2026 | + Publisher.sendMessage('Update peel visualization', data=self.peel_loaded) | |
2025 | 2027 | else: |
2026 | 2028 | actor = None |
2029 | + self.peel_loaded = False | |
2030 | + Publisher.sendMessage('Update peel visualization', data= self.peel_loaded) | |
2031 | + | |
2027 | 2032 | Publisher.sendMessage('Update peel', flag=ctrl.GetValue(), actor=actor) |
2028 | 2033 | |
2029 | 2034 | def OnEnableTracts(self, evt, ctrl): | ... | ... |