Changeset 3486:dd005507af79 in orange


Ignore:
Timestamp:
04/04/07 13:30:57 (7 years ago)
Author:
Gregor <Gregor@…>
Branch:
default
Convert:
87b1da32c16d360faa48003c454e3516d013e186
Message:
  • small changes and bugfixes
  • added getSelections and setSelections to load and save selections
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWGraph.py

    r3413 r3486  
    6565        self.tempSelectionCurve = None 
    6666        self.selectionCurveKeyList = [] 
    67         self.autoSendSelectionCallback = None   # callback function to call when we add new selection polygon or rectangle 
     67        self.selectionChangedCallback = None   # callback function to call when we add new selection polygon or rectangle 
    6868        self.legendCurveKeys = [] 
    6969 
     
    330330        self.removeCurves() 
    331331        self.legendCurveKeys = [] 
     332        if hasattr(self, "oldLegendKeys"): 
     333            self.oldLegendKeys = {} 
    332334        self.removeMarkers() 
    333335        self.tips.removeAll() 
     
    428430            self.tempSelectionCurve = None 
    429431            self.replot() 
    430             if self.autoSendSelectionCallback: 
    431                 self.autoSendSelectionCallback() # do we want to send new selection 
     432            if self.selectionChangedCallback: 
     433                self.selectionChangedCallback() # do we want to send new selection 
    432434            return 1 
    433435        else: 
     
    439441        self.selectionCurveKeyList = [] 
    440442        self.replot() 
    441         if send and self.autoSendSelectionCallback: 
    442             self.autoSendSelectionCallback() # do we want to send new selection 
     443        if send and self.selectionChangedCallback: 
     444            self.selectionChangedCallback() 
    443445 
    444446    def zoomOut(self): 
     
    487489                self.tempSelectionCurve = None 
    488490                self.replot() 
    489                 if self.autoSendSelectionCallback: self.autoSendSelectionCallback() # do we want to send new selection 
     491                if self.selectionChangedCallback: 
     492                    self.selectionChangedCallback() # do we want to send new selection 
    490493 
    491494        # fake a mouse move to show the cursor position 
     
    556559                if self.tempSelectionCurve: 
    557560                    self.tempSelectionCurve = None 
    558                 if self.autoSendSelectionCallback: self.autoSendSelectionCallback() # do we want to send new selection 
     561                if self.selectionChangedCallback: 
     562                    self.selectionChangedCallback() # do we want to send new selection 
    559563 
    560564        elif e.button() == Qt.RightButton: 
     
    601605        selected = 1 - unselected 
    602606        return selected.tolist(), unselected.tolist() 
     607 
     608    # set selections 
     609    def setSelections(self, selections): 
     610        for (xs, ys) in selections: 
     611            curve = SelectionCurve(self) 
     612            curve.setData(xs, ys) 
     613            key = self.insertCurve(curve) 
     614            self.selectionCurveKeyList.append(key) 
     615 
     616    # get current selections in the form [([xs1, ys1]), (xs2, ys2)] 
     617    def getSelections(self): 
     618        data = [] 
     619        for key in self.selectionCurveKeyList: 
     620            curve = self.curve(key) 
     621            data.append(([curve.x(i) for i in range(curve.dataSize())], [curve.y(i) for i in range(curve.dataSize())])) 
     622        return data 
    603623 
    604624    def randomChange(self): 
Note: See TracChangeset for help on using the changeset viewer.