Commit d7439bcd0a4f7050815fe2a640dc65d90b7133d2

Authored by Thiago Franco de Moraes
1 parent 87c3a46d

invesalius/style.py was removed

Showing 1 changed file with 112 additions and 0 deletions   Show diff stats
invesalius/style.py 0 → 100644
... ... @@ -0,0 +1,112 @@
  1 +#--------------------------------------------------------------------------
  2 +# Software: InVesalius - Software de Reconstrucao 3D de Imagens Medicas
  3 +# Copyright: (C) 2001 Centro de Pesquisas Renato Archer
  4 +# Homepage: http://www.softwarepublico.gov.br
  5 +# Contact: invesalius@cti.gov.br
  6 +# License: GNU - GPL 2 (LICENSE.txt/LICENCA.txt)
  7 +#--------------------------------------------------------------------------
  8 +# Este programa e software livre; voce pode redistribui-lo e/ou
  9 +# modifica-lo sob os termos da Licenca Publica Geral GNU, conforme
  10 +# publicada pela Free Software Foundation; de acordo com a versao 2
  11 +# da Licenca.
  12 +#
  13 +# Este programa eh distribuido na expectativa de ser util, mas SEM
  14 +# QUALQUER GARANTIA; sem mesmo a garantia implicita de
  15 +# COMERCIALIZACAO ou de ADEQUACAO A QUALQUER PROPOSITO EM
  16 +# PARTICULAR. Consulte a Licenca Publica Geral GNU para obter mais
  17 +# detalhes.
  18 +#--------------------------------------------------------------------------
  19 +
  20 +from wx.lib.pubsub import pub as Publisher
  21 +
  22 +
  23 +# mode.py
  24 +# to be instanced inside Controller (control.py)
  25 +
  26 +
  27 +
  28 +# IMPORTANT: When adding a new state, remember o insert it into LEVEL
  29 +# dictionary
  30 +
  31 +
  32 +# RULE:
  33 +# default is the only level 0
  34 +# states controlled somehow by taskmenu are level 1
  35 +# states controlled by toolbar are level 2
  36 +#LEVEL = {SLICE_STATE_DEFAULT: 0,
  37 +# SLICE_STATE_EDITOR: 1,
  38 +# SLICE_STATE_WL: 2,
  39 +# SLICE_STATE_SPIN: 2,
  40 +# SLICE_STATE_ZOOM: 2,
  41 +# SLICE_STATE_ZOOM_SL: 2}
  42 +#----------------------
  43 +# TODO: Add to viewer_slice.py:
  44 +
  45 +#ps.Publisher().subscribe(self.OnSetMode, 'Set slice mode')
  46 +
  47 +#def OnSetMode(self, pubsub_evt):
  48 +# mode = pubsub_evt.data
  49 + # according to mode, set cursor, interaction, etc
  50 +#----------------------
  51 +# TODO: Add GUI classes (frame, tasks related to slice, toolbar):
  52 +
  53 +# always bind to this class (regarding slice mode) and not to
  54 +# viewer_slice directly
  55 +
  56 +# example - pseudo code
  57 +#def OnToggleButtonSpin(self, evt)
  58 +# if evt.toggle: # doesn't exist, just to illustrate
  59 +# ps.Publisher().sendMessage('Enable mode', const.SLICE_STATE_ZOOM)
  60 +# else:
  61 +# ps.Publisher().subscribe('Disable mode', const.SLICE_STATE_ZOOM)
  62 +
  63 +
  64 +#----------------------
  65 +
  66 +
  67 +import constants as const
  68 +
  69 +class StyleStateManager(object):
  70 +# don't need to be singleton, only needs to be instantiated inside
  71 +# (Controller) self.slice_mode = SliceMode()
  72 +
  73 + def __init__(self):
  74 + self.stack = {}
  75 +
  76 + # push default value to stack
  77 + self.stack[const.STYLE_LEVEL[const.STATE_DEFAULT]] = \
  78 + const.STATE_DEFAULT
  79 +
  80 + def AddState(self, state):
  81 +
  82 + level = const.STYLE_LEVEL[state]
  83 + max_level = max(self.stack.keys())
  84 +
  85 + # Insert new state into stack
  86 + self.stack[level] = state
  87 +
  88 +
  89 + new_max_level = max(self.stack.keys())
  90 + return self.stack[new_max_level]
  91 +
  92 + def RemoveState(self, state):
  93 + level = const.STYLE_LEVEL[state]
  94 + if level in self.stack.keys():
  95 + max_level = max(self.stack.keys())
  96 +
  97 + # Remove item from stack
  98 + self.stack.pop(level)
  99 +
  100 + # New max level
  101 + new_max_level = max(self.stack.keys())
  102 +
  103 + # Only will affect InVesalius behaviour if the highest
  104 + # level in stack has been removed
  105 + if level == max_level:
  106 + new_state = self.stack[new_max_level]
  107 +
  108 + return self.stack[new_max_level]
  109 +
  110 + max_level = max(self.stack.keys())
  111 + return self.stack[max_level]
  112 +
... ...