def __init__(self, parent,label=None, displayLabel=True,includeInReports=True, name = '', data = None):
        ## want to init a graphics view with a new graphics scene, the scene will be accessable through the widget.
        widgetState.__init__(self,parent,label,includeInReports)
        
        QGraphicsView.__init__(self, self.controlArea)
        self.topArea = widgetBox(self.controlArea,
        sizePolicy = QSizePolicy(QSizePolicy.Maximum,QSizePolicy.Maximum),includeInReports=False, orientation = 'horizontal')
        self.middleArea = widgetBox(self.controlArea)
        self.bottomArea = widgetBox(self.controlArea,includeInReports=False)  #, sizePolicy = QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
        
        self.middleArea.layout().addWidget(self)  # place the widget into the parent widget
        scene = QGraphicsScene()
        self.setScene(scene)
        self.parent = parent
        self.data = data
        self.printQuery = ''
        self.widgetSelectionRect = None
        self.mainItem = None
        self.query = ''
        self.function = 'plot'
        self.layers = []
        self.image = 'plot'+unicode(time.time()) # the base file name without an extension
        self.imageFileName = ''
        self.currentScale = 1

    ################################
    ####   Themes              #####
    ################################
        
        
        self.options = {
            'device': {
                'Rcall': 'Cairo',
                'parameters': {
                    'type':{
                            'default':'svg',
                            'qtWidget': 'imageType'
                        }
                    ,'dpi':{
                            'default':'75',
                            'qtWidget': 'dpi'
                        }
                    ,'bg': {
                            'default':'#FFFFFF', 
                            'color': '#FFFFFF',
                            'qtWidget':'bgColor'
                            
                            }
                    ,'height': {
                            'default':400, 
                            'qtWidget': 'dheight'
                            }
                    ,'width': {
                            'default':400, 
                            'qtWidget': 'dwidth'
                            }
                    ,'units': {
                            'default':'px', 
                            'qtWidget': 'units'
                            }
                    }
                }
            ,'main': {
                'Rcall': 'plot',
                'parameters': {
                    'col': {
                        'default':None, 
                        'qtWidget':'colorSeries',
                        'series': '',
                        'seriesLen': 0,
                        'getFunction': self.getColorSeries,
                        'setFunction': self.setColorSeries,
                        }
                    ,'lty': {
                        'default':None, 
                        'qtWidget':'linesListBox',
                        'getFunction': self.getLineTypes,
                        'setFunction': self.setLineTypes,
                        }
                    ,'lwd': {
                        'default':None, 
                        'qtWidget':'lineWidth'
                        }
                    ,'pch': {
                        'default':None, 
                        'qtWidget':'pointListBox',
                        'getFunction': self.getLineTypes,
                        'setFunction': self.setLineTypes,
                        }
                }
            },
            'title': {
                'Rcall': 'title',
                'parameters': {
                    'main': {
                          'default':"Title", 
                          'qtWidget':'mainTitle' 
                          }
                    ,'xlab': {
                        'default':"XLab", 
                        'qtWidget':'xLab'
                        }
                    ,'ylab': {
                        'default':"YLab", 
                        'qtWidget':'yLab'
                        }   
                    ,'col.main': {
                          'default':'#000000', 
                          'qtWidget':'titleColor' 
                          }
                    ,'col.sub': {
                          'default':'#000000', 
                          'qtWidget':'subColor' 
                          }
                    ,'col.lab': {
                          'default':'#000000', 
                          'qtWidget':'labColor' 
                          }                        
                }
            },
            'par': {
                'Rcall':'par',
                'parameters': {
                    'cex.axis': {
                          'default':1, 
                          'qtWidget':'axisFont' 
                          }
                    ,'cex.lab': {
                          'default':1, 
                          'qtWidget':'labFont' 
                          }
                    ,'cex': {
                          'default':1, 
                          'qtWidget':'plotFont' 
                          }
                    ,'cex.main': {
                          'default':1, 
                          'qtWidget':'mainFont' 
                          }
                    ,'cex.sub': {
                          'default':1, 
                          'qtWidget':'subFont' 
                          }
                    ,'col.axis': {
                          'default':'#000000', 
                          'qtWidget':'axisColor' 
                          }
                    # ,'family': {
                          # 'default':'serif', 
                          # 'qtWidget':'fontCombo' 
                          # }
                }
            }
        }
        
        
        ### ggplot options
        self.optionsDialog = dialog(self.controlArea)
        self.optionsTab = tabWidget(self.optionsDialog)
        
        plotGridTab = self.optionsTab.createTabPage("Plot Grid Area", orientation = 'vertical')
        
        self.panelGridMajorTheme = comboBox(plotGridTab, label = 'Major Grid General Theme', toolTip = 'If Ignore, no options are set for this.  If not None overrides all other options set and sets the theme specified.', items = [('ignore', 'Ignore'), ('none', 'None'), ('theme_bw()', 'Black and White'), ('theme_blank()', 'Blank Theme')])
        self.panelGridMajorColour = colorButton(plotGridTab, label = "Major Grid Color")
        self.panelGridMajorSize = spinBox(plotGridTab, label = "Major Grid Size")
        self.panelGridMajorLineType = comboBox(plotGridTab, label = "Major Grid Line Type", items = [('solid', 'Solid'), ('dotted', 'Dotted'), ('dashed', 'Dashed')])
        
        self.panelGridMinorTheme = comboBox(plotGridTab, label = 'Minor Grid General Theme', toolTip = 'If Ignore, no options are set for this.  If not None overrides all other options set and sets the theme specified.', items = [('ignore', 'Ignore'), ('none', 'None'), ('theme_bw()', 'Black and White'), ('theme_blank()', 'Blank Theme')])
        self.panelGridMinorColour = colorButton(plotGridTab, label = "Minor Grid Color")
        self.panelGridMinorSize = spinBox(plotGridTab, label = "Minor Grid Size")
        self.panelGridMinorLineType = comboBox(plotGridTab, label = "Minor Grid Line Type", items = [('solid', 'Solid'), ('dotted', 'Dotted'), ('dashed', 'Dashed')])
        
        panelTab = self.optionsTab.createTabPage("panel Background Options", orientation = 'vertical')
        
        self.panelBackgroundTheme = comboBox(panelTab, label = 'panel Background Theme', toolTip = 'If Ignore, no options are set for this.  If not None overrides all other options set and sets the theme specified.', items = [('ignore', 'Ignore'), ('none', 'None'), ('theme_bw()', 'Black and White'), ('theme_blank()', 'Blank Theme')])
        
        textTab = self.optionsTab.createTabPage("Text Options", orientation = 'vertical')
        
        self.useTextOptions = comboBox(textTab, label = 'Use Text Options', items = [('ignore', 'No'), ('yes', 'Yes')])
        self.plotTitle = lineEdit(textTab, label = 'Plot Title')
        self.plotTitleSize = spinBox(textTab, label = 'Title Font Size', min = 1, value = 20)
        self.plotTitleAngle = spinBox(textTab, label = 'Title Angle', min = 0, max = 360, value = 0)
        self.plotTitleFontFace = comboBox(textTab, label = 'Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.axisTitleX = lineEdit(textTab, label = 'X Axis Title')
        self.axisTitleXColor = colorButton(textTab, label = 'X Axis Color')
        self.axisTitleXSize = spinBox(textTab, label = 'X Axis Title Size', min = 1, value = 14)
        self.axisTitleXAngle = spinBox(textTab, label = 'X Axis Title Angle', min = 0, max = 360, value = 0)
        self.axisTitleXFontFace = comboBox(textTab, label = 'X Axis Title Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.axisTextXSize = spinBox(textTab, label = 'X Axis Text Size', min = 1, value = 14)
        self.axisTextXColor = colorButton(textTab, label = 'X Axis Text Color')
        self.axisTextXAngle = spinBox(textTab, label = 'X Axis Text Angle', min = 0, max = 360, value = 0)
        self.axisTextXFontFace = comboBox(textTab, label = 'X Axis Text Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.axisTitleY = lineEdit(textTab, label = 'Y Axis Title')
        self.axisTitleYColor = colorButton(textTab, label = 'Y Axis Color')
        self.axisTitleYSize = spinBox(textTab, label = 'Y Axis Title Size', min = 1, value = 14)
        self.axisTitleYAngle = spinBox(textTab, label = 'Y Axis Title Angle', min = 0, max = 360, value = 0)
        self.axisTitleYFontFace = comboBox(textTab, label = 'Y Axis Title Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.axisTextYSize = spinBox(textTab, label = 'Y Axis Text Size', min = 1, value = 14)
        self.axisTextYColor = colorButton(textTab, label = 'Y Axis Text Color')
        self.axisTextYAngle = spinBox(textTab, label = 'Y Axis Text Angle', min = 0, max = 360, value = 0)
        self.axisTextYFontFace = comboBox(textTab, label = 'Y Axis Text Font Face', items = [('none', 'None'), ('bold', 'Bold')])
        
        self.optionsDialog.hide()
        
        self.optionWidgets = {}
        self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff']       

        self.extraOptionsLineEdit = lineEdit(self.topArea, label = 'Extra Options', toolTip = 'These options will be appended to the plotting call, remember that these are ggplot options that will be added to the plot object')
        self.extraOptionsLineEdit.controlArea.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        
        self.heightSpinBox = spinBox(self.topArea, label = 'Height', min = 0, value = 7, decimals = 3)
        self.widthSpinBox = spinBox(self.topArea, label = 'Width', min = 0, value = 7, decimals = 3)
        button(self.topArea, label = 'Show Options', callback = self.optionsDialog.show)
        
    
    ################################
    ### right click menu     #######
    ################################
        self.menu = QMenu(self)
        save = self.menu.addMenu('Save As')
        save.addAction('Bitmap')
        save.addAction('PDF')
        save.addAction('Post Script')
        save.addAction('JPEG')
        save.addAction('SVG')
        self.menu.addAction('Copy')
        self.menu.addAction('Fit In Window')
        self.menu.addAction('Zoom Out')
        self.menu.addAction('Zoom In')
        self.menu.addAction('R Graphics Device')
        #self.menu.addAction('Undock')
        #self.menu.addAction('Redock')
        
        self.dialog = QDialog()
        self.dialog.setWindowTitle('Red-R Graphics View' + name)
        self.dialog.setLayout(QHBoxLayout())
        
        self.standardImageType = 'svg'
        self.imageType = 'svg'
        QObject.connect(self.dialog, SIGNAL('finished(int)'), self.dialogClosed)
 def __init__(self, **kwargs):
     OWRpy.__init__(self, **kwargs)
     
     self.require_librarys(["ggplot2"])
     self.RFunctionParam_y = ''
     self.RFunctionParam_x = ''
     self.setRvariableNames(["lineplot"])
     self.inputs.addInput('id0', 'Data Table', redRDataFrame, self.processy)
     self.colours = [(0, _('Two Color Gradient')), (1, _('Three Color Gradient')), (2, _('Sequential Brewer Colors')), (3, _('Diverging Brewer Colors')), (4, _('Qualitative Brewer Colors')), (5, _('No Color'))]
     self.colourScaleWidgets = []
     topBox = redRWidgetBox(self.controlArea, orientation = 'horizontal')
     aestheticsBox = redRGroupBox(topBox, label = _('Aesthetics'), orientation = 'horizontal')
     aestheticsBox.setSizePolicy(QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum))
     self.xGroup = comboBox(aestheticsBox, label = _('X Values'))
     self.yData = comboBox(aestheticsBox, label = _('Y Values'))
     self.fillData = comboBox(aestheticsBox, label = _('Fill Data'), callback = self.fillDataChanged)
     self.linetypeCombo = comboBox(aestheticsBox, label = _('Line Type'))
     self.colourScale = comboBox(aestheticsBox, label = _('Color Scale'), items = self.colours, callback = self.colourScaleChanged)
     
     ## make the scale selector
     self.colourSelectorStack = stackedWidget(aestheticsBox)
     
     
     
     ## vlaue stack 0; gradient selector
     gradientBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(gradientBox)
     self.gradientFrom = colorButton(gradientBox, label = _('From'), startColor = '#000000')
     self.gradientTo = colorButton(gradientBox, label = _('To'), startColor = '#FFFFFF')
     
     ## value stack 1; gradient2 selector
     gradient2Box = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(gradient2Box)
     self.gradient2From = colorButton(gradient2Box, label = _('From'), startColor = '#FF0000')
     self.gradient2To = colorButton(gradient2Box, label = _('To'), startColor = '#00FF00')
     self.gradient2Via = colorButton(gradient2Box, label = _('Via'), startColor = '#FFFFFF')
     
     ## value stack 2; sequential brewer colors
     sequentialBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(sequentialBox)
     self.sequentialPalettes = comboBox(sequentialBox, label = _('Palette'), items = [('Blues', _('Blues')), ('BuGn', _('Blue Green')), ('BuPu', _('Blue Purple')), ('GnBu', _('Green Blue')), ('Greens', _('Greens')), ('Greys', _('Greys')), ('Oranges', _('Oranges')), ('OrRd', _('Orange Red')), ('PuBu', _('Purple Blue')), ('PuBuGn', _('Purple Blue Green')), ('PuRd', _('Purple Red')), ('Purples', _('Purples')), ('RdPu', _('Red Purple')), ('Reds', _('Reds')), ('YlGn', _('Yellow Green')), ('YlGnBu', _('Yellow Green Blue')), ('YlOrBr', _('Yellow Orange Brown')), ('YlOrRd', _('Yellow Orange Red'))])
     self.sequentialVariations = spinBox(sequentialBox, label = _('Variations'), decimals = 0, min = 3, max = 9, value = 5)
     
     ## value stack 3; diverging brewer colors
     divergingBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(divergingBox)
     paletteItems = [('BrBG', _('Brown Blue Green')), ('PiYG', _('Pink Yellow Green')), ('PRGn', _('Pink Red Green')), ('PuOr', _('Purple Orange')), ('RdBu', _('Red Blue')), ('RdGy', _('Red Grey')), ('RdYlBu', _('Red Yellow Blue')), ('RdYlGn', _('Red Yellow Green')), ('Spectral', _('Spectral'))]
     self.divergingPalettes = comboBox(divergingBox, label = _('Palette'), items = paletteItems)
     self.divergingVariations = spinBox(divergingBox, label = _('Variations'), decimals = 0, min = 3, max = 11, value = 5)
     
     ## value stack 4; qualitative brewer colors
     qualitativeBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(qualitativeBox)
     self.qualitativePalettes = comboBox(qualitativeBox, label = _('Palette'), items = [('Accent', _('Accent')), ('Dark2', _('Dark2')), ('Paired', _('Paired')), ('Pastel1', _('Pastel1')), ('Pastel2', _('Pastel2')), ('Set1', _('Set1')), ('Set2', _('Set2')), ('Set3', _('Set3'))])
     self.qualitativeVariations = spinBox(qualitativeBox, label = _('Variations'), decimals = 0, min = 3, max = 8, value = 5)
     
     ## value stack 5; no color
     noColorBox = self.colourSelectorStack.createWidgetBox()
     self.colourScaleWidgets.append(noColorBox)
     
     ## error bars
     errorBox = redRGroupBox(self.controlArea, label = _('Error Bar Options'), orientation = 'horizontal')
     self.errorBarData = comboBox(errorBox, label = _('Error Bar Data'))
     
     
     self.colourSelectorStack.setCurrentIndex(0)
     
     self.graphicsView = redRGGPlot(self.controlArea,label='Box Plot',displayLabel=False,
     name = self.captionTitle)
     self.commit = redRCommitButton(self.bottomAreaRight, _("Commit"), callback = self.commitFunction,
     processOnInput=True)
     self.colourScaleChanged()