Changeset 4951:24f23f48d1b2 in orange


Ignore:
Timestamp:
07/10/08 12:42:10 (6 years ago)
Author:
ales_erjavec <ales.erjavec@…>
Branch:
default
Convert:
a288ef574df7e42206b22a73130aa96bab860b06
Message:

-fixed graph saving for tree widgets

Location:
orange/OrangeWidgets
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/Classify/OWClassificationTreeGraph.py

    r4948 r4951  
    355355        return b 
    356356 
    357     def saveGraph(self, fileName = None): 
    358         if not fileName: 
    359             qfileName = QFileDialog.getSaveFileName(None, "Save to..", "tree.png","Portable Network Graphics (.PNG)\nWindows Bitmap (.BMP)\nGraphics Interchange Format (.GIF)\nDot Tree File(.DOT)") 
    360             fileName = str(qfileName) 
    361             if not fileName: 
    362                 return 
    363  
    364         (fil,ext) = os.path.splitext(fileName) 
    365         ext = ext.replace(".","") 
    366         ext = ext.upper() 
    367         if ext=="DOT": 
    368             orngTree.printDot(self.tree, fileName) 
    369             return 
    370         dSize= self.scene.size() 
    371         buffer = QPixmap(dSize.width(),dSize.height()) # any size can do, now using the window size 
    372         painter = QPainter(buffer) 
    373  
    374         painter.fillRect(buffer.rect(), QBrush(QColor(255, 255, 255))) # make background same color as the widget's background 
    375         self.sceneView.drawContents(painter,0,0,dSize.width(), dSize.height()) 
    376         painter.end() 
    377         buffer.save(fileName, ext) 
    378357 
    379358#    def sendReport(self): 
  • orange/OrangeWidgets/OWTreeViewer2D.py

    r4949 r4951  
    901901            self.send("Examples", None) 
    902902 
     903    def saveGraph(self, fileName = None): 
     904        if not fileName: 
     905            qfileName = QFileDialog.getSaveFileName(None, "Save to..", "tree.png","Portable Network Graphics (.PNG)\nWindows Bitmap (.BMP)\nGraphics Interchange Format (.GIF)\nDot Tree File(.DOT)") 
     906            fileName = str(qfileName) 
     907            if not fileName: 
     908                return 
     909 
     910        (fil,ext) = os.path.splitext(fileName) 
     911        ext = ext.replace(".","") 
     912        ext = ext.upper() 
     913        if ext=="DOT": 
     914            orngTree.printDot(self.tree, fileName) 
     915            return 
     916        dSize= self.scene.sceneRect().size() 
     917        buffer = QPixmap(dSize.width(),dSize.height()) # any size can do, now using the window size 
     918        painter = QPainter(buffer) 
     919 
     920        painter.fillRect(buffer.rect(), QBrush(QColor(255, 255, 255))) # make background same color as the widget's background 
     921        self.scene.render(painter) 
     922        painter.end() 
     923        buffer.save(fileName, ext) 
     924         
    903925class OWDefTreeViewer2D(OWTreeViewer2D): 
    904926    def __init__(self, parent=None, signalManager = None, name='DefTreeViewer2D'): 
  • orange/OrangeWidgets/Regression/OWRegressionTreeViewer2D.py

    r4905 r4951  
    263263        return b 
    264264 
    265     def saveGraph(self): 
    266         qfileName = QFileDialog.getSaveFileName(None, "Save to..", "tree.png","Portable Network Graphics (.PNG)\nWindows Bitmap (.BMP)\nGraphics Interchange Format (.GIF)\nDot Tree File(.DOT)") 
    267         fileName = str(qfileName) 
    268         if fileName == "": return 
    269         (fil,ext) = os.path.splitext(fileName) 
    270         ext = ext.replace(".","") 
    271         ext = ext.upper() 
    272         if ext=="DOT": 
    273             orngTree.printDot(self.tree, fileName) 
    274             return 
    275         dSize= self.scene.size() 
    276         buffer = QPixmap(dSize.width(),dSize.height()) # any size can do, now using the window size 
    277         painter = QPainter(buffer) 
    278  
    279         painter.fillRect(buffer.rect(), QBrush(QColor(255, 255, 255))) # make background same color as the widget's background 
    280         self.sceneView.drawContents(painter,0,0,dSize.width(), dSize.height()) 
    281         painter.end() 
    282         buffer.save(fileName, ext) 
    283265 
    284266if __name__=="__main__": 
Note: See TracChangeset for help on using the changeset viewer.