Commit 434b1edae6097e2011d5800f68b0d08e297a78ed
1 parent
ff84d81a
Exists in
master
and in
68 other branches
ENH: Colour's of the measures
Showing
2 changed files
with
22 additions
and
16 deletions
Show diff stats
invesalius/constants.py
| @@ -28,7 +28,7 @@ from project import Project | @@ -28,7 +28,7 @@ from project import Project | ||
| 28 | #--------------- | 28 | #--------------- |
| 29 | 29 | ||
| 30 | # Measurements | 30 | # Measurements |
| 31 | -MEASURE_NAME_PATTERN = _("M %d") | 31 | +MEASURE_NAME_PATTERN = _("M %d") |
| 32 | MEASURE_LINEAR = 101 | 32 | MEASURE_LINEAR = 101 |
| 33 | MEASURE_ANGULAR = 102 | 33 | MEASURE_ANGULAR = 102 |
| 34 | 34 | ||
| @@ -36,7 +36,7 @@ DEFAULT_MEASURE_COLOUR = (1,0,0) | @@ -36,7 +36,7 @@ DEFAULT_MEASURE_COLOUR = (1,0,0) | ||
| 36 | DEFAULT_MEASURE_BG_COLOUR = (250/255.0, 247/255.0, 218/255.0) | 36 | DEFAULT_MEASURE_BG_COLOUR = (250/255.0, 247/255.0, 218/255.0) |
| 37 | DEFAULT_MEASURE_RADIUS = 1 | 37 | DEFAULT_MEASURE_RADIUS = 1 |
| 38 | DEFAULT_MEASURE_TYPE = MEASURE_LINEAR | 38 | DEFAULT_MEASURE_TYPE = MEASURE_LINEAR |
| 39 | - | 39 | + |
| 40 | 40 | ||
| 41 | # VTK text | 41 | # VTK text |
| 42 | TEXT_SIZE_SMALL = 11 | 42 | TEXT_SIZE_SMALL = 11 |
| @@ -205,6 +205,12 @@ MASK_COLOUR = [[0.33, 1, 0.33], | @@ -205,6 +205,12 @@ MASK_COLOUR = [[0.33, 1, 0.33], | ||
| 205 | #(0.66666666666666663, 0.792156862745098, 1.0)] | 205 | #(0.66666666666666663, 0.792156862745098, 1.0)] |
| 206 | 206 | ||
| 207 | 207 | ||
| 208 | +MEASURE_COLOUR = [[1, 0, 0], | ||
| 209 | + [1, 0.4, 0], | ||
| 210 | + [0, 0, 1], | ||
| 211 | + [1, 0, 1], | ||
| 212 | + [0, 0.6, 0]] | ||
| 213 | + | ||
| 208 | SURFACE_COLOUR = [(0.33, 1, 0.33), | 214 | SURFACE_COLOUR = [(0.33, 1, 0.33), |
| 209 | (1, 1, 0.33), | 215 | (1, 1, 0.33), |
| 210 | (0.33, 0.91, 1), | 216 | (0.33, 0.91, 1), |
| @@ -304,7 +310,7 @@ RAYCASTING_FILES = {_("Airways"): "Airways.plist", | @@ -304,7 +310,7 @@ RAYCASTING_FILES = {_("Airways"): "Airways.plist", | ||
| 304 | _("Bone + Skin"): "Bone + Skin.plist", | 310 | _("Bone + Skin"): "Bone + Skin.plist", |
| 305 | _("Bone + Skin II"): "Bone + Skin II.plist", | 311 | _("Bone + Skin II"): "Bone + Skin II.plist", |
| 306 | _("Dark Bone"): "Dark Bone.plist", | 312 | _("Dark Bone"): "Dark Bone.plist", |
| 307 | - _("Glossy"): "Glossy.plist", | 313 | + _("Glossy"): "Glossy.plist", |
| 308 | _("Glossy II"): "Glossy II.plist", | 314 | _("Glossy II"): "Glossy II.plist", |
| 309 | _("Gold Bone"): "Gold Bone.plist", | 315 | _("Gold Bone"): "Gold Bone.plist", |
| 310 | _("High Contrast"): "High Contrast.plist", | 316 | _("High Contrast"): "High Contrast.plist", |
| @@ -335,7 +341,7 @@ RAYCASTING_TYPES = [_(filename.split(".")[0]) for filename in | @@ -335,7 +341,7 @@ RAYCASTING_TYPES = [_(filename.split(".")[0]) for filename in | ||
| 335 | os.listdir(folder) if | 341 | os.listdir(folder) if |
| 336 | os.path.isfile(os.path.join(folder,filename))] | 342 | os.path.isfile(os.path.join(folder,filename))] |
| 337 | 343 | ||
| 338 | - | 344 | + |
| 339 | LOG_FOLDER = os.path.join(os.path.expanduser('~'), '.invesalius', 'logs') | 345 | LOG_FOLDER = os.path.join(os.path.expanduser('~'), '.invesalius', 'logs') |
| 340 | if not os.path.isdir(LOG_FOLDER): | 346 | if not os.path.isdir(LOG_FOLDER): |
| 341 | os.makedirs(LOG_FOLDER) | 347 | os.makedirs(LOG_FOLDER) |
| @@ -343,7 +349,7 @@ if not os.path.isdir(LOG_FOLDER): | @@ -343,7 +349,7 @@ if not os.path.isdir(LOG_FOLDER): | ||
| 343 | folder = os.path.join(os.path.expanduser('~'), '.invesalius', 'presets') | 349 | folder = os.path.join(os.path.expanduser('~'), '.invesalius', 'presets') |
| 344 | if not os.path.isdir(folder): | 350 | if not os.path.isdir(folder): |
| 345 | os.makedirs(folder) | 351 | os.makedirs(folder) |
| 346 | - | 352 | + |
| 347 | 353 | ||
| 348 | USER_RAYCASTING_PRESETS_DIRECTORY = folder | 354 | USER_RAYCASTING_PRESETS_DIRECTORY = folder |
| 349 | RAYCASTING_TYPES += [_(filename.split(".")[0]) for filename in | 355 | RAYCASTING_TYPES += [_(filename.split(".")[0]) for filename in |
| @@ -469,7 +475,7 @@ SLICE_STYLES.append(STATE_DEFAULT) | @@ -469,7 +475,7 @@ SLICE_STYLES.append(STATE_DEFAULT) | ||
| 469 | SLICE_STYLES.append(SLICE_STATE_EDITOR) | 475 | SLICE_STYLES.append(SLICE_STATE_EDITOR) |
| 470 | 476 | ||
| 471 | VOLUME_STYLES = TOOL_STATES + [VOLUME_STATE_SEED, STATE_MEASURE_DISTANCE, | 477 | VOLUME_STYLES = TOOL_STATES + [VOLUME_STATE_SEED, STATE_MEASURE_DISTANCE, |
| 472 | - STATE_MEASURE_ANGLE] | 478 | + STATE_MEASURE_ANGLE] |
| 473 | VOLUME_STYLES.append(STATE_DEFAULT) | 479 | VOLUME_STYLES.append(STATE_DEFAULT) |
| 474 | 480 | ||
| 475 | 481 |
invesalius/data/measures.py
| @@ -65,7 +65,7 @@ class MeasurementManager(object): | @@ -65,7 +65,7 @@ class MeasurementManager(object): | ||
| 65 | else: | 65 | else: |
| 66 | mr = AngularMeasure(m.colour) | 66 | mr = AngularMeasure(m.colour) |
| 67 | self.current = (m, mr) | 67 | self.current = (m, mr) |
| 68 | - | 68 | + |
| 69 | x, y, z = position | 69 | x, y, z = position |
| 70 | actors = self.current[1].AddPoint(x, y, z) | 70 | actors = self.current[1].AddPoint(x, y, z) |
| 71 | ps.Publisher().sendMessage(("Add actors", location), actors) | 71 | ps.Publisher().sendMessage(("Add actors", location), actors) |
| @@ -116,7 +116,7 @@ class Measurement(): | @@ -116,7 +116,7 @@ class Measurement(): | ||
| 116 | Measurement.general_index += 1 | 116 | Measurement.general_index += 1 |
| 117 | self.index = Measurement.general_index | 117 | self.index = Measurement.general_index |
| 118 | self.name = const.MEASURE_NAME_PATTERN %(self.index+1) | 118 | self.name = const.MEASURE_NAME_PATTERN %(self.index+1) |
| 119 | - self.colour = random.choice(const.MASK_COLOUR) | 119 | + self.colour = random.choice(const.MEASURE_COLOUR) |
| 120 | self.value = 0 | 120 | self.value = 0 |
| 121 | self.location = const.SURFACE # AXIAL, CORONAL, SAGITTAL | 121 | self.location = const.SURFACE # AXIAL, CORONAL, SAGITTAL |
| 122 | self.type = const.LINEAR # ANGULAR | 122 | self.type = const.LINEAR # ANGULAR |
| @@ -154,10 +154,10 @@ class CirclePointRepresentation(object): | @@ -154,10 +154,10 @@ class CirclePointRepresentation(object): | ||
| 154 | sphere = vtk.vtkSphereSource() | 154 | sphere = vtk.vtkSphereSource() |
| 155 | sphere.SetCenter(x, y, z) | 155 | sphere.SetCenter(x, y, z) |
| 156 | sphere.SetRadius(self.radius) | 156 | sphere.SetRadius(self.radius) |
| 157 | - | 157 | + |
| 158 | # c = vtk.vtkCoordinate() | 158 | # c = vtk.vtkCoordinate() |
| 159 | # c.SetCoordinateSystemToWorld() | 159 | # c.SetCoordinateSystemToWorld() |
| 160 | - | 160 | + |
| 161 | m = vtk.vtkPolyDataMapper() | 161 | m = vtk.vtkPolyDataMapper() |
| 162 | m.SetInputConnection(sphere.GetOutputPort()) | 162 | m.SetInputConnection(sphere.GetOutputPort()) |
| 163 | # m.SetTransformCoordinate(c) | 163 | # m.SetTransformCoordinate(c) |
| @@ -181,7 +181,7 @@ class CrossPointRepresentation(object): | @@ -181,7 +181,7 @@ class CrossPointRepresentation(object): | ||
| 181 | self.camera = camera | 181 | self.camera = camera |
| 182 | self.colour = colour | 182 | self.colour = colour |
| 183 | self.size = size | 183 | self.size = size |
| 184 | - | 184 | + |
| 185 | def GetRepresentation(self, x, y, z): | 185 | def GetRepresentation(self, x, y, z): |
| 186 | pc = self.camera.GetPosition() # camera position | 186 | pc = self.camera.GetPosition() # camera position |
| 187 | pf = self.camera.GetFocalPoint() # focal position | 187 | pf = self.camera.GetFocalPoint() # focal position |
| @@ -199,7 +199,7 @@ class CrossPointRepresentation(object): | @@ -199,7 +199,7 @@ class CrossPointRepresentation(object): | ||
| 199 | vtk.vtkMath.Cross(vcp, vcf, n) | 199 | vtk.vtkMath.Cross(vcp, vcf, n) |
| 200 | # then normalize n to only indicate the direction of this vector | 200 | # then normalize n to only indicate the direction of this vector |
| 201 | vtk.vtkMath.Normalize(n) | 201 | vtk.vtkMath.Normalize(n) |
| 202 | - # then | 202 | + # then |
| 203 | p1 = [i*self.size + j for i,j in zip(n, pp)] | 203 | p1 = [i*self.size + j for i,j in zip(n, pp)] |
| 204 | p2 = [i*-self.size + j for i,j in zip(n, pp)] | 204 | p2 = [i*-self.size + j for i,j in zip(n, pp)] |
| 205 | 205 | ||
| @@ -323,7 +323,7 @@ class LinearMeasure(object): | @@ -323,7 +323,7 @@ class LinearMeasure(object): | ||
| 323 | if self.point_actor1: | 323 | if self.point_actor1: |
| 324 | self.render.RemoveActor(self.point_actor1) | 324 | self.render.RemoveActor(self.point_actor1) |
| 325 | renderer.AddActor(self.point_actor1) | 325 | renderer.AddActor(self.point_actor1) |
| 326 | - | 326 | + |
| 327 | if self.point_actor2: | 327 | if self.point_actor2: |
| 328 | self.render.RemoveActor(self.point_actor2) | 328 | self.render.RemoveActor(self.point_actor2) |
| 329 | renderer.AddActor(self.point_actor2) | 329 | renderer.AddActor(self.point_actor2) |
| @@ -363,7 +363,7 @@ class LinearMeasure(object): | @@ -363,7 +363,7 @@ class LinearMeasure(object): | ||
| 363 | if self.point_actor1: | 363 | if self.point_actor1: |
| 364 | self.render.RemoveActor(self.point_actor1) | 364 | self.render.RemoveActor(self.point_actor1) |
| 365 | del self.point_actor1 | 365 | del self.point_actor1 |
| 366 | - | 366 | + |
| 367 | if self.point_actor2: | 367 | if self.point_actor2: |
| 368 | self.render.RemoveActor(self.point_actor2) | 368 | self.render.RemoveActor(self.point_actor2) |
| 369 | del self.point_actor2 | 369 | del self.point_actor2 |
| @@ -555,7 +555,7 @@ class AngularMeasure(object): | @@ -555,7 +555,7 @@ class AngularMeasure(object): | ||
| 555 | if self.point_actor1: | 555 | if self.point_actor1: |
| 556 | self.render.RemoveActor(self.point_actor1) | 556 | self.render.RemoveActor(self.point_actor1) |
| 557 | del self.point_actor1 | 557 | del self.point_actor1 |
| 558 | - | 558 | + |
| 559 | if self.point_actor2: | 559 | if self.point_actor2: |
| 560 | self.render.RemoveActor(self.point_actor2) | 560 | self.render.RemoveActor(self.point_actor2) |
| 561 | del self.point_actor2 | 561 | del self.point_actor2 |
| @@ -576,7 +576,7 @@ class AngularMeasure(object): | @@ -576,7 +576,7 @@ class AngularMeasure(object): | ||
| 576 | if self.point_actor1: | 576 | if self.point_actor1: |
| 577 | self.render.RemoveActor(self.point_actor1) | 577 | self.render.RemoveActor(self.point_actor1) |
| 578 | renderer.AddActor(self.point_actor1) | 578 | renderer.AddActor(self.point_actor1) |
| 579 | - | 579 | + |
| 580 | if self.point_actor2: | 580 | if self.point_actor2: |
| 581 | self.render.RemoveActor(self.point_actor2) | 581 | self.render.RemoveActor(self.point_actor2) |
| 582 | renderer.AddActor(self.point_actor2) | 582 | renderer.AddActor(self.point_actor2) |