Changeset 8356:02c7fb226307 in orange


Ignore:
Timestamp:
07/05/11 10:49:00 (3 years ago)
Author:
Noughmad <Noughmad@…>
Branch:
default
Convert:
72fdc1e0d327852c14a935da21bd22e84a3bd36b
Message:

Fix regression where the graph was upside down because of Qt coordinate system.

Location:
orange/OrangeWidgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Graph/tools.py

    r8354 r8356  
    99""" 
    1010 
    11 def resize_plot_item_list(lst, size, item_type, scene): 
     11def resize_plot_item_list(lst, size, item_type, parent): 
    1212    n = len(lst) 
    1313    if n > size: 
    14         if scene: 
     14        if parent and parent.scene(): 
    1515            for i in lst[n:]: 
    16                 scene.removeItem(i) 
     16                parent.scene().removeItem(i) 
    1717        return lst[:n] 
    1818    elif n < size: 
    19         return lst + [item_type() for i in range(size - n)] 
     19        return lst + [item_type(parent) for i in range(size - n)] 
    2020    else: 
    2121        return lst 
  • orange/OrangeWidgets/OWGraphQt.py

    r8353 r8356  
    504504                    rect = self.data_rect_for_axes(x,y) 
    505505                    if id == xBottom: 
     506                        line = QLineF(rect.topLeft(), rect.topRight()) 
     507                    elif id == xTop: 
    506508                        line = QLineF(rect.bottomLeft(), rect.bottomRight()) 
    507                     elif id == xTop: 
    508                         line = QLineF(rect.topLeft(), rect.topRight()) 
    509509                    elif id == yLeft: 
    510                         line = QLineF(rect.bottomLeft(), rect.topLeft()) 
     510                        line = QLineF(rect.topLeft(), rect.bottomLeft()) 
    511511                    elif id == yRight: 
    512                         line = QLineF(rect.bottomRight(), rect.topRight()) 
     512                        line = QLineF(rect.topRight(), rect.bottomRight()) 
    513513                    else: 
    514514                        line = None 
     
    749749    def transform_for_axes(self, x_axis = xBottom, y_axis = yLeft): 
    750750        if not (x_axis, y_axis) in self._transform_cache: 
    751             self._transform_cache[(x_axis, y_axis)] = self.transform_from_rects(self.data_rect_for_axes(x_axis, y_axis), self.graph_area) 
     751            # We must flip the graph area, becase Qt coordinates start from top left, while graph coordinates start from bottom left 
     752            a = QRectF(self.graph_area) 
     753            t = a.top() 
     754            a.setTop(a.bottom()) 
     755            a.setBottom(t) 
     756            self._transform_cache[(x_axis, y_axis)] = self.transform_from_rects(self.data_rect_for_axes(x_axis, y_axis), a) 
    752757        return self._transform_cache[(x_axis, y_axis)] 
    753758         
Note: See TracChangeset for help on using the changeset viewer.