Changeset 8441:cfc8bead4479 in orange
- Timestamp:
- 07/25/11 10:51:32 (22 months ago)
- Branch:
- default
- Convert:
- db98babdfb88638b04b418eb8183b9bd114f2285
- Location:
- orange/OrangeWidgets/plot
- Files:
-
- 2 edited
-
owlegend.py (modified) (3 diffs)
-
owplot.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
orange/OrangeWidgets/plot/owlegend.py
r8437 r8441 49 49 self.mouse_down = False 50 50 self._orientation = Qt.Vertical 51 self.animated = True 51 self.animated = True 52 self._center_point = None 53 52 54 53 55 def clear(self): … … 68 70 y = 0 69 71 for item in self.items: 70 self. move_item(item,0, y)72 self.box_rect = self.box_rect | item.boundingRect().translated(0, y) 71 73 y = y + item.boundingRect().height() 72 self.box_rect = self.box_rect | item.mapRectToParent(item.boundingRect())73 74 elif self._orientation == Qt.Horizontal: 74 75 x = 0 75 76 for item in self.items: 76 self. move_item(item,x, 0)77 self.box_rect = self.box_rect | item.boundingRect().translated(x, 0) 77 78 x = x + item.boundingRect().width() 78 self.box_rect = self.box_rect | item.mapRectToParent(item.boundingRect()) 79 79 80 if self._center_point: 81 self.setPos(self.pos() + self._center_point - self.box_rect.center()) 82 x, y = 0, 0 83 if self._orientation == Qt.Vertical: 84 for item in self.items: 85 self.move_item(item, x, y) 86 y = y + item.boundingRect().height() 87 elif self._orientation == Qt.Horizontal: 88 for item in self.items: 89 self.move_item(item, x, y) 90 x = x + item.boundingRect().width() 91 80 92 def mouseMoveEvent(self, event): 81 93 self.setPos(self.pos() + event.scenePos() - event.lastScenePos()) 82 self.graph.notify_legend_moved( )94 self.graph.notify_legend_moved(event.scenePos()) 83 95 event.accept() 84 96 … … 99 111 pass 100 112 101 def set_orientation(self, orientation): 102 self._orientation = orientation 103 self.update() 113 def set_orientation(self, orientation, origin_point = QPointF()): 114 if self._orientation != orientation: 115 self._orientation = orientation 116 if origin_point.isNull(): 117 self._center_point = origin_point 118 else: 119 self._center_point = self.mapFromScene(origin_point) 120 self.update() 104 121 105 122 def move_item(self, item, x, y): -
orange/OrangeWidgets/plot/owplot.py
r8438 r8441 949 949 QToolTip.showText(self.mapToGlobal(QPoint(x, y)), text, self, QRect(x-3,y-3,6,6)) 950 950 951 def notify_legend_moved(self ):951 def notify_legend_moved(self, pos): 952 952 self._legend_moved = True 953 953 l = self.legend_rect() 954 954 g = getattr(self, '_legend_outside_area', QRectF()) 955 offset = 10955 offset = 2 956 956 rect = QRectF() 957 if l.right() > g.right() - offset:957 if pos.x() > g.right() - offset: 958 958 rect.setRight(l.width()) 959 elif l.left() < g.left() + offset:959 elif pos.x() < g.left() + offset: 960 960 rect.setLeft(l.width()) 961 elif l.top() < g.top() + offset:961 elif pos.y() < g.top() + offset: 962 962 rect.setTop(l.height()) 963 elif l.bottom() > g.bottom() - offset:963 elif pos.y() > g.bottom() - offset: 964 964 rect.setBottom(l.height()) 965 965 if rect != self._legend_margin: 966 self._legend.set_orientation(Qt.Horizontal if rect.top() or rect.bottom() else Qt.Vertical )966 self._legend.set_orientation(Qt.Horizontal if rect.top() or rect.bottom() else Qt.Vertical, pos) 967 967 self._legend_animation = QPropertyAnimation(self, 'legend_margin') 968 968 self._legend_animation.setStartValue(self._legend_margin)
Note: See TracChangeset
for help on using the changeset viewer.
