Changeset c039589 in sasview for src/sas/guiframe/local_perspectives/plotting/sector_mask.py
- Timestamp:
- Mar 5, 2015 2:37:00 PM (9 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- b40ad40
- Parents:
- 090e07e
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/sas/guiframe/local_perspectives/plotting/sector_mask.py
r79492222 rc039589 1 1 """ 2 Sector mask interactor 3 """ 2 4 import math 3 5 import wx … … 18 20 ## Class initialization 19 21 self.markers = [] 20 self.axes = axes 22 self.axes = axes 21 23 self.is_inside = side 22 ## connect the plot to event 24 ## connect the plot to event 23 25 self.connect = self.base.connect 24 25 ## compute qmax limit to reset the graph 26 x = math.pow(max(self.base.data.xmax, 26 27 ## compute qmax limit to reset the graph 28 x = math.pow(max(self.base.data.xmax, 27 29 math.fabs(self.base.data.xmin)), 2) 28 y = math.pow(max(self.base.data.ymax, 30 y = math.pow(max(self.base.data.ymax, 29 31 math.fabs(self.base.data.ymin)), 2) 30 32 self.qmax = math.sqrt(x + y) … … 32 34 self.nbins = 20 33 35 ## Angle of the middle line 34 self.theta2 = math.pi /336 self.theta2 = math.pi / 3 35 37 ## Absolute value of the Angle between the middle line and any side line 36 self.phi = math.pi /1237 38 self.phi = math.pi / 12 39 38 40 ## Middle line 39 41 self.main_line = LineInteractor(self, self.base.subplot, color='blue', 40 zorder=zorder, r=self.qmax, theta=self.theta2)42 zorder=zorder, r=self.qmax, theta=self.theta2) 41 43 self.main_line.qmax = self.qmax 42 44 ## Right Side line 43 45 self.right_line = SideInteractor(self, self.base.subplot, color='gray', 44 zorder=zorder, r=self.qmax, phi= -1*self.phi,45 46 zorder=zorder, r=self.qmax, phi=-1 * self.phi, 47 theta2=self.theta2) 46 48 self.right_line.qmax = self.qmax 47 ## Left Side line 48 self.left_line = SideInteractor(self, self.base.subplot, color='gray', 49 zorder=zorder, r=self.qmax, phi=self.phi,50 49 ## Left Side line 50 self.left_line = SideInteractor(self, self.base.subplot, color='gray', 51 zorder=zorder, r=self.qmax, phi=self.phi, 52 theta2=self.theta2) 51 53 self.left_line.qmax = self.qmax 52 ## draw the sector 54 ## draw the sector 53 55 self.update() 54 56 self._post_data() 55 57 56 58 def clear(self): 57 59 """ … … 63 65 self.right_line.clear() 64 66 self.base.connect.clearall() 65 #self.base.Unbind(EVT_SLICER_PARS) 66 67 67 68 def update(self): 68 69 """ … … 70 71 resetting the widgets. 71 72 """ 72 # Update locations 73 ## Check if the middle line was dragged and 74 #update the picture accordingly 73 # Update locations 74 ## Check if the middle line was dragged and 75 #update the picture accordingly 75 76 if self.main_line.has_move: 76 77 self.main_line.update() 77 self.right_line.update(delta=-self.left_line.phi/2, 78 mline=self.main_line.theta) 79 self.left_line.update(delta=self.left_line.phi/2, 78 self.right_line.update(delta=-self.left_line.phi / 2, 80 79 mline=self.main_line.theta) 81 ## Check if the left side has moved and update the slicer accordingly 80 self.left_line.update(delta=self.left_line.phi / 2, 81 mline=self.main_line.theta) 82 ## Check if the left side has moved and update the slicer accordingly 82 83 if self.left_line.has_move: 83 84 self.main_line.update() 84 self.left_line.update(phi=None, delta=None, mline=self.main_line 85 side=True, left=True 85 self.left_line.update(phi=None, delta=None, mline=self.main_line, 86 side=True, left=True) 86 87 self.right_line.update(phi=self.left_line.phi, delta=None, 87 88 89 ## Check if the right side line has moved and 88 mline=self.main_line, side=True, 89 left=False, right=True) 90 ## Check if the right side line has moved and 90 91 #update the slicer accordingly 91 92 if self.right_line.has_move: … … 94 95 side=True, left=False, right=True) 95 96 self.left_line.update(phi=self.right_line.phi, delta=None, 96 97 mline=self.main_line, side=True, left=False) 97 98 #if self.is_inside != None: 98 99 out = self._post_data() … … 118 119 if data == None: 119 120 return 120 121 mask = data.mask122 121 ## Averaging 123 122 from sas.dataloader.manipulations import Sectorcut 124 radius = self.qmax 125 phimin = -self.left_line.phi + self.main_line.theta 123 phimin = -self.left_line.phi + self.main_line.theta 126 124 phimax = self.left_line.phi + self.main_line.theta 127 125 128 126 mask = Sectorcut(phi_min=phimin, phi_max=phimax) 129 127 if self.is_inside: … … 131 129 else: 132 130 out = (mask(data)) 133 #self.base.data.mask=out 134 return out 131 return out 135 132 136 133 def moveend(self, ev): 137 134 """ 138 Called a dragging motion ends.Get slicer event 135 Called a dragging motion ends.Get slicer event 139 136 """ 140 137 self.base.thaw_axes() … … 146 143 wx.PostEvent(self.base, event) 147 144 self._post_data() 148 145 149 146 def restore(self): 150 147 """ … … 160 157 """ 161 158 pass 162 159 163 160 def set_cursor(self, x, y): 164 161 pass 165 162 166 163 def get_params(self): 167 164 """ 168 165 Store a copy of values of parameters of the slicer into a dictionary. 169 166 170 167 :return params: the dictionary created 171 168 172 169 """ 173 170 params = {} 174 ## Always make sure that the left and the right line are at phi 171 ## Always make sure that the left and the right line are at phi 175 172 ## angle of the middle line 176 173 if math.fabs(self.left_line.phi) != math.fabs(self.right_line.phi): 177 174 msg = "Phi left and phi right are " 178 msg += "different %f, %f" % (self.left_line.phi, 175 msg += "different %f, %f" % (self.left_line.phi, 179 176 self.right_line.phi) 180 177 raise ValueError, msg … … 182 179 params["Delta_Phi"] = math.fabs(self.left_line.phi) 183 180 return params 184 181 185 182 def set_params(self, params): 186 183 """ 187 Receive a dictionary and reset the slicer with values contained 184 Receive a dictionary and reset the slicer with values contained 188 185 in the values of the dictionary. 189 190 :param params: a dictionary containing name of slicer parameters and 186 187 :param params: a dictionary containing name of slicer parameters and 191 188 values the user assigned to the slicer. 192 189 """ 193 main = params["Phi"] 190 main = params["Phi"] 194 191 phi = math.fabs(params["Delta_Phi"]) 195 192 196 193 self.main_line.theta = main 197 194 ## Reset the slicer parameters … … 203 200 ## post the new corresponding data 204 201 self._post_data() 205 202 206 203 def freeze_axes(self): 207 204 """ 208 205 """ 209 206 self.base.freeze_axes() 210 207 211 208 def thaw_axes(self): 212 209 """ … … 218 215 """ 219 216 self.base.update() 220
Note: See TracChangeset
for help on using the changeset viewer.