Changeset 8973:531ff177ce34 in orange


Ignore:
Timestamp:
09/15/11 13:47:33 (3 years ago)
Author:
matejd <matejd@…>
Branch:
default
Convert:
073024097e5e69aca9e480e0944dae7a84a5f335
Message:

Fixed save_to_file

Location:
orange/OrangeWidgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/OWDlgs.py

    r8735 r8973  
    1010 
    1111from PyQt4.QtGui import QGraphicsScene, QGraphicsView 
     12from PyQt4.QtOpenGL import QGLWidget 
    1213from PyQt4.QtSvg import * 
    1314from ColorPalette import * 
     
    4344            self.customYEdit = OWGUI.lineEdit(OWGUI.indentedBox(box), self, "customY", "Height:", orientation = "horizontal", valueType = int) 
    4445            OWGUI.comboBoxWithCaption(self.space, self, "penWidthFactor", label = 'Factor:   ', box = " Pen width multiplication factor ",  tooltip = "Set the pen width factor for all curves in the plot\n(Useful for example when the lines in the plot look to thin)\nDefault: 1", sendSelectedValue = 1, valueType = int, items = range(1,20)) 
    45         elif isinstance(graph, QGraphicsScene) or isinstance(graph, QGraphicsView): 
     46        elif isinstance(graph, QGraphicsScene) or isinstance(graph, QGraphicsView) or isinstance(graph, QGLWidget): 
    4647            OWGUI.widgetLabel(box, "Image size will be set automatically.") 
    4748 
     
    4950        #self.printButton =          OWGUI.button(self.space, self, "Print", callback = self.printPic) 
    5051        self.saveImageButton =      OWGUI.button(box, self, "Save Image", callback = self.saveImage) 
    51         self.saveMatplotlibButton = OWGUI.button(box, self, "Save Graph as matplotlib Script", callback = self.saveToMatplotlib) 
     52        if not isinstance(graph, QGLWidget): 
     53            self.saveMatplotlibButton = OWGUI.button(box, self, "Save Graph as matplotlib Script", callback = self.saveToMatplotlib) 
    5254        for (text, funct) in extraButtons: 
    5355            butt = OWGUI.button(box, self, text, callback = funct) 
     
    6769            ext = ".png"                                        # if no format was specified, we choose png 
    6870        filename = fil + ext 
    69          
     71        
     72        if isinstance(self.graph, QGLWidget): 
     73            img = self.graph.grabFrameBuffer() 
     74            if size != None: 
     75                img = img.scaled(size) 
     76            img.save(filename) 
     77            if closeDialog: 
     78                QDialog.accept(self) 
     79            return 
     80 
    7081        real_graph = self.graph if isinstance(self.graph, QGraphicsView) else None 
    7182        if real_graph: 
  • orange/OrangeWidgets/plot/owplot3d.py

    r8972 r8973  
    1919 
    2020from OWDlgs import OWChooseImageSizeDlg 
    21 from Orange.misc import deprecated_attribute 
     21from Orange.misc import deprecated_attribute, deprecated_members 
    2222 
    2323import orangeqt 
     
    6565from plot.primitives import get_symbol_geometry, clamp, normalize, GeometryType 
    6666 
     67name_map = { 
     68    "saveToFileDirect": "save_to_file_direct", 
     69    "saveToFile" : "save_to_file", 
     70} 
     71 
     72@deprecated_members(name_map, wrap_methods=name_map.keys()) 
    6773class OWLegend3D(OWLegend): 
    6874    def set_symbol_geometry(self, symbol, geometry): 
     
    934940        self._zoomed_size = 1. / new_scale 
    935941 
    936     def save_to_file(self): 
    937         size_dlg = OWChooseImageSizeDlg(self, [], parent=self) 
    938         size_dlg.exec_() 
    939  
    940     def save_to_file_direct(self, file_name, size=None): 
    941         img = self.grabFrameBuffer() 
    942         if size != None: 
    943             img = img.scaled(size) 
    944         return img.save(file_name) 
     942    def save_to_file(self, extraButtons=[]): 
     943        sizeDlg = OWChooseImageSizeDlg(self, extraButtons, parent=self) 
     944        sizeDlg.exec_() 
     945 
     946    def save_to_file_direct(self, fileName, size=None): 
     947        sizeDlg = OWChooseImageSizeDlg(self) 
     948        sizeDlg.saveImage(fileName, size) 
    945949 
    946950    def map_to_plot(self, point, original=True): 
     
    11851189    def set_palette(self, p): 
    11861190        ''' 
    1187             Sets the plot palette to ``p``.  
    1188              
    1189             :param p: The new color palette 
    1190             :type p: :obj:`.QPalette` 
     1191        Sets the plot palette to ``p``.  
     1192 
     1193        :param p: The new color palette 
     1194        :type p: :obj:`.QPalette` 
    11911195        ''' 
    11921196        self.setPalette(p) 
     
    11991203    def clear(self): 
    12001204        ''' 
    1201         Clears the plot (data, legend) but remembers plot transformations (zoom, scale, translation). 
     1205        Clears the plot (legend) but remembers plot transformations (zoom, scale, translation). 
    12021206        ''' 
    12031207        self._legend.clear() 
Note: See TracChangeset for help on using the changeset viewer.