Changeset 8922:1122c9ebca13 in orange


Ignore:
Timestamp:
09/07/11 22:49:57 (3 years ago)
Author:
matejd <matejd@…>
Branch:
default
Convert:
5a040d6de6fdf1b6c6114a73d3630fa2e4982dba
Message:

Fixed zoom select toolbar in 3d widgets

Location:
orange/OrangeWidgets
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Visualize Qt/OWLinProj3DPlot.py

    r8857 r8922  
    11from plot.owplot3d import * 
    2 from plot.owplotgui import * 
    32from plot.primitives import parse_obj 
    43from plot import OWPoint 
     
    3736            self.mouseover_callback = self._update_arrow_values 
    3837 
    39         self.gui = OWPlotGUI(self) 
    40  
    4138    def setData(self, data, subsetData=None, **args): 
    4239        if data == None: 
     
    4946 
    5047        self.makeCurrent() 
    51         self.state = PlotState.IDLE # Override for now, apparently this is modified by OWPlotGUI 
    5248        self.before_draw_callback = lambda: self.before_draw() 
    5349 
  • orange/OrangeWidgets/Visualize Qt/OWLinProjQt.py

    r8847 r8922  
    175175##        self.connect(self.clusterDlg.resultList, SIGNAL("selectionChanged()"),self.showSelectedCluster) 
    176176 
    177         g = self.graph.gui 
     177        gui = self.graph.gui 
    178178 
    179179        if "3d" in name_lower: 
    180180            toolbar_buttons = [ 
    181                 OWPlotGUI.StateButtonsBegin, 
    182                     OWPlotGUI.Select, 
    183                 OWPlotGUI.StateButtonsEnd, 
    184                 OWPlotGUI.Spacing, 
    185                 OWPlotGUI.StateButtonsBegin, 
    186                     OWPlotGUI.SelectionOne, 
    187                     OWPlotGUI.SelectionAdd,  
    188                     OWPlotGUI.SelectionRemove, 
    189                 OWPlotGUI.StateButtonsEnd, 
    190                 OWPlotGUI.Spacing, 
    191                 OWPlotGUI.SendSelection, 
    192                 OWPlotGUI.ClearSelection 
     181                gui.Select, 
     182                gui.Spacing, 
     183                gui.SendSelection, 
     184                gui.ClearSelection 
    193185            ] 
    194186 
    195             self.zoomSelectToolbar = g.zoom_select_toolbar(self.GeneralTab, buttons=toolbar_buttons) 
    196             gui = g 
    197             self.connect(self.zoomSelectToolbar.buttons[gui.SelectionOne], SIGNAL("clicked()"), self._set_behavior_replace) 
    198             self.connect(self.zoomSelectToolbar.buttons[gui.SelectionAdd], SIGNAL("clicked()"), self._set_behavior_add) 
    199             self.connect(self.zoomSelectToolbar.buttons[gui.SelectionRemove], SIGNAL("clicked()"), self._set_behavior_remove) 
    200             self.connect(self.zoomSelectToolbar.buttons[gui.ClearSelection], SIGNAL("clicked()"), self.graph.unselect_all_points) 
    201             self._set_behavior_replace() 
     187            self.zoomSelectToolbar = gui.zoom_select_toolbar(self.GeneralTab, buttons = toolbar_buttons) 
     188            self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.sendSelections) 
     189            self.graph.set_selection_behavior(OWPlot.ReplaceSelection) 
    202190        else: 
    203191            # zooming / selection 
    204             self.zoomSelectToolbar = g.zoom_select_toolbar(self.GeneralTab, buttons = g.default_zoom_select_buttons + [g.Spacing, g.ShufflePoints]) 
    205             self.connect(self.zoomSelectToolbar.buttons[g.SendSelection], SIGNAL("clicked()"), self.sendSelections) 
     192            self.zoomSelectToolbar = gui.zoom_select_toolbar(self.GeneralTab, buttons = gui.default_zoom_select_buttons + [gui.Spacing, gui.ShufflePoints]) 
     193            self.connect(self.zoomSelectToolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.sendSelections) 
    206194 
    207195        # #################################### 
     
    295283 
    296284        self.resize(900, 700) 
    297  
    298     def _set_behavior_add(self): 
    299         self.graph.set_selection_behavior(OWPlot.AddSelection) 
    300  
    301     def _set_behavior_replace(self): 
    302         self.graph.set_selection_behavior(OWPlot.ReplaceSelection) 
    303  
    304     def _set_behavior_remove(self): 
    305         self.graph.set_selection_behavior(OWPlot.RemoveSelection) 
    306285 
    307286    def saveToFile(self): 
  • orange/OrangeWidgets/Visualize Qt/OWScatterPlot3D.py

    r8856 r8922  
    88from plot.owplot3d import * 
    99from plot.owtheme import ScatterLightTheme, ScatterDarkTheme 
    10 from plot.owplotgui import OWPlotGUI 
    11 from plot.owplot import OWPlot 
    1210from plot import OWPoint 
    1311 
     
    368366 
    369367        box = OWGUI.widgetBox(self.settings_tab, 'Point properties') 
    370         ss = OWGUI.hSlider(box, self, 'plot.symbol_scale', label='Symbol scale', 
     368        OWGUI.hSlider(box, self, 'plot.symbol_scale', label='Symbol scale', 
    371369            minValue=1, maxValue=20, 
    372370            tooltip='Scale symbol size', 
     
    412410                      tooltip='Change mouse sensitivity') 
    413411 
    414         self.gui = OWPlotGUI(self) 
    415         gui = self.gui 
     412        gui = self.plot.gui 
    416413        self.zoom_select_toolbar = gui.zoom_select_toolbar(self.main_tab, buttons=gui.default_zoom_select_buttons) 
    417414        self.connect(self.zoom_select_toolbar.buttons[gui.SendSelection], SIGNAL("clicked()"), self.send_selection) 
    418         self.connect(self.zoom_select_toolbar.buttons[gui.Zoom], SIGNAL("clicked()"), self._set_behavior_zoom) 
    419         self.connect(self.zoom_select_toolbar.buttons[gui.SelectionOne], SIGNAL("clicked()"), self._set_behavior_replace) 
    420         self.connect(self.zoom_select_toolbar.buttons[gui.SelectionAdd], SIGNAL("clicked()"), self._set_behavior_add) 
    421         self.connect(self.zoom_select_toolbar.buttons[gui.SelectionRemove], SIGNAL("clicked()"), self._set_behavior_remove) 
     415        self.connect(self.zoom_select_toolbar.buttons[gui.Zoom], SIGNAL("clicked()"), self.plot.unselect_all_points) 
     416        self.plot.set_selection_behavior(OWPlot.ReplaceSelection) 
    422417 
    423418        self.tooltip_kind = TooltipKind.NONE 
     
    438433        self.on_theme_change() 
    439434 
    440         self._set_behavior_replace() 
    441  
    442435        self.data = None 
    443436        self.subset_data = None 
    444437        self.resize(1100, 600) 
    445  
    446     def _set_behavior_zoom(self): 
    447         self.plot.unselect_all_points() 
    448         self.plot.zoom_into_selection = True 
    449  
    450     def _set_behavior_add(self): 
    451         self.plot.set_selection_behavior(OWPlot.AddSelection) 
    452  
    453     def _set_behavior_replace(self): 
    454         self.plot.set_selection_behavior(OWPlot.ReplaceSelection) 
    455  
    456     def _set_behavior_remove(self): 
    457         self.plot.set_selection_behavior(OWPlot.RemoveSelection) 
    458438 
    459439    def mouseover_callback(self, index): 
  • orange/OrangeWidgets/plot/owplot3d.py

    r8856 r8922  
    1414 
    1515import os 
    16 import sys 
    1716import time 
    1817from math import sin, cos, pi, floor, ceil, log10 
     
    2625from Orange.misc import deprecated_attribute 
    2726 
    28 import orange 
    2927import orangeqt 
     28from plot.owplotgui import OWPlotGUI 
    3029from owtheme import PlotTheme 
    3130from owplot import OWPlot 
    3231from owlegend import OWLegend, OWLegendItem, OWLegendTitle, OWLegendGradient 
    3332from owopenglrenderer import OWOpenGLRenderer 
     33from owconstants import ZOOMING 
    3434 
    3535from OWColorPalette import ColorPaletteGenerator 
     
    227227        self._zoomed_size = [1., 1., 1.] 
    228228 
    229         self.state = PlotState.IDLE 
     229        self._state = PlotState.IDLE 
    230230 
    231231        self._selection = None 
    232         self._selection_behavior = OWPlot.AddSelection 
     232        self.selection_behavior = OWPlot.AddSelection 
    233233 
    234234        ## Callbacks 
     
    261261 
    262262        self._zoom_stack = [] 
    263         self.zoom_into_selection = True # If True, zoom is done after selection, else SelectionBehavior is considered 
    264263 
    265264        self._theme = PlotTheme() 
     
    285284        self.continuous_palette = ColorPaletteGenerator(numberOfColors=-1) 
    286285        self.discrete_palette = ColorPaletteGenerator() 
     286 
     287        self.gui = OWPlotGUI(self) 
    287288 
    288289    def __del__(self): 
     
    617618        self.renderer.set_transform(projection, modelview) 
    618619 
    619         if self.state == PlotState.SCALING: 
     620        if self._state == PlotState.SCALING: 
    620621            x, y = self.mouse_position.x(), self.mouse_position.y() 
    621622            self.renderer.draw_triangle(QVector3D(x-5, y-30, 0), 
     
    651652            self.renderText(x, y-50, 'Scale y axis', font=self._theme.labels_font) 
    652653            self.renderText(x+60, y+3, 'Scale x and z axes', font=self._theme.labels_font) 
    653         elif self.state == PlotState.SELECTING: 
     654        elif self._state == PlotState.SELECTING: 
    654655            internal_color = QColor(168, 202, 236, 50) 
    655656            self.renderer.draw_rectangle(QVector3D(self._selection.left(), self._selection.top(), 0), 
     
    10671068 
    10681069    def set_selection_behavior(self, behavior): 
    1069         self.zoom_into_selection = False 
    1070         self._selection_behavior = behavior 
     1070        self.selection_behavior = behavior 
    10711071 
    10721072    def mousePressEvent(self, event): 
     
    10831083                self._legend.mousePressEvent(event) 
    10841084                self.setCursor(Qt.ClosedHandCursor) 
    1085                 self.state = PlotState.DRAGGING_LEGEND 
     1085                self._state = PlotState.DRAGGING_LEGEND 
    10861086            else: 
    1087                 self.state = PlotState.SELECTING 
     1087                self._state = PlotState.SELECTING 
    10881088                self._selection = QRect(pos.x(), pos.y(), 0, 0) 
    10891089        elif buttons & Qt.RightButton: 
    10901090            if QApplication.keyboardModifiers() & Qt.ShiftModifier: 
    1091                 self.state = PlotState.SCALING 
     1091                self._state = PlotState.SCALING 
    10921092                self.scaling_init_pos = self.mouse_position 
    10931093                self.additional_scale = array([0., 0., 0.]) 
     
    10971097        elif buttons & Qt.MiddleButton: 
    10981098            if QApplication.keyboardModifiers() & Qt.ShiftModifier: 
    1099                 self.state = PlotState.PANNING 
     1099                self._state = PlotState.PANNING 
    11001100            else: 
    1101                 self.state = PlotState.ROTATING 
     1101                self._state = PlotState.ROTATING 
    11021102 
    11031103    def _check_mouseover(self, pos): 
    1104         if self.mouseover_callback != None and self.state == PlotState.IDLE: 
     1104        if self.mouseover_callback != None and self._state == PlotState.IDLE: 
    11051105            if abs(pos.x() - self.tooltip_win_center[0]) > 100 or\ 
    11061106               abs(pos.y() - self.tooltip_win_center[1]) > 100: 
     
    11331133            dx = -dx 
    11341134 
    1135         if self.state == PlotState.SELECTING: 
     1135        if self._state == PlotState.SELECTING: 
    11361136            self._selection.setBottomRight(pos) 
    1137         elif self.state == PlotState.DRAGGING_LEGEND: 
     1137        elif self._state == PlotState.DRAGGING_LEGEND: 
    11381138            event.scenePos = lambda: QPointF(pos) 
    11391139            self._legend.mouseMoveEvent(event) 
    1140         elif self.state == PlotState.ROTATING: 
     1140        elif self._state == PlotState.ROTATING: 
    11411141            self.yaw += (self.mouse_sensitivity / 5.) * dx / (self.rotation_factor*self.width()) 
    11421142            self.pitch += (self.mouse_sensitivity / 5.) * dy / (self.rotation_factor*self.height()) 
    11431143            self.update_camera() 
    1144         elif self.state == PlotState.PANNING: 
     1144        elif self._state == PlotState.PANNING: 
    11451145            right_vec = normalize(numpy.cross(self.camera, [0, 1, 0])) 
    11461146            up_vec = normalize(numpy.cross(right_vec, self.camera)) 
     
    11511151            up_scale = self.height() * self.plot_scale[1] * self.panning_factor 
    11521152            self.plot_translation -= right_vec + up_vec * (dy / up_scale) * (self.mouse_sensitivity / 5.) 
    1153         elif self.state == PlotState.SCALING: 
     1153        elif self._state == PlotState.SCALING: 
    11541154            dx = pos.x() - self.scaling_init_pos.x() 
    11551155            dy = pos.y() - self.scaling_init_pos.y() 
     
    11631163                                     dy, 
    11641164                                     -dx * abs(right_vec[2]) / float(self._zoomed_size[2])] 
    1165         elif self.state == PlotState.IDLE: 
     1165        elif self._state == PlotState.IDLE: 
    11661166            legend_pos = self._legend.pos() 
    11671167            lx, ly = legend_pos.x(), legend_pos.y() 
     
    11751175 
    11761176    def mouseReleaseEvent(self, event): 
    1177         if self.state == PlotState.DRAGGING_LEGEND: 
     1177        if self._state == PlotState.DRAGGING_LEGEND: 
    11781178            self._legend.mouseReleaseEvent(event) 
    1179         if self.state == PlotState.SCALING: 
     1179        if self._state == PlotState.SCALING: 
    11801180            self.plot_scale = numpy.maximum([1e-5, 1e-5, 1e-5], self.plot_scale+self.additional_scale) 
    11811181            self.additional_scale = array([0., 0., 0.]) 
    1182             self.state = PlotState.IDLE 
    1183         elif self.state == PlotState.SELECTING: 
     1182            self._state = PlotState.IDLE 
     1183        elif self._state == PlotState.SELECTING: 
    11841184            self._selection.setBottomRight(event.pos()) 
    1185             if self.zoom_into_selection: 
     1185            if self.state == ZOOMING: # self.state is actually set by OWPlotGUI (different from self._state!) 
    11861186                min_max = self.get_min_max_selected(self._selection) 
    11871187                self.set_new_zoom(*min_max, plot_coordinates=True) 
     
    11931193                                              viewport, 
    11941194                                              QVector3D(*self.plot_scale), QVector3D(*self.plot_translation), 
    1195                                               self._selection_behavior) 
     1195                                              self.selection_behavior) 
    11961196                self.makeCurrent() 
    11971197                orangeqt.Plot3D.update_data(self, self.x_index, self.y_index, self.z_index, 
     
    12051205        self.tooltip_fbo_dirty = True 
    12061206        self.unsetCursor() 
    1207         self.state = PlotState.IDLE 
     1207        self._state = PlotState.IDLE 
    12081208        self.update() 
    12091209 
Note: See TracChangeset for help on using the changeset viewer.