def _loadWidgets(self): """ Load the widgets in the Groupbox """ baseNumberChoices = ('None (default)', 'Strands and segments', 'Strands only', 'Segments only') self._baseNumberComboBox = \ PM_ComboBox( self, label = "Base numbers:", choices = baseNumberChoices, setAsDefault = True) numberingOrderChoices = ('5\' to 3\' (default)', '3\' to 5\'' ) self._baseNumberingOrderComboBox = \ PM_ComboBox( self, label = "Base numbers:", choices = numberingOrderChoices, setAsDefault = True) prefs_key = dnaBaseNumberLabelColor_prefs_key self._baseNumberLabelColorChooser = \ PM_ColorComboBox(self, color = env.prefs[prefs_key])
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ includeStrandsChoices = [ "All strands in model", "Selected strands only" ] self.includeStrandsComboBox = \ PM_ComboBox( pmGroupBox, label = "Include strands:", choices = includeStrandsChoices, setAsDefault = True) self.numberOfBasesLineEdit = \ PM_LineEdit( pmGroupBox, label = "Total nucleotides:", text = str(self.getNumberOfBases())) self.numberOfBasesLineEdit.setEnabled(False) self.numberOfXBasesLineEdit = \ PM_LineEdit( pmGroupBox, label = "Unassigned:", text = str(self.getNumberOfBases(unassignedOnly = True))) self.numberOfXBasesLineEdit.setEnabled(False) self.viewDnaOrderFileButton = \ PM_PushButton( pmGroupBox, label = "", text = "View DNA Order File...", spanWidth = True) return
def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box 4. """ self.conformationComboBox = \ PM_ComboBox( pmGroupBox, label = "Conformation:", choices = ["B-DNA"], setAsDefault = True) dnaModelChoices = ['PAM3', 'PAM5'] self.dnaModelComboBox = \ PM_ComboBox( pmGroupBox, label = "Model:", choices = dnaModelChoices, setAsDefault = True) self.basesPerTurnDoubleSpinBox = \ PM_DoubleSpinBox( pmGroupBox, label = "Bases per turn:", value = env.prefs[bdnaBasesPerTurn_prefs_key], setAsDefault = True, minimum = 8.0, maximum = 20.0, decimals = 2, singleStep = 0.1 ) self.duplexRiseDoubleSpinBox = \ PM_DoubleSpinBox( pmGroupBox, label = "Rise:", value = env.prefs[bdnaRise_prefs_key], setAsDefault = True, minimum = 2.0, maximum = 4.0, decimals = 3, singleStep = 0.01 ) # Strand Length (i.e. the number of bases) self.numberOfBasePairsSpinBox = \ PM_SpinBox( pmGroupBox, label = "Base pairs:", value = self._numberOfBases, setAsDefault = False, minimum = 0, maximum = 10000 ) self.numberOfBasePairsSpinBox.setDisabled(True) # Duplex Length self.duplexLengthLineEdit = \ PM_LineEdit( pmGroupBox, label = "Duplex length: ", text = "0.0 Angstroms", setAsDefault = False) self.duplexLengthLineEdit.setDisabled(True)
def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. @param pmGroupBox: group box that contains protein display choices @see: L{PM_GroupBox} """ proteinStyleChoices = ['CA trace (wire)', 'CA trace (cylinders)', 'CA trace (ball and stick)', 'Tube', 'Ladder', 'Zigzag', 'Flat ribbon', 'Solid ribbon', 'Cartoons', 'Fancy cartoons', 'Peptide tiles' ] self.proteinStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Style:", choices = proteinStyleChoices, setAsDefault = True) scaleChoices = ['Constant', 'Secondary structure', 'B-factor'] self.scaleComboBox = \ PM_ComboBox( pmGroupBox, label = "Scaling:", choices = scaleChoices, setAsDefault = True) self.scaleFactorDoubleSpinBox = \ PM_DoubleSpinBox( pmGroupBox, label = "Scaling factor:", value = 1.00, setAsDefault = True, minimum = 0.1, maximum = 3.0, decimals = 1, singleStep = 0.1 ) self.splineDoubleSpinBox = \ PM_DoubleSpinBox( pmGroupBox, label = "Resolution:", value = 3, setAsDefault = True, minimum = 2, maximum = 8, decimals = 0, singleStep = 1 ) self.smoothingCheckBox = \ PM_CheckBox( pmGroupBox, text = "Smoothing", setAsDefault = True)
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ self.nameLineEdit = PM_LineEdit(pmGroupBox, label="Name:") self.lengthLineEdit = PM_LineEdit(pmGroupBox, label="Length:") self.lengthLineEdit.setEnabled(False) self.currentResidueComboBox = PM_ComboBox(pmGroupBox, label="Current residue:", setAsDefault=False) BUTTON_LIST = [ ("QToolButton", 1, "Previous residue", "ui/actions/Properties Manager/Previous.png", "", "Previous residue", 0), ("QToolButton", 2, "Next residue", "ui/actions/Properties Manager/Next.png", "", "Next residue", 1) ] self.prevNextButtonRow = \ PM_ToolButtonRow( pmGroupBox, title = "", buttonList = BUTTON_LIST, label = 'Previous / Next:', isAutoRaise = True, isCheckable = False ) self.prevButton = self.prevNextButtonRow.getButtonById(1) self.nextButton = self.prevNextButtonRow.getButtonById(2) self.recenterViewCheckBox = \ PM_CheckBox( pmGroupBox, text = "Center view on current residue", setAsDefault = True, state = Qt.Unchecked, widgetColumn = 0, spanWidth = True) self.lockEditedCheckBox = \ PM_CheckBox( pmGroupBox, text = "Lock edited rotamers", setAsDefault = True, state = Qt.Checked, widgetColumn = 0, spanWidth = True) self.showAllResiduesCheckBox = \ PM_CheckBox( pmGroupBox, text = "Show all residues", setAsDefault = False, state = Qt.Unchecked, widgetColumn = 0, spanWidth = True) return
def _loadPM_ComboBox(self, inPmGroupBox): """ PM_ComboBox widgets. """ choices = [ "First", "Second", "Third (Default)", "Forth" ] self.comboBox1= \ PM_ComboBox( inPmGroupBox, label = 'Choices: ', choices = choices, index = 2, setAsDefault = True, spanWidth = False ) self.comboBox2= \ PM_ComboBox( inPmGroupBox, label = ' :Choices', labelColumn = 1, choices = choices, index = 2, setAsDefault = True, spanWidth = False ) self.comboBox3= \ PM_ComboBox( inPmGroupBox, label = ' Choices (SpanWidth = True):', labelColumn = 1, choices = choices, index = 2, setAsDefault = True, spanWidth = True ) self.nestedGroupBox1 = \ PM_GroupBox( inPmGroupBox, title = "Group Box Title" ) self.comboBox4= \ PM_ComboBox( self.nestedGroupBox1, label = "Choices:", choices = choices, index = 2, setAsDefault = True, spanWidth = False ) self.nestedGroupBox2 = \ PM_GroupBox( inPmGroupBox, title = "Group Box Title" ) self.comboBox6= \ PM_ComboBox( self.nestedGroupBox2, label = "Choices:", choices = choices, index = 2, setAsDefault = True, spanWidth = True )
def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. @param pmGroupBox: group box that contains protein display choices @see: L{PM_GroupBox} """ proteinStyleChoices = [ 'CA trace (wire)', 'CA trace (cylinders)', 'CA trace (ball and stick)', 'Tube', 'Ladder', 'Zigzag', 'Flat ribbon', 'Solid ribbon', 'Cartoons', 'Fancy cartoons', 'Peptide tiles' ] self.proteinStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Style:", choices = proteinStyleChoices, setAsDefault = True) scaleChoices = ['Constant', 'Secondary structure', 'B-factor'] self.scaleComboBox = \ PM_ComboBox( pmGroupBox, label = "Scaling:", choices = scaleChoices, setAsDefault = True) self.scaleFactorDoubleSpinBox = \ PM_DoubleSpinBox( pmGroupBox, label = "Scaling factor:", value = 1.00, setAsDefault = True, minimum = 0.1, maximum = 3.0, decimals = 1, singleStep = 0.1 ) self.splineDoubleSpinBox = \ PM_DoubleSpinBox( pmGroupBox, label = "Resolution:", value = 3, setAsDefault = True, minimum = 2, maximum = 8, decimals = 0, singleStep = 1 ) self.smoothingCheckBox = \ PM_CheckBox( pmGroupBox, text = "Smoothing", setAsDefault = True)
def _loadGroupBox3(self, pmGroupBox): """ Load widgets in group box. """ # hover highlighting style and color self.hoverHighlightingStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Highlighting:", ) self._loadHoverHighlightingStyleItems() hhColorList = [ yellow, orange, red, magenta, cyan, blue, white, black, gray ] hhColorNames = [ "Yellow (default)", "Orange", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..." ] self.hoverHighlightingColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = hhColorList, colorNames = hhColorNames, color = env.prefs[hoverHighlightingColor_prefs_key] ) # selection style and color self.selectionStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Selection:", ) self._loadSelectionStyleItems() selColorList = [ darkgreen, green, orange, red, magenta, cyan, blue, white, black, gray ] selColorNames = [ "Dark green (default)", "Green", "Orange", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..." ] self.selectionColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = selColorList, colorNames = selColorNames, color = env.prefs[selectionColor_prefs_key] ) return
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ #stereoSettingsGroupBox = PM_GroupBox( None ) self.stereoEnabledCheckBox = \ PM_CheckBox(pmGroupBox, text = 'Enable Stereo View', widgetColumn = 1 ) stereoModeChoices = [ 'Relaxed view', 'Cross-eyed view', 'Red/blue anaglyphs', 'Red/cyan anaglyphs', 'Red/green anaglyphs' ] self.stereoModeComboBox = \ PM_ComboBox( pmGroupBox, label = "Stereo Mode:", choices = stereoModeChoices, setAsDefault = True) self.stereoModeComboBox.setCurrentIndex( env.prefs[stereoViewMode_prefs_key] - 1) self.stereoSeparationSlider = \ PM_Slider( pmGroupBox, currentValue = 50, minimum = 0, maximum = 300, label = 'Separation' ) self.stereoSeparationSlider.setValue( env.prefs[stereoViewSeparation_prefs_key]) self.stereoAngleSlider = \ PM_Slider( pmGroupBox, currentValue = 50, minimum = 0, maximum = 100, label = 'Angle' ) self.stereoAngleSlider.setValue(env.prefs[stereoViewAngle_prefs_key]) self._updateWidgets()
def _loadFuseOptionsGroupBox(self, inPmGroupBox): """ Load the widgets inside the Fuse Options groupbox. """ #@ Warning: If you change fuseChoices, you must also change the # constants MAKEBONDS and FUSEATOMS in FuseChunks_Command.py. # This implementation is fragile and should be fixed. Mark 2008-07-16 fuseChoices = ['Make bonds between chunks', 'Fuse overlapping atoms'] self.fuseComboBox = \ PM_ComboBox( inPmGroupBox, label = '', choices = fuseChoices, index = 0, setAsDefault = False, spanWidth = True) self.connect(self.fuseComboBox, SIGNAL("activated(const QString&)"), self.parentMode.change_fuse_mode) self.fusePushButton = PM_PushButton( inPmGroupBox, label = "", text = "Make Bonds", spanWidth = True ) self.connect( self.fusePushButton, SIGNAL("clicked()"), self.parentMode.fuse_something) self.toleranceSlider = PM_Slider( inPmGroupBox, currentValue = 100, minimum = 0, maximum = 300, label = \ 'Tolerance:100% => 0 bondable pairs' ) self.connect(self.toleranceSlider, SIGNAL("valueChanged(int)"), self.parentMode.tolerance_changed) self.mergeChunksCheckBox = PM_CheckBox( inPmGroupBox, text = 'Merge chunks', widgetColumn = 0, state = Qt.Checked )
def _loadGroupBox1(self, inPmGroupBox): """ Load widgets into group box 1. """ # User input to specify what type of element/atom to generate elementComboBoxItems = self._sElementSymbolList self.elementComboBox = \ PM_ComboBox( inPmGroupBox, label = "Elements :", choices = elementComboBoxItems, index = 0, setAsDefault = True, spanWidth = False ) # User input to specify x-coordinate # of the generated atom's position. self.xCoordinateField = \ PM_DoubleSpinBox( inPmGroupBox, label = "x :", value = 0.0, setAsDefault = True, minimum = self._sMinCoordinateValue, maximum = self._sMaxCoordinateValue, singleStep = self._sStepCoordinateValue, decimals = self._sCoordinateDecimals, suffix = ' ' + self._sCoordinateUnits ) return
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box 1. @param pmGroupBox: group box that contains protein name combo box and number of amino acids spin box @see: L{PM_GroupBox} """ self._updateProteinList() if len(self.protein_name_list) >= 1: self.set_current_protein_chunk_name(self.protein_name_list[0]) self.structureComboBox = PM_ComboBox(pmGroupBox, label="Name:", choices=self.protein_name_list, setAsDefault=False) #Urmi 20080713: May be useful to set the minimum value to not zero #Now it does not matter, since its disabled. But zero as the minimum #value in a spinbox does not work otherwise. self.numberOfAASpinBox = \ PM_SpinBox( pmGroupBox, label = "Amino Acids:", value = 0, setAsDefault = False, minimum = 0, maximum = 10000 ) #for now we do not allow changing number of residues self.numberOfAASpinBox.setEnabled(False) self.editPropertiesPushButton = PM_PushButton(pmGroupBox, text="Edit Sequence", setAsDefault=True)
def _loadTranslateGroupBox(self, inPmGroupBox): """ Load widgets in the Translate group box. @param inPmGroupBox: The Translate group box in the PM @type inPmGroupBox: L{PM_GroupBox} """ translateChoices = ["Free Drag", "By Delta XYZ", "To XYZ Position"] self.translateComboBox = \ PM_ComboBox( inPmGroupBox, label = '', choices = translateChoices, index = 0, setAsDefault = False, spanWidth = True ) self.freeDragTranslateGroupBox = PM_GroupBox(inPmGroupBox) self._loadFreeDragTranslateGroupBox(self.freeDragTranslateGroupBox) self.byDeltaGroupBox = PM_GroupBox(inPmGroupBox) self._loadByDeltaGroupBox(self.byDeltaGroupBox) self.toPositionGroupBox = PM_GroupBox(inPmGroupBox) self._loadToPositionGroupBox(self.toPositionGroupBox) self.updateTranslateGroupBoxes(0)
def _loadProductSpecsGroupBox(self, inPmGroupBox): """ Load widgets in the Product specifications group box. @param inPmGroupBox: The roduct specifications box in the PM @type inPmGroupBox: L{PM_GroupBox} """ productChoices = ['Rod', 'Ring'] self.extrude_productTypeComboBox = \ PM_ComboBox( inPmGroupBox, label = 'Final product:', labelColumn = 0, choices = productChoices, index = 0, setAsDefault = True, spanWidth = False ) # names used in the code, same order #if you comment out items from combobox, you also have to remove them # from this list unless they are at the end!!! self.extrude_productTypeComboBox_ptypes = ["straight rod", \ "closed ring", \ "corkscrew"] self.extrudeSpinBox_n = \ PM_SpinBox( inPmGroupBox, label = "Number of copies:", labelColumn = 0, value = 3, minimum = 1, maximum = 99 ) #@WARNING: This method initializes some instance varaiables for various #checkboxes. (Example: self.mergeCopiesCheckBox.default = False). #These values are needed in extrudemode.py. This #won't be needed once extrudeMode.py is cleaned up. -- ninad 2007-09-10 self.extrudeBondCriterionSlider = \ PM_Slider( inPmGroupBox, currentValue = 100, minimum = 0, maximum = 300, label = 'Tolerence' ) self.extrudeBondCriterionLabel = \ self.extrudeBondCriterionSlider.labelWidget self.extrudeBondCriterionSlider_dflt = 100 self.extrudeBondCriterionSlider.setPageStep(5) self.makeBondsCheckBox = \ PM_CheckBox(inPmGroupBox, text = 'Make bonds' , widgetColumn = 0, state = Qt.Checked ) self.makeBondsCheckBox.default = True self.makeBondsCheckBox.attr = 'whendone_make_bonds' self.makeBondsCheckBox.repaintQ = False
def _loadDisplayOptionsGroupBox(self, inPmGroupBox): """ Load widgets in the Display Options groupbox. @param inPmGroupBox: The Display Options groupbox @type inPmGroupBox: L{PM_GroupBox} """ displayChoices = ['Tubes', 'Spheres'] self.dispModeComboBox = \ PM_ComboBox( inPmGroupBox, label = 'Display style:', choices = displayChoices, index = 0, setAsDefault = False, spanWidth = False ) self.gridLineCheckBox = PM_CheckBox(inPmGroupBox, text="Show grid lines", widgetColumn=0, state=Qt.Checked) self.fullModelCheckBox = PM_CheckBox(inPmGroupBox, text="Show model", widgetColumn=0, state=Qt.Unchecked)
def _loadDisplayOptionsGroupBox(self, pmGroupBox): """ Load widgets in the Display Options GroupBox @see: DnaOrCnt_PropertyManager. _loadDisplayOptionsGroupBox """ #Call the superclass method that loads the cursor text checkboxes. #Note, as of 2008-05-19, the superclass, DnaOrCnt_PropertyManager #only loads the cursor text groupboxes. Subclasses like this can #call custom methods like self._loadCursorTextCheckBoxes etc if they #don't need all groupboxes that the superclass loads. _superclass._loadDisplayOptionsGroupBox(self, pmGroupBox) self._rubberbandLineGroupBox = PM_GroupBox(pmGroupBox, title='Rubber band line:') dnaLineChoices = ['Ribbons', 'Ladder'] self.dnaRubberBandLineDisplayComboBox = \ PM_ComboBox( self._rubberbandLineGroupBox , label = " Display as:", choices = dnaLineChoices, setAsDefault = True) self.lineSnapCheckBox = \ PM_CheckBox(self._rubberbandLineGroupBox , text = 'Enable line snap' , widgetColumn = 1, state = Qt.Checked )
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ includeStrandsChoices = ["All strands in model", "Selected strands only"] self.includeStrandsComboBox = \ PM_ComboBox( pmGroupBox, label = "Include strands:", choices = includeStrandsChoices, setAsDefault = True) self.numberOfBasesLineEdit = \ PM_LineEdit( pmGroupBox, label = "Number of bases:", text = str(self.getNumberOfBases())) self.numberOfBasesLineEdit.setEnabled(False) self.viewDnaOrderFileButton = \ PM_PushButton( pmGroupBox, label = "", text = "View DNA Order File...", spanWidth = True)
def _loadRotateGroupBox(self, inPmGroupBox): """ Load widgets in the Rotate group box, @param inPmGroupBox: The Rotate GroupBox in the PM @type inPmGroupBox: L{PM_GroupBox} """ rotateChoices = ["Free Drag", "By Specified Angle"] self.rotateComboBox = \ PM_ComboBox( inPmGroupBox, label = '', choices = rotateChoices, index = 0, setAsDefault = False, spanWidth = True ) self.rotateAsUnitCB = \ PM_CheckBox( inPmGroupBox, text = 'Rotate as a unit' , widgetColumn = 0, state = Qt.Checked ) self.freeDragRotateGroupBox = PM_GroupBox(inPmGroupBox) self._loadFreeDragRotateGroupBox(self.freeDragRotateGroupBox) self.bySpecifiedAngleGroupBox = PM_GroupBox(inPmGroupBox) self._loadBySpecifiedAngleGroupBox(self.bySpecifiedAngleGroupBox) self.updateRotateGroupBoxes(0)
def _loadGroupBox3(self, pmGroupBox): """ Load widgets in group box. """ # hover highlighting style and color self.hoverHighlightingStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Highlighting:", ) self._loadHoverHighlightingStyleItems() hhColorList = [yellow, orange, red, magenta, cyan, blue, white, black, gray] hhColorNames = ["Yellow (default)", "Orange", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.hoverHighlightingColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = hhColorList, colorNames = hhColorNames, color = env.prefs[hoverHighlightingColor_prefs_key] ) # selection style and color self.selectionStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Selection:", ) self._loadSelectionStyleItems() selColorList = [darkgreen, green, orange, red, magenta, cyan, blue, white, black, gray] selColorNames = ["Dark green (default)", "Green", "Orange", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.selectionColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = selColorList, colorNames = selColorNames, color = env.prefs[selectionColor_prefs_key] ) return
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in groubox 1. """ self.heightField = \ PM_DoubleSpinBox( pmGroupBox, label = "Height :", value = 20.0, setAsDefault = True, minimum = 1.0, maximum = 100.0, singleStep = 1.0, decimals = 3, suffix = ' Angstroms') self.widthField = \ PM_DoubleSpinBox( pmGroupBox, label = "Width :", value = 20.0, setAsDefault = True, minimum = 1.0, maximum = 100.0, singleStep = 1.0, decimals = 3, suffix = ' Angstroms') self.bondLengthField = \ PM_DoubleSpinBox( pmGroupBox, label = "Bond Length :", value = CC_GRAPHITIC_BONDLENGTH, setAsDefault = True, minimum = 1.0, maximum = 3.0, singleStep = 0.1, decimals = 3, suffix = ' Angstroms') endingChoices = ["None", "Hydrogen", "Nitrogen"] self.endingsComboBox= \ PM_ComboBox( pmGroupBox, label = "Endings :", choices = endingChoices, index = 0, setAsDefault = True, spanWidth = False )
def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. """ #background color combo box self.backgroundColorComboBox = \ PM_ComboBox( pmGroupBox, label = "Color:", spanWidth = False) self._loadBackgroundColorItems() self.enableFogCheckBox = \ PM_CheckBox( pmGroupBox, text = "Enable fog" ) connect_checkbox_with_boolean_pref( self.enableFogCheckBox, fogEnabled_prefs_key ) return
def _loadNucleotidesGroupBox(self): """ Load the Nucleotides group box. """ nucleotidesGroupBox = PM_GroupBox( None ) self.nucleotidesGroupBox = nucleotidesGroupBox nucleotidesShapeChoices = ['None', 'Sugar spheres', 'Base cartoons'] self.nucleotidesShapeComboBox = \ PM_ComboBox( nucleotidesGroupBox , label = "Shape:", choices = nucleotidesShapeChoices, setAsDefault = True) self.nucleotidesScaleDoubleSpinBox = \ PM_DoubleSpinBox( nucleotidesGroupBox, label = "Scale:", value = 1.00, setAsDefault = True, minimum = 0.1, maximum = 3.0, decimals = 2, singleStep = 0.1 ) nucleotidesColorChoices = ['Same as strand', 'Base order', 'Strand order', 'Base type'] self.nucleotidesColorComboBox = \ PM_ComboBox( nucleotidesGroupBox , label = "Color:", choices = nucleotidesColorChoices, setAsDefault = True) self.dnaStyleBasesDisplayLettersCheckBox = \ PM_CheckBox(nucleotidesGroupBox , text = 'Display base letters', widgetColumn = 1 )
def _loadLayerPropertiesGroupBox(self, inPmGroupBox): """ Load widgets in the Layer Properties group box. @param inPmGroupBox: The Layer Properties groupbox in the PM @type inPmGroupBox: L{PM_GroupBox} """ self.currentLayerComboBox = \ PM_ComboBox( inPmGroupBox, index = 0, spanWidth = True ) self.addLayerButton = PM_PushButton(inPmGroupBox) self.addLayerButton.setIcon( geticon('ui/actions/Properties Manager/addlayer.png')) self.addLayerButton.setFixedSize(QSize(26, 26)) self.addLayerButton.setIconSize(QSize(22, 22)) # A widget list to create a widget row. # Format: # - Widget type, # - widget object, # - column firstRowWidgetList = [('PM_ComboBox', self.currentLayerComboBox, 1), ('PM_PushButton', self.addLayerButton, 2)] widgetRow = PM_WidgetRow( inPmGroupBox, title='', widgetList=firstRowWidgetList, label="Layer:", labelColumn=0, ) self.layerCellsSpinBox = \ PM_SpinBox( inPmGroupBox, label = "Lattice cells:", labelColumn = 0, value = 2, minimum = 1, maximum = 25 ) self.layerThicknessLineEdit = PM_LineEdit(inPmGroupBox, label="Thickness:", text="", setAsDefault=False, spanWidth=False) #self.layerThicknessLineEdit.setReadOnly(True) self.layerThicknessLineEdit.setDisabled(True) tooltip = "Thickness of layer in Angstroms" self.layerThicknessLineEdit.setToolTip(tooltip)
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ aa_list = [] for mol in self.win.assy.molecules: if mol.isProteinChunk(): aa_list = mol.protein.get_amino_acid_id_list() break self.aminoAcidsComboBox = PM_ComboBox(pmGroupBox, label="Residue:", choices=aa_list, setAsDefault=False) self.previousAAPushButton = \ PM_PushButton( pmGroupBox, text = "Previous AA", setAsDefault = True) self.nextAAPushButton = \ PM_PushButton( pmGroupBox, text = "Next AA", setAsDefault = True) self.recenterViewCheckBox = \ PM_CheckBox( pmGroupBox, text = "Re-center view", setAsDefault = True, state = Qt.Checked) self.expandAllPushButton = \ PM_PushButton( pmGroupBox, text = "Expand All", setAsDefault = True) self.collapseAllPushButton = \ PM_PushButton( pmGroupBox, text = "Collapse All", setAsDefault = True)
def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. """ proteinStyleChoices = [ "CA trace (wire)", "CA trace (cylinders)", "CA trace (ball and stick)", "Tube", "Ladder", "Zigzag", "Flat ribbon", "Solid ribbon", "Cartoons", "Fancy cartoons", "Peptide tiles", ] self.proteinStyleComboBox = PM_ComboBox( pmGroupBox, label="Style:", choices=proteinStyleChoices, setAsDefault=True ) scaleChoices = ["Constant", "Secondary structure", "B-factor"] self.scaleComboBox = PM_ComboBox(pmGroupBox, label="Scaling:", choices=scaleChoices, setAsDefault=True) self.scaleFactorDoubleSpinBox = PM_DoubleSpinBox( pmGroupBox, label="Scaling factor:", value=1.00, setAsDefault=True, minimum=0.1, maximum=3.0, decimals=1, singleStep=0.1, ) self.splineDoubleSpinBox = PM_DoubleSpinBox( pmGroupBox, label="Resolution:", value=4, setAsDefault=True, minimum=2, maximum=8, decimals=0, singleStep=1 ) self.smoothingCheckBox = PM_CheckBox(pmGroupBox, text="Smoothing", setAsDefault=True)
def _loadGroupBox2( self, pmGroupBox ): """ Load widgets in group box 2. """ self.modelComboBox = \ PM_ComboBox( pmGroupBox, label = "Model :", choices = self._modelChoices, setAsDefault = True) self.conformationComboBox = \ PM_ComboBox( pmGroupBox, label = "Conformation :", choices = ["B-DNA"], setAsDefault = True) self.connect( self.conformationComboBox, SIGNAL("currentIndexChanged(int)"), self.conformationComboBoxChanged ) self.basesPerTurnComboBox= \ PM_ComboBox( pmGroupBox, label = "Bases Per Turn :", choices = ["10.0", "10.5", "10.67"], setAsDefault = True) # I may decide to reintroduce "base-pair chunks" at a later time. # Please talk to me if you have a strong feeling about including # this. Mark 2007-08-19. createChoices = ["Strand chunks", \ "Single chunk" ] #@ "Base-pair chunks"] self.createComboBox = \ PM_ComboBox( pmGroupBox, label = "Create :", choices = createChoices, index = 0, setAsDefault = True, spanWidth = False )
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in 1st group box. @param pmGroupBox: The 1st group box in the PM. @type pmGroupBox: L{PM_GroupBox} """ self.axesCombobox = PM_ComboBox(pmGroupBox, label='Axes: ', choices=self._axes_display_choices, index=0, setAsDefault=True, spanWidth=False) self.basesCombobox = PM_ComboBox(pmGroupBox, label='Bases: ', choices=self._bases_display_choices, index=0, setAsDefault=True, spanWidth=False)
def _loadStrutsGroupBox(self): """ Load the Struts group box. """ strutsGroupBox = PM_GroupBox( None ) self.strutsGroupBox = strutsGroupBox strutsShapeChoices = ['None', 'Base-axis-base cylinders', 'Straight cylinders'] self.strutsShapeComboBox = \ PM_ComboBox( strutsGroupBox , label = "Shape:", choices = strutsShapeChoices, setAsDefault = True) self.strutsScaleDoubleSpinBox = \ PM_DoubleSpinBox( strutsGroupBox, label = "Scale:", value = 1.00, setAsDefault = True, minimum = 0.1, maximum = 3.0, decimals = 2, singleStep = 0.1 ) strutsColorChoices = ['Same as strand', 'Base order', 'Strand order', 'Base type'] self.strutsColorComboBox = \ PM_ComboBox( strutsGroupBox , label = "Color:", choices = strutsColorChoices, setAsDefault = True)
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in 1st group box. @param pmGroupBox: The 1st group box in the PM. @type pmGroupBox: L{PM_GroupBox} """ self.axesCombobox = PM_ComboBox( pmGroupBox, label = 'Axes: ', choices = self._axes_display_choices, index = 0, setAsDefault = True, spanWidth = False ) self.basesCombobox = PM_ComboBox( pmGroupBox, label = 'Bases: ', choices = self._bases_display_choices, index = 0, setAsDefault = True, spanWidth = False )
def _loadAtomChooserGroupBox(self, inPmGroupBox): """ Load the widgets inside the Atom Chooser groupbox. @param inPmGroupBox: The Atom Chooser box in the PM @type inPmGroupBox: L{PM_GroupBox} """ atomChooserChoices = [ "Periodic Table Elements", "PAM5 Atoms", "PAM3 Atoms" ] self.atomChooserComboBox = \ PM_ComboBox( inPmGroupBox, label = '', choices = atomChooserChoices, index = 0, setAsDefault = False, spanWidth = True ) #Following fixes bug 2550 self.atomChooserComboBox.setFocusPolicy(Qt.NoFocus) self._addElementChooserGroupBox(inPmGroupBox) self._add_PAM5_AtomChooserGroupBox(inPmGroupBox) self._add_PAM3_AtomChooserGroupBox(inPmGroupBox)
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ #stereoSettingsGroupBox = PM_GroupBox( None ) self.stereoEnabledCheckBox = \ PM_CheckBox(pmGroupBox, text = 'Enable Stereo View', widgetColumn = 1 ) stereoModeChoices = ['Relaxed view', 'Cross-eyed view', 'Red/blue anaglyphs', 'Red/cyan anaglyphs', 'Red/green anaglyphs'] self.stereoModeComboBox = \ PM_ComboBox( pmGroupBox, label = "Stereo Mode:", choices = stereoModeChoices, setAsDefault = True) self.stereoModeComboBox.setCurrentIndex(env.prefs[stereoViewMode_prefs_key]-1) self.stereoSeparationSlider = \ PM_Slider( pmGroupBox, currentValue = 50, minimum = 0, maximum = 300, label = 'Separation' ) self.stereoSeparationSlider.setValue(env.prefs[stereoViewSeparation_prefs_key]) self.stereoAngleSlider = \ PM_Slider( pmGroupBox, currentValue = 50, minimum = 0, maximum = 100, label = 'Angle' ) self.stereoAngleSlider.setValue(env.prefs[stereoViewAngle_prefs_key]) self._updateWidgets()
def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. """ dnaRenditionChoices = ['3D (default)', '2D with base letters', '2D ball and stick', '2D ladder'] self.dnaRenditionComboBox = \ PM_ComboBox( pmGroupBox, label = "Rendition:", choices = dnaRenditionChoices, setAsDefault = True) dnaComponentChoices = ['Axis', 'Strands', 'Struts', 'Nucleotides'] self.dnaComponentComboBox = \ PM_ComboBox( pmGroupBox, label = "Component:", choices = dnaComponentChoices, setAsDefault = True) self._loadAxisGroupBox() self._loadStrandsGroupBox() self._loadStrutsGroupBox() self._loadNucleotidesGroupBox() widgetList = [self.axisGroupBox, self.strandsGroupBox, self.strutsGroupBox, self.nucleotidesGroupBox] self.dnaComponentStackedWidget = \ PM_StackedWidget( pmGroupBox, self.dnaComponentComboBox, widgetList ) standLabelColorChoices = ['Hide', 'Show (in strand color)', 'Black', 'White', 'Custom color...'] self.standLabelColorComboBox = \ PM_ComboBox( pmGroupBox, label = "Strand labels:", choices = standLabelColorChoices, setAsDefault = True) # This disables "Component" widgets if rendition style is 2D. self.change_dnaRendition(env.prefs[dnaRendition_prefs_key])
def _loadWidgetSelectorGroupBox(self, inPmGroupBox): """ Widget selector group box. """ # The widget choices are set via self._getGroupBoxTitles() later. widgetTypeChoices = [ "PM_CheckBox" ] self.widgetSelectorComboBox = \ PM_ComboBox( inPmGroupBox, label = "Select a PM widget:", choices = widgetTypeChoices, index = 0, setAsDefault = False, spanWidth = True ) self.connect(self.widgetSelectorComboBox, SIGNAL("currentIndexChanged(int)"), self._updateGroupBoxes)
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ aa_list = [] for mol in self.win.assy.molecules: if mol.isProteinChunk(): aa_list = mol.protein.get_amino_acid_id_list() break self.aminoAcidsComboBox = PM_ComboBox( pmGroupBox, label = "Residue:", choices = aa_list, setAsDefault = False) self.previousAAPushButton = \ PM_PushButton( pmGroupBox, text = "Previous AA", setAsDefault = True) self.nextAAPushButton = \ PM_PushButton( pmGroupBox, text = "Next AA", setAsDefault = True) self.recenterViewCheckBox = \ PM_CheckBox( pmGroupBox, text = "Re-center view", setAsDefault = True, state = Qt.Checked) self.expandAllPushButton = \ PM_PushButton( pmGroupBox, text = "Expand All", setAsDefault = True) self.collapseAllPushButton = \ PM_PushButton( pmGroupBox, text = "Collapse All", setAsDefault = True)
def _loadGroupBox5(self, pmGroupBox): """ Load widgets in group box 5. """ self._rubberbandLineGroupBox = PM_GroupBox(pmGroupBox, title='Rubber band Line:') ntLineChoices = ['Ladder'] self.ntRubberBandLineDisplayComboBox = \ PM_ComboBox( self._rubberbandLineGroupBox , label = " Display as:", choices = ntLineChoices, setAsDefault = True) self.lineSnapCheckBox = \ PM_CheckBox(self._rubberbandLineGroupBox , text = 'Enable line snap' , widgetColumn = 1, state = Qt.Checked )
def _loadAxisGroupBox(self): """ Load the Axis group box. """ axisGroupBox = PM_GroupBox( None ) self.axisGroupBox = axisGroupBox axisShapeChoices = ['None', 'Wide tube', 'Narrow tube'] self.axisShapeComboBox = \ PM_ComboBox( axisGroupBox , label = "Shape:", choices = axisShapeChoices, setAsDefault = True) self.axisScaleDoubleSpinBox = \ PM_DoubleSpinBox( axisGroupBox, label = "Scale:", value = 1.00, setAsDefault = True, minimum = 0.1, maximum = 2.0, decimals = 2, singleStep = 0.1 ) axisColorChoices = ['Same as chunk', 'Base order', 'Base order (discrete)', 'Base type', 'Strand order'] self.axisColorComboBox = \ PM_ComboBox( axisGroupBox , label = "Color:", choices = axisColorChoices, setAsDefault = True) endingTypeChoices = ['Flat', 'Taper start', 'Taper end', 'Taper both', 'Spherical'] self.axisEndingStyleComboBox = \ PM_ComboBox( axisGroupBox , label = "Ending style:", choices = endingTypeChoices, setAsDefault = True)
def _loadStrandsGroupBox(self): """ Load the Strands group box. """ strandsGroupBox = PM_GroupBox( None ) self.strandsGroupBox = strandsGroupBox strandsShapeChoices = ['None', 'Cylinders', 'Tube'] self.strandsShapeComboBox = \ PM_ComboBox( strandsGroupBox , label = "Shape:", choices = strandsShapeChoices, setAsDefault = True) self.strandsScaleDoubleSpinBox = \ PM_DoubleSpinBox( strandsGroupBox, label = "Scale:", value = 1.00, setAsDefault = True, minimum = 0.1, maximum = 5.0, decimals = 2, singleStep = 0.1 ) strandsColorChoices = ['Same as chunk', 'Base order', 'Strand order'] self.strandsColorComboBox = \ PM_ComboBox( strandsGroupBox , label = "Color:", choices = strandsColorChoices, setAsDefault = True) strandsArrowsChoices = ['None', '5\'', '3\'', '5\' and 3\''] self.strandsArrowsComboBox = \ PM_ComboBox( strandsGroupBox , label = "Arrows:", choices = strandsArrowsChoices, setAsDefault = True)
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ convertChoices = [ "Convert from PAM3 to PAM5", "Convert from PAM5 to PAM3" ] self._convertChoiceComboBox = \ PM_ComboBox( pmGroupBox, label = "", choices = convertChoices, index = 0, setAsDefault = True, spanWidth = True) self._convertButton = \ PM_PushButton( pmGroupBox, label = "", text = "Convert Selection Now", spanWidth = True) return
class BackrubProteinSim_PropertyManager(Command_PropertyManager): """ The BackrubProteinSim_PropertyManager class provides a Property Manager for the B{Fixed backbone Protein Sequence Design} command on the flyout toolbar in the Build > Protein > Simulate mode. @ivar title: The title that appears in the property manager header. @type title: str @ivar pmName: The name of this property manager. This is used to set the name of the PM_Dialog object via setObjectName(). @type name: str @ivar iconPath: The relative path to the PNG file that contains a 22 x 22 icon image that appears in the PM header. @type iconPath: str """ title = "Backrub Motion" pmName = title iconPath = "ui/actions/Command Toolbar/BuildProtein/Backrub.png" def __init__( self, command ): """ Constructor for the property manager. """ _superclass.__init__(self, command) self.showTopRowButtons( PM_DONE_BUTTON | \ PM_WHATS_THIS_BUTTON) msg = "Choose various parameters from below to design an optimized" \ " protein sequence with Rosetta with backrub motion allowed." self.updateMessage(msg) def connect_or_disconnect_signals(self, isConnect = True): """ Connect or disconnect widget signals sent to their slot methods. This can be overridden in subclasses. By default it does nothing. @param isConnect: If True the widget will send the signals to the slot method. @type isConnect: boolean """ if isConnect: change_connect = self.win.connect else: change_connect = self.win.disconnect change_connect(self.ex1Checkbox, SIGNAL("stateChanged(int)"), self.update_ex1) change_connect(self.ex1aroCheckbox, SIGNAL("stateChanged(int)"), self.update_ex1aro) change_connect(self.ex2Checkbox, SIGNAL("stateChanged(int)"), self.update_ex2) change_connect(self.ex2aroOnlyCheckbox, SIGNAL("stateChanged(int)"), self.update_ex2aro_only) change_connect(self.ex3Checkbox, SIGNAL("stateChanged(int)"), self.update_ex3) change_connect(self.ex4Checkbox, SIGNAL("stateChanged(int)"), self.update_ex4) change_connect(self.rotOptCheckbox, SIGNAL("stateChanged(int)"), self.update_rot_opt) change_connect(self.tryBothHisTautomersCheckbox, SIGNAL("stateChanged(int)"), self.update_try_both_his_tautomers) change_connect(self.softRepDesignCheckbox, SIGNAL("stateChanged(int)"), self.update_soft_rep_design) change_connect(self.useElecRepCheckbox, SIGNAL("stateChanged(int)"), self.update_use_elec_rep) change_connect(self.norepackDisulfCheckbox, SIGNAL("stateChanged(int)"), self.update_norepack_disulf) #signal slot connections for the push buttons change_connect(self.okButton, SIGNAL("clicked()"), self.runRosettaBackrubSim) return #Protein Display methods def show(self): """ Shows the Property Manager. Exends superclass method. """ self.sequenceEditor = self.win.createProteinSequenceEditorIfNeeded() self.sequenceEditor.hide() #update the min and max residues spinbox max values based on the length #of the current protein numResidues = self._getNumResiduesForCurrentProtein() if numResidues == 0: self.minresSpinBox.setMaximum(numResidues + 2) self.maxresSpinBox.setMaximum(numResidues + 2) else: self.minresSpinBox.setMaximum(numResidues) self.maxresSpinBox.setMaximum(numResidues) _superclass.show(self) return def _addGroupBoxes( self ): """ Add the Property Manager group boxes. """ self._pmGroupBox2 = PM_GroupBox( self, title = "Backrub Specific Parameters") self._loadGroupBox2( self._pmGroupBox2 ) self._pmGroupBox1 = PM_GroupBox( self, title = "Rosetta Sequence Design Parameters") self._loadGroupBox1( self._pmGroupBox1 ) return def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. """ self.bondAngleWeightSimSpinBox = PM_DoubleSpinBox( pmGroupBox, labelColumn = 0, label = "Bond angle weight:", minimum = 0.01, decimals = 2, maximum = 1.0, singleStep = 0.01, value = 1.0, setAsDefault = False, spanWidth = False) bond_angle_param_list = ['Amber', 'Charmm'] self.bondAngleParamComboBox = PM_ComboBox( pmGroupBox, label = "Bond angle parameters:", choices = bond_angle_param_list, setAsDefault = False) self.onlybbSpinBox = PM_DoubleSpinBox( pmGroupBox, labelColumn = 0, label = "Only backbone rotation:", minimum = 0.01, maximum = 1.0, value = 0.75, decimals = 2, singleStep = 0.01, setAsDefault = False, spanWidth = False) self.onlyrotSpinBox = PM_DoubleSpinBox( pmGroupBox, labelColumn = 0, label = "Only rotamer rotation:", minimum = 0.01, maximum = 1.0, decimals = 2, value = 0.25, singleStep = 0.01, setAsDefault = False, spanWidth = False) self.mctempSpinBox = PM_DoubleSpinBox( pmGroupBox, labelColumn = 0, label = "MC simulation temperature:", minimum = 0.1, value = 0.6, maximum = 1.0, decimals = 2, singleStep = 0.1, setAsDefault = False, spanWidth = False) numResidues = self._getNumResiduesForCurrentProtein() self.minresSpinBox = PM_SpinBox( pmGroupBox, labelColumn = 0, label = "Minimum number of residues:", minimum = 2, maximum = numResidues, singleStep = 1, setAsDefault = False, spanWidth = False) self.maxresSpinBox = PM_SpinBox( pmGroupBox, labelColumn = 0, label = "Maximum number of residues:", minimum = 2, maximum = numResidues, singleStep = 1, setAsDefault = False, spanWidth = False) if numResidues == 0: self.minresSpinBox.setMaximum(numResidues + 2) self.maxresSpinBox.setMaximum(numResidues + 2) return def _addWhatsThisText( self ): """ What's This text for widgets in this Property Manager. """ pass def _addToolTipText(self): """ Tool Tip text for widgets in this Property Manager. """ pass def _getNumResiduesForCurrentProtein(self): """ Get number of residues for the current protein """ _current_protein = self.win.assy.getSelectedProteinChunk() if _current_protein: return len(_current_protein.protein.get_sequence_string()) return 0 def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ self.numSimSpinBox = PM_SpinBox( pmGroupBox, labelColumn = 0, label = "Number of trials:", minimum = 1000, maximum = 1000000, singleStep = 1000, setAsDefault = False, spanWidth = False) self.ex1Checkbox = PM_CheckBox(pmGroupBox, text = "Expand rotamer library for chi1 angle", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.ex1aroCheckbox = PM_CheckBox(pmGroupBox, text = "Use large chi1 library for aromatic residues", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.ex2Checkbox = PM_CheckBox(pmGroupBox, text = "Expand rotamer library for chi2 angle", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.ex2aroOnlyCheckbox = PM_CheckBox(pmGroupBox, text = "Use large chi2 library only for aromatic residues", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.ex3Checkbox = PM_CheckBox(pmGroupBox, text = "Expand rotamer library for chi3 angle", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.ex4Checkbox = PM_CheckBox(pmGroupBox, text ="Expand rotamer library for chi4 angle", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.rotOptCheckbox = PM_CheckBox(pmGroupBox, text ="Optimize one-body energy", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.tryBothHisTautomersCheckbox = PM_CheckBox(pmGroupBox, text ="Try both histidine tautomers", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.softRepDesignCheckbox = PM_CheckBox(pmGroupBox, text ="Use softer Lennard-Jones repulsive term", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.useElecRepCheckbox = PM_CheckBox(pmGroupBox, text ="Use electrostatic repulsion", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.norepackDisulfCheckbox = PM_CheckBox(pmGroupBox, text ="Don't re-pack disulphide bonds", state = Qt.Unchecked, setAsDefault = False, widgetColumn = 0, spanWidth = True) self.otherCommandLineOptions = PM_TextEdit(pmGroupBox, label = "Command line options:", spanWidth = True) self.otherCommandLineOptions.setFixedHeight(80) self.okButton = PM_PushButton( pmGroupBox, text = "Run Rosetta", setAsDefault = True, spanWidth = True) return def update_ex1(self, state): """ Update the command text edit depending on the state of the update_ex1 checkbox @param state:state of the update_ex1 checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.ex1Checkbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -ex1 ' else: otherOptionsText = otherOptionsText.replace(' -ex1 ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_ex1aro(self, state): """ Update the command text edit depending on the state of the update_ex1aro checkbox @param state:state of the update_ex1aro checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.ex1aroCheckbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -ex1aro ' else: otherOptionsText = otherOptionsText.replace(' -ex1aro ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_ex2(self, state): """ Update the command text edit depending on the state of the update_ex2 checkbox @param state:state of the update_ex2 checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.ex2Checkbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -ex2 ' else: otherOptionsText = otherOptionsText.replace(' -ex2 ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_ex2aro_only(self, state): """ Update the command text edit depending on the state of the update_ex2aro_only checkbox @param state:state of the update_ex2aro_only checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.ex2aroOnlyCheckbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -ex2aro_only ' else: otherOptionsText = otherOptionsText.replace(' -ex2aro_only ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_ex3(self, state): """ Update the command text edit depending on the state of the update_ex3 checkbox @param state:state of the update_ex3 checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.ex3Checkbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -ex3 ' else: otherOptionsText = otherOptionsText.replace(' -ex3 ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_ex4(self, state): """ Update the command text edit depending on the state of the update_ex4 checkbox @param state:state of the update_ex4 checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.ex4Checkbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -ex4 ' else: otherOptionsText = otherOptionsText.replace(' -ex4 ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_rot_opt(self, state): """ Update the command text edit depending on the state of the update_rot_opt checkbox @param state:state of the update_rot_opt checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.rotOptCheckbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -rot_opt ' else: otherOptionsText = otherOptionsText.replace(' -rot_opt ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_try_both_his_tautomers(self, state): """ Update the command text edit depending on the state of the update_try_both_his_tautomers checkbox @param state:state of the update_try_both_his_tautomers checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.tryBothHisTautomersCheckbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -try_both_his_tautomers ' else: otherOptionsText = otherOptionsText.replace(' -try_both_his_tautomers ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_soft_rep_design(self, state): """ Update the command text edit depending on the state of the update_soft_rep_design checkbox @param state:state of the update_soft_rep_design checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.softRepDesignCheckbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -soft_rep_design ' else: otherOptionsText = otherOptionsText.replace(' -soft_rep_design ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_use_elec_rep(self, state): """ Update the command text edit depending on the state of the update_use_elec_rep checkbox @param state:state of the update_use_elec_rep checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.useElecRepCheckbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -use_electrostatic_repulsion ' else: otherOptionsText = otherOptionsText.replace(' -use_electrostatic_repulsion ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def update_norepack_disulf(self, state): """ Update the command text edit depending on the state of the update_no_repack checkbox @param state:state of the update_no_repack checkbox @type state: int """ otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) if self.norepackDisulfCheckbox.isChecked() == True: otherOptionsText = otherOptionsText + ' -norepack_disulf ' else: otherOptionsText = otherOptionsText.replace(' -norepack_disulf ', '') self.otherCommandLineOptions.setText(otherOptionsText) return def runRosettaBackrubSim(self): """ Get all the parameters from the PM and run a rosetta simulation """ proteinChunk = self.win.assy.getSelectedProteinChunk() if not proteinChunk: msg = "You must select a single protein to run a Rosetta <i>Backrub</i> simulation." self.updateMessage(msg) return otherOptionsText = str(self.otherCommandLineOptions.toPlainText()) numSim = self.numSimSpinBox.value() argList = [numSim, otherOptionsText, proteinChunk.name] backrubSpecificArgList = self.getBackrubSpecificArgumentList() from simulation.ROSETTA.rosetta_commandruns import rosettaSetup_CommandRun if argList[0] > 0: env.prefs[rosetta_backrub_enabled_prefs_key] = True cmdrun = rosettaSetup_CommandRun(self.win, argList, "BACKRUB_PROTEIN_SEQUENCE_DESIGN", backrubSpecificArgList) cmdrun.run() return def getBackrubSpecificArgumentList(self): """ get list of backrub specific parameters from PM """ listOfArgs = [] bond_angle_weight = str(self.bondAngleWeightSimSpinBox.value()) listOfArgs.append('-bond_angle_weight') listOfArgs.append( bond_angle_weight) if self.bondAngleParamComboBox.currentIndex() == 0: bond_angle_params = 'bond_angle_amber_rosetta' else: bond_angle_params = 'bond_angle_charmm_rosetta' listOfArgs.append('-bond_angle_params') listOfArgs.append(bond_angle_params) only_bb = str(self.onlybbSpinBox.value()) listOfArgs.append('-only_bb') listOfArgs.append( only_bb) only_rot = str(self.onlyrotSpinBox.value()) listOfArgs.append('-only_rot') listOfArgs.append( only_rot) mc_temp = str(self.mctempSpinBox.value()) listOfArgs.append('-mc_temp') listOfArgs.append( mc_temp) min_res = self.minresSpinBox.value() max_res = self.maxresSpinBox.value() if max_res < min_res: msg = redmsg("Maximum number of residues for rosetta simulation with backrub" \ " motion cannot be less than minimum number of residues."\ " Neglecting this parameter for this simulation.") env.history.message("BACKRUB SIMULATION: " + msg) else: listOfArgs.append('-min_res') listOfArgs.append( str(min_res)) listOfArgs.append('-max_res') listOfArgs.append( str(max_res)) return listOfArgs
class StereoProperties_PropertyManager(Command_PropertyManager): """ The StereoProperties_PropertyManager class provides a Property Manager for the Stereo View command. @ivar title: The title that appears in the property manager header. @type title: str @ivar pmName: The name of this property manager. This is used to set the name of the PM_Dialog object via setObjectName(). @type name: str @ivar iconPath: The relative path to the PNG file that contains a 22 x 22 icon image that appears in the PM header. @type iconPath: str """ title = "Stereo View" pmName = title iconPath = "ui/actions/View/Stereo_View.png" def __init__( self, command ): """ Constructor for the property manager. """ _superclass.__init__(self, command) self.showTopRowButtons( PM_DONE_BUTTON | \ PM_WHATS_THIS_BUTTON) msg = "Modify the Stereo View settings below." self.updateMessage(msg) def connect_or_disconnect_signals(self, isConnect): """ Connect or disconnect widget signals sent to their slot methods. This can be overridden in subclasses. By default it does nothing. @param isConnect: If True the widget will send the signals to the slot method. @type isConnect: boolean """ if isConnect: change_connect = self.win.connect else: change_connect = self.win.disconnect change_connect(self.stereoEnabledCheckBox, SIGNAL("toggled(bool)"), self._enableStereo ) change_connect( self.stereoModeComboBox, SIGNAL("currentIndexChanged(int)"), self._stereoModeComboBoxChanged ) change_connect(self.stereoSeparationSlider, SIGNAL("valueChanged(int)"), self._stereoModeSeparationSliderChanged ) change_connect(self.stereoAngleSlider, SIGNAL("valueChanged(int)"), self._stereoModeAngleSliderChanged ) def _addGroupBoxes( self ): """ Add the Property Manager group boxes. """ self._pmGroupBox1 = PM_GroupBox( self, title = "Settings") self._loadGroupBox1( self._pmGroupBox1 ) #@ self._pmGroupBox1.hide() def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ #stereoSettingsGroupBox = PM_GroupBox( None ) self.stereoEnabledCheckBox = \ PM_CheckBox(pmGroupBox, text = 'Enable Stereo View', widgetColumn = 1 ) stereoModeChoices = ['Relaxed view', 'Cross-eyed view', 'Red/blue anaglyphs', 'Red/cyan anaglyphs', 'Red/green anaglyphs'] self.stereoModeComboBox = \ PM_ComboBox( pmGroupBox, label = "Stereo Mode:", choices = stereoModeChoices, setAsDefault = True) self.stereoModeComboBox.setCurrentIndex(env.prefs[stereoViewMode_prefs_key]-1) self.stereoSeparationSlider = \ PM_Slider( pmGroupBox, currentValue = 50, minimum = 0, maximum = 300, label = 'Separation' ) self.stereoSeparationSlider.setValue(env.prefs[stereoViewSeparation_prefs_key]) self.stereoAngleSlider = \ PM_Slider( pmGroupBox, currentValue = 50, minimum = 0, maximum = 100, label = 'Angle' ) self.stereoAngleSlider.setValue(env.prefs[stereoViewAngle_prefs_key]) self._updateWidgets() def _addWhatsThisText( self ): """ What's This text for widgets in the Stereo Property Manager. """ pass def _addToolTipText(self): """ Tool Tip text for widgets in the Stereo Property Manager. """ pass def _enableStereo(self, enabled): """ Enable stereo view. """ glpane = self.o if glpane: glpane.set_stereo_enabled( enabled) # switch to perspective mode if enabled: # store current projection mode glpane.__StereoProperties_last_ortho = glpane.ortho if glpane.ortho: # dont use glpane.setViewProjection # because we don't want to modify # default projection setting glpane.ortho = 0 else: # restore default mode if hasattr(glpane, "__StereoProperties_last_ortho"): projection = glpane.__StereoProperties_last_ortho if glpane.ortho != projection: glpane.ortho = projection self._updateWidgets() glpane.gl_update() def _stereoModeComboBoxChanged(self, mode): """ Change stereo mode. @param mode: stereo mode (0=relaxed, 1=cross-eyed, 2=red/blue, 3=red/cyan, 4=red/green) @type value: int """ env.prefs[stereoViewMode_prefs_key] = mode + 1 self._updateSeparationSlider() def _stereoModeSeparationSliderChanged(self, value): """ Change stereo view separation. @param value: separation (0..300) @type value: int """ env.prefs[stereoViewSeparation_prefs_key] = value def _stereoModeAngleSliderChanged(self, value): """ Change stereo view angle. @param value: stereo angle (0..100) @type value: int """ env.prefs[stereoViewAngle_prefs_key] = value def _updateSeparationSlider(self): """ Update the separation slider widget. """ if self.stereoModeComboBox.currentIndex() >= 2: # for anaglyphs disable the separation slider self.stereoSeparationSlider.setEnabled(False) else: # otherwise, enable the separation slider self.stereoSeparationSlider.setEnabled(True) def _updateWidgets(self): """ Update stereo PM widgets. """ if self.stereoEnabledCheckBox.isChecked(): self.stereoModeComboBox.setEnabled(True) self.stereoSeparationSlider.setEnabled(True) self.stereoAngleSlider.setEnabled(True) self._updateSeparationSlider() else: self.stereoModeComboBox.setEnabled(False) self.stereoSeparationSlider.setEnabled(False) self.stereoAngleSlider.setEnabled(False)
class Ui_BuildAtomsPropertyManager(Command_PropertyManager): """ The Ui_BuildAtomsPropertyManager class defines UI elements for the Property Manager of the B{Build Atoms mode}. @ivar title: The title that appears in the property manager header. @type title: str @ivar pmName: The name of this property manager. This is used to set the name of the PM_Dialog object via setObjectName(). @type name: str @ivar iconPath: The relative path to the PNG file that contains a 22 x 22 icon image that appears in the PM header. @type iconPath: str """ # The title that appears in the Property Manager header title = "Build Atoms" # The name of this Property Manager. This will be set to # the name of the PM_Dialog object via setObjectName(). pmName = title # The relative path to the PNG file that appears in the header iconPath = "ui/actions/Tools/Build Structures/BuildAtoms.png" def __init__(self, command): """ Constructor for the B{Build Atoms} property manager class that defines its UI. @param command: The parent mode where this Property Manager is used @type command: L{depositMode} """ self.previewGroupBox = None self.regularElementChooser = None self.PAM5Chooser = None self.PAM3Chooser = None self.elementChooser = None self.advancedOptionsGroupBox = None self.bondToolsGroupBox = None self.selectionFilterCheckBox = None self.filterlistLE = None self.selectedAtomInfoLabel = None #Initialize the following to None. (subclasses may not define this) #Make sure you initialize it before adding groupboxes! self.selectedAtomPosGroupBox = None self.showSelectedAtomInfoCheckBox = None _superclass.__init__(self, command) self.showTopRowButtons(PM_DONE_BUTTON | PM_WHATS_THIS_BUTTON) msg = '' self.MessageGroupBox.insertHtmlMessage(msg, setAsDefault=False) def _addGroupBoxes(self): """ Add various group boxes to the Build Atoms Property manager. """ self._addPreviewGroupBox() self._addAtomChooserGroupBox() self._addBondToolsGroupBox() #@@@TODO HIDE the bonds tool groupbox initially as the #by default, the atoms tool is active when BuildAtoms command is #finist invoked. self.bondToolsGroupBox.hide() self._addSelectionOptionsGroupBox() self._addAdvancedOptionsGroupBox() def _addPreviewGroupBox(self): """ Adde the preview groupbox that shows the element selected in the element chooser. """ self.previewGroupBox = PM_PreviewGroupBox( self, glpane = self.o ) def _addAtomChooserGroupBox(self): """ Add the Atom Chooser groupbox. This groupbox displays one of the following three groupboxes depending on the choice selected in the combobox: a) Periodic Table Elements L{self.regularElementChooser} b) PAM5 Atoms L{self.PAM5Chooser} c) PAM3 Atoms L{self.PAM3Chooser} @see: L{self.__updateAtomChooserGroupBoxes} """ self.atomChooserGroupBox = \ PM_GroupBox(self, title = "Atom Chooser") self._loadAtomChooserGroupBox(self.atomChooserGroupBox) self._updateAtomChooserGroupBoxes(currentIndex = 0) def _addElementChooserGroupBox(self, inPmGroupBox): """ Add the 'Element Chooser' groupbox. (present within the Atom Chooser Groupbox) """ if not self.previewGroupBox: return elementViewer = self.previewGroupBox.elementViewer self.regularElementChooser = \ PM_ElementChooser( inPmGroupBox, parentPropMgr = self, elementViewer = elementViewer) def _add_PAM5_AtomChooserGroupBox(self, inPmGroupBox): """ Add the 'PAM5 Atom Chooser' groupbox (present within the Atom Chooser Groupbox) """ if not self.previewGroupBox: return elementViewer = self.previewGroupBox.elementViewer self.PAM5Chooser = \ PM_PAM5_AtomChooser( inPmGroupBox, parentPropMgr = self, elementViewer = elementViewer) def _add_PAM3_AtomChooserGroupBox(self, inPmGroupBox): """ Add the 'PAM3 Atom Chooser' groupbox (present within the Atom Chooser Groupbox) """ if not self.previewGroupBox: return elementViewer = self.previewGroupBox.elementViewer self.PAM3Chooser = \ PM_PAM3_AtomChooser( inPmGroupBox, parentPropMgr = self, elementViewer = elementViewer) def _hideAllAtomChooserGroupBoxes(self): """ Hides all Atom Chooser group boxes. """ if self.regularElementChooser: self.regularElementChooser.hide() if self.PAM5Chooser: self.PAM5Chooser.hide() if self.PAM3Chooser: self.PAM3Chooser.hide() def _addBondToolsGroupBox(self): """ Add the 'Bond Tools' groupbox. """ self.bondToolsGroupBox = \ PM_GroupBox( self, title = "Bond Tools") self._loadBondToolsGroupBox(self.bondToolsGroupBox) def _addSelectionOptionsGroupBox(self): """ Add 'Selection Options' groupbox """ self.selectionOptionsGroupBox = \ PM_GroupBox( self, title = "Selection Options" ) self._loadSelectionOptionsGroupBox(self.selectionOptionsGroupBox) def _loadAtomChooserGroupBox(self, inPmGroupBox): """ Load the widgets inside the Atom Chooser groupbox. @param inPmGroupBox: The Atom Chooser box in the PM @type inPmGroupBox: L{PM_GroupBox} """ atomChooserChoices = [ "Periodic Table Elements", "PAM5 Atoms", "PAM3 Atoms" ] self.atomChooserComboBox = \ PM_ComboBox( inPmGroupBox, label = '', choices = atomChooserChoices, index = 0, setAsDefault = False, spanWidth = True ) #Following fixes bug 2550 self.atomChooserComboBox.setFocusPolicy(Qt.NoFocus) self._addElementChooserGroupBox(inPmGroupBox) self._add_PAM5_AtomChooserGroupBox(inPmGroupBox) self._add_PAM3_AtomChooserGroupBox(inPmGroupBox) def _loadSelectionOptionsGroupBox(self, inPmGroupBox): """ Load widgets in the Selection Options group box. @param inPmGroupBox: The Selection Options box in the PM @type inPmGroupBox: L{PM_GroupBox} """ self.selectionFilterCheckBox = \ PM_CheckBox( inPmGroupBox, text = "Enable atom selection filter", widgetColumn = 0, state = Qt.Unchecked ) self.selectionFilterCheckBox.setDefaultValue(False) self.filterlistLE = PM_LineEdit( inPmGroupBox, label = "", text = "", setAsDefault = False, spanWidth = True ) self.filterlistLE.setReadOnly(True) if self.selectionFilterCheckBox.isChecked(): self.filterlistLE.setEnabled(True) else: self.filterlistLE.setEnabled(False) self.showSelectedAtomInfoCheckBox = \ PM_CheckBox( inPmGroupBox, text = "Show Selected Atom Info", widgetColumn = 0, state = Qt.Unchecked) self.selectedAtomPosGroupBox = \ PM_GroupBox( inPmGroupBox, title = "") self._loadSelectedAtomPosGroupBox(self.selectedAtomPosGroupBox) self.toggle_selectedAtomPosGroupBox(show = 0) self.enable_or_disable_selectedAtomPosGroupBox( bool_enable = False) self.reshapeSelectionCheckBox = \ PM_CheckBox( inPmGroupBox, text = 'Dragging reshapes selection', widgetColumn = 0, state = Qt.Unchecked ) connect_checkbox_with_boolean_pref( self.reshapeSelectionCheckBox, reshapeAtomsSelection_prefs_key ) env.prefs[reshapeAtomsSelection_prefs_key] = False self.waterCheckBox = \ PM_CheckBox( inPmGroupBox, text = "Z depth filter (water surface)", widgetColumn = 0, state = Qt.Unchecked ) def _loadSelectedAtomPosGroupBox(self, inPmGroupBox): """ Load the selected Atoms position groupbox It is a sub-gropbox of L{self.selectionOptionsGroupBox) @param inPmGroupBox: 'The Selected Atom Position Groupbox' @type inPmGroupBox: L{PM_GroupBox} """ self.selectedAtomLineEdit = PM_LineEdit( inPmGroupBox, label = "Selected Atom:", text = "", setAsDefault = False, spanWidth = False ) self.selectedAtomLineEdit.setReadOnly(True) self.selectedAtomLineEdit.setEnabled(False) self.coordinateSpinboxes = PM_CoordinateSpinBoxes(inPmGroupBox) # User input to specify x-coordinate self.xCoordOfSelectedAtom = self.coordinateSpinboxes.xSpinBox # User input to specify y-coordinate self.yCoordOfSelectedAtom = self.coordinateSpinboxes.ySpinBox # User input to specify z-coordinate self.zCoordOfSelectedAtom = self.coordinateSpinboxes.zSpinBox def _addAdvancedOptionsGroupBox(self): """ Add 'Advanced Options' groupbox """ self.advancedOptionsGroupBox = \ PM_GroupBox( self, title = "Advanced Options" ) self._loadAdvancedOptionsGroupBox(self.advancedOptionsGroupBox) def _loadAdvancedOptionsGroupBox(self, inPmGroupBox): """ Load widgets in the Advanced Options group box. @param inPmGroupBox: The Advanced Options box in the PM @type inPmGroupBox: L{PM_GroupBox} """ self.autoBondCheckBox = \ PM_CheckBox( inPmGroupBox, text = 'Auto bond', widgetColumn = 0, state = Qt.Checked ) self.highlightingCheckBox = \ PM_CheckBox( inPmGroupBox, text = "Hover highlighting", widgetColumn = 0, state = Qt.Checked ) def _loadBondToolsGroupBox(self, inPmGroupBox): """ Load widgets in the Bond Tools group box. @param inPmGroupBox: The Bond Tools box in the PM @type inPmGroupBox: L{PM_GroupBox} """ # Button list to create a toolbutton row. # Format: # - buttonId, # - buttonText , # - iconPath # - tooltip # - shortcut # - column BOND_TOOL_BUTTONS = \ [ ( "QToolButton", 0, "SINGLE", "", "", None, 0), ( "QToolButton", 1, "DOUBLE", "", "", None, 1), ( "QToolButton", 2, "TRIPLE", "", "", None, 2), ( "QToolButton", 3, "AROMATIC", "", "", None, 3), ( "QToolButton", 4, "GRAPHITIC", "", "", None, 4), ( "QToolButton", 5, "CUTBONDS", "", "", None, 5) ] self.bondToolButtonRow = \ PM_ToolButtonRow( inPmGroupBox, title = "", buttonList = BOND_TOOL_BUTTONS, checkedId = None, setAsDefault = True ) def _addWhatsThisText(self): """ "What's This" text for widgets in this Property Manager. """ from ne1_ui.WhatsThisText_for_PropertyManagers import whatsThis_BuildAtomsPropertyManager whatsThis_BuildAtomsPropertyManager(self) def _addToolTipText(self): """ Tool Tip text for widgets in this Property Manager. """ from ne1_ui.ToolTipText_for_PropertyManagers import ToolTip_BuildAtomsPropertyManager ToolTip_BuildAtomsPropertyManager(self) def toggle_selectedAtomPosGroupBox(self, show = 0): """ Show or hide L{self.selectedAtomPosGroupBox} depending on the state of the checkbox (L{self.showSelectedAtomInfoCheckBox}) @param show: Flag that shows or hides the groupbox (can have values 0 or 1 @type show: int """ if show: self.selectedAtomPosGroupBox.show() else: self.selectedAtomPosGroupBox.hide() def enable_or_disable_selectedAtomPosGroupBox(self, bool_enable = False): """ Enable or disable Selected AtomPosGroupBox present within 'selection options' and also the checkbox that shows or hide this groupbox. These two widgets are enabled when only a single atom is selected from the 3D workspace. @param bool_enable: Flag that enables or disables widgets @type bool_enable: boolean """ if self.showSelectedAtomInfoCheckBox: self.showSelectedAtomInfoCheckBox.setEnabled(bool_enable) if self.selectedAtomPosGroupBox: self.selectedAtomPosGroupBox.setEnabled(bool_enable) def _updateAtomChooserGroupBoxes(self, currentIndex): """ Updates the Atom Chooser Groupbox. It displays one of the following three groupboxes depending on the choice selected in the combobox: a) Periodic Table Elements L{self.regularElementChooser} b) PAM5 Atoms L{self.PAM5Chooser} c) PAM3 Atoms L{self.PAM3Chooser} It also sets self.elementChooser to the current active Atom chooser and updates the display accordingly in the Preview groupbox. """ self._hideAllAtomChooserGroupBoxes() if currentIndex is 0: self.elementChooser = self.regularElementChooser self.regularElementChooser.show() if currentIndex is 1: self.elementChooser = self.PAM5Chooser self.PAM5Chooser.show() if currentIndex is 2: self.elementChooser = self.PAM3Chooser self.PAM3Chooser.show() if self.elementChooser: self.elementChooser.updateElementViewer() self.updateMessage() def updateMessage(self): """ Update the Message groupbox with informative message. Subclasses should override this. """ pass
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. @param pmGroupBox: group box that contains various favorite buttons @see: L{PM_GroupBox} """ # Other info # Not only loads the factory default settings but also all the favorite # files stored in the ~/Nanorex/Favorites/ProteinDisplayStyle directory favoriteChoices = ['Factory default settings'] #look for all the favorite files in the favorite folder and add them to # the list from platform_dependent.PlatformDependent import find_or_make_Nanorex_subdir _dir = find_or_make_Nanorex_subdir('Favorites/ProteinDisplayStyle') for file in os.listdir(_dir): fullname = os.path.join( _dir, file) if os.path.isfile(fullname): if fnmatch.fnmatch( file, "*.txt"): # leave the extension out favoriteChoices.append(file[0:len(file)-4]) self.favoritesComboBox = \ PM_ComboBox( pmGroupBox, choices = favoriteChoices, spanWidth = True) self.favoritesComboBox.setWhatsThis( """<b> List of Favorites </b> <p> Creates a list of favorite Protein display styles. Once favorite styles have been added to the list using the Add Favorite button, the list will display the chosen favorites. To change the current favorite, select a current favorite from the list, and push the Apply Favorite button.""") # PM_ToolButtonRow =============== # Button list to create a toolbutton row. # Format: # - QToolButton, buttonId, buttonText, # - iconPath, # - tooltip, shortcut, column BUTTON_LIST = [ ( "QToolButton", 1, "APPLY_FAVORITE","ui/actions/Properties Manager/ApplyPeptideDisplayStyleFavorite.png", "Apply Favorite", "", 0), ( "QToolButton", 2, "ADD_FAVORITE", "ui/actions/Properties Manager/AddFavorite.png","Add Favorite", "", 1), ( "QToolButton", 3, "DELETE_FAVORITE", "ui/actions/Properties Manager/DeleteFavorite.png", "Delete Favorite", "", 2), ( "QToolButton", 4, "SAVE_FAVORITE", "ui/actions/Properties Manager/SaveFavorite.png", "Save Favorite", "", 3), ( "QToolButton", 5, "LOAD_FAVORITE", "ui/actions/Properties Manager/LoadFavorite.png", "Load Favorite", \ "", 4) ] self.favsButtonGroup = \ PM_ToolButtonRow( pmGroupBox, title = "", buttonList = BUTTON_LIST, spanWidth = True, isAutoRaise = False, isCheckable = False, setAsDefault = True, ) self.favsButtonGroup.buttonGroup.setExclusive(False) self.applyFavoriteButton = self.favsButtonGroup.getButtonById(1) self.addFavoriteButton = self.favsButtonGroup.getButtonById(2) self.deleteFavoriteButton = self.favsButtonGroup.getButtonById(3) self.saveFavoriteButton = self.favsButtonGroup.getButtonById(4) self.loadFavoriteButton = self.favsButtonGroup.getButtonById(5)
class QuteMolPropertyManager(PM_Dialog): """ The QuteMolPropertyManager class provides a Property Manager for QuteMolX, allowing its launch for external rendering of the model. """ # The title that appears in the Property Manager header. title = "QuteMolX" # The name of this Property Manager. This will be set to # the name of the PM_Dialog object via setObjectName(). pmName = title # The relative path to the PNG file that appears in the header iconPath = "ui/actions/Properties Manager/QuteMol.png" # DNA Display choices. _axes_display_choices = [ "Render axes", "Hide axes" ] _bases_display_choices = [ "Render bases", "Hide bases" ] #"Color bases black", #"Color bases by type" ] # PDB exclude flags = _axesFlags | _basesFlags _axesFlags = EXCLUDE_HIDDEN_ATOMS _basesFlags = EXCLUDE_HIDDEN_ATOMS def __init__(self, win): """ Construct the QuteMolX Property Manager. @param win: The main window. @type win: QMainWindow """ self.win = win self.pw = None PM_Dialog.__init__( self, self.pmName, self.iconPath, self.title ) msg = "Select a QuteMolX rendering style and click the \ <b>Launch QuteMolX</b> button when ready." # This causes the "Message" box to be displayed as well. self.updateMessage(msg) # Hide Preview and Restore defaults button for Alpha9. self.hideTopRowButtons(PM_RESTORE_DEFAULTS_BUTTON | PM_PREVIEW_BUTTON) def _addGroupBoxes(self): """ Add the 1st group box to the Property Manager. """ self.pmGroupBox1 = PM_GroupBox(self, title = "DNA Display Options") self._loadGroupBox1(self.pmGroupBox1) self.pmGroupBox2 = PM_GroupBox(self, title = "Launch") self._loadGroupBox2(self.pmGroupBox2) def _loadGroupBox1(self, pmGroupBox): """ Load widgets in 1st group box. @param pmGroupBox: The 1st group box in the PM. @type pmGroupBox: L{PM_GroupBox} """ self.axesCombobox = PM_ComboBox( pmGroupBox, label = 'Axes: ', choices = self._axes_display_choices, index = 0, setAsDefault = True, spanWidth = False ) self.basesCombobox = PM_ComboBox( pmGroupBox, label = 'Bases: ', choices = self._bases_display_choices, index = 0, setAsDefault = True, spanWidth = False ) def _loadGroupBox2(self, pmGroupBox): """ Load widgets in 2nd group box. @param pmGroupBox: The 1st group box in the PM. @type pmGroupBox: L{PM_GroupBox} """ self.launchQuteMolButton = PM_ToolButton( pmGroupBox, text = "Launch QuteMolX", iconPath = "ui/actions/Properties Manager/QuteMol.png", spanWidth = True ) self.launchQuteMolButton.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) def _addWhatsThisText(self): """ "What's This" text for widgets in this Property Manager. """ from ne1_ui.WhatsThisText_for_PropertyManagers import whatsThis_QuteMolPropertyManager whatsThis_QuteMolPropertyManager(self) def _addToolTipText(self): """ Tool Tip text for widgets in this Property Manager. """ from ne1_ui.ToolTipText_for_PropertyManagers import ToolTip_QuteMolPropertyManager ToolTip_QuteMolPropertyManager(self) def show(self): """ Shows the Property Manager. Overrides PM_Dialog.show) """ if self.isVisible(): # Fixes bug 2680. --Mark 2008-03-19 return PM_Dialog.show(self) self.connect_or_disconnect_signals(isConnect = True) def close(self): """ Closes the Property Manager. Overrides PM_Dialog.close. """ #First exit temporary modes (e.g. Pan mode) if any. currentCommand = self.win.commandSequencer.currentCommand if not currentCommand.command_has_its_own_gui: currentCommand.Done() self.connect_or_disconnect_signals(isConnect = False) PM_Dialog.close(self) def ok_btn_clicked(self): """ Slot for the OK button """ self.accept() self.close() # Close the property manager. # The following reopens the property manager of the mode after # when the PM of the reference geometry is closed. -- Ninad 20070603 # Note: the value of self.modePropertyManager can be None # @see: anyMode.propMgr # # (Note: once we have a real command sequencer, it will be # handling this kind of thing itself, and the situation # in which the currentCommand does not correspond to # the current PM (as is true here while this separate PM # is open, since it's not currentCommand.propMgr) # will be deprecated or impossible. [bruce 071011 comment]) self.modePropertyManager = self.win.currentCommand.propMgr if self.modePropertyManager: # (re)open the PM of the current command (i.e. "Build > Atoms"). self.open(self.modePropertyManager) return def cancel_btn_clicked(self): """ Slot for the Cancel button. """ self.reject() self.close() # The following reopens the property manager of the command after # the PM of the reference geometry editCommand (i.e. Plane) is closed. # Note: the value of self.modePropertyManager can be None. # See anyMode.propMgr # (See similar code in ok_btn_clicked [bruce 071011 comment]) self.modePropertyManager = self.win.currentCommand.propMgr if self.modePropertyManager: # (re)open the PM of the current command (i.e. "Build > Atoms"). self.open(self.modePropertyManager) return def connect_or_disconnect_signals(self, isConnect): """ Connect or disconnect widget signals sent to their slot methods. This can be overridden in subclasses. By default it does nothing. @param isConnect: If True the widget will send the signals to the slot method. @type isConnect: boolean """ if isConnect: change_connect = self.win.connect else: change_connect = self.win.disconnect change_connect(self.axesCombobox, SIGNAL("currentIndexChanged(const QString&)"), self.changeAxesDisplay) change_connect(self.basesCombobox, SIGNAL("currentIndexChanged(const QString&)"), self.changeBasesDisplay) change_connect(self.launchQuteMolButton, SIGNAL("clicked()"), self.launchQuteMol) def updateMessage(self, msg = ''): """ Updates the message box with an informative message @param msg: Message to be displayed in the Message groupbox of the property manager @type msg: string """ self.MessageGroupBox.insertHtmlMessage(msg, setAsDefault = False, minLines = 5) def changeAxesDisplay(self, optionText): """ Slot to change the axes display style. @param optionText: The text of the combobox option selected. @type optionText: str """ if optionText == self._axes_display_choices[0]: self._axesFlags = EXCLUDE_HIDDEN_ATOMS # Cannot display axes if axis atoms are excluded. self.basesCombobox.setCurrentIndex(0) elif optionText == self._axes_display_choices[1]: self._axesFlags = EXCLUDE_HIDDEN_ATOMS | EXCLUDE_DNA_AXIS_BONDS else: print "Unknown axes display option: ", optionText #print "Axes display option=", optionText #print "Axes Flags=", self._axesFlags def changeBasesDisplay(self, optionText): """ Slot to change the bases display style. @param optionText: The text of the combobox option selected. @type optionText: str """ if optionText == self._bases_display_choices[0]: self._basesFlags = EXCLUDE_HIDDEN_ATOMS elif optionText == self._bases_display_choices[1]: self._basesFlags = EXCLUDE_HIDDEN_ATOMS | EXCLUDE_DNA_AXIS_ATOMS # Cannot display axesif axis atoms are excluded. self.axesCombobox.setCurrentIndex(1) else: print "Unknown bases display option: ", optionText #print "Bases display option=", optionText #print "Bases Flags=", self._basesFlags def launchQuteMol(self): """ Slot for 'Launch QuteMolX' button. Opens the QuteMolX rendering program and loads a copy of the current model. Method: 1. Write a PDB file of the current part. 2. Write an atom attributes table text file containing atom radii and color information. 3. Launches QuteMolX (with the PDB file as an argument). """ cmd = greenmsg("QuteMolX : ") excludeFlags = self._axesFlags | self._basesFlags #print "Exclude flags=", excludeFlags pdb_file = write_qutemol_files(self.win.assy, excludeFlags) # Launch QuteMolX. It will verify the plugin. errorcode, msg = launch_qutemol(pdb_file) # errorcode is ignored. env.history.message(cmd + msg)
def _loadGroupBox3(self, pmGroupBox): """ Load widgets in group box. @param pmGroupBox: group box that contains various color choices @see: L{PM_GroupBox} """ colorChoices = ['Chunk', 'Chain', 'Order', 'Hydropathy', 'Polarity', 'Acidity', 'Size', 'Character', 'Number of contacts', 'Secondary structure type', 'Secondary structure order', 'B-factor', 'Occupancy', 'Custom'] self.proteinComponentComboBox = \ PM_ComboBox( pmGroupBox, label = "Color by:", choices = colorChoices, setAsDefault = True) colorList = [orange, yellow, red, magenta, cyan, blue, white, black, gray] colorNames = ["Orange(default)", "Yellow", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.customColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorList, colorNames = colorNames, label = "Custom:", color = orange, setAsDefault = True) colorChoices1 = [ 'Same as main color', 'Lighter', 'Darker', 'Gray', 'Custom'] self.proteinAuxComponentComboBox = \ PM_ComboBox( pmGroupBox, label = "Aux:", choices = colorChoices1, setAsDefault = True) colorListAux = [orange, yellow, red, magenta,cyan, blue, white, black, gray] colorNamesAux = ["Orange(default)", "Yellow", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.auxColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorListAux, colorNames = colorNamesAux, label = "Custom aux:", color = gray, setAsDefault = True) #self.discColorCheckBox = \ # PM_CheckBox( pmGroupBox, # text = "Discretize colors", # setAsDefault = True # ) # colorListHelix = [red, yellow, gray, magenta, cyan, blue, white, black, orange] colorNamesHelix = ["Red(default)", "Yellow", "Gray", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.helixColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorListHelix, colorNames = colorNamesHelix, label = "Helix:", color = red, setAsDefault = True) colorListStrand = [cyan, yellow, gray, magenta, red, blue, white, black, orange] colorNamesStrand = ["Cyan(default)", "Yellow", "Gray", "Magenta", "Red", "Blue", "White", "Black", "Other color..."] self.strandColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorListStrand, colorNames = colorNamesStrand, label = "Strand:", color = cyan, setAsDefault = True) self.coilColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorListAux, colorNames = colorNamesAux, label = "Coil:", color = orange, setAsDefault = True)
def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. """ self.bondAngleWeightSimSpinBox = PM_DoubleSpinBox( pmGroupBox, labelColumn = 0, label = "Bond angle weight:", minimum = 0.01, decimals = 2, maximum = 1.0, singleStep = 0.01, value = 1.0, setAsDefault = False, spanWidth = False) bond_angle_param_list = ['Amber', 'Charmm'] self.bondAngleParamComboBox = PM_ComboBox( pmGroupBox, label = "Bond angle parameters:", choices = bond_angle_param_list, setAsDefault = False) self.onlybbSpinBox = PM_DoubleSpinBox( pmGroupBox, labelColumn = 0, label = "Only backbone rotation:", minimum = 0.01, maximum = 1.0, value = 0.75, decimals = 2, singleStep = 0.01, setAsDefault = False, spanWidth = False) self.onlyrotSpinBox = PM_DoubleSpinBox( pmGroupBox, labelColumn = 0, label = "Only rotamer rotation:", minimum = 0.01, maximum = 1.0, decimals = 2, value = 0.25, singleStep = 0.01, setAsDefault = False, spanWidth = False) self.mctempSpinBox = PM_DoubleSpinBox( pmGroupBox, labelColumn = 0, label = "MC simulation temperature:", minimum = 0.1, value = 0.6, maximum = 1.0, decimals = 2, singleStep = 0.1, setAsDefault = False, spanWidth = False) numResidues = self._getNumResiduesForCurrentProtein() self.minresSpinBox = PM_SpinBox( pmGroupBox, labelColumn = 0, label = "Minimum number of residues:", minimum = 2, maximum = numResidues, singleStep = 1, setAsDefault = False, spanWidth = False) self.maxresSpinBox = PM_SpinBox( pmGroupBox, labelColumn = 0, label = "Maximum number of residues:", minimum = 2, maximum = numResidues, singleStep = 1, setAsDefault = False, spanWidth = False) if numResidues == 0: self.minresSpinBox.setMaximum(numResidues + 2) self.maxresSpinBox.setMaximum(numResidues + 2) return
def __init__(self, parentWidget, label = 'Color:', labelColumn = 0, colorList = [], colorNames = [], color = white, setAsDefault = True, spanWidth = False, ): """ Appends a color chooser widget to <parentWidget>, a property manager group box. @param parentWidget: the parent group box containing this widget. @type parentWidget: PM_GroupBox @param label: The label that appears to the left or right of the color frame (and "Browse" button). If spanWidth is True, the label will be displayed on its own row directly above the lineedit (and button). To suppress the label, set I{label} to an empty string. @type label: str @param labelColumn: The column number of the label in the group box grid layout. The only valid values are 0 (left column) and 1 (right column). The default is 0 (left column). @type labelColumn: int @param colorList: List of colors. @type colorList: List where each item contains 3 floats (r, g, b) @param colorNames: List of color names. @type colorNames: List of strings @param color: The initial color. White is the default. If I{color} is not in I{colorList}, then the initial color will be set to the last color item (i.e. "Other color..."). @type color: tuple of 3 floats (r, g, b) @param setAsDefault: if True, will restore L{color} when the "Restore Defaults" button is clicked. @type setAsDefault: boolean @param spanWidth: if True, the widget and its label will span the width of the group box. Its label will appear directly above the widget (unless the label is empty) and is left justified. @type spanWidth: boolean """ if len(colorNames) and len(colorList): assert len(colorNames) == len(colorList) self.colorNames = colorNames self.colorList = colorList self.colorDict = dict(zip(self.colorNames, self.colorList)) PM_ComboBox.__init__(self, parentWidget, label = label, labelColumn = labelColumn, choices = self.colorNames, index = 0, # Gets (re)set by setColor() setAsDefault = setAsDefault, spanWidth = spanWidth ) # Load QComboBox widget choices and set initial choice (index). idx = 0 for colorName in self.colorNames: pixmap = QPixmap(12, 12) qcolor = RGBf_to_QColor(self.colorDict[str(colorName)]) pixmap.fill(qcolor) self.setItemIcon(idx, QIcon(pixmap)) idx += 1 self.setIconSize(QSize(12, 12)) # Default is 16x16. self.setColor(color) # Sets current index. self.connect(self, SIGNAL("activated(QString)"), self._setColorFromName) return
class QuteMolPropertyManager(Command_PropertyManager): """ The QuteMolPropertyManager class provides a Property Manager for QuteMolX, allowing its launch for external rendering of the model. """ # The title that appears in the Property Manager header. title = "QuteMolX" # The name of this Property Manager. This will be set to # the name of the PM_Dialog object via setObjectName(). pmName = title # The relative path to the PNG file that appears in the header iconPath = "ui/actions/Properties Manager/QuteMol.png" # DNA Display choices. _axes_display_choices = [ "Render axes", "Hide axes" ] _bases_display_choices = [ "Render bases", "Hide bases" ] #"Color bases black", #"Color bases by type" ] # PDB exclude flags = _axesFlags | _basesFlags _axesFlags = EXCLUDE_HIDDEN_ATOMS _basesFlags = EXCLUDE_HIDDEN_ATOMS def __init__( self, command ): """ Constructor for the property manager. """ _superclass.__init__(self, command) self.showTopRowButtons( PM_DONE_BUTTON | \ PM_WHATS_THIS_BUTTON) msg = "Select a QuteMolX rendering style and click the "\ "<b>Launch QuteMolX</b> button when ready." # This causes the "Message" box to be displayed as well. self.updateMessage(msg) def _addGroupBoxes(self): """ Add the 1st group box to the Property Manager. """ self.pmGroupBox1 = PM_GroupBox(self, title = "DNA Display Options") self._loadGroupBox1(self.pmGroupBox1) self.pmGroupBox2 = PM_GroupBox(self, title = "Launch") self._loadGroupBox2(self.pmGroupBox2) def _loadGroupBox1(self, pmGroupBox): """ Load widgets in 1st group box. @param pmGroupBox: The 1st group box in the PM. @type pmGroupBox: L{PM_GroupBox} """ self.axesCombobox = PM_ComboBox( pmGroupBox, label = 'Axes: ', choices = self._axes_display_choices, index = 0, setAsDefault = True, spanWidth = False ) self.basesCombobox = PM_ComboBox( pmGroupBox, label = 'Bases: ', choices = self._bases_display_choices, index = 0, setAsDefault = True, spanWidth = False ) def _loadGroupBox2(self, pmGroupBox): """ Load widgets in 2nd group box. @param pmGroupBox: The 1st group box in the PM. @type pmGroupBox: L{PM_GroupBox} """ self.launchQuteMolButton = PM_ToolButton( pmGroupBox, text = "Launch QuteMolX", iconPath = "ui/actions/Properties Manager/QuteMol.png", spanWidth = True ) self.launchQuteMolButton.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) def _addWhatsThisText(self): """ "What's This" text for widgets in this Property Manager. """ from ne1_ui.WhatsThisText_for_PropertyManagers import whatsThis_QuteMolPropertyManager whatsThis_QuteMolPropertyManager(self) def _addToolTipText(self): """ Tool Tip text for widgets in this Property Manager. """ from ne1_ui.ToolTipText_for_PropertyManagers import ToolTip_QuteMolPropertyManager ToolTip_QuteMolPropertyManager(self) def connect_or_disconnect_signals(self, isConnect): """ Connect or disconnect widget signals sent to their slot methods. This can be overridden in subclasses. By default it does nothing. @param isConnect: If True the widget will send the signals to the slot method. @type isConnect: boolean """ if isConnect: change_connect = self.win.connect else: change_connect = self.win.disconnect change_connect(self.axesCombobox, SIGNAL("currentIndexChanged(const QString&)"), self.changeAxesDisplay) change_connect(self.basesCombobox, SIGNAL("currentIndexChanged(const QString&)"), self.changeBasesDisplay) change_connect(self.launchQuteMolButton, SIGNAL("clicked()"), self.launchQuteMol) def updateMessage(self, msg = ''): """ Updates the message box with an informative message @param msg: Message to be displayed in the Message groupbox of the property manager @type msg: string """ self.MessageGroupBox.insertHtmlMessage(msg, setAsDefault = False, minLines = 5) def changeAxesDisplay(self, optionText): """ Slot to change the axes display style. @param optionText: The text of the combobox option selected. @type optionText: str """ if optionText == self._axes_display_choices[0]: self._axesFlags = EXCLUDE_HIDDEN_ATOMS # Cannot display axes if axis atoms are excluded. self.basesCombobox.setCurrentIndex(0) elif optionText == self._axes_display_choices[1]: self._axesFlags = EXCLUDE_HIDDEN_ATOMS | EXCLUDE_DNA_AXIS_BONDS else: print "Unknown axes display option: ", optionText #print "Axes display option=", optionText #print "Axes Flags=", self._axesFlags def changeBasesDisplay(self, optionText): """ Slot to change the bases display style. @param optionText: The text of the combobox option selected. @type optionText: str """ if optionText == self._bases_display_choices[0]: self._basesFlags = EXCLUDE_HIDDEN_ATOMS elif optionText == self._bases_display_choices[1]: self._basesFlags = EXCLUDE_HIDDEN_ATOMS | EXCLUDE_DNA_AXIS_ATOMS # Cannot display axesif axis atoms are excluded. self.axesCombobox.setCurrentIndex(1) else: print "Unknown bases display option: ", optionText #print "Bases display option=", optionText #print "Bases Flags=", self._basesFlags def launchQuteMol(self): """ Slot for 'Launch QuteMolX' button. Opens the QuteMolX rendering program and loads a copy of the current model. Method: 1. Write a PDB file of the current part. 2. Write an atom attributes table text file containing atom radii and color information. 3. Launches QuteMolX (with the PDB file as an argument). """ cmd = greenmsg("QuteMolX : ") excludeFlags = self._axesFlags | self._basesFlags #print "Exclude flags=", excludeFlags pdb_file = write_qutemol_files(self.win.assy, excludeFlags) # Launch QuteMolX. It will verify the plugin. errorcode, msg = launch_qutemol(pdb_file) # errorcode is ignored. env.history.message(cmd + msg)
class FusePropertyManager(MovePropertyManager): # <title> - the title that appears in the property manager header. title = "Fuse Chunks" # <iconPath> - full path to PNG file that appears in the header. iconPath = "ui/actions/Tools/Build Tools/Fuse_Chunks.png" def __init__(self, parentMode): """ Constructor for Fuse Property manager. @param parentMode: The parent mode for this property manager @type parentMode: L{fuseChunksmode} """ self.parentMode = parentMode MovePropertyManager.__init__(self, self.parentMode) self.activate_translateGroupBox_in_fuse_PM() def _addGroupBoxes(self): """ Add various groupboxes to Fuse property manager. """ self.fuseOptionsGroupBox = PM_GroupBox( self, title = "Fuse Options") self._loadFuseOptionsGroupBox(self.fuseOptionsGroupBox) MovePropertyManager._addGroupBoxes(self) def _loadFuseOptionsGroupBox(self, inPmGroupBox): """ Load the widgets inside the Fuse Options groupbox. """ #@ Warning: If you change fuseChoices, you must also change the # constants MAKEBONDS and FUSEATOMS in FuseChunks_Command.py. # This implementation is fragile and should be fixed. Mark 2008-07-16 fuseChoices = ['Make bonds between chunks', 'Fuse overlapping atoms'] self.fuseComboBox = \ PM_ComboBox( inPmGroupBox, label = '', choices = fuseChoices, index = 0, setAsDefault = False, spanWidth = True) self.connect(self.fuseComboBox, SIGNAL("activated(const QString&)"), self.parentMode.change_fuse_mode) self.fusePushButton = PM_PushButton( inPmGroupBox, label = "", text = "Make Bonds", spanWidth = True ) self.connect( self.fusePushButton, SIGNAL("clicked()"), self.parentMode.fuse_something) self.toleranceSlider = PM_Slider( inPmGroupBox, currentValue = 100, minimum = 0, maximum = 300, label = \ 'Tolerance:100% => 0 bondable pairs' ) self.connect(self.toleranceSlider, SIGNAL("valueChanged(int)"), self.parentMode.tolerance_changed) self.mergeChunksCheckBox = PM_CheckBox( inPmGroupBox, text = 'Merge chunks', widgetColumn = 0, state = Qt.Checked ) def activate_translateGroupBox_in_fuse_PM(self): """ Show contents of translate groupbox, deactivae the rotate groupbox. Also check the action that was checked when this groupbox was active last time. (if applicable). This method is called only when move groupbox button is clicked. @see: L{self.activate_translateGroupBox_in_fuse_PM} """ self.parentMode.switchGraphicsModeTo(newGraphicsMode = 'TRANSLATE_CHUNKS') self.toggle_translateGroupBox() self.deactivate_rotateGroupBox() buttonToCheck = self.getTranslateButtonToCheck() if buttonToCheck: buttonToCheck.setChecked(True) else: buttonToCheck = self.transFreeButton buttonToCheck.setChecked(True) self.changeMoveOption(buttonToCheck) self.isTranslateGroupBoxActive = True self.parentMode.graphicsMode.update_cursor() def activate_rotateGroupBox_in_fuse_PM(self): """ Show contents of rotate groupbox (in fuse PM), deactivae the translate groupbox. Also check the action that was checked when this groupbox was active last time. (if applicable). This method is called only when rotate groupbox button is clicked. @see: L{activate_rotateGroupBox_in_fuse_PM} """ self.parentMode.switchGraphicsModeTo(newGraphicsMode = 'TRANSLATE_CHUNKS') self.toggle_rotateGroupBox() self.deactivate_translateGroupBox() buttonToCheck = self.getRotateButtonToCheck() if buttonToCheck: buttonToCheck.setChecked(True) else: buttonToCheck = self.rotateFreeButton buttonToCheck.setChecked(True) self.changeRotateOption(buttonToCheck) self.isTranslateGroupBoxActive = False self.parentMode.graphicsMode.update_cursor() return def updateMessage(self, msg = ''): """ Updates the message box with an informative message. @param msg: The message to display. If msg is an empty string, a default message is displayed. @type msg: string Overrides the MovePropertyManager.updateMessage method @see: MovePropertyManager.updateMessage """ #@bug: BUG: The message box height is fixed. The verticle scrollbar # appears as the following message is long. It however tries to make the # cursor visible within the message box . This results in scrolling the # msg box to the last line and thus doesn't look good.-- ninad 20070723 if msg: self.MessageGroupBox.insertHtmlMessage( msg, setAsDefault = True ) return if self.fuseComboBox.currentIndex() == 0: #i.e. 'Make Bonds Between Chunks' msg = "To <b> make bonds</b> between two or more chunks, "\ "drag the selected chunk(s) such that their one or more "\ "bondpoints overlap with the other chunk(s). Then click the "\ "<b> Make Bonds </b> button to create bond(s) between them. " else: msg = "To <b>fuse overlapping atoms</b> in two or more chunks, "\ "drag the selected chunk(s) such that their one or more atoms "\ "overlap with the atoms in the other chunk(s). Then click the "\ "<b> Fuse Atoms </b>\ button to remove the overlapping atoms of "\ "unselected chunk. " self.MessageGroupBox.insertHtmlMessage( msg, setAsDefault = True ) return
def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ # Other info # Not only loads the factory default settings but also all the favorite # files stored in the ~/Nanorex/Favorites/DnaDisplayStyle directory favoriteChoices = ['Factory default settings'] #look for all the favorite files in the favorite folder and add them to # the list from platform_dependent.PlatformDependent import find_or_make_Nanorex_subdir _dir = find_or_make_Nanorex_subdir('Favorites/ColorScheme') for file in os.listdir(_dir): fullname = os.path.join( _dir, file) if os.path.isfile(fullname): if fnmatch.fnmatch( file, "*.txt"): # leave the extension out favoriteChoices.append(file[0:len(file)-4]) self.favoritesComboBox = \ PM_ComboBox( pmGroupBox, choices = favoriteChoices, spanWidth = True) # PM_ToolButtonRow =============== # Button list to create a toolbutton row. # Format: # - QToolButton, buttonId, buttonText, # - iconPath, # - tooltip, shortcut, column BUTTON_LIST = [ ( "QToolButton", 1, "APPLY_FAVORITE", "ui/actions/Properties Manager/ApplyColorSchemeFavorite.png", "Apply Favorite", "", 0), ( "QToolButton", 2, "ADD_FAVORITE", "ui/actions/Properties Manager/AddFavorite.png", "Add Favorite", "", 1), ( "QToolButton", 3, "DELETE_FAVORITE", "ui/actions/Properties Manager/DeleteFavorite.png", "Delete Favorite", "", 2), ( "QToolButton", 4, "SAVE_FAVORITE", "ui/actions/Properties Manager/SaveFavorite.png", "Save Favorite", "", 3), ( "QToolButton", 5, "LOAD_FAVORITE", "ui/actions/Properties Manager/LoadFavorite.png", "Load Favorite", \ "", 4) ] self.favsButtonGroup = \ PM_ToolButtonRow( pmGroupBox, title = "", buttonList = BUTTON_LIST, spanWidth = True, isAutoRaise = False, isCheckable = False, setAsDefault = True, ) self.favsButtonGroup.buttonGroup.setExclusive(False) self.applyFavoriteButton = self.favsButtonGroup.getButtonById(1) self.addFavoriteButton = self.favsButtonGroup.getButtonById(2) self.deleteFavoriteButton = self.favsButtonGroup.getButtonById(3) self.saveFavoriteButton = self.favsButtonGroup.getButtonById(4) self.loadFavoriteButton = self.favsButtonGroup.getButtonById(5)
class ColorScheme_PropertyManager(Command_PropertyManager): """ The ColorScheme_PropertyManager class provides a Property Manager for choosing background and other colors for the Choose Color toolbar command as well as the View/Color Scheme command @ivar title: The title that appears in the property manager header. @type title: str @ivar pmName: The name of this property manager. This is used to set the name of the PM_Dialog object via setObjectName(). @type name: str @ivar iconPath: The relative path to the PNG file that contains a 22 x 22 icon image that appears in the PM header. @type iconPath: str """ title = "Color Scheme" pmName = title iconPath = "ui/actions/View/ColorScheme.png" def __init__( self, command ): """ Constructor for the property manager. """ self.currentWorkingDirectory = env.prefs[workingDirectory_prefs_key] _superclass.__init__(self, command) self.showTopRowButtons( PM_DONE_BUTTON | \ PM_WHATS_THIS_BUTTON) msg = "Edit the color scheme for NE1, including the background color, "\ "hover highlighting and selection colors, etc." self.updateMessage(msg) def connect_or_disconnect_signals(self, isConnect): """ Connect or disconnect widget signals sent to their slot methods. This can be overridden in subclasses. By default it does nothing. @param isConnect: If True the widget will send the signals to the slot method. @type isConnect: boolean """ if isConnect: change_connect = self.win.connect else: change_connect = self.win.disconnect # Favorite buttons signal-slot connections. change_connect( self.applyFavoriteButton, SIGNAL("clicked()"), self.applyFavorite) change_connect( self.addFavoriteButton, SIGNAL("clicked()"), self.addFavorite) change_connect( self.deleteFavoriteButton, SIGNAL("clicked()"), self.deleteFavorite) change_connect( self.saveFavoriteButton, SIGNAL("clicked()"), self.saveFavorite) change_connect( self.loadFavoriteButton, SIGNAL("clicked()"), self.loadFavorite) # background color setting combo box. change_connect( self.backgroundColorComboBox, SIGNAL("activated(int)"), self.changeBackgroundColor ) #hover highlighting style combo box change_connect(self.hoverHighlightingStyleComboBox, SIGNAL("currentIndexChanged(int)"), self.changeHoverHighlightingStyle) change_connect(self.hoverHighlightingColorComboBox, SIGNAL("editingFinished()"), self.changeHoverHighlightingColor) #selection style combo box change_connect(self.selectionStyleComboBox, SIGNAL("currentIndexChanged(int)"), self.changeSelectionStyle) change_connect(self.selectionColorComboBox, SIGNAL("editingFinished()"), self.changeSelectionColor) def changeHoverHighlightingColor(self): """ Slot method for Hover Highlighting color chooser. Change the (3D) hover highlighting color. """ color = self.hoverHighlightingColorComboBox.getColor() env.prefs[hoverHighlightingColor_prefs_key] = color return def changeHoverHighlightingStyle(self, idx): """ Slot method for Hover Highlighting combobox. Change the (3D) hover highlighting style. """ env.prefs[hoverHighlightingColorStyle_prefs_key] = HHS_INDEXES[idx] def changeSelectionStyle(self, idx): """ Slot method for Selection color style combobox. Change the (3D) Selection color style. """ env.prefs[selectionColorStyle_prefs_key] = SS_INDEXES[idx] def changeSelectionColor(self): """ Slot method for Selection color chooser. Change the (3D) Selection color. """ color = self.selectionColorComboBox.getColor() env.prefs[selectionColor_prefs_key] = color return def show(self): """ Shows the Property Manager. Extends superclass method. """ self._updateAllWidgets() _superclass.show(self) def _addGroupBoxes( self ): """ Add the Property Manager group boxes. """ self._pmGroupBox1 = PM_GroupBox( self, title = "Favorites") self._loadGroupBox1( self._pmGroupBox1 ) self._pmGroupBox2 = PM_GroupBox( self, title = "Background") self._loadGroupBox2( self._pmGroupBox2 ) self._pmGroupBox3 = PM_GroupBox( self, title = "Highlighting and Selection") self._loadGroupBox3( self._pmGroupBox3 ) self._updateAllWidgets() def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. """ # Other info # Not only loads the factory default settings but also all the favorite # files stored in the ~/Nanorex/Favorites/DnaDisplayStyle directory favoriteChoices = ['Factory default settings'] #look for all the favorite files in the favorite folder and add them to # the list from platform_dependent.PlatformDependent import find_or_make_Nanorex_subdir _dir = find_or_make_Nanorex_subdir('Favorites/ColorScheme') for file in os.listdir(_dir): fullname = os.path.join( _dir, file) if os.path.isfile(fullname): if fnmatch.fnmatch( file, "*.txt"): # leave the extension out favoriteChoices.append(file[0:len(file)-4]) self.favoritesComboBox = \ PM_ComboBox( pmGroupBox, choices = favoriteChoices, spanWidth = True) # PM_ToolButtonRow =============== # Button list to create a toolbutton row. # Format: # - QToolButton, buttonId, buttonText, # - iconPath, # - tooltip, shortcut, column BUTTON_LIST = [ ( "QToolButton", 1, "APPLY_FAVORITE", "ui/actions/Properties Manager/ApplyColorSchemeFavorite.png", "Apply Favorite", "", 0), ( "QToolButton", 2, "ADD_FAVORITE", "ui/actions/Properties Manager/AddFavorite.png", "Add Favorite", "", 1), ( "QToolButton", 3, "DELETE_FAVORITE", "ui/actions/Properties Manager/DeleteFavorite.png", "Delete Favorite", "", 2), ( "QToolButton", 4, "SAVE_FAVORITE", "ui/actions/Properties Manager/SaveFavorite.png", "Save Favorite", "", 3), ( "QToolButton", 5, "LOAD_FAVORITE", "ui/actions/Properties Manager/LoadFavorite.png", "Load Favorite", \ "", 4) ] self.favsButtonGroup = \ PM_ToolButtonRow( pmGroupBox, title = "", buttonList = BUTTON_LIST, spanWidth = True, isAutoRaise = False, isCheckable = False, setAsDefault = True, ) self.favsButtonGroup.buttonGroup.setExclusive(False) self.applyFavoriteButton = self.favsButtonGroup.getButtonById(1) self.addFavoriteButton = self.favsButtonGroup.getButtonById(2) self.deleteFavoriteButton = self.favsButtonGroup.getButtonById(3) self.saveFavoriteButton = self.favsButtonGroup.getButtonById(4) self.loadFavoriteButton = self.favsButtonGroup.getButtonById(5) def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. """ #background color combo box self.backgroundColorComboBox = \ PM_ComboBox( pmGroupBox, label = "Color:", spanWidth = False) self._loadBackgroundColorItems() self.enableFogCheckBox = \ PM_CheckBox( pmGroupBox, text = "Enable fog" ) connect_checkbox_with_boolean_pref( self.enableFogCheckBox, fogEnabled_prefs_key ) return def _loadGroupBox3(self, pmGroupBox): """ Load widgets in group box. """ # hover highlighting style and color self.hoverHighlightingStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Highlighting:", ) self._loadHoverHighlightingStyleItems() hhColorList = [yellow, orange, red, magenta, cyan, blue, white, black, gray] hhColorNames = ["Yellow (default)", "Orange", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.hoverHighlightingColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = hhColorList, colorNames = hhColorNames, color = env.prefs[hoverHighlightingColor_prefs_key] ) # selection style and color self.selectionStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Selection:", ) self._loadSelectionStyleItems() selColorList = [darkgreen, green, orange, red, magenta, cyan, blue, white, black, gray] selColorNames = ["Dark green (default)", "Green", "Orange", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.selectionColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = selColorList, colorNames = selColorNames, color = env.prefs[selectionColor_prefs_key] ) return def _updateAllWidgets(self): """ Update all the PM widgets. This is typically called after applying a favorite. """ self._updateBackgroundColorComboBoxIndex() self.updateCustomColorItemIcon(RGBf_to_QColor(env.prefs[backgroundColor_prefs_key])) self.hoverHighlightingStyleComboBox.setCurrentIndex(HHS_INDEXES.index(env.prefs[hoverHighlightingColorStyle_prefs_key])) self.hoverHighlightingColorComboBox.setColor(env.prefs[hoverHighlightingColor_prefs_key]) self.selectionStyleComboBox.setCurrentIndex(SS_INDEXES.index(env.prefs[selectionColorStyle_prefs_key])) self.selectionColorComboBox.setColor(env.prefs[selectionColor_prefs_key]) return def _loadSelectionStyleItems(self): """ Load the selection color style combobox with items. """ for selectionStyle in SS_OPTIONS: self.selectionStyleComboBox.addItem(selectionStyle) return def _loadHoverHighlightingStyleItems(self): """ Load the hover highlighting style combobox with items. """ for hoverHighlightingStyle in HHS_OPTIONS: self.hoverHighlightingStyleComboBox.addItem(hoverHighlightingStyle) return def _loadBackgroundColorItems(self): """ Load the background color combobox with all the color options and sets the current background color """ backgroundIndexes = [bg_BLUE_SKY, bg_EVENING_SKY, bg_SEAGREEN, bg_BLACK, bg_WHITE, bg_GRAY, bg_CUSTOM] backgroundNames = ["Blue Sky (default)", "Evening Sky", "Sea Green", "Black", "White", "Gray", "Custom..."] backgroundIcons = ["Background_BlueSky", "Background_EveningSky", "Background_SeaGreen", "Background_Black", "Background_White", "Background_Gray", "Background_Custom"] backgroundIconsDict = dict(zip(backgroundNames, backgroundIcons)) backgroundNamesDict = dict(zip(backgroundIndexes, backgroundNames)) for backgroundName in backgroundNames: basename = backgroundIconsDict[backgroundName] + ".png" iconPath = os.path.join("ui/dialogs/Preferences/", basename) self.backgroundColorComboBox.addItem(geticon(iconPath), backgroundName) self._updateBackgroundColorComboBoxIndex() # Not needed, but OK. return def _updateBackgroundColorComboBoxIndex(self): """ Set current index in the background color combobox. """ if self.win.glpane.backgroundGradient: self.backgroundColorComboBox.setCurrentIndex(self.win.glpane.backgroundGradient - 1) else: if (env.prefs[ backgroundColor_prefs_key ] == black): self.backgroundColorComboBox.setCurrentIndex(bg_BLACK) elif (env.prefs[ backgroundColor_prefs_key ] == white): self.backgroundColorComboBox.setCurrentIndex(bg_WHITE) elif (env.prefs[ backgroundColor_prefs_key ] == gray): self.backgroundColorComboBox.setCurrentIndex(bg_GRAY) else: self.backgroundColorComboBox.setCurrentIndex(bg_CUSTOM) return def changeBackgroundColor(self, idx): """ Slot method for the background color combobox. """ #print "changeBackgroundColor(): Slot method called. Idx =", idx if idx == bg_BLUE_SKY: self.win.glpane.setBackgroundGradient(idx + 1) elif idx == bg_EVENING_SKY: self.win.glpane.setBackgroundGradient(idx + 1) elif idx == bg_SEAGREEN: self.win.glpane.setBackgroundGradient(idx + 1) elif idx == bg_BLACK: self.win.glpane.setBackgroundColor(black) elif idx == bg_WHITE: self.win.glpane.setBackgroundColor(white) elif idx == bg_GRAY: self.win.glpane.setBackgroundColor(gray) elif idx == bg_CUSTOM: #change background color to Custom Color self.chooseCustomBackgroundColor() else: msg = "Unknown color idx=", idx print_compact_traceback(msg) self.win.glpane.gl_update() # Needed! return def chooseCustomBackgroundColor(self): """ Choose a custom background color. """ c = QColorDialog.getColor(RGBf_to_QColor(self.win.glpane.getBackgroundColor()), self) if c.isValid(): self.win.glpane.setBackgroundColor(QColor_to_RGBf(c)) self.updateCustomColorItemIcon(c) else: # User cancelled. Need to reset combobox to correct index. self._updateBackgroundColorComboBoxIndex() return def updateCustomColorItemIcon(self, qcolor): """ Update the custom color item icon in the background color combobox with I{qcolor}. """ pixmap = QPixmap(16, 16) pixmap.fill(qcolor) self.backgroundColorComboBox.setItemIcon(bg_CUSTOM, QIcon(pixmap)) return def applyFavorite(self): """ Apply the color scheme settings stored in the current favorite (selected in the combobox) to the current color scheme settings. """ # Rules and other info: # The user has to press the button related to this method when he loads # a previously saved favorite file current_favorite = self.favoritesComboBox.currentText() if current_favorite == 'Factory default settings': env.prefs.restore_defaults(colorSchemePrefsList) # set it back to blue sky self.win.glpane.setBackgroundGradient(1) else: favfilepath = getFavoritePathFromBasename(current_favorite) loadFavoriteFile(favfilepath) if env.prefs[backgroundGradient_prefs_key]: self.win.glpane.setBackgroundGradient(env.prefs[backgroundGradient_prefs_key]) else: self.win.glpane.setBackgroundColor(env.prefs[backgroundColor_prefs_key]) #self.hoverHighlightingColorComboBox.setColor(env.prefs[hoverHighlightingColor_prefs_key]) #self.selectionColorComboBox.setColor(env.prefs[selectionColor_prefs_key]) self._updateAllWidgets() self.win.glpane.gl_update() return def addFavorite(self): """ Adds a new favorite to the user's list of favorites. """ # Rules and other info: # - The new favorite is defined by the current color scheme # settings. # - The user is prompted to type in a name for the new # favorite. # - The color scheme settings are written to a file in a special # directory on the disk # (i.e. $HOME/Nanorex/Favorites/ColorScheme/$FAV_NAME.txt). # - The name of the new favorite is added to the list of favorites in # the combobox, which becomes the current option. # Existence of a favorite with the same name is checked in the above # mentioned location and if a duplicate exists, then the user can either # overwrite and provide a new name. # Prompt user for a favorite name to add. from widgets.simple_dialogs import grab_text_line_using_dialog ok1, name = \ grab_text_line_using_dialog( title = "Add new favorite", label = "favorite name:", iconPath = "ui/actions/Properties Manager/AddFavorite.png", default = "" ) if ok1: # check for duplicate files in the # $HOME/Nanorex/Favorites/ColorScheme/ directory fname = getFavoritePathFromBasename( name ) if os.path.exists(fname): #favorite file already exists! _ext= ".txt" ret = QMessageBox.warning( self, "Warning!", "The favorite file \"" + name + _ext + "\"already exists.\n" "Do you want to overwrite the existing file?", "&Overwrite", "&Cancel", "", 0, # Enter == button 0 1) # Escape == button 1 if ret == 0: #overwrite favorite file ok2, text = writeColorSchemeToFavoritesFile(name) indexOfDuplicateItem = self.favoritesComboBox.findText(name) self.favoritesComboBox.removeItem(indexOfDuplicateItem) print "Add Favorite: removed duplicate favorite item." else: env.history.message("Add Favorite: cancelled overwriting favorite item.") return else: ok2, text = writeColorSchemeToFavoritesFile(name) else: # User cancelled. return if ok2: self.favoritesComboBox.addItem(name) _lastItem = self.favoritesComboBox.count() self.favoritesComboBox.setCurrentIndex(_lastItem - 1) msg = "New favorite [%s] added." % (text) else: msg = "Can't add favorite [%s]: %s" % (name, text) # text is reason why not env.history.message(msg) return def deleteFavorite(self): """ Deletes the current favorite from the user's personal list of favorites (and from disk, only in the favorites folder though). @note: Cannot delete "Factory default settings". """ currentIndex = self.favoritesComboBox.currentIndex() currentText = self.favoritesComboBox.currentText() if currentIndex == 0: msg = "Cannot delete '%s'." % currentText else: self.favoritesComboBox.removeItem(currentIndex) # delete file from the disk deleteFile= getFavoritePathFromBasename( currentText ) os.remove(deleteFile) msg = "Deleted favorite named [%s].\n" \ "and the favorite file [%s.txt]." \ % (currentText, currentText) env.history.message(msg) return def saveFavorite(self): """ Writes the current favorite (selected in the combobox) to a file, any where in the disk that can be given to another NE1 user (i.e. as an email attachment). """ cmd = greenmsg("Save Favorite File: ") env.history.message(greenmsg("Save Favorite File:")) current_favorite = self.favoritesComboBox.currentText() favfilepath = getFavoritePathFromBasename(current_favorite) #Check to see if favfilepath exists first if not os.path.exists(favfilepath): msg = "%s does not exist" % favfilepath env.history.message(cmd + msg) return formats = \ "Favorite (*.txt);;"\ "All Files (*.*)" directory = self.currentWorkingDirectory saveLocation = directory + "/" + current_favorite + ".txt" fn = QFileDialog.getSaveFileName( self, "Save Favorite As", # caption saveLocation, #where to save formats, # file format options QString("Favorite (*.txt)") # selectedFilter ) if not fn: env.history.message(cmd + "Cancelled") else: #remember this directory dir, fil = os.path.split(str(fn)) self.setCurrentWorkingDirectory(dir) saveFavoriteFile(str(fn), favfilepath) return def setCurrentWorkingDirectory(self, dir = None): if os.path.isdir(dir): self.currentWorkingDirectory = dir self._setWorkingDirectoryInPrefsDB(dir) else: self.currentWorkingDirectory = getDefaultWorkingDirectory() def _setWorkingDirectoryInPrefsDB(self, workdir = None): """ [private method] Set the working directory in the user preferences database. @param workdir: The fullpath directory to write to the user pref db. If I{workdir} is None (default), there is no change. @type workdir: string """ if not workdir: return workdir = str(workdir) if os.path.isdir(workdir): workdir = os.path.normpath(workdir) env.prefs[workingDirectory_prefs_key] = workdir # Change pref in prefs db. else: msg = "[" + workdir + "] is not a directory. Working directory was not changed." env.history.message( redmsg(msg)) return def loadFavorite(self): """ Prompts the user to choose a "favorite file" (i.e. *.txt) from disk to be added to the personal favorites list. """ # If the file already exists in the favorites folder then the user is # given the option of overwriting it or renaming it env.history.message(greenmsg("Load Favorite File:")) formats = \ "Favorite (*.txt);;"\ "All Files (*.*)" directory = self.currentWorkingDirectory if directory == '': directory= getDefaultWorkingDirectory() fname = QFileDialog.getOpenFileName(self, "Choose a file to load", directory, formats) if not fname: env.history.message("User cancelled loading file.") return else: dir, fil = os.path.split(str(fname)) self.setCurrentWorkingDirectory(dir) canLoadFile = loadFavoriteFile(fname) if canLoadFile == 1: #get just the name of the file for loading into the combobox favName = os.path.basename(str(fname)) name = favName[0:len(favName)-4] indexOfDuplicateItem = self.favoritesComboBox.findText(name) #duplicate exists in combobox if indexOfDuplicateItem != -1: ret = QMessageBox.warning( self, "Warning!", "The favorite file \"" + name + "\"already exists.\n" "Do you want to overwrite the existing file?", "&Overwrite", "&Rename", "&Cancel", 0, # Enter == button 0 1 # button 1 ) if ret == 0: self.favoritesComboBox.removeItem(indexOfDuplicateItem) self.favoritesComboBox.addItem(name) _lastItem = self.favoritesComboBox.count() self.favoritesComboBox.setCurrentIndex(_lastItem - 1) ok2, text = writeColorSchemeToFavoritesFile(name) msg = "Overwrote favorite [%s]." % (text) env.history.message(msg) elif ret == 1: # add new item to favorites folder as well as combobox self.addFavorite() else: #reset the display setting values to factory default factoryIndex = self.favoritesComboBox.findText( 'Factory default settings') self.favoritesComboBox.setCurrentIndex(factoryIndex) env.prefs.restore_defaults(colorSchemePrefsList) # set it back to blue sky self.win.glpane.setBackgroundGradient(1) self.win.glpane.gl_update() env.history.message("Cancelled overwriting favorite file.") return else: self.favoritesComboBox.addItem(name) _lastItem = self.favoritesComboBox.count() self.favoritesComboBox.setCurrentIndex(_lastItem - 1) msg = "Loaded favorite [%s]." % (name) env.history.message(msg) if env.prefs[backgroundGradient_prefs_key]: self.win.glpane.setBackgroundGradient(env.prefs[backgroundGradient_prefs_key]) else: self.win.glpane.setBackgroundColor(env.prefs[backgroundColor_prefs_key]) self.win.glpane.gl_update() return def _addWhatsThisText( self ): """ What's This text for widgets in the Color Scheme Property Manager. """ from ne1_ui.WhatsThisText_for_PropertyManagers import WhatsThis_ColorScheme_PropertyManager WhatsThis_ColorScheme_PropertyManager(self) def _addToolTipText(self): """ Tool Tip text for widgets in the Color Scheme Property Manager. """ #modify this for color schemes from ne1_ui.ToolTipText_for_PropertyManagers import ToolTip_ColorScheme_PropertyManager ToolTip_ColorScheme_PropertyManager(self)
class ProteinDisplayStyle_PropertyManager(Command_PropertyManager): """ The ProteinDisplayStyle_PropertyManager class provides a Property Manager for the B{Display Style} command on the flyout toolbar in the Build > Protein mode. @ivar title: The title that appears in the property manager header. @type title: str @ivar pmName: The name of this property manager. This is used to set the name of the PM_Dialog object via setObjectName(). @type name: str @ivar iconPath: The relative path to the PNG file that contains a 22 x 22 icon image that appears in the PM header. @type iconPath: str """ title = "Edit Protein Display Style" pmName = title iconPath = "ui/actions/Edit/EditProteinDisplayStyle.png" def __init__( self, command ): """ Constructor for the property manager. """ self.currentWorkingDirectory = env.prefs[workingDirectory_prefs_key] _superclass.__init__(self, command) self.showTopRowButtons( PM_DONE_BUTTON | \ PM_WHATS_THIS_BUTTON) msg = "Modify the protein display settings below." self.updateMessage(msg) def connect_or_disconnect_signals(self, isConnect = True): """ Connect or disconnect widget signals sent to their slot methods. This can be overridden in subclasses. By default it does nothing. @param isConnect: If True the widget will send the signals to the slot method. @type isConnect: boolean """ if isConnect: change_connect = self.win.connect else: change_connect = self.win.disconnect # Favorite buttons signal-slot connections. change_connect( self.applyFavoriteButton, SIGNAL("clicked()"), self.applyFavorite) change_connect( self.addFavoriteButton, SIGNAL("clicked()"), self.addFavorite) change_connect( self.deleteFavoriteButton, SIGNAL("clicked()"), self.deleteFavorite) change_connect( self.saveFavoriteButton, SIGNAL("clicked()"), self.saveFavorite) change_connect( self.loadFavoriteButton, SIGNAL("clicked()"), self.loadFavorite) #Display group box signal slot connections change_connect(self.proteinStyleComboBox, SIGNAL("currentIndexChanged(int)"), self.changeProteinDisplayStyle) change_connect(self.smoothingCheckBox, SIGNAL("stateChanged(int)"), self.smoothProteinDisplay) change_connect(self.scaleComboBox, SIGNAL("currentIndexChanged(int)"), self.changeProteinDisplayScale) change_connect(self.splineDoubleSpinBox, SIGNAL("valueChanged(double)"), self.changeProteinSplineValue) change_connect(self.scaleFactorDoubleSpinBox, SIGNAL("valueChanged(double)"), self.changeProteinScaleFactor) #color groupbox change_connect(self.proteinComponentComboBox, SIGNAL("currentIndexChanged(int)"), self.chooseProteinComponent) change_connect(self.proteinAuxComponentComboBox, SIGNAL("currentIndexChanged(int)"), self.chooseAuxilliaryProteinComponent) change_connect(self.customColorComboBox, SIGNAL("editingFinished()"), self.chooseCustomColor) change_connect(self.auxColorComboBox, SIGNAL("editingFinished()"), self.chooseAuxilliaryColor) #change_connect(self.discColorCheckBox, # SIGNAL("stateChanged(int)"), # self.setDiscreteColors) change_connect(self.helixColorComboBox, SIGNAL("editingFinished()"), self.chooseHelixColor) change_connect(self.strandColorComboBox, SIGNAL("editingFinished()"), self.chooseStrandColor) change_connect(self.coilColorComboBox, SIGNAL("editingFinished()"), self.chooseCoilColor) #Protein Display methods def changeProteinDisplayStyle(self, idx): """ Change protein display style @param idx: index of the protein display style combo box @type idx: int """ env.prefs[proteinStyle_prefs_key] = idx return def changeProteinDisplayQuality(self, idx): env.prefs[proteinStyleQuality_prefs_key] = idx return def smoothProteinDisplay(self, state): """ Smoooth protein display. @param state: state of the smooth protein display check box. @type state: int """ if state == Qt.Checked: env.prefs[proteinStyleSmooth_prefs_key] = True else: env.prefs[proteinStyleSmooth_prefs_key] = False return def changeProteinDisplayScale(self, idx): """ Change protein display scale @param idx: index of the protein display scaling choices combo box @type idx: int """ env.prefs[proteinStyleScaling_prefs_key] = idx return def changeProteinSplineValue(self, val): """ Change protein display resolution @param val: value in the protein display resolution double spinbox @type val: double """ env.prefs[proteinStyleQuality_prefs_key] = val return def changeProteinScaleFactor(self, val): """ Change protein display scale factor @param val: value in the protein display scale factor double spinbox @type val: double """ env.prefs[proteinStyleScaleFactor_prefs_key] = val return def chooseProteinComponent(self, idx): """ Choose protein component to set the color of @param idx: index of the protein component choices combo box @type idx: int """ env.prefs[proteinStyleColors_prefs_key] = idx return def chooseAuxilliaryProteinComponent(self, idx): """ Choose auxilliary protein component to set the color of @param idx: index of the auxilliary protein component choices combo box @type idx: int """ env.prefs[proteinStyleAuxColors_prefs_key] = idx - 1 return def chooseCustomColor(self): """ Choose custom color of the chosen protein component """ color = self.customColorComboBox.getColor() env.prefs[proteinStyleCustomColor_prefs_key] = color return def chooseAuxilliaryColor(self): """ Choose custom color of the chosen auxilliary protein component """ color = self.auxColorComboBox.getColor() env.prefs[proteinStyleAuxCustomColor_prefs_key] = color return def chooseHelixColor(self): """ Choose helix color """ color = self.helixColorComboBox.getColor() env.prefs[proteinStyleHelixColor_prefs_key] = color return def chooseStrandColor(self): """ Choose strand color """ color = self.strandColorComboBox.getColor() env.prefs[proteinStyleStrandColor_prefs_key] = color return def chooseCoilColor(self): """ Choose coil color """ color = self.coilColorComboBox.getColor() env.prefs[proteinStyleCoilColor_prefs_key] = color return def setDiscreteColors(self, state): """ Set discrete colors. @param state: state of the set discrete colors check box. @type state: int """ if state == Qt.Checked: env.prefs[proteinStyleColorsDiscrete_prefs_key] = True else: env.prefs[proteinStyleColorsDiscrete_prefs_key] = False return def show_OLD(self): """ Shows the Property Manager.Extends superclass method. """ #@REVIEW: See comment in CompareProteins_PropertyManager self.sequenceEditor = self.win.createProteinSequenceEditorIfNeeded() self.sequenceEditor.hide() self.updateProteinDisplayStyleWidgets() _superclass.show(self) def show(self): """ Shows the Property Manager. Extends superclass method """ _superclass.show(self) #@REVIEW: Is it safe to do the follwoing before calling superclass.show()? #-- Ninad 2008-10-02 # Force the Global Display Style to "DNA Cylinder" so the user # can see the display style setting effects on any DNA in the current # model. The current global display style will be restored when leaving # this command (via self.close()). self.originalDisplayStyle = self.o.displayMode # TODO: rename that public attr of GLPane (widely used) # from displayMode to displayStyle. [bruce 080910 comment] self.o.setGlobalDisplayStyle(diPROTEIN) # Update all PM widgets, . # note: It is important to update the widgets by blocking the # 'signals'. If done in the reverse order, it will generate signals #when updating the PM widgets (via updateDnaDisplayStyleWidgets()), #causing unneccessary repaints of the model view. self.updateProteinDisplayStyleWidgets()#@@@ blockSignals = True) return def close(self): """ Closes the Property Manager. Extends superclass method. """ _superclass.close(self) # Restore the original global display style. self.o.setGlobalDisplayStyle(self.originalDisplayStyle) return def _addGroupBoxes( self ): """ Add the Property Manager group boxes. """ self._pmGroupBox1 = PM_GroupBox( self, title = "Favorites") self._loadGroupBox1( self._pmGroupBox1 ) self._pmGroupBox2 = PM_GroupBox( self, title = "Display") self._loadGroupBox2( self._pmGroupBox2 ) self._pmGroupBox3 = PM_GroupBox( self, title = "Color") self._loadGroupBox3( self._pmGroupBox3 ) def _loadGroupBox1(self, pmGroupBox): """ Load widgets in group box. @param pmGroupBox: group box that contains various favorite buttons @see: L{PM_GroupBox} """ # Other info # Not only loads the factory default settings but also all the favorite # files stored in the ~/Nanorex/Favorites/ProteinDisplayStyle directory favoriteChoices = ['Factory default settings'] #look for all the favorite files in the favorite folder and add them to # the list from platform_dependent.PlatformDependent import find_or_make_Nanorex_subdir _dir = find_or_make_Nanorex_subdir('Favorites/ProteinDisplayStyle') for file in os.listdir(_dir): fullname = os.path.join( _dir, file) if os.path.isfile(fullname): if fnmatch.fnmatch( file, "*.txt"): # leave the extension out favoriteChoices.append(file[0:len(file)-4]) self.favoritesComboBox = \ PM_ComboBox( pmGroupBox, choices = favoriteChoices, spanWidth = True) self.favoritesComboBox.setWhatsThis( """<b> List of Favorites </b> <p> Creates a list of favorite Protein display styles. Once favorite styles have been added to the list using the Add Favorite button, the list will display the chosen favorites. To change the current favorite, select a current favorite from the list, and push the Apply Favorite button.""") # PM_ToolButtonRow =============== # Button list to create a toolbutton row. # Format: # - QToolButton, buttonId, buttonText, # - iconPath, # - tooltip, shortcut, column BUTTON_LIST = [ ( "QToolButton", 1, "APPLY_FAVORITE","ui/actions/Properties Manager/ApplyPeptideDisplayStyleFavorite.png", "Apply Favorite", "", 0), ( "QToolButton", 2, "ADD_FAVORITE", "ui/actions/Properties Manager/AddFavorite.png","Add Favorite", "", 1), ( "QToolButton", 3, "DELETE_FAVORITE", "ui/actions/Properties Manager/DeleteFavorite.png", "Delete Favorite", "", 2), ( "QToolButton", 4, "SAVE_FAVORITE", "ui/actions/Properties Manager/SaveFavorite.png", "Save Favorite", "", 3), ( "QToolButton", 5, "LOAD_FAVORITE", "ui/actions/Properties Manager/LoadFavorite.png", "Load Favorite", \ "", 4) ] self.favsButtonGroup = \ PM_ToolButtonRow( pmGroupBox, title = "", buttonList = BUTTON_LIST, spanWidth = True, isAutoRaise = False, isCheckable = False, setAsDefault = True, ) self.favsButtonGroup.buttonGroup.setExclusive(False) self.applyFavoriteButton = self.favsButtonGroup.getButtonById(1) self.addFavoriteButton = self.favsButtonGroup.getButtonById(2) self.deleteFavoriteButton = self.favsButtonGroup.getButtonById(3) self.saveFavoriteButton = self.favsButtonGroup.getButtonById(4) self.loadFavoriteButton = self.favsButtonGroup.getButtonById(5) def _loadGroupBox2(self, pmGroupBox): """ Load widgets in group box. @param pmGroupBox: group box that contains protein display choices @see: L{PM_GroupBox} """ proteinStyleChoices = ['CA trace (wire)', 'CA trace (cylinders)', 'CA trace (ball and stick)', 'Tube', 'Ladder', 'Zigzag', 'Flat ribbon', 'Solid ribbon', 'Cartoons', 'Fancy cartoons', 'Peptide tiles' ] self.proteinStyleComboBox = \ PM_ComboBox( pmGroupBox, label = "Style:", choices = proteinStyleChoices, setAsDefault = True) scaleChoices = ['Constant', 'Secondary structure', 'B-factor'] self.scaleComboBox = \ PM_ComboBox( pmGroupBox, label = "Scaling:", choices = scaleChoices, setAsDefault = True) self.scaleFactorDoubleSpinBox = \ PM_DoubleSpinBox( pmGroupBox, label = "Scaling factor:", value = 1.00, setAsDefault = True, minimum = 0.1, maximum = 3.0, decimals = 1, singleStep = 0.1 ) self.splineDoubleSpinBox = \ PM_DoubleSpinBox( pmGroupBox, label = "Resolution:", value = 3, setAsDefault = True, minimum = 2, maximum = 8, decimals = 0, singleStep = 1 ) self.smoothingCheckBox = \ PM_CheckBox( pmGroupBox, text = "Smoothing", setAsDefault = True) def _loadGroupBox3(self, pmGroupBox): """ Load widgets in group box. @param pmGroupBox: group box that contains various color choices @see: L{PM_GroupBox} """ colorChoices = ['Chunk', 'Chain', 'Order', 'Hydropathy', 'Polarity', 'Acidity', 'Size', 'Character', 'Number of contacts', 'Secondary structure type', 'Secondary structure order', 'B-factor', 'Occupancy', 'Custom'] self.proteinComponentComboBox = \ PM_ComboBox( pmGroupBox, label = "Color by:", choices = colorChoices, setAsDefault = True) colorList = [orange, yellow, red, magenta, cyan, blue, white, black, gray] colorNames = ["Orange(default)", "Yellow", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.customColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorList, colorNames = colorNames, label = "Custom:", color = orange, setAsDefault = True) colorChoices1 = [ 'Same as main color', 'Lighter', 'Darker', 'Gray', 'Custom'] self.proteinAuxComponentComboBox = \ PM_ComboBox( pmGroupBox, label = "Aux:", choices = colorChoices1, setAsDefault = True) colorListAux = [orange, yellow, red, magenta,cyan, blue, white, black, gray] colorNamesAux = ["Orange(default)", "Yellow", "Red", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.auxColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorListAux, colorNames = colorNamesAux, label = "Custom aux:", color = gray, setAsDefault = True) #self.discColorCheckBox = \ # PM_CheckBox( pmGroupBox, # text = "Discretize colors", # setAsDefault = True # ) # colorListHelix = [red, yellow, gray, magenta, cyan, blue, white, black, orange] colorNamesHelix = ["Red(default)", "Yellow", "Gray", "Magenta", "Cyan", "Blue", "White", "Black", "Other color..."] self.helixColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorListHelix, colorNames = colorNamesHelix, label = "Helix:", color = red, setAsDefault = True) colorListStrand = [cyan, yellow, gray, magenta, red, blue, white, black, orange] colorNamesStrand = ["Cyan(default)", "Yellow", "Gray", "Magenta", "Red", "Blue", "White", "Black", "Other color..."] self.strandColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorListStrand, colorNames = colorNamesStrand, label = "Strand:", color = cyan, setAsDefault = True) self.coilColorComboBox = \ PM_ColorComboBox(pmGroupBox, colorList = colorListAux, colorNames = colorNamesAux, label = "Coil:", color = orange, setAsDefault = True) def updateProteinDisplayStyleWidgets( self ): """ Updates all the Protein Display style widgets based on the current pref keys values """ self.proteinStyleComboBox.setCurrentIndex(env.prefs[proteinStyle_prefs_key]) self.splineDoubleSpinBox.setValue(env.prefs[proteinStyleQuality_prefs_key]) if env.prefs[proteinStyleSmooth_prefs_key] == True: self.smoothingCheckBox.setCheckState(Qt.Checked) else: self.smoothingCheckBox.setCheckState(Qt.Unchecked) self.scaleComboBox.setCurrentIndex(env.prefs[proteinStyleScaling_prefs_key]) self.scaleFactorDoubleSpinBox.setValue(env.prefs[proteinStyleScaleFactor_prefs_key]) self.proteinComponentComboBox.setCurrentIndex(env.prefs[proteinStyleColors_prefs_key]) self.customColorComboBox.setColor(env.prefs[proteinStyleCustomColor_prefs_key]) self.proteinAuxComponentComboBox.setCurrentIndex(env.prefs[proteinStyleAuxColors_prefs_key]) self.auxColorComboBox.setColor(env.prefs[proteinStyleAuxCustomColor_prefs_key]) #if env.prefs[proteinStyleColorsDiscrete_prefs_key] == True: # self.discColorCheckBox.setCheckState(Qt.Checked) #else: # self.discColorCheckBox.setCheckState(Qt.Unchecked) self.helixColorComboBox.setColor(env.prefs[proteinStyleHelixColor_prefs_key]) self.strandColorComboBox.setColor(env.prefs[proteinStyleStrandColor_prefs_key]) self.coilColorComboBox.setColor(env.prefs[proteinStyleCoilColor_prefs_key]) return def applyFavorite(self): """ Apply a favorite to the current display chosen in the favorites combo box """ current_favorite = self.favoritesComboBox.currentText() if current_favorite == 'Factory default settings': env.prefs.restore_defaults(proteinDisplayStylePrefsList) else: favfilepath = getFavoritePathFromBasename(current_favorite) loadFavoriteFile(favfilepath) self.updateProteinDisplayStyleWidgets() return def addFavorite(self): """ create and add favorite to favorites directory and favorites combo box in PM @note: Rules and other info: - The new favorite is defined by the current Protein display style settings. - The user is prompted to type in a name for the new favorite. - The Protein display style settings are written to a file in a special directory on the disk (i.e. $HOME/Nanorex/Favorites/ProteinDisplayStyle/$FAV_NAME.txt). - The name of the new favorite is added to the list of favorites in the combobox, which becomes the current option. Existence of a favorite with the same name is checked in the above mentioned location and if a duplicate exists, then the user can either overwrite and provide a new name. """ # Prompt user for a favorite name to add. from widgets.simple_dialogs import grab_text_line_using_dialog ok1, name = \ grab_text_line_using_dialog( title = "Add new favorite", label = "favorite name:", iconPath = "ui/actions/Properties Manager/AddFavorite.png", default = "" ) if ok1: # check for duplicate files in the # $HOME/Nanorex/Favorites/DnaDisplayStyle/ directory fname = getFavoritePathFromBasename( name ) if os.path.exists(fname): #favorite file already exists! _ext= ".txt" ret = QMessageBox.warning( self, "Warning!", "The favorite file \"" + name + _ext + "\"already exists.\n" "Do you want to overwrite the existing file?", "&Overwrite", "&Cancel", "", 0, # Enter == button 0 1) # Escape == button 1 if ret == 0: #overwrite favorite file ok2, text = writeProteinDisplayStyleSettingsToFavoritesFile(name) indexOfDuplicateItem = self.favoritesComboBox.findText(name) self.favoritesComboBox.removeItem(indexOfDuplicateItem) print "Add Favorite: removed duplicate favorite item." else: env.history.message("Add Favorite: cancelled overwriting favorite item.") return else: ok2, text = writeProteinDisplayStyleSettingsToFavoritesFile(name) else: # User cancelled. return if ok2: self.favoritesComboBox.addItem(name) _lastItem = self.favoritesComboBox.count() self.favoritesComboBox.setCurrentIndex(_lastItem - 1) msg = "New favorite [%s] added." % (text) else: msg = "Can't add favorite [%s]: %s" % (name, text) # text is reason why not env.history.message(msg) return def deleteFavorite(self): """ Delete favorite file from the favorites directory """ currentIndex = self.favoritesComboBox.currentIndex() currentText = self.favoritesComboBox.currentText() if currentIndex == 0: msg = "Cannot delete '%s'." % currentText else: self.favoritesComboBox.removeItem(currentIndex) # delete file from the disk deleteFile= getFavoritePathFromBasename( currentText ) os.remove(deleteFile) msg = "Deleted favorite named [%s].\n" \ "and the favorite file [%s.txt]." \ % (currentText, currentText) env.history.message(msg) return def saveFavorite(self): """ Save favorite file in a user chosen location """ cmd = greenmsg("Save Favorite File: ") env.history.message(greenmsg("Save Favorite File:")) current_favorite = self.favoritesComboBox.currentText() favfilepath = getFavoritePathFromBasename(current_favorite) formats = \ "Favorite (*.txt);;"\ "All Files (*.*)" directory = self.currentWorkingDirectory saveLocation = directory + "/" + current_favorite + ".txt" fn = QFileDialog.getSaveFileName( self, "Save Favorite As", # caption favfilepath, #where to save formats, # file format options QString("Favorite (*.txt)") # selectedFilter ) if not fn: env.history.message(cmd + "Cancelled") else: dir, fil = os.path.split(str(fn)) self.setCurrentWorkingDirectory(dir) saveFavoriteFile(str(fn), favfilepath) return def setCurrentWorkingDirectory(self, dir = None): """ Set dir as current working diretcory @param dir: dirname @type dir: str """ if os.path.isdir(dir): self.currentWorkingDirectory = dir self._setWorkingDirectoryInPrefsDB(dir) else: self.currentWorkingDirectory = getDefaultWorkingDirectory() return def _setWorkingDirectoryInPrefsDB(self, workdir = None): """ Set workdir as current working diretcory in prefDB @param workdir: dirname @type workdir: str """ if not workdir: return workdir = str(workdir) if os.path.isdir(workdir): workdir = os.path.normpath(workdir) env.prefs[workingDirectory_prefs_key] = workdir # Change pref in prefs db. else: msg = "[" + workdir + "] is not a directory. Working directory was not changed." env.history.message( redmsg(msg)) return def loadFavorite(self): """ Load a favorite file """ # If the file already exists in the favorites folder then the user is # given the option of overwriting it or renaming it env.history.message(greenmsg("Load Favorite File:")) formats = \ "Favorite (*.txt);;"\ "All Files (*.*)" directory = self.currentWorkingDirectory if directory == '': directory= getDefaultWorkingDirectory() fname = QFileDialog.getOpenFileName(self, "Choose a file to load", directory, formats) if not fname: env.history.message("User cancelled loading file.") return else: dir, fil = os.path.split(str(fname)) self.setCurrentWorkingDirectory(dir) canLoadFile=loadFavoriteFile(fname) if canLoadFile == 1: #get just the name of the file for loading into the combobox favName = os.path.basename(str(fname)) name = favName[0:len(favName)-4] indexOfDuplicateItem = self.favoritesComboBox.findText(name) #duplicate exists in combobox if indexOfDuplicateItem != -1: ret = QMessageBox.warning( self, "Warning!", "The favorite file \"" + name + "\"already exists.\n" "Do you want to overwrite the existing file?", "&Overwrite", "&Rename", "&Cancel", 0, # Enter == button 0 1 # button 1 ) if ret == 0: self.favoritesComboBox.removeItem(indexOfDuplicateItem) self.favoritesComboBox.addItem(name) _lastItem = self.favoritesComboBox.count() self.favoritesComboBox.setCurrentIndex(_lastItem - 1) ok2, text = writeProteinDisplayStyleSettingsToFavoritesFile(name) msg = "Overwrote favorite [%s]." % (text) env.history.message(msg) elif ret == 1: # add new item to favorites folder as well as combobox self.addFavorite() else: #reset the display setting values to factory default factoryIndex = self.favoritesComboBox.findText( 'Factory default settings') self.favoritesComboBox.setCurrentIndex(factoryIndex) env.prefs.restore_defaults(proteinDisplayStylePrefsList) env.history.message("Cancelled overwriting favorite file.") return else: self.favoritesComboBox.addItem(name) _lastItem = self.favoritesComboBox.count() self.favoritesComboBox.setCurrentIndex(_lastItem - 1) msg = "Loaded favorite [%s]." % (name) env.history.message(msg) self.updateProteinDisplayStyleWidgets() return def _addWhatsThisText( self ): """ Add what's this text for this PM """ from ne1_ui.WhatsThisText_for_PropertyManagers import WhatsThis_EditDnaDisplayStyle_PropertyManager WhatsThis_EditDnaDisplayStyle_PropertyManager(self) def _addToolTipText(self): """ Add tool tip text to all widgets. """ from ne1_ui.ToolTipText_for_PropertyManagers import ToolTip_EditProteinDisplayStyle_PropertyManager ToolTip_EditProteinDisplayStyle_PropertyManager(self)