Changeset 8312:d014849cffa9 in orange


Ignore:
Timestamp:
06/12/11 16:33:44 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
565723deeae1c273e3a58a9c11ac2206ed17ebb5
Message:

Basic support for selection curves

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWGraphQt.py

    r8311 r8312  
    112112        self.tips = TooltipManager(self) 
    113113         
     114        self._pressed_mouse_button = Qt.NoButton 
    114115        self.selection_items = [] 
    115116        self.selectionCurveList = [] 
     117        self._current_ps_item = None 
    116118        self.curves = [] 
    117119        self.data_range = {xBottom : (0, 1), yLeft : (0, 1)} 
     
    410412            return 
    411413        self.static_click = True 
     414        self._pressed_mouse_button = event.button() 
     415        if event.button() == Qt.LeftButton and self.state == SELECT_RECTANGLE: 
     416            qDebug('Press: ' + repr(event.button())) 
     417            self._selection_start_point = QPointF(event.pos()) 
     418            self._current_ps_item = QGraphicsRectItem() 
     419            self.canvas.addItem(self._current_ps_item) 
    412420             
    413421    def mouseMoveEvent(self, event): 
     
    417425        if event.buttons(): 
    418426            self.static_click = False 
     427        qDebug('Move: ' + repr(event.button())) 
     428        if self._pressed_mouse_button == Qt.LeftButton: 
     429            if self.state == SELECT_RECTANGLE: 
     430                qDebug('Move move event') 
     431                self._current_ps_item.setRect(QRectF(self._selection_start_point, QPointF(event.pos()))) 
    419432             
    420433    def mouseReleaseEvent(self, event): 
     
    425438            event.accept() 
    426439            return 
     440        self._pressed_mouse_button = Qt.NoButton 
     441        if event.button() == Qt.LeftButton and self._current_ps_item: 
     442            qDebug('Mouse release event') 
     443            self.selection_items.append(self._current_ps_item) 
     444            self._current_ps_item = None 
    427445     
    428446    def mouseStaticClick(self, event): 
     
    442460            self.zoom_factor_animation.start(QAbstractAnimation.DeleteWhenStopped) 
    443461            return True 
    444         elif self.state == SELECT_POLYGON: 
     462        elif self.state == SELECT_POLYGON and event.button() == Qt.LeftButton: 
    445463            self._current_ps_polygon.addPoint(QPointF(event.pos())) 
    446464            self._current_ps_item.setPolygon(self._current_ps_polygon) 
     465        elif (self.state == SELECT_RECTANGLE or self.state == SELECT_POLYGON) and event.button() == Qt.RightButton: 
     466            self.selection_items.reverse() 
     467            for i in self.selection_items: 
     468                if i.shape().contains(QPointF(event.pos())): 
     469                    self.canvas.removeItem(i) 
     470                    self.selection_items.remove(i) 
     471                    break 
     472            self.selection_items.reverse() 
    447473        else: 
    448474            return False 
     
    493519        self._zoom_point = value 
    494520        self.update_zoom() 
     521         
     522    def set_state(self, state): 
     523        self.state = state 
Note: See TracChangeset for help on using the changeset viewer.