Commit 508c5f6e75ff0ece83f145bf2682e8b8754b0668

Authored by tfmoraes
1 parent 7a321d6f

ENH: Window width & level working with 8 bit raycasting preset

Showing 1 changed file with 27 additions and 26 deletions   Show diff stats
invesalius/data/volume.py
@@ -138,35 +138,36 @@ class Volume(): @@ -138,35 +138,36 @@ class Volume():
138 def SetWWWL(self, pubsub_evt): 138 def SetWWWL(self, pubsub_evt):
139 ww, wl, n = pubsub_evt.data 139 ww, wl, n = pubsub_evt.data
140 print "Setting ww, wl", ww, wl 140 print "Setting ww, wl", ww, wl
141 - curve = self.config['16bitClutCurves'][n]  
142 -  
143 - p1 = curve[0]  
144 - p2 = curve[-1]  
145 - half = (p2['x'] - p1['x']) / 2.0  
146 - middle = p1['x'] + half  
147 -  
148 - shiftWL = wl - middle  
149 - shiftWW = p1['x'] + shiftWL - (wl - 0.5 * ww)  
150 -  
151 - factor = 1.0  
152 - for n,i in enumerate(curve):  
153 - factor = abs(i['x'] - middle) / half  
154 - if factor < 0:  
155 - factor = 0  
156 - i['x'] += shiftWL  
157 - if n < len(curve)/2.0:  
158 - i['x'] -= shiftWW * factor  
159 - else:  
160 - i['x'] += shiftWW * factor  
161 -  
162 - self.Create16bColorTable(self.scale)  
163 - self.CreateOpacityTable(self.scale)  
164 - print curve 141 + if self.config['advancedCLUT']:
  142 + curve = self.config['16bitClutCurves'][n]
  143 +
  144 + p1 = curve[0]
  145 + p2 = curve[-1]
  146 + half = (p2['x'] - p1['x']) / 2.0
  147 + middle = p1['x'] + half
  148 +
  149 + shiftWL = wl - middle
  150 + shiftWW = p1['x'] + shiftWL - (wl - 0.5 * ww)
  151 +
  152 + factor = 1.0
  153 + for n,i in enumerate(curve):
  154 + factor = abs(i['x'] - middle) / half
  155 + if factor < 0:
  156 + factor = 0
  157 + i['x'] += shiftWL
  158 + if n < len(curve)/2.0:
  159 + i['x'] -= shiftWW * factor
  160 + else:
  161 + i['x'] += shiftWW * factor
  162 + else:
  163 + self.config['wl'] = wl
  164 + self.config['ww'] = ww
  165 +
  166 + self.__config_preset()
165 ps.Publisher().sendMessage('Render volume viewer', None) 167 ps.Publisher().sendMessage('Render volume viewer', None)
166 168
167 def Refresh(self, pubsub_evt): 169 def Refresh(self, pubsub_evt):
168 - self.Create16bColorTable(self.scale)  
169 - self.CreateOpacityTable(self.scale) 170 + self.__config_preset()
170 171
171 #*************** 172 #***************
172 def Create16bColorTable(self, scale): 173 def Create16bColorTable(self, scale):