Changeset 8533:58320b3299de in orange
 Timestamp:
 07/29/11 21:02:57 (3 years ago)
 Branch:
 default
 Convert:
 55dd1d4f302ef4b241e2b59c21f720f480456456
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

orange/OrangeWidgets/plot/owplot3d.py
r8532 r8533 435 435 self.additional_scale = [0, 0, 0] 436 436 self.scale_x_axis = True 437 self.scale_factor = 100.437 self.scale_factor = 0.05 438 438 self.data_scale = numpy.array([1., 1., 1.]) 439 439 self.data_center = numpy.array([0., 0., 0.]) 440 self.zoomed_size = [self.view_cube_edge, 441 self.view_cube_edge, 442 self.view_cube_edge] 440 443 441 444 self.state = PlotState.IDLE … … 1095 1098 range_x, range_y, range_z = maxmin 1096 1099 self.data_center = (min + max) / 2 1097 self.zoom_stack.append((min, max))1098 1100 1099 1101 scale_x = self.view_cube_edge / range_x … … 1163 1165 1164 1166 def set_new_zoom(self, x_min, x_max, y_min, y_max, z_min, z_max): 1167 self.selections = [] 1168 self.zoom_stack.append((self.scale, self.translation)) 1169 1165 1170 max = numpy.array([x_max, y_max, z_max]) 1166 1171 min = numpy.array([x_min, y_min, z_min]) 1167 self.selections = []1168 self.zoom_stack.append((min, max))1169 1172 min, max = map(numpy.copy, [min, max]) 1170 1173 min = self.data_center … … 1173 1176 max *= self.data_scale 1174 1177 center = (max + min) / 2. 1175 num_steps = 101176 1178 new_translation = numpy.array(center) 1177 1179 # Avoid division by zero by adding a small value (this happens when zooming in 1178 1180 # on elements with the same value of an attribute). 1179 size = numpy.array(map(lambda i: i+0.001 if i == 0 else i, maxmin)) 1180 new_scale = self.view_cube_edge / size 1181 self.size = numpy.array(map(lambda i: i+0.001 if i == 0 else i, maxmin)) 1182 new_scale = self.view_cube_edge / self.size 1183 self._animate_new_scale_translation(new_scale, new_translation) 1184 1185 def _animate_new_scale_translation(self, new_scale, new_translation, num_steps=10): 1181 1186 translation_step = (new_translation  self.translation) / float(num_steps) 1182 1187 scale_step = (new_scale  self.scale) / float(num_steps) … … 1198 1203 1199 1204 def pop_zoom(self): 1200 if len(self.zoom_stack) < 2:1201 return1202 1203 self.zoom_stack.pop()1204 min, max= self.zoom_stack.pop()1205 self. set_new_zoom(min[0], max[0], min[1], max[1], min[2], max[2])1205 if len(self.zoom_stack) < 1: 1206 new_translation = numpy.array([0., 0., 0.]) 1207 new_scale = numpy.array([1., 1., 1.]) 1208 else: 1209 new_scale, new_translation = self.zoom_stack.pop() 1210 self._animate_new_scale_translation(new_scale, new_translation) 1206 1211 1207 1212 def save_to_file(self): … … 1258 1263 indices.add(color) 1259 1264 1260 print(indices)1261 1265 return indices 1262 1266 else: … … 1298 1302 indices.append(i) 1299 1303 1300 print(indices)1301 1304 return indices 1302 1305 … … 1392 1395 dx = pos.x()  self.scaling_init_pos.x() 1393 1396 dy = pos.y()  self.scaling_init_pos.y() 1394 self.additional_scale = [dx / self.scale_factor, dy / self.scale_factor, 0]\ 1395 if self.scale_x_axis else [0, dy / self.scale_factor, dx / self.scale_factor] 1397 dx /= float(self.size[0 if self.scale_x_axis else 2]) 1398 dy /= float(self.size[1]) 1399 dx /= self.scale_factor * self.width() 1400 dy /= self.scale_factor * self.height() 1401 self.additional_scale = [dx, dy, 0] if self.scale_x_axis else [0, dy, dx] 1396 1402 elif self.state == PlotState.PANNING: 1397 1403 self.dragged_selection.move(dx, dy) … … 1422 1428 self.updateGL() 1423 1429 self.selection_changed_callback() if self.selection_changed_callback else None 1424 elif self.state == PlotState.ROTATING:1425 self.state = PlotState.IDLE1426 1430 elif self.state == PlotState.PANNING: 1427 1431 self.selection_changed_callback() if self.selection_changed_callback else None
Note: See TracChangeset
for help on using the changeset viewer.