def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self) self.setRvariableNames(['heatsubset']) self.plotOnConnect = 0 self.plotdata = '' self.rowvChoice = None self.inputs.addInput('id0', 'Expression Matrix', redRRMatrix, self.processMatrix) #GUI mainArea = widgetBox(self.controlArea,orientation='horizontal') #mainArea.setMaximumWidth(300) options = widgetBox(mainArea,orientation='vertical') options.setMaximumWidth(175) options.setMinimumWidth(175) dendrogramsBox = groupBox(options, label='Calculate dendrogram ', orientation='vertical') self.notice = widgetLabel(dendrogramsBox,label='The data set has > 1000 rows.\nClustering on rows will likely fail.') self.notice.setHidden(True) self.dendrogramOptions = checkBox(dendrogramsBox, buttons = ['Rows', 'Columns'], setChecked=['Rows', 'Columns'], orientation='horizontal', callback=self.dendrogramChanged) functions = widgetBox(dendrogramsBox,orientation='vertical') self.distOptions = lineEdit(functions,label='Distance Function:', text='dist', orientation='vertical') self.hclustOptions = lineEdit(functions,label='Clustering Function:',text='hclust', orientation='vertical') #self.reorderOptions = lineEdit(functions,label='Reorder Function:', text='reorder.dendrogram') self.scaleOptions = radioButtons(options,label='Scale', buttons=['row','column','none'], setChecked='row',orientation='horizontal') otherOptions = groupBox(options,label='Other Options') self.narmOptions = checkBox(otherOptions, buttons = ['Remove NAs'], setChecked=['Remove NAs']) # self.showDendroOptions = checkBox(otherOptions,buttons=['Show dendrogram '], setChecked=['Show dendrogram ']) self.colorTypeCombo = comboBox(otherOptions, label = 'Color Type:', items = ['rainbow', 'heat.colors', 'terrain.colors', 'topo.colors', 'cm.colors'],callback=self.colorTypeChange) self.startSaturation = spinBox(otherOptions, label = 'Starting Saturation', min = 0, max = 100) self.endSaturation = spinBox(otherOptions, label = 'Ending Saturation', min = 0, max = 100) self.endSaturation.setValue(30) separator(otherOptions,height=10) self.imageWidth = spinBox(otherOptions, label = 'Image Width', min = 1, max = 1000) self.imageWidth.setValue(4) self.imageHeight = spinBox(otherOptions, label = 'Image Height', min = 1, max = 1000) self.imageHeight.setValue(4) self.notice2 = widgetLabel(options,label='The input matrix is not numeric.') self.notice2.setHidden(True) self.buttonsBox = widgetBox(options,orientation='horizontal') self.buttonsBox.layout().setAlignment(Qt.AlignRight) self.plotOnConnect = checkBox(self.buttonsBox, buttons=['Plot on Connect']) button(self.buttonsBox, label = "Plot", callback=self.makePlot)
def addSpinBox(self, key, name, items): """Adds a new spinBox to the DynamicSpinBox""" print 'Adding spinbox %s' % key if key in self.spinBoxes.keys(): redRLog.log(redRLog.REDRCORE, redRLog.DEBUG, 'key exists, loading applying settings') self.spinBoxes[key].setMaximum(items[0]) self.spinBoxes[key].setMinimum(items[1]) self.spinBoxes[key].setValue(items[2]) self.spinBoxes[key].setDecimals(items[3]) else: self.spinBoxes[key] = spinBox(self, label = name, max = items[0], min = items[1], value = items[2], decimals = items[3], orientation = self.orientation, callback = self.callback, toolTip = self.toolTip)
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)
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)
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, parent,label=_('Graph'), 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. self.R = RSession.Rcommand self.require_librarys = RSession.require_librarys widgetState.__init__(self,parent,label,includeInReports) QGraphicsView.__init__(self, self.controlArea) if displayLabel: self.controlArea = groupBox(self.controlArea,label=label, orientation='vertical') else: self.controlArea = widgetBox(self.controlArea,orientation='vertical') #self.controlArea = widgetBox(parent) self.topArea = widgetBox(self.controlArea) self.middleArea = widgetBox(self.controlArea) self.bottomArea = widgetBox(self.controlArea) self.middleArea.layout().addWidget(self) # place the widget into the parent widget scene = QGraphicsScene() self.setScene(scene) self.parent = self.controlArea self.widgetSelectionRect = None self.mainItem = None self.query = '' self.function = 'plot' self.data = data self.layers = [] self._bg = None self._cex = None self._cexAxis = None self._cexLab = None self._cexMain = None self._cexSub = None self._col = None self._colAxis = None self._colMain = None self._colSub = None self._family = None self._fg = None self._lty = None self._lwd = None self._legendNames = None self._legendLocation = 'bottomleft' self._pch = None self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff'] self._replotAfterChange = True self._dheight = 4 self._dwidth = 4 self.image = 'plot'+unicode(time.time()) # the base file name without an extension self.imageFileName = '' self.currentScale = 1 ## bottom menu bar self.menuBar = QMenuBar(self.bottomArea) self.bottomArea.layout().addWidget(self.menuBar) self.menuParameters = QMenu(_('Parameters'), self) colors = self.menuParameters.addMenu(_('Colors')) colors.addAction(_('Set Plotting Colors'), self.setPlotColors) colors.addAction(_('Set Axis Colors'), self.setAxisColors) colors.addAction(_('Set Label Colors'), self.setLabelColors) colors.addAction(_('Set Main Title Color'), self.setTitleColors) colors.addAction(_('Set Subtitle Color'), self.setSubtitleColors) colors.addAction(_('Set Forground Color'), self.setForgroundColors) colors.addAction(_('Set Background Color'), self.setBackgroundColors) font = self.menuParameters.addMenu(_('Font')) ffa = font.addMenu(_('Set Font Family')) legend = self.menuParameters.addMenu(_('Legend')) ll = legend.addMenu(_('Legend Location')) ll.addAction(_('Set to bottom right'), lambda x = 'bottomright': self._setLegendLocation(x)) ll.addAction(_('Set to bottom left'), lambda x = 'bottomleft': self._setLegendLocation(x)) ll.addAction(_('Set to top right'), lambda x = 'topleft': self._setLegendLocation(x)) ll.addAction(_('Set to top left'), lambda x = 'topright': self._setLegendLocation(x)) fontComboAction = QWidgetAction(font) self.fontCombo = comboBox(None, items = ['serif', 'sans', 'mono'], label='fonts', displayLabel=False, #'HersheySerif', 'HersheySans', 'HersheyScript', #'HersheyGothicEnglish', 'HersheyGothicGerman', 'HersheyGothicItalian', 'HersheySymbol', 'HersheySansSymbol'], callback = self.setFontFamily) fontComboAction.setDefaultWidget(self.fontCombo) ffa.addAction(fontComboAction) #font.addAction(_('Set Font Magnification'), self.setFontMagnification) wb = widgetBox(None) self.fontMag = spinBox(wb, label = 'Font Magnification:', min = 0, max = 500, value = 100) #, callback = self.setFontMagnification) QObject.connect(self.fontMag, SIGNAL('editingFinished ()'), self.setFontMagnification) ## must define ourselves because the function calls the attribute and this causes an error in Qt magAction = QWidgetAction(font) magAction.setDefaultWidget(wb) font.addAction(magAction) self.menuParameters.setToolTip(_('Set the parameters of the rendered image.\nThese parameters are standard graphics parameters which may or may not be applicable or rendered\ndepending on the image type and the settings of the plotting widget.')) fa = font.addMenu(_('Font Attributes')) lines = self.menuParameters.addMenu(_('Lines')) lines.addAction(_('Set Line Type'), self.setLineType) lines.addAction(_('Set Line Width'), self.setLineWidth) points = self.menuParameters.addMenu(_('Points')) points.addAction(_('Set Point Characters'), self.setPointCharacters) self.imageParameters = QMenu(_('Image'), self) type = self.imageParameters.addMenu(_('Type')) type.addAction(_('Set Image Vector Graphics'), self.setImageSVG).setToolTip(_('Renders the image using vector graphics which are scaleable and zoomable,\nbut may not show all graphical options such as forground color changes.')) type.addAction(_('Set Image Bitmap Graphics'), self.setImagePNG).setToolTip(_('Redners the image using bitmap graphics which will become distorted on zooming,\nbut will show all graphical options.')) #type.addAction(_('Set Image JPEG'), self.setImageJPEG) type.setToolTip(_('Changes the plotting type of the rendered image.\nDifferent image types may enable or disable certain graphics parameters.')) self.fileParameters = QMenu(_('File'), self) save = self.fileParameters.addMenu(_('Save')) save.addAction(_('Bitmap'), self.saveAsBitmap) save.addAction(_('PDF'), self.saveAsPDF) save.addAction(_('Post Script'), self.saveAsPostScript) save.addAction(_('JPEG'), self.saveAsJPEG) printScene = self.fileParameters.addAction(_('Print'), self.printMe) self.menuBar.addMenu(self.fileParameters) self.menuBar.addMenu(self.menuParameters) #self.menuBar.addMenu(self.imageParameters) ### lower Line Edit self.extrasLineEdit = lineEdit(self.bottomArea, label = _('Advanced plotting parameters'), toolTip = _('Add extra parameters to the main plot.\nPlease see documentation for more details about parameters.'), callback = self.replot) ### 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' self.plotExactlySwitch = False ## a switch that can be activated to allow plotting exactly as the plot is sent, no function generation will be performed and all attribute alteration will be disabled QObject.connect(self.dialog, SIGNAL('finished(int)'), self.dialogClosed)
def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self) self.setRvariableNames(['heatsubset']) self.plotOnConnect = 0 self.plotdata = '' self.rowvChoice = None self.inputs.addInput('id0', 'Expression Matrix', redRRMatrix, self.processMatrix) #GUI mainArea = widgetBox(self.controlArea, orientation='horizontal') #mainArea.setMaximumWidth(300) options = widgetBox(mainArea, orientation='vertical') options.setMaximumWidth(175) options.setMinimumWidth(175) dendrogramsBox = groupBox(options, label='Calculate dendrogram ', orientation='vertical') self.notice = widgetLabel( dendrogramsBox, label= 'The data set has > 1000 rows.\nClustering on rows will likely fail.' ) self.notice.setHidden(True) self.dendrogramOptions = checkBox(dendrogramsBox, buttons=['Rows', 'Columns'], setChecked=['Rows', 'Columns'], orientation='horizontal', callback=self.dendrogramChanged) functions = widgetBox(dendrogramsBox, orientation='vertical') self.distOptions = lineEdit(functions, label='Distance Function:', text='dist', orientation='vertical') self.hclustOptions = lineEdit(functions, label='Clustering Function:', text='hclust', orientation='vertical') #self.reorderOptions = lineEdit(functions,label='Reorder Function:', text='reorder.dendrogram') self.scaleOptions = radioButtons(options, label='Scale', buttons=['row', 'column', 'none'], setChecked='row', orientation='horizontal') otherOptions = groupBox(options, label='Other Options') self.narmOptions = checkBox(otherOptions, buttons=['Remove NAs'], setChecked=['Remove NAs']) # self.showDendroOptions = checkBox(otherOptions,buttons=['Show dendrogram '], setChecked=['Show dendrogram ']) self.colorTypeCombo = comboBox(otherOptions, label='Color Type:', items=[ 'rainbow', 'heat.colors', 'terrain.colors', 'topo.colors', 'cm.colors' ], callback=self.colorTypeChange) self.startSaturation = spinBox(otherOptions, label='Starting Saturation', min=0, max=100) self.endSaturation = spinBox(otherOptions, label='Ending Saturation', min=0, max=100) self.endSaturation.setValue(30) separator(otherOptions, height=10) self.imageWidth = spinBox(otherOptions, label='Image Width', min=1, max=1000) self.imageWidth.setValue(4) self.imageHeight = spinBox(otherOptions, label='Image Height', min=1, max=1000) self.imageHeight.setValue(4) self.notice2 = widgetLabel(options, label='The input matrix is not numeric.') self.notice2.setHidden(True) self.buttonsBox = widgetBox(options, orientation='horizontal') self.buttonsBox.layout().setAlignment(Qt.AlignRight) self.plotOnConnect = checkBox(self.buttonsBox, buttons=['Plot on Connect']) button(self.buttonsBox, label="Plot", callback=self.makePlot)
def __init__(self, parent=None, signalManager=None): OWRpy.__init__(self) self.setRvariableNames(['heatsubset', 'hclust', 'heatvect']) self.plotOnConnect = 0 self.plotdata = '' self.rowvChoice = None self.colvChoice = None self.listOfColors = ['"red"', '"white"', '"blue"'] self.inputs.addInput('id0', 'Expression Matrix', redRRDataFrame, self.processMatrix) self.inputs.addInput('id1', 'Classes Data', redRRVector, self.processClasses) #self.outputs.addOutput('id0', 'Cluster Subset List', redRRVector) self.outputs.addOutput('id1', 'Cluster Classes', redRRVector) #GUI infobox = groupBox(self.controlArea, label="Options") self.commit = redRCommitButton(self.bottomAreaRight, label="Replot", callback=self.makePlot, width=200, processOnInput=True) button(infobox, label='Identify', callback=self.identify, width=200) self.groupOrHeight = radioButtons(infobox, label='Identify by:', buttons=['Groups', 'Height'], setChecked='Groups', orientation='horizontal') self.groupOrHeightSpin = spinBox(infobox, label='Identify Value:', min=1, value=5) self.startSaturation = spinBox(infobox, label='Starting Saturation:', min=0, max=100) self.endSaturation = spinBox(infobox, label='Ending Saturation:', min=0, max=100) self.endSaturation.setValue(30) redRButton(self.controlArea, label='Reset Colors', callback=self.resetColors) #self.classesDropdown = comboBox(infobox, label = 'Classes:', toolTip = 'If classes data is connected you may select columns in the data to represent classes of your columns in the plotted data') self.rowDendrogram = checkBox( infobox, label='Dendrogram Options', displayLabel=False, buttons=['Plot Row Dendrogram', 'Plot Column Dendrogram'], setChecked=['Plot Row Dendrogram', 'Plot Column Dendrogram']) self.showClasses = checkBox(infobox, label='Show Classes', displayLabel=False, buttons=['Show Classes']) self.showClasses.setEnabled(False) #OWGUI.checkBox(infobox, self, ) self.infoa = widgetLabel(infobox, label="Nothing to report") self.gview1 = graphicsView(self.controlArea, label='Heatmap', displayLabel=False) self.gview1.image = 'heatmap1_' + self.widgetID
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)
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()
def __init__(self, parent,label=_('Graph'), displayLabel=True,name = '', data = None,**kwargs): ## want to init a graphics view with a new graphics scene, the scene will be accessable through the widget. kwargs.setdefault('includeInReports', True) kwargs.setdefault('sizePolicy', QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)) widgetState.__init__(self,parent,label,**kwargs) QGraphicsView.__init__(self, self.controlArea) self.R = RSession.Rcommand self.require_librarys = RSession.require_librarys if displayLabel: self.controlArea = groupBox(self.controlArea,label=label, orientation='vertical') else: self.controlArea = widgetBox(self.controlArea,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) self.middleArea.layout().addWidget(self) # place the widget into the parent widget scene = QGraphicsScene() self.setScene(scene) self.parent = self.controlArea self.widgetSelectionRect = None self.mainItem = None self.query = '' self.function = 'plot' self.data = data self.layers = [] self._bg = None self._cex = None self._cexAxis = None self._cexLab = None self._cexMain = None self._cexSub = None self._col = None self._colAxis = None self._colMain = None self._colSub = None self._family = None self._fg = None self._lty = None self._lwd = None self._legendNames = None self._legendLocation = 'bottomleft' self._pch = None self.colorList = ['#000000', '#ff0000', '#00ff00', '#0000ff'] self._replotAfterChange = True self._dheight = 4 self._dwidth = 4 self.image = 'plot'+unicode(time.time()) # the base file name without an extension self.imageFileName = '' self.currentScale = 1 ## bottom menu bar self.menuBar = QMenuBar(self.bottomArea) self.bottomArea.layout().addWidget(self.menuBar) self.menuParameters = QMenu(_('Parameters'), self) colors = self.menuParameters.addMenu(_('Colors')) colors.addAction(_('Set Plotting Colors'), self.setPlotColors) colors.addAction(_('Set Axis Colors'), self.setAxisColors) colors.addAction(_('Set Label Colors'), self.setLabelColors) colors.addAction(_('Set Main Title Color'), self.setTitleColors) colors.addAction(_('Set Subtitle Color'), self.setSubtitleColors) colors.addAction(_('Set Forground Color'), self.setForgroundColors) colors.addAction(_('Set Background Color'), self.setBackgroundColors) font = self.menuParameters.addMenu(_('Font')) ffa = font.addMenu(_('Set Font Family')) legend = self.menuParameters.addMenu(_('Legend')) ll = legend.addMenu(_('Legend Location')) ll.addAction(_('Set to bottom right'), lambda x = 'bottomright': self._setLegendLocation(x)) ll.addAction(_('Set to bottom left'), lambda x = 'bottomleft': self._setLegendLocation(x)) ll.addAction(_('Set to top right'), lambda x = 'topleft': self._setLegendLocation(x)) ll.addAction(_('Set to top left'), lambda x = 'topright': self._setLegendLocation(x)) fontComboAction = QWidgetAction(font) self.fontCombo = comboBox(None, items = ['serif', 'sans', 'mono'], label='fonts', displayLabel=False, #'HersheySerif', 'HersheySans', 'HersheyScript', #'HersheyGothicEnglish', 'HersheyGothicGerman', 'HersheyGothicItalian', 'HersheySymbol', 'HersheySansSymbol'], callback = self.setFontFamily) fontComboAction.setDefaultWidget(self.fontCombo) ffa.addAction(fontComboAction) #font.addAction(_('Set Font Magnification'), self.setFontMagnification) wb = widgetBox(None) self.fontMag = spinBox(wb, label = _('Font Magnification:'), min = 0, max = 500, value = 100) #, callback = self.setFontMagnification) QObject.connect(self.fontMag, SIGNAL('editingFinished ()'), self.setFontMagnification) ## must define ourselves because the function calls the attribute and this causes an error in Qt magAction = QWidgetAction(font) magAction.setDefaultWidget(wb) font.addAction(magAction) self.menuParameters.setToolTip(_('Set the parameters of the rendered image.\nThese parameters are standard graphics parameters which may or may not be applicable or rendered\ndepending on the image type and the settings of the plotting widget.')) fa = font.addMenu(_('Font Attributes')) lines = self.menuParameters.addMenu(_('Lines')) lines.addAction(_('Set Line Type'), self.setLineType) lines.addAction(_('Set Line Width'), self.setLineWidth) points = self.menuParameters.addMenu(_('Points')) points.addAction(_('Set Point Characters'), self.setPointCharacters) self.imageParameters = QMenu(_('Image'), self) type = self.imageParameters.addMenu(_('Type')) type.addAction(_('Set Image Vector Graphics'), self.setImageSVG).setToolTip(_('Renders the image using vector graphics which are scaleable and zoomable,\nbut may not show all graphical options such as forground color changes.')) type.addAction(_('Set Image Bitmap Graphics'), self.setImagePNG).setToolTip(_('Redners the image using bitmap graphics which will become distorted on zooming,\nbut will show all graphical options.')) #type.addAction(_('Set Image JPEG'), self.setImageJPEG) type.setToolTip(_('Changes the plotting type of the rendered image.\nDifferent image types may enable or disable certain graphics parameters.')) self.fileParameters = QMenu(_('File'), self) save = self.fileParameters.addMenu(_('Save')) save.addAction(_('Bitmap'), self.saveAsBitmap) save.addAction(_('PDF'), self.saveAsPDF) save.addAction(_('Post Script'), self.saveAsPostScript) save.addAction(_('JPEG'), self.saveAsJPEG) if sys.platform == 'win32': save.addAction('WMF', self.saveAsWMF) printScene = self.fileParameters.addAction(_('Print'), self.printMe) self.menuBar.addMenu(self.fileParameters) self.menuBar.addMenu(self.menuParameters) #self.menuBar.addMenu(self.imageParameters) ### lower Line Edit self.extrasLineEdit = lineEdit(self.bottomArea, label = _('Advanced plotting parameters'), toolTip = _('Add extra parameters to the main plot.\nPlease see documentation for more details about parameters.'), callback = self.replot) ### 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' self.plotExactlySwitch = False ## a switch that can be activated to allow plotting exactly as the plot is sent, no function generation will be performed and all attribute alteration will be disabled 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()