Пример #1
0
 def __init__(self, parent = None, layout = 'vertical', title = 'Color List Dialog', data = ''):
     QDialog.__init__(self, parent)
     self.setWindowTitle(title)
     if layout == 'horizontal':
         self.setLayout(QHBoxLayout())
     else:
         self.setLayout(QVBoxLayout())
     
     self.listOfColors = []
     self.controlArea = widgetBox(self)
     mainArea = widgetBox(self.controlArea, 'horizontal')
     leftBox = widgetBox(mainArea)
     rightBox = widgetBox(mainArea)
     ## GUI
     
     # color list
     self.colorList = listBox(leftBox, label = 'Color List')
     button(leftBox, label = 'Add Color', callback = self.addColor)
     button(leftBox, label = 'Remove Color', callback = self.removeColor)
     button(leftBox, label = 'Clear Colors', callback = self.colorList.clear)
     button(mainArea, label = 'Finished', callback = self.accept)
     # attribute list
     self.attsList = listBox(rightBox, label = 'Data Parameters', callback = self.attsListSelected)
     if data:
         names = self.R('names('+data+')')
         print names
         self.attsList.update(names)
     self.data = data
Пример #2
0
 def __init__(self, parent = None, layout = 'vertical', title = 'Color List Dialog', data = ''):
     QDialog.__init__(self, parent)
     self.setWindowTitle(title)
     if layout == 'horizontal':
         self.setLayout(QHBoxLayout())
     else:
         self.setLayout(QVBoxLayout())
     
     self.listOfColors = []
     self.controlArea = widgetBox(self)
     mainArea = widgetBox(self.controlArea, 'horizontal')
     leftBox = widgetBox(mainArea)
     rightBox = widgetBox(mainArea)
     ## GUI
     
     # color list
     self.colorList = listBox(leftBox, label = 'Color List')
     button(leftBox, label = 'Add Color', callback = self.addColor)
     button(leftBox, label = 'Remove Color', callback = self.removeColor)
     button(leftBox, label = 'Clear Colors', callback = self.colorList.clear)
     button(mainArea, label = 'Finished', callback = self.accept)
     # attribute list
     self.attsList = listBox(rightBox, label = 'Data Parameters', callback = self.attsListSelected)
     if data:
         names = self.R('names('+data+')')
         print names
         self.attsList.update(names)
     self.data = data
Пример #3
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["intersect"])
        self.dataA = None
        self.dataB = None

        self.inputs.addInput('id0', _('Input Data A'), redRRList,
                             self.processA)
        self.inputs.addInput('id1', _('Input Data B'), redRRList,
                             self.processB)

        self.outputs.addOutput('id0', _('intersect Output'), redRRVector)

        box = widgetBox(self.controlArea, orientation='vertical')
        dataSetBox = widgetBox(box, orientation='horizontal')
        #pickA = groupBox(dataSetBox, "Dataset A:")
        self.colA = listBox(dataSetBox,
                            label=_('Input Data A'),
                            callback=self.onSelect)

        #pickB = groupBox(dataSetBox, "Dataset B:")
        self.colB = listBox(dataSetBox,
                            label=_('Input Data B'),
                            callback=self.onSelect)

        self.resultInfo = textEdit(box,
                                   label=_('Results'),
                                   displayLabel=False,
                                   includeInReports=False,
                                   editable=False,
                                   alignment=Qt.AlignHCenter)
        self.resultInfo.setMaximumWidth(170)
        self.resultInfo.setMaximumHeight(25)
        self.resultInfo.setMinimumWidth(170)
        self.resultInfo.setMinimumHeight(25)
        #box.layout().setAlignment(self.resultInfo,Qt.AlignHCenter)
        self.resultInfo.hide()
        self.type = radioButtons(self.bottomAreaLeft,
                                 label=_("Perform"),
                                 buttons=[
                                     _('Intersect'),
                                     _('Union'),
                                     _('Set Difference'),
                                     _('Set Equal')
                                 ],
                                 setChecked=_('Intersect'),
                                 orientation='horizontal',
                                 callback=self.onTypeSelect)

        commitBox = widgetBox(self.bottomAreaRight, orientation='horizontal')
        self.bottomAreaRight.layout().setAlignment(commitBox, Qt.AlignBottom)

        self.commit = redRCommitButton(commitBox,
                                       _("Commit"),
                                       callback=self.commitFunction,
                                       processOnChange=True,
                                       processOnInput=True)
Пример #4
0
    def __init__(self, widget, label = _('Formula Entry'), displayLabel=True, includeInReports=True):
        # make a widgetBox to hold everything
        widgetState.__init__(self,widget,label,includeInReports)
        
        box = groupBox(self.controlArea,label=label)

        ## add the elements to the box
        #place the command keys
        self.buttonsBox = groupBox(box, label = _("Formula Commands"))
        self.plusButton = button(self.buttonsBox, _("And (+)"), callback = self.plusButtonClicked)
        self.plusButton.setEnabled(False)
        self.colonButton = button(self.buttonsBox, _("Interacting With (:)"), callback = self.colonButtonClicked)
        self.colonButton.setEnabled(False)
        self.starButton = button(self.buttonsBox, _("Together and Interacting (*)"), callback = self.starButtonClicked)
        self.starButton.setEnabled(False)
        button(self.buttonsBox, _('Clear'), self.clearFormula)
        self.elementsListBox = listBox(self.buttonsBox, label = _('Elements'), callback = self.FormulaEntryElementSelected)
        self.elementsListBox.setEnabled(True)
        
        # place the formula line edit
        self.modelBox = groupBox(box, label = _("Model Formula"), orientation = 'horizontal')
        self.extrasBox = widgetBox(self.modelBox)
        self.outcomeVariable = comboBox(self.modelBox, label = _('Outcome (f(x)):'))
        widgetLabel(self.modelBox, ' = ')
        self.modelLineEdit = lineEdit(self.modelBox, label = _('model'), displayLabel=False)
        self.label = label
Пример #5
0
    def __init__(self, widget, label = _('Formula Entry'), displayLabel=True, **kwargs):
        kwargs.setdefault('includeInReports', True)
        kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
        # make a widgetBox to hold everything
        widgetState.__init__(self,widget,label,**kwargs)
        
        box = groupBox(self.controlArea,label=label)

        ## add the elements to the box
        #place the command keys
        self.buttonsBox = groupBox(box, label = _("Formula Commands"), orientation = 'horizontal')
        self.plusButton = button(self.buttonsBox, _("And (+)"), callback = self.plusButtonClicked)
        self.plusButton.setEnabled(False)
        self.colonButton = button(self.buttonsBox, _("Interacting With (:)"), callback = self.colonButtonClicked)
        self.colonButton.setEnabled(False)
        self.starButton = button(self.buttonsBox, _("Together and Interacting (*)"), callback = self.starButtonClicked)
        self.starButton.setEnabled(False)
        button(self.buttonsBox, _('Clear'), self.clearFormula)
        self.elementsListBox = listBox(box, label = _('Elements'), callback = self.FormulaEntryElementSelected)
        self.elementsListBox.setEnabled(True)
        
        # place the formula line edit
        self.modelBox = groupBox(box, label = _("Model Formula"), orientation = 'horizontal')
        self.extrasBox = widgetBox(self.modelBox)
        self.outcomeVariable = comboBox(self.modelBox, label = _('Outcome (f(x)):'))
        widgetLabel(self.modelBox, ' = ')
        self.modelLineEdit = lineEdit(self.modelBox, label = _('model'), displayLabel=False)
        self.label = label
Пример #6
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.outputs.addOutput('id0', _('R Session'), redRREnvironment)

        # print os.path.abspath('/')
        self.path = os.path.abspath('/')
        self.setRvariableNames(['sessionEnviron'])

        gbox = groupBox(self.controlArea,
                        orientation='vertical',
                        label=_('Select R session'))

        box = widgetBox(gbox, orientation='horizontal')
        self.filecombo = fileNamesComboBox(box,
                                           label=_('Session File'),
                                           displayLabel=False,
                                           orientation='vertical')
        self.filecombo.setSizePolicy(QSizePolicy.MinimumExpanding,
                                     QSizePolicy.Maximum)

        button(box, label=_('Browse'), callback=self.browseFile)
        self.commit = commitButton(gbox,
                                   label=_('Load Session'),
                                   callback=self.loadSession,
                                   alignment=Qt.AlignRight)
        #gbox.layout().setAlignment(self.commit,Qt.AlignRight)

        self.infoa = widgetLabel(self.controlArea, '')
        self.varBox = listBox(self.controlArea, label=_('Variables'))
        self.varBox.hide()
        self.infob = widgetLabel(self.controlArea, '')
Пример #7
0
 def __init__(self, parent = None, layout = 'vertical', title = _('Line Type Dialog')):
     dialog.__init__(self, parent = parent, layout = layout, title = title)
     
     ## add a set of line types that can be shown in R and allow the user to pick them
     self.linesListBox = listBox(self, label = 'Line types:', items = ['________', '- - - -', '........', '_._._._.', '__ __ __', '__.__.__.'], callback = self.setLineTypes)
     self.linesListBox.setSelectionMode(QAbstractItemView.MultiSelection)
     button(self, _("Done"), callback = self.accept)
Пример #8
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)

        #self.selection = 0
        self.setRvariableNames(['listelement'])
        self.data = None

        self.inputs.addInput('id0', _('R List'),
                             [redRRList, redRRArbitraryList], self.process)

        self.outputs.addOutput('id0', _('R Data Frame'), redRRDataFrame)
        self.outputs.addOutput('id1', _('R Vector'), redRRVector)
        self.outputs.addOutput('id2', _('R List'), redRRList)
        self.outputs.addOutput('id3', _('R Variable'), redRRVariable)
        self.outputs.addOutput('id4', _('R Matrix'), redRRMatrix)

        #GUI
        #box = groupBox(self.controlArea, "List Data")

        self.names = listBox(self.controlArea,
                             label=_("List of Data"),
                             displayLabel=True,
                             callback=self.selectionChanged)
        self.infoa = widgetLabel(self.controlArea, '')

        self.commit = redRCommitButton(self.bottomAreaRight,
                                       _("Commit"),
                                       callback=self.sendSelection,
                                       processOnChange=True,
                                       processOnInput=True)
Пример #9
0
 def __init__(self, parent = None, layout = 'vertical', title = _('Line Type Dialog')):
     dialog.__init__(self, parent = parent, layout = layout, title = title)
     
     ## add a set of line types that can be shown in R and allow the user to pick them
     self.linesListBox = listBox(self, label = 'Line types:', items = ['________', '- - - -', '........', '_._._._.', '__ __ __', '__.__.__.'], callback = self.setLineTypes)
     self.linesListBox.setSelectionMode(QAbstractItemView.MultiSelection)
     button(self, _("Done"), callback = self.accept)
Пример #10
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["apply"])
        self.numDims = 2
        self.data = None
        self.inputs.addInput('id0', _('X'), redRRMatrix, self.processX)

        self.outputs.addOutput('id0', _('apply Output'), redRRDataFrame)

        area = widgetBox(self.controlArea, orientation='horizontal')

        box = widgetBox(area)
        box.setMinimumWidth(200)
        area.layout().setAlignment(box, Qt.AlignLeft)

        self.functions = listBox(
            box,
            label=_("Select Function"),
            items=['mean', 'median', 'max', 'min', 'sum', 'log2', 'log10'],
            callback=self.functionSelect)
        self.functions.setSelectionMode(QAbstractItemView.SingleSelection)

        separator(box, height=10)
        self.functionText = redRTextEdit(box,
                                         label=_('Function:'),
                                         orientation='vertical')
        self.parameters = redRLineEdit(box,
                                       label=_('Additional Parameters:'),
                                       orientation='vertical')

        self.demension = radioButtons(box,
                                      label=_("To:"),
                                      buttons=[_('Rows'),
                                               _('Columns'),
                                               _('')],
                                      setChecked=_('Rows'),
                                      orientation='horizontal',
                                      callback=lambda: self.dimensionChange(1))
        self.indexSpinBox = RedRSpinBox(
            self.demension.box,
            label=_('Demension'),
            displayLabel=False,
            min=1,
            value=1,
            callback=lambda: self.dimensionChange(2))
        buttonBox = widgetBox(box, orientation='horizontal')

        self.commit = redRCommitButton(buttonBox,
                                       _("Commit"),
                                       alignment=Qt.AlignLeft,
                                       callback=self.commitFunction,
                                       processOnInput=True,
                                       processOnChange=True)

        self.outputTable = redRFilterTable(area,
                                           label=_('Results of Apply'),
                                           sortable=True)
Пример #11
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["melt.data.frame", "melt.data.frame.cm"])
        self.RFunctionParam_data = ''
        self.data = {}
        self.inputs.addInput('id0', _('data'), redRRDataFrame, self.processdata)

        self.outputs.addOutput('id0', _('melt.data.frame Output'), redRRDataFrame)

        
        box = widgetBox(self.controlArea, _("Widget Box"))
        self.RFunctionParam_na_rm = comboBox(box, label = _("Remove NA:"), items = [_('Yes'), _('No')])
        self.RFunctionParam_measure_var = listBox(box, label = _("Result Variable:"), toolTip = _('The column that contains the result or the measurement that the data should be melted around.'))
        self.RFunctionParam_measure_var.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.RFunctionParam_id_var = listBox(box, label = _("Groupings:"), toolTip = _('The columns indicating the groupings of the data.'))
        self.RFunctionParam_id_var.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.RFunctionParam_variable_name = lineEdit(box, label = _("New Group Name:"), toolTip = _('The name of the new column that the groupings will be put into.'))
        self.commit = redRCommitButton(self.bottomAreaRight, _("Commit"), callback = self.commitFunction, 
        processOnInput=True)
Пример #12
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        
        # self.dataParentA = {}
        # self.dataParentB = {}
        self.dataA = ''
        self.dataB = ''
        
        
        self.inputs.addInput('id0', _('Dataset A'), redRRDataFrame, self.processA)
        self.inputs.addInput('id1', _('Dataset B'), redRRDataFrame, self.processB)

        self.outputs.addOutput('id0', _('Merged'), redRRDataFrame)

        #default values        
        self.colAsel = None
        self.colBsel = None
        #self.forceMergeAll = 0 #checkbox value for forcing merger on all data, default is to remove instances from the rows or cols.
        
        #set R variable names
        self.setRvariableNames(['merged'])
                
        #GUI
        box = widgetBox(self.controlArea,orientation='horizontal')
    
        self.colA = listBox(box, label=_('Columns to Merge From A'), callback = self.setcolA)
        self.colB = listBox(box, label=_('Columns to Merge From B'),  callback = self.setcolB)
        

        self.sortOption = checkBox(self.bottomAreaLeft, label=_('Sort by Selected Column'), displayLabel=False, 
        buttons = [_('Sort by Selected Column')], 
        toolTips = [_('logical. Should the results be sorted on the by columns?')])
        self.rownamesOption = checkBox(self.bottomAreaLeft, label = _('Include Row Names in Merge'), displayLabel = False, buttons = [_('Include Row in Merge')], toolTips = [_('This will include the row names in the data after merge.')], setChecked = [_('Include Row in Merge')])
        self.sortOption.layout().setAlignment(Qt.AlignLeft)
        
        self.mergeOptions = radioButtons(self.bottomAreaCenter,label=_('Type of merge'), displayLabel=False,
        buttons=['A+B','B+A','AB'],setChecked='A+B',
        orientation='horizontal')
        
        self.mergeOptions.layout().setAlignment(Qt.AlignCenter) 
        
        self.commit = redRCommitButton(self.bottomAreaRight, _('Commit'), callback = self.run, 
        processOnChange=True,processOnInput=True)
Пример #13
0
 def isDataFrame(self):
     self.mystatus.setText(
         _("Data Frame Connected with %s columns") %
         unicode(self.R('length(' + self.data + ')')))
     colnames = self.R('colnames(' + self.data + ')')
     if colnames != 'NULL' and self.dfselected == None:
         self.dfselected = listBox(self.dataBox, self)
         for e in colnames:
             self.dfselected.addItem(e)
     elif colnames != 'NULL' and self.dfselected != None:
         self.dfselected.clear()
         for e in colnames:
             self.dfselected.addItem(e)
Пример #14
0
 def isMatrix(self):
     self.mystatus.setText(
         _("Matrix connected with %s elements and %s columns") %
         (unicode(self.R('length(' + self.data + ')')),
          unicode(self.R('length(' + self.data + '[1,])'))))
     colnames = self.R('colnames(' + self.data + ')')
     if colnames != 'NULL' and colnames != '' and colnames != 'None' and colnames != None:
         self.dfselected = listBox(self.dataBox, self)
         try:
             for e in colnames:
                 self.dfselected.addItem(e)
         except:
             print _('Error with colnames, may not exist.')
Пример #15
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
        self.setRvariableNames(["percentileClassifier_df", "percentileClassifier", 'percentileClassifier_cm'])
        self.data = ''
        self.dataParent = None
        self.inputs.addInput('id0', _('Data Frame'), redRRDataFrame, self.processData)

        self.outputs.addOutput('id0', _('Data Frame'), redRRDataFrame)

        
        ### GUI ###
        self.colNames_listBox = listBox(self.controlArea, label = _('Column Names:'),callback=self.onChange)
        self.colNames_listBox.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.percentile_spinBox = spinBox(self.controlArea, label= _('Percentile Cutoff Selector:'), min = 0, max = 100, callback=self.onChange)
        self.percentile_lineEdit = lineEdit(self.controlArea, label = _('Percentile Cutoff:'), toolTip = _('Input multiple cutoffs in the form; a, b, c.  Where a, b, and c are cutoffs.\nThis takes the place of the Percentile Cutoff Selector if not blank.'))
        self.outputWindow = textEdit(self.controlArea, label = _('Output Summary'))
        
        self.commitButton = redRCommitButton(self.bottomAreaRight, _("Commit"), callback = self.commit,
        processOnInput=True,processOnChange=True)
Пример #16
0
    def __init__(self, **kwargs):
        OWRpy.__init__(self, **kwargs)
        self.data = None
        self.RFunctionParam_x = ''
        self.plotAttributes = {}
        self.saveSettingsList = ['plotArea', 'data', 'RFunctionParam_x', 'plotAttributes']
        self.inputs.addInput('id0', 'x', redRRVariable, self.processx)

        # self.R('data <- iris')
        # self.RFunctionParam_x = 'data'
        self.data = 'iris'
        self.plotArea = graphicsView2(self.controlArea,label='Plot', displayLabel=False)
        #self.plotArea.hideTab('Points/Lines')
        
        self.plotArea.setCustomPlot(self.updatePlot)
        
        self.plotControls = self.plotArea.createTab('Barplot')
        imageBox = self.plotArea.createControlGroup('Barplot',label='Barplot')
        
        self.namesCombo = comboBox(imageBox,label='Group Name')
        self.heightCombo = listBox(self.plotControls,label='Heights',selectionMode=QAbstractItemView.ExtendedSelection)
        
        self.commit = redRCommitButton(self.bottomAreaRight, "Commit", callback = self.commitFunction,
        processOnInput=True)
Пример #17
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)
       
        self.inputs.addInput('id0', _('R Environment'), renv.REnvironment, self.process)

        self.outputs.addOutput('id0', _('R Session'), renv.REnvironment)
        self.outputs.addOutput('id1', _('Non-Standard R Variable'), rvar.RVariable)
        self.outputs.addOutput('id2', _('R Data Frame (Data Table)'), rdf.RDataFrame)
        self.outputs.addOutput('id3', _('R List'), rlist.RList)
        self.outputs.addOutput('id4', _('R Vector'), rvec.RVector)
        self.outputs.addOutput('ral', _('R Arbitrary List'), ral.RArbitraryList)

       
        # self.help.setHtml('The R Variable Separator is used to separate variables from a loaded R session.  Connecting the R Loader widget to this widget will display a list of available variables in the local environment to which the session was loaded.  Clicking on an element in the list will send that element on to downstream widgets.  One should take note of the class of the element that is sent as this will specify the output connection of the data.  More infromation is available on the <a href="http://www.red-r.org/?cat=10">RedR website</a>.')

        self.controlArea.setMinimumWidth(300)
        self.varBox = listBox(self.controlArea, label = _('Variables'), callback = self.select)
        
        box = widgetBox(self.controlArea, orientation='horizontal') 
        #self.filecombo.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Minimum)
        self.controlArea.layout().setAlignment(box,Qt.AlignRight)
        
        self.commitButton = redRCommitButton(box,label=_('Commit'),callback=self.commit,
        processOnInput=True,processOnChange=True)
Пример #18
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)

        self.setRvariableNames(['math'])

        self.counter = 1
        self.functionsList = [
            'log2', 'log10', 'add', 'subtract', 'multiply', 'divide', 'match',
            'as.numeric', 'as.character', 'exp', 'logicAND', 'logicOR',
            'toDateTime (MDY)', 'toDateTime (DMY)', 'toDateTime (YMD)'
        ]

        self.inputs.addInput('id0', _('Data Frame'), redRRDataFrame,
                             self.gotData)

        self.outputs.addOutput('id0', _('Data Frame'), redRRDataFrame)

        #GUI#

        mainArea = widgetBox(self.controlArea, orientation='horizontal')
        leftArea = groupBox(mainArea, label=_('Table View'))
        rightArea = groupBox(mainArea, label=_('Math Box'))

        self.table = redRfilterTable(leftArea,
                                     label=_('Data Table'),
                                     displayLabel=False,
                                     filterable=False,
                                     sortable=False)

        self.functionLineEdit = lineEdit(rightArea,
                                         label=_('Function Search or Run'),
                                         callback=self.functionDone)
        QObject.connect(self.functionLineEdit,
                        SIGNAL('textChanged(const QString&)'),
                        lambda s: self.textChanged(s))

        self.functionListBox = listBox(rightArea,
                                       label=_('List of Functions'),
                                       displayLabel=False,
                                       includeInReports=False,
                                       items=self.functionsList,
                                       callback=self.funcionPressed)

        #self.helpButton = button(rightArea, label = 'Help') #, toolTip = 'Press this then select a function from the list for help.')
        self.dialog = dialog(self)
        self.dialogTopArea = groupBox(self.dialog, label=_('Left Side'))
        self.dialogTopLineEdit = lineEdit(self.dialogTopArea,
                                          label=_('Constant'),
                                          toolTip=_('Must be a number'))
        self.dialogTopListBox = listBox(self.dialogTopArea,
                                        label=_('Columns'),
                                        toolTip=_('Select one of the columns'),
                                        callback=self.dialogTopLineEdit.clear)

        self.dialogLabel = widgetLabel(self.dialog)

        self.dialogBottomArea = groupBox(self.dialog, label=_('Right Side'))
        self.dialogBottomLineEdit = lineEdit(self.dialogBottomArea,
                                             label=_('Constant'),
                                             toolTip=_('Must be a number'))
        self.dialogBottomListBox = listBox(
            self.dialogBottomArea,
            label=_('Columns'),
            toolTip=_('Select one of the columns'),
            callback=self.dialogBottomLineEdit.clear)
        redRCommitButton(self.dialog,
                         label=_('Done'),
                         callback=self.functionCommit)
        self.dialog.hide()
Пример #19
0
    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)
        # if displayLabel:
            # self.controlArea = groupBox(parent,label=label, orientation='vertical')
        # else:
            # self.controlArea = widgetBox(parent,orientation='vertical')
        
        #self.controlArea = widgetBox(parent)
        self.topArea = widgetBox(self.controlArea,
        sizePolicy = QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Maximum),includeInReports=False)
        self.middleArea = widgetBox(self.controlArea)
        self.bottomArea = widgetBox(self.controlArea,includeInReports=False)
        
        self.middleArea.layout().addWidget(self)  # place the widget into the parent widget
        scene = QGraphicsScene()
        self.setScene(scene)
        self.parent = parent
        self.data = data
        
        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' 
                          # }
                }
            }
        }
        # ,'fg' : None
        # ,'legendNames' : None
        # ,'legendLocation' : "'bottomleft'"
        # }
        
        self.optionWidgets = {}
        self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff']       


    ################################
    ####   Setup Tabs          #####
    ################################
        self.graphicOptionsButton = button(self.topArea,label='Graphic Options',
        toggleButton = True,callback=self.displayGraphicOptions)
        self.graphicOptionsWidget = widgetBox(self.topArea)
        self.graphicOptions = tabWidget(self.graphicOptionsWidget)
        self.graphicOptions.setFixedHeight(180)
        hbox = widgetBox(self.graphicOptionsWidget,orientation='horizontal',alignment= Qt.AlignLeft)
        self.resizeCheck = checkBox(hbox,label='resize',displayLabel=False,buttons={'true':'Resize Image'},setChecked='true')
        button(hbox,label='Update Graphic', alignment=Qt.AlignLeft, callback=self.plotMultiple)
        

        self.labels = self.graphicOptions.createTabPage('Main')
        self.points = self.graphicOptions.createTabPage('Points/Lines')
        self.advanced = self.graphicOptions.createTabPage('Advanced')
        #self.graphicOptions.hide()
        
        firstTab = widgetBox(self.labels,orientation='horizontal',alignment=Qt.AlignLeft | Qt.AlignTop)
        secondTab = widgetBox(self.points,orientation='horizontal',alignment=Qt.AlignLeft | Qt.AlignTop)
        advancedTab = widgetBox(self.advanced,orientation='vertical',alignment=Qt.AlignLeft | Qt.AlignTop)
    ################################
    ####   Advanced Tabs       #####
    ################################
        
        self.optionWidgets['extrasLineEdit'] = lineEdit(advancedTab, label = 'Advanced plotting parameters', 
        toolTip = 'Add extra parameters to the main plot.\nPlease see documentation for more details about parameters.')
        
        self.optionWidgets['onlyAdvanced'] = checkBox(advancedTab,
        buttons=['Only use the advanced options here'],
        label='advancedOnly',displayLabel=False)

    ################################
    ####   First Tabs          #####
    ################################
        imageBox = groupBox(firstTab,label='Image Properties', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        self.optionWidgets['imageType'] = comboBox(imageBox,label='Image Type',items=['svg','png'])
        self.optionWidgets['imageType'].setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Minimum)
        
        hbox = widgetBox(imageBox,orientation='horizontal')
        self.optionWidgets['dheight'] = spinBox(hbox, label = 'Height', min = 1, max = 5000, value = 400)
        self.optionWidgets['dwidth'] = spinBox(hbox, label = 'Width', min = 1, max = 5000, value = 400)
        hbox = widgetBox(imageBox,orientation='horizontal')
        self.optionWidgets['units'] = comboBox(hbox,label='units',items=[('px','Pixel'),('in','Inches')])
        self.optionWidgets['dpi'] = comboBox(hbox,label='DPI',items=['75','100','150','auto'],editable=True)
        
        
        labelBox = groupBox(firstTab,label='Labels', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        self.optionWidgets['mainTitle'] = lineEdit(labelBox,label='Main Title')
        self.optionWidgets['xLab'] = lineEdit(labelBox,label='X Axis Label')        
        self.optionWidgets['yLab'] = lineEdit(labelBox,label='Y Axis Label')

        
        fontBox = groupBox(firstTab,label='Sizes', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        fontColumnBox = widgetBox(fontBox,orientation='horizontal')
        fontColumn1 = widgetBox(fontColumnBox,orientation='vertical')
        fontColumn2 = widgetBox(fontColumnBox,orientation='vertical')
        
        #self.optionWidgets['fontCombo'] = comboBox(fontColumn1, items = ['serif', 'sans', 'mono'], label='Font Family')
        
        self.optionWidgets['lineWidth'] = spinBox(fontColumn1,label='Point/Line Size',decimals=2,min=1,max=50)
        self.optionWidgets['plotFont'] = spinBox(fontColumn1, label = 'Plot Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['axisFont'] = spinBox(fontColumn1, label = 'Axis Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['mainFont'] = spinBox(fontColumn2, label = 'Title Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['subFont'] = spinBox(fontColumn2, label = 'Subtitle Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['labFont'] = spinBox(fontColumn2, label = ' XY Label Text Size',decimals=2, min = 1, max = 50)
        
        colorBox = groupBox(firstTab,label='Colors', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        hbox = widgetBox(colorBox,orientation='horizontal')

        self.optionWidgets['colorSeries'] = comboBox(hbox,label='Generate Colors Series',orientation='vertical',
        items = ['select','rainbow','heat.colors','terrain.colors','topo.colors','cm.colors'])
        self.optionWidgets['colorSeriesLen'] = spinBox(hbox,label='Length of Series',displayLabel=False, min=0, max=500)
        hbox.layout().setAlignment(self.optionWidgets['colorSeriesLen'].controlArea, Qt.AlignBottom)
        
        self.optionWidgets['bgColor'] = ColorIcon(colorBox,label='Background')

        #self.optionWidgets['customColors'] = button(colorBox,label='Custom Plot Colors',callback=self.setPlotColors)

    
    ################################
    ####   Second Tabs         #####
    ################################
        colorBox2 = groupBox(secondTab,label='Colors', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        # colorColumnBox = widgetBox(colorBox2,orientation='horizontal')
        # colorColumn1 = widgetBox(colorColumnBox,orientation='vertical')
        # colorColumn2 = widgetBox(colorColumnBox,orientation='vertical')
      
         
        self.optionWidgets['titleColor'] = ColorIcon(colorBox2,label='Title')
        self.optionWidgets['subColor'] = ColorIcon(colorBox2,label='Subtitle')
        self.optionWidgets['labColor'] = ColorIcon(colorBox2,label='Subtitle')
        self.optionWidgets['axisColor'] = ColorIcon(colorBox2,label='Axis')
        
        lineBox = groupBox(secondTab,label='Lines', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
       
        self.optionWidgets['linesListBox'] = listBox(lineBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection,
        items = [(1,'________'), (2,'- - - -'), (3,'........'), (4,'_._._._.'), 
        (5,'__ __ __'), (6,'__.__.__.')])
        
        
        
        pointBox = groupBox(secondTab,label='Points', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        items = []
        for i in range(1,26):
            items.append((i-1,QListWidgetItem(QIcon(os.path.join(redREnviron.directoryNames['picsDir'],
            'R icon (%d).png' %i)),'')))
        
        for i in range(32,128):
            items.append((i-1,'%s' % (chr(i))))
            
        self.optionWidgets['pointListBox'] = listBox(pointBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection, items = items)
        


        self.setTheme(self.options)
    ################################
    ### 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')
        self.menu.addAction('Copy')
        self.menu.addAction('Fit In Window')
        self.menu.addAction('Zoom Out')
        self.menu.addAction('Zoom In')
        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'
        QObject.connect(self.dialog, SIGNAL('finished(int)'), self.dialogClosed)
Пример #20
0
    def __init__(self, parent=None, signalManager=None):
        OWRpy.__init__(self)  #initialize the widget
        self.dataClass = None
        self.dataParent = None
        self.setRvariableNames(['rowcolSelector', 'rowcolSelectorNot'])
        self.SubsetByAttached = 0

        self.inputs.addInput('id0', _('Data Table'), redRRDataFrame,
                             self.setWidget)
        self.inputs.addInput('id1', _('Subsetting Vector'), redRRList,
                             self.setSubsettingVector)

        self.outputs.addOutput('id0', _('Selected Items'), redRRDataFrame)
        self.outputs.addOutput('id1', _('Non-selected Items'), redRRDataFrame)

        #set the gui

        area = widgetBox(self.controlArea, orientation='horizontal')
        options = widgetBox(area, orientation='vertical')

        self.rowcolBox = radioButtons(options,
                                      label=_('Select On'),
                                      buttons=[_('Column'),
                                               _('Row')],
                                      setChecked=_('Column'),
                                      callback=self.rowcolButtonSelected,
                                      orientation='horizontal')

        self.sendSection = checkBox(options,
                                    label=_('Create subset from:'),
                                    displayLabel=True,
                                    buttons=[_('Selected'),
                                             _('Not Selected')],
                                    setChecked=[_('Selected')],
                                    orientation='horizontal')

        # toolTips = [_("Select True to send data from the Data slot where the selections that you made are True."),
        # _("Select False to send data from the Not Data slot that are not the selections you made.")])

        self.invertButton = button(options,
                                   _("Invert Selection"),
                                   callback=self.invertSelection)

        separator(options, height=15)

        self.subsetBox = groupBox(options, label=_('Subset by'))
        self.subsetColumn = comboBox(self.subsetBox,
                                     label=_("Column:"),
                                     orientation='vertical',
                                     items=[_('Select')])
        self.subOnAttachedButton = button(self.subsetBox,
                                          _("Subset by column"),
                                          callback=self.subOnAttached)
        self.subsetBox.setDisabled(True)

        separator(options, height=20)

        info = widgetBox(options)
        options.layout().setAlignment(info, Qt.AlignBottom)
        self.infoBox = widgetLabel(info)
        separator(info, height=15)
        self.selectionInfoBox = widgetLabel(info)
        mainArea = widgetBox(area, orientation='vertical')
        self.attributes = listBox(mainArea,
                                  label=_('Select'),
                                  callback=self.onSelect)
        self.attributes.setSelectionMode(QAbstractItemView.ExtendedSelection)

        self.subsetButton = commitButton(mainArea,
                                         _("Subset on Selection"),
                                         callback=self.subset,
                                         processOnChange=True,
                                         processOnInput=True,
                                         alignment=Qt.AlignRight)
Пример #21
0
    def __init__(self, parent,label=None, displayLabel=True,includeInReports=True, name = '', data = None, prePlottingCallback = None):
        ## want to init a graphics view with a new graphics scene, the scene will be accessable through the widget.
        graphicsView.__init__(self, parent, label = label, displayLabel = displayLabel, includeInReports = includeInReports,
            name = name, data = data)
        ## __init__(self, parent,label=_('Graph'), displayLabel=True,includeInReports=True, name = '', data = None)
        
    ################################
    ####   Themes              #####
    ################################
        
        self.prePlottingCallback = prePlottingCallback
        self.options = {
            'device': {
                'imageType':'svg',
                'dpi':'75',
                'bgColor':'#FFFFFF',
                'dheight':400,
                'dwidth':400,
                'units':'px'},
            'main':{
                'col':None,
                'lty':None,
                'lwd':None,
                'pch':None,},
            'title':{
                'main':'',
                'xlab':'',
                'ylab':'',
                'col.main':'#000000',
                'col.sub':'#000000',
                'col.lab':'#000000'},
            'par':{
                'cex.axis':1,
                'cex.lab':1,
                'cex.main':1,
                'cex.sub':1,
                'cex':1,
                'col.axis':'#000000'}
            }
        
        
        self.optionWidgets = {}
        self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff']       


    ################################
    ####   Setup Tabs          #####
    ################################
        self.graphicOptionsButton = button(self.topArea,label='Graphic Options',
        toggleButton = True,callback=self.displayGraphicOptions)
        self.graphicOptionsWidget = widgetBox(self.topArea)
        self.graphicOptions = tabWidget(self.graphicOptionsWidget)
        self.graphicOptions.setFixedHeight(180)
        hbox = widgetBox(self.graphicOptionsWidget,orientation='horizontal',alignment= Qt.AlignLeft)
        self.resizeCheck = checkBox(hbox,label='resize',displayLabel=False,buttons={'true':'Resize Image'},setChecked='true')
        self.monkey = checkBox(hbox, label='useopts', displayLabel = False, buttons={'true':'Use Custom Plot Options'}, callback = self.enablePlotOptions)
        button(hbox,label='Update Graphic', alignment=Qt.AlignLeft, callback=self.plotMultiple)
        

        self.labels = self.graphicOptions.createTabPage('Main')
        self.points = self.graphicOptions.createTabPage('Points/Lines')
        self.advanced = self.graphicOptions.createTabPage('Advanced')
        #self.graphicOptions.hide()
        
        firstTab = widgetBox(self.labels,orientation='horizontal',alignment=Qt.AlignLeft | Qt.AlignTop)
        secondTab = widgetBox(self.points,orientation='horizontal',alignment=Qt.AlignLeft | Qt.AlignTop)
        advancedTab = widgetBox(self.advanced,orientation='vertical',alignment=Qt.AlignLeft | Qt.AlignTop)
    ################################
    ####   Advanced Tabs       #####
    ################################
        
        self.optionWidgets['extrasLineEdit'] = lineEdit(advancedTab, label = 'Advanced plotting parameters', 
        toolTip = 'Add extra parameters to the main plot.\nPlease see documentation for more details about parameters.')
        
        self.optionWidgets['onlyAdvanced'] = checkBox(advancedTab,
        buttons=[(1, 'Only use the advanced options here')],
        label='advancedOnly',displayLabel=False)

    ################################
    ####   First Tabs          #####
    ################################
        imageBox = groupBox(firstTab,label='Image Properties', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        self.optionWidgets['imageType'] = comboBox(imageBox,label='Image Type',items=['svg', 'cairo' ,'png'])
        self.optionWidgets['imageType'].setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Minimum)
        
        hbox = widgetBox(imageBox,orientation='horizontal')
        self.optionWidgets['dheight'] = spinBox(hbox, label = 'Height', min = 1, max = 5000, value = 400)
        self.optionWidgets['dwidth'] = spinBox(hbox, label = 'Width', min = 1, max = 5000, value = 400)
        hbox = widgetBox(imageBox,orientation='horizontal')
        self.optionWidgets['units'] = comboBox(hbox,label='units',items=[('px','Pixel'),('in','Inches')])
        self.optionWidgets['dpi'] = comboBox(hbox,label='DPI',items=['75','100','150','auto'],editable=True)
        
        
        labelBox = groupBox(firstTab,label='Labels', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        self.optionWidgets['mainTitle'] = lineEdit(labelBox,label='Main Title')
        self.optionWidgets['xLab'] = lineEdit(labelBox,label='X Axis Label')        
        self.optionWidgets['yLab'] = lineEdit(labelBox,label='Y Axis Label')

        
        fontBox = groupBox(firstTab,label='Sizes', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        fontColumnBox = widgetBox(fontBox,orientation='horizontal')
        fontColumn1 = widgetBox(fontColumnBox,orientation='vertical')
        fontColumn2 = widgetBox(fontColumnBox,orientation='vertical')
        
        #self.optionWidgets['fontCombo'] = comboBox(fontColumn1, items = ['serif', 'sans', 'mono'], label='Font Family')
        
        self.optionWidgets['lineWidth'] = spinBox(fontColumn1,label='Point/Line Size',decimals=2,min=1,max=50)
        self.optionWidgets['plotFont'] = spinBox(fontColumn1, label = 'Plot Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['axisFont'] = spinBox(fontColumn1, label = 'Axis Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['mainFont'] = spinBox(fontColumn2, label = 'Title Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['subFont'] = spinBox(fontColumn2, label = 'Subtitle Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['labFont'] = spinBox(fontColumn2, label = ' XY Label Text Size',decimals=2, min = 1, max = 50)
        
        colorBox = groupBox(firstTab,label='Colors', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        hbox = widgetBox(colorBox,orientation='horizontal')

        self.optionWidgets['colorSeries'] = comboBox(hbox,label='Generate Colors Series',orientation='vertical',
        items = ['select','rainbow','heat.colors','terrain.colors','topo.colors','cm.colors'])
        self.optionWidgets['colorSeriesLen'] = spinBox(hbox,label='Length of Series',displayLabel=False, min=0, max=500)
        hbox.layout().setAlignment(self.optionWidgets['colorSeriesLen'].controlArea, Qt.AlignBottom)
        
        self.optionWidgets['bgColor'] = ColorIcon(colorBox,label='Background')

        #self.optionWidgets['customColors'] = button(colorBox,label='Custom Plot Colors',callback=self.setPlotColors)

    
    ################################
    ####   Second Tabs         #####
    ################################
        colorBox2 = groupBox(secondTab,label='Colors', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        # colorColumnBox = widgetBox(colorBox2,orientation='horizontal')
        # colorColumn1 = widgetBox(colorColumnBox,orientation='vertical')
        # colorColumn2 = widgetBox(colorColumnBox,orientation='vertical')
      
         
        self.optionWidgets['titleColor'] = ColorIcon(colorBox2,label='Title')
        self.optionWidgets['subColor'] = ColorIcon(colorBox2,label='Subtitle')
        self.optionWidgets['labColor'] = ColorIcon(colorBox2,label='Subtitle')
        self.optionWidgets['axisColor'] = ColorIcon(colorBox2,label='Axis')
        
        lineBox = groupBox(secondTab,label='Lines', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
       
        self.optionWidgets['linesListBox'] = listBox(lineBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection,
        items = [(1,'________'), (2,'- - - -'), (3,'........'), (4,'_._._._.'), 
        (5,'__ __ __'), (6,'__.__.__.')])
        
        
        
        pointBox = groupBox(secondTab,label='Points', orientation='vertical',
        sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        items = []
        for i in range(1,26):
            items.append((i-1,QListWidgetItem(QIcon(os.path.join(redREnviron.directoryNames['picsDir'],
            'R icon (%d).png' %i)),'')))
        
        for i in range(32,128):
            items.append((i-1,'%s' % (chr(i))))
            
        self.optionWidgets['pointListBox'] = listBox(pointBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection, items = items)
        


        self.setTheme(self.options)
    ################################
    ### right click menu     #######
    ################################
        self.menu = QMenu(self)
        save = self.menu.addMenu('Save As')
        save.addAction('Bitmap')
        save.addAction('PDF')
        save.addAction('PDF (LATEX)')
        save.addAction('Post Script')
        save.addAction('JPEG')
        if sys.platform == 'win32':
            save.addAction('WMF')
        self.menu.addAction('Copy')
        self.menu.addAction('Fit In Window')
        self.menu.addAction('Zoom Out')
        self.menu.addAction('Zoom In')
        #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'
        QObject.connect(self.dialog, SIGNAL('finished(int)'), self.dialogClosed)

        
        self.graphicOptionsWidget.hide()
Пример #22
0
    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)
        # if displayLabel:
            # self.controlArea = groupBox(parent,label=label, orientation='vertical')
        # else:
            # self.controlArea = widgetBox(parent,orientation='vertical')
        
        #self.controlArea = widgetBox(parent)
        self.topArea = widgetBox(self.controlArea,
        sizePolicy = QSizePolicy(QSizePolicy.Minimum,QSizePolicy.Maximum),includeInReports=False)
        self.middleArea = widgetBox(self.controlArea)
        self.bottomArea = widgetBox(self.controlArea,includeInReports=False)
        
        self.middleArea.layout().addWidget(self)  # place the widget into the parent widget
        scene = QGraphicsScene()
        self.setScene(scene)
        self.parent = parent
        self.data = data
        
        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
        self.customPlotFunction = None
        self.controlGroups = {}
        self.tabs = {}
    ################################
    ####   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,
                        }
                    ,'xlim': {
                        'default':None, 
                        'qtWidget':['xstart','xend'],
                        'getFunction': self.getLimits,
                        'setFunction': self.setLimits,                    
                    }
                    ,'ylim': {
                        'default':None, 
                        'qtWidget':['ystart','yend'],
                        'getFunction': self.getLimits,
                        'setFunction': self.setLimits,                    
                    }
                }
            },
            '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' 
                          # }
                }
            }
        }
        # ,'fg' : None
        # ,'legendNames' : None
        # ,'legendLocation' : "'bottomleft'"
        # }
        
        self.optionWidgets = {}
        self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff']       


    ################################
    ####   Setup Tabs          #####
    ################################
        self.graphicOptionsButton = button(self.topArea,label='Graphic Options',
        toggleButton = True,callback=self.displayGraphicOptions)
        self.graphicOptionsWidget = widgetBox(self.topArea)
        self.tabWidget = tabWidget(self.graphicOptionsWidget)
        self.tabWidget.setFixedHeight(180)
        hbox = widgetBox(self.graphicOptionsWidget,orientation='horizontal',alignment= Qt.AlignLeft)
        self.resizeCheck = checkBox(hbox,label='resize',displayLabel=False,buttons={'true':'Resize Image'},setChecked='true')
        button(hbox,label='Update Graphic', alignment=Qt.AlignLeft, callback=self.updatePlot)
        
        self.createTab('General')
        self.createTab('Points/Lines')
        self.createTab('Advanced')

    ################################
    ####   Advanced Tabs       #####
    ################################
        imageBox = self.createControlGroup('Advanced',label='Image Properties')
        self.optionWidgets['extrasLineEdit'] = lineEdit(imageBox, label = 'Advanced plotting parameters', 
        orientation='horizontal',
        toolTip = 'Add extra parameters to the main plot.\nPlease see documentation for more details about parameters.')
        
        self.optionWidgets['onlyAdvanced'] = checkBox(imageBox,
        buttons=['Only use the advanced options here'],
        label='advancedOnly',displayLabel=False)

    ################################
    ####   First Tabs          #####
    ################################
        imageBox = self.createControlGroup('General',label='Image Properties')
        # imageBox = groupBox(firstTab,label='Image Properties', orientation='vertical',
        # sizePolicy = QSizePolicy(QSizePolicy.Maximum ,QSizePolicy.Minimum))
        
        self.optionWidgets['imageType'] = comboBox(imageBox,label='Image Type',items=['svg','png'])
        self.optionWidgets['imageType'].setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Minimum)
        
        hbox = widgetBox(imageBox,orientation='horizontal')
        self.optionWidgets['dheight'] = spinBox(hbox, label = 'Height', min = 1, max = 5000, value = 400)
        self.optionWidgets['dwidth'] = spinBox(hbox, label = 'Width', min = 1, max = 5000, value = 400)
        hbox = widgetBox(imageBox,orientation='horizontal')
        self.optionWidgets['units'] = comboBox(hbox,label='units',items=[('px','Pixel'),('in','Inches')])
        self.optionWidgets['dpi'] = comboBox(hbox,label='DPI',items=['75','100','150','auto'],editable=True)
        
        
        labelBox = self.createControlGroup('General',label='Labels')
        
        self.optionWidgets['mainTitle'] = lineEdit(labelBox,label='Main Title')
        self.optionWidgets['xLab'] = lineEdit(labelBox,label='X Axis Label')        
        self.optionWidgets['yLab'] = lineEdit(labelBox,label='Y Axis Label')

        
        fontBox = self.createControlGroup('General',label='Sizes')
        fontColumnBox = widgetBox(fontBox,orientation='horizontal')
        fontColumn1 = widgetBox(fontColumnBox,orientation='vertical')
        fontColumn2 = widgetBox(fontColumnBox,orientation='vertical')
        
        #self.optionWidgets['fontCombo'] = comboBox(fontColumn1, items = ['serif', 'sans', 'mono'], label='Font Family')
        
        self.optionWidgets['lineWidth'] = spinBox(fontColumn1,label='Point/Line Size',decimals=2,min=1,max=50)
        self.optionWidgets['plotFont'] = spinBox(fontColumn1, label = 'Plot Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['axisFont'] = spinBox(fontColumn1, label = 'Axis Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['mainFont'] = spinBox(fontColumn2, label = 'Title Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['subFont'] = spinBox(fontColumn2, label = 'Subtitle Text Size',decimals=2, min = 1, max = 50)
        self.optionWidgets['labFont'] = spinBox(fontColumn2, label = ' XY Label Text Size',decimals=2, min = 1, max = 50)
        
        limitBox = self.createControlGroup('General',label='Limits')
        col2Box = widgetBox(limitBox,orientation='horizontal')
        column1 = widgetBox(col2Box,orientation='vertical')
        column2 = widgetBox(col2Box,orientation='vertical')

        self.optionWidgets['xstart'] = lineEdit(column1,label='X Start', width=40)
        self.optionWidgets['xend'] = lineEdit(column2,label='X End', width=40)
        self.optionWidgets['ystart'] = lineEdit(column1,label='Y Start', width=40)
        self.optionWidgets['yend'] = lineEdit(column2,label='Y End', width=40)
        

    
    ################################
    ####   Second Tabs         #####
    ################################
        colorBox = self.createControlGroup('Points/Lines',label='Colors')
        hbox = widgetBox(colorBox,orientation='horizontal')

        self.optionWidgets['colorSeries'] = comboBox(hbox,label='Generate Colors Series',orientation='vertical',
        items = ['select','rainbow','heat.colors','terrain.colors','topo.colors','cm.colors'])
        self.optionWidgets['colorSeriesLen'] = spinBox(hbox,label='Length of Series',displayLabel=False, min=0, max=500)
        hbox.layout().setAlignment(self.optionWidgets['colorSeriesLen'].controlArea, Qt.AlignBottom)
        
        self.optionWidgets['bgColor'] = ColorIcon(colorBox,label='Background')

        #self.optionWidgets['customColors'] = button(colorBox,label='Custom Plot Colors',callback=self.setPlotColors)
        colorBox2 = self.createControlGroup('Points/Lines',label='More Colors')
        
        # colorColumnBox = widgetBox(colorBox2,orientation='horizontal')
        # colorColumn1 = widgetBox(colorColumnBox,orientation='vertical')
        # colorColumn2 = widgetBox(colorColumnBox,orientation='vertical')
      
         
        self.optionWidgets['titleColor'] = ColorIcon(colorBox2,label='Title')
        self.optionWidgets['subColor'] = ColorIcon(colorBox2,label='Subtitle')
        self.optionWidgets['labColor'] = ColorIcon(colorBox2,label='Subtitle')
        self.optionWidgets['axisColor'] = ColorIcon(colorBox2,label='Axis')
        
        lineBox = self.createControlGroup('Points/Lines',label='Lines')
       
        self.optionWidgets['linesListBox'] = listBox(lineBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection,
        items = [(1,'________'), (2,'- - - -'), (3,'........'), (4,'_._._._.'), 
        (5,'__ __ __'), (6,'__.__.__.')])
        
        
        
        pointBox = self.createControlGroup('Points/Lines',label='Points')
        
        items = []
        for i in range(1,26):
            items.append((i-1,QListWidgetItem(QIcon(os.path.join(redREnviron.directoryNames['picsDir'],
            'R icon (%d).png' %i)),'')))
        
        for i in range(32,128):
            items.append((i-1,'%s' % (chr(i))))
            
        self.optionWidgets['pointListBox'] = listBox(pointBox, label = 'Line types', displayLabel=False,
        selectionMode = QAbstractItemView.ExtendedSelection, items = items)
        


        self.setTheme(self.options)
    ################################
    ### 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')
        self.menu.addAction('Copy')
        self.menu.addAction('Fit In Window')
        self.menu.addAction('Zoom Out')
        self.menu.addAction('Zoom In')
        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'
        QObject.connect(self.dialog, SIGNAL('finished(int)'), self.dialogClosed)
Пример #23
0
    def __init__(self, parent=None, signalManager=None):
        #OWWidget.__init__(self, parent, signalManager, "Sample Data")
        OWRpy.__init__(self, wantGUIDialog=1)

        self.command = ''
        self.sendthis = ''
        self.sendt = {}
        self.dfselected = None
        self.setRvariableNames(['rExecutor', 'rExecutor_cm'])

        self.inputs.addInput('id0', _('R.object'), redRRVariable, self.process)

        self.outputs.addOutput('id0', _('R Data Frame'), redRRDataFrame)
        self.outputs.addOutput('id1', _('R List'), redRRList)
        self.outputs.addOutput('id2', _('R Vector'), redRRVector)
        self.outputs.addOutput('id3', _('R.object'), 'All')
        self.outputs.addOutput('id4', _('R Matrix'), redRRMatrix)

        #self.breakme()

        #self.help.setHtml('The R Executor widget provides direct access to the R session that runs under RedR.  R Executor can recieve any output from an R compatible widget.  The recieved data can be shown using the Recieved button.  The R history can be shown by pressing the RHistory button and the complete parsing of any recieved data is shown in the Metadata section.  More infromation is available on the <a href="http://www.red-r.org/?cat=10">RedR website</a>.')

        #GUI

        #GUIDialog
        self.box = groupBox(self.GUIDialog, _("R Executor Advanced"))
        self.infob = widgetLabel(self.box, "")

        self.infoa = widgetLabel(self.box, "")
        # grid
        area = widgetBox(self.controlArea, orientation='horizontal')
        area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

        leftArea = widgetBox(self.box)
        leftArea.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Expanding)
        rightArea = widgetBox(area)

        runbox = groupBox(rightArea,
                          label=_("Command Edit:"),
                          orientation='horizontal')
        runbox.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
        #self.command = lineEdit(runbox, "", orientation=QHBoxLayout(), callback = self.runR, width = -1)
        self.command = textEdit(runbox, label=_('Command Edit:'))
        #self.command.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        processbutton = button(runbox,
                               label=_("&Run"),
                               callback=self.runR,
                               width=100)
        statusBox = groupBox(rightArea, label=_("Status"))
        self.sendStatus = widgetLabel(statusBox, _('Nothing Sent'))
        self.dataBox = groupBox(leftArea, label=_("Input Infromation"))
        self.mystatus = widgetLabel(self.dataBox, _("No Input"))

        # self.metadataBox = widgetBox(leftArea, _("Metadata"))
        # self.infoM = widgetLabel(self.metadataBox, _("No Meta Data"))
        # self.metadataLB = listBox(self.metadataBox, callback = self.insertMetaDataVar)
        varbutton = button(leftArea,
                           _("Recieved"),
                           callback=self.putrecieved,
                           width=150)
        history = button(leftArea,
                         _("RHistory"),
                         callback=self.putRHistory,
                         width=150)
        button(leftArea, _("Clear Output"), callback=self.clearOutput)

        self.lsList = listBox(self.box,
                              label=_('Available R Items'),
                              items=self.R('ls()', wantType='list'),
                              callback=self.addlsList)
        button(self.box, 'Refresh List', callback=self.refreshLsList)

        self.thistext = textEdit(rightArea,
                                 label=_('Output'),
                                 displayLabel=False)

        sendbutton = button(
            runbox,
            label=_("&Send"),
            toolTip=_(
                'Send the data in the command line into the Red-R schema.'),
            callback=self.sendThis,
            width=100)
Пример #24
0
 def setSettings(self,settings, globalSettings = False):
     redRLog.log(redRLog.REDRCORE, redRLog.DEBUG, 'Loading settings')
     #settings = self.sqlite.setObject(settingsID)
     # import pprint
     # pp = pprint.PrettyPrinter(indent=4)
     # pp.pprint(settings)
     for k,v in settings.iteritems():
         try:
             #redRLog.log(redRLog.REDRCORE, redRLog.ERROR, 'Loading %s' % k)
             if k in ['inputs', 'outputs']: continue
             if v == None:
                 continue
             elif 'pythonObject' in v.keys():
                 #print '|#| Setting pythonObject %s to %s' % (k,unicode(v['pythonObject']))
                 self.__setattr__(k, v['pythonObject'])
             elif 'signalsObject' in v.keys():
                 #print '|#| Setting signalsObject'
                 varClass = self.setSignalClass(v['signalsObject'])
                 self.__setattr__(k, varClass)
             elif 'sentItemsList' in v.keys():
                 #print '|#| settingItemsList'
                 # print v['sentItemsList']
                 #self.setSentItemsList(v['sentItemsList'])        
                 for (sentItemName, sentItemDict) in v['sentItemsList']:
                     #print '|#| setting sent items %s to %s' % (sentItemName, unicode(sentItemDict))
                     #for kk,vv in sentItemDict.items():
                     var = self.setSignalClass(sentItemDict)
                     ## add compatibility layer for the case that the sent item name is not longer in existance or has changed
                     if sentItemName in self.outputs.outputIDs():
                         self.send(sentItemName, var)
                     else:
                         signalItemNames = [name for (key, name) in self.outputs.outputNames().items()]
                         if sentItemName in signalItemNames:
                             signalID = self.outputs.getSignalByName(sentItemName)
                             self.send(signalID, var)
                         else:
                             #print 'Error in matching item name'
                             from libraries.base.qtWidgets.dialog import dialog
                             tempDialog = dialog(None)
                             from libraries.base.qtWidgets.widgetLabel import widgetLabel
                             from libraries.base.qtWidgets.listBox import listBox
                             from libraries.base.qtWidgets.button import button
                             widgetLabel(tempDialog, 'Error occured in matching the loaded signal (Name:%s, Value:%s) to the appropriate signal name.\nPlease select the signal that matches the desired output,\n or press cancel to abandon the signal.' % (sentItemName, unicode(var)))
                             
                             #print self.outputs.outputSignals
                             itemListBox = listBox(tempDialog, items = signalItemNames)
                             button(tempDialog, label = 'Done', callback = tempDialog.accept)
                             button(tempDialog, label = 'Cancel', callback = tempDialog.reject)
                             res = tempDialog.exec_()
                             if res != QDialog.rejected:
                                 signalName = unicode(itemListBox.selectedItems()[0].text())
                                 signalID = self.outputs.getSignalByName(signalName)
                                 self.send(signalID, var)
 #############################################
             elif not hasattr(self,k):
                 continue
             elif 'redRGUIObject' in v.keys():
                 #print getattr(self, k)
                 try:
                     getattr(self, k).loadSettings(v['redRGUIObject'])
                     getattr(self, k).setDefaultState(v['redRGUIObject'])
                 except Exception as inst:
                     #print 'Exception occured during loading of settings.  These settings may not be the same as when the widget was closed.'
                     redRLog.log(redRLog.REDRCORE, redRLog.ERROR,redRLog.formatException())
             elif 'dict' in v.keys():
                 var = getattr(self, k)
                 #print 'dict',len(var),len(v['dict'])
                 if len(var) != len(v['dict']): continue
                 self.recursiveSetSetting(var,v['dict'])
             elif 'list' in v.keys():
                 var = getattr(self, k)
                 # print 'list',len(var),len(v['list'])
                 if len(var) != len(v['list']): continue
                 self.recursiveSetSetting(var,v['list'])
         except:
             redRLog.log(redRLog.REDRCORE, redRLog.ERROR, 'Exception occured during loading. The Error will be ignored.')
             redRLog.log(redRLog.REDRCORE, redRLog.DEBUG, redRLog.formatException())