📄 style_manager.cpp
字号:
heterogens.style = eWire; solvents.isOn = false; solvents.style = eBallAndStick; connections.style = eWire; helixObjects.isOn = strandObjects.isOn = false; helixObjects.style = strandObjects.style = eWithArrows; break; case eBallAndStickShortcut: proteinBackbone.type = nucleotideBackbone.type = eComplete; proteinBackbone.style = nucleotideBackbone.style = eBallAndStick; proteinSidechains.isOn = nucleotideSidechains.isOn = true; proteinSidechains.style = nucleotideSidechains.style = eBallAndStick; heterogens.style = eBallAndStick; solvents.isOn = false; solvents.style = eBallAndStick; connections.style = eTubes; helixObjects.isOn = strandObjects.isOn = false; helixObjects.style = strandObjects.style = eWithArrows; break; case eSpacefillShortcut: proteinBackbone.type = nucleotideBackbone.type = eComplete; proteinBackbone.style = nucleotideBackbone.style = eSpaceFill; proteinSidechains.isOn = nucleotideSidechains.isOn = true; proteinSidechains.style = nucleotideSidechains.style = eSpaceFill; heterogens.style = eSpaceFill; solvents.isOn = false; solvents.style = eSpaceFill; connections.style = eTubes; helixObjects.isOn = strandObjects.isOn = false; helixObjects.style = strandObjects.style = eWithArrows; break; } // common settings heterogens.isOn = true; connections.isOn = true; virtualDisulfidesOn = true; hydrogensOn = true; helixRadius = 1.8; strandWidth = 2.0; strandThickness = 0.5; spaceFillProportion = 1.0; ballRadius = 0.4; stickRadius = 0.2; tubeRadius = 0.3; tubeWormRadius = 0.3;}void StyleSettings::SetColorScheme(ePredefinedColorScheme scheme){ // variable settings switch (scheme) { case eSecondaryStructureShortcut: proteinBackbone.colorScheme = eSecondaryStructure; nucleotideBackbone.colorScheme = eMolecule; proteinSidechains.colorScheme = nucleotideSidechains.colorScheme = eElement; heterogens.colorScheme = solvents.colorScheme = eElement; helixObjects.colorScheme = strandObjects.colorScheme = eSecondaryStructure; break; case eAlignedShortcut: case eIdentityShortcut: case eVarietyShortcut: case eWeightedVarietyShortcut: case eInformationContentShortcut: case eFitShortcut: case eBlockFitShortcut: case eBlockZFitShortcut: case eBlockRowFitShortcut: switch (scheme) { case eAlignedShortcut: proteinBackbone.colorScheme = eAligned; break; case eIdentityShortcut: proteinBackbone.colorScheme = eIdentity; break; case eVarietyShortcut: proteinBackbone.colorScheme = eVariety; break; case eWeightedVarietyShortcut: proteinBackbone.colorScheme = eWeightedVariety; break; case eInformationContentShortcut: proteinBackbone.colorScheme = eInformationContent; break; case eFitShortcut: proteinBackbone.colorScheme = eFit; break; case eBlockFitShortcut: proteinBackbone.colorScheme = eBlockFit; break; case eBlockZFitShortcut: proteinBackbone.colorScheme = eBlockZFit; break; case eBlockRowFitShortcut: proteinBackbone.colorScheme = eBlockRowFit; break; } nucleotideBackbone.colorScheme = eMolecule; proteinSidechains.colorScheme = nucleotideSidechains.colorScheme = eElement; heterogens.colorScheme = solvents.colorScheme = eElement; helixObjects.colorScheme = strandObjects.colorScheme = eObject; break; case eObjectShortcut: proteinBackbone.colorScheme = eObject; nucleotideBackbone.colorScheme = eObject; proteinSidechains.colorScheme = nucleotideSidechains.colorScheme = eObject; heterogens.colorScheme = solvents.colorScheme = eObject; helixObjects.colorScheme = strandObjects.colorScheme = eObject; break; case eDomainShortcut: proteinBackbone.colorScheme = eDomain; nucleotideBackbone.colorScheme = eDomain; proteinSidechains.colorScheme = nucleotideSidechains.colorScheme = eElement; heterogens.colorScheme = solvents.colorScheme = eElement; helixObjects.colorScheme = strandObjects.colorScheme = eDomain; break; case eMoleculeShortcut: proteinBackbone.colorScheme = eMolecule; nucleotideBackbone.colorScheme = eMolecule; proteinSidechains.colorScheme = nucleotideSidechains.colorScheme = eMolecule; heterogens.colorScheme = solvents.colorScheme = eMolecule; helixObjects.colorScheme = strandObjects.colorScheme = eMolecule; break; case eRainbowShortcut: proteinBackbone.colorScheme = eRainbow; nucleotideBackbone.colorScheme = eRainbow; proteinSidechains.colorScheme = nucleotideSidechains.colorScheme = eRainbow; heterogens.colorScheme = solvents.colorScheme = eElement; helixObjects.colorScheme = strandObjects.colorScheme = eObject; break; case eHydrophobicityShortcut: proteinBackbone.colorScheme = eHydrophobicity; nucleotideBackbone.colorScheme = eMolecule; proteinSidechains.colorScheme = eHydrophobicity; nucleotideSidechains.colorScheme = eElement; heterogens.colorScheme = solvents.colorScheme = eElement; helixObjects.colorScheme = strandObjects.colorScheme = eObject; break; case eChargeShortcut: proteinBackbone.colorScheme = eCharge; nucleotideBackbone.colorScheme = eElement; proteinSidechains.colorScheme = eCharge; nucleotideSidechains.colorScheme = eElement; heterogens.colorScheme = solvents.colorScheme = eElement; helixObjects.colorScheme = strandObjects.colorScheme = eObject; break; case eTemperatureShortcut: proteinBackbone.colorScheme = eTemperature; nucleotideBackbone.colorScheme = eTemperature; proteinSidechains.colorScheme = nucleotideSidechains.colorScheme = eTemperature; heterogens.colorScheme = solvents.colorScheme = eTemperature; helixObjects.colorScheme = strandObjects.colorScheme = eObject; break; case eElementShortcut: proteinBackbone.colorScheme = eElement; nucleotideBackbone.colorScheme = eElement; proteinSidechains.colorScheme = nucleotideSidechains.colorScheme = eElement; heterogens.colorScheme = eElement; solvents.colorScheme = eElement; helixObjects.colorScheme = strandObjects.colorScheme = eObject; break; } // common settings connections.colorScheme = eUserSelect; connections.userColor.Set(0.9,0.9,1); virtualDisulfideColor.Set(0.93,0.55,0.05); backgroundColor.Set(0,0,0); proteinSidechains.userColor = nucleotideSidechains.userColor = proteinBackbone.userColor = nucleotideBackbone.userColor = heterogens.userColor = solvents.userColor = helixObjects.userColor = strandObjects.userColor = Vector(0.5,0.5,0.5);}void StyleSettings::SetDefaultLabeling(void){ SetDefaultLabelStyle(&proteinLabels); SetDefaultLabelStyle(&nucleotideLabels); ionLabelsOn = true;}///// StyleManager stuff /////StyleManager::StyleManager(const StructureSet *set) : structureSet(set){}bool StyleManager::CheckGlobalStyleSettings(){ return CheckStyleSettings(&globalStyle);}// check for inconsistencies in style settings; returns false if there's an uncorrectable problembool StyleManager::CheckStyleSettings(StyleSettings *settings){ // can't do worm with partial or complete backbone if (((settings->proteinBackbone.style == StyleSettings::eWireWorm || settings->proteinBackbone.style == StyleSettings::eTubeWorm) && (settings->proteinBackbone.type == StyleSettings::ePartial || settings->proteinBackbone.type == StyleSettings::eComplete))) { settings->proteinBackbone.type = StyleSettings::eTrace; } if (((settings->nucleotideBackbone.style == StyleSettings::eWireWorm || settings->nucleotideBackbone.style == StyleSettings::eTubeWorm) && (settings->nucleotideBackbone.type == StyleSettings::ePartial || settings->nucleotideBackbone.type == StyleSettings::eComplete))) { settings->nucleotideBackbone.type = StyleSettings::eTrace; } // can't do non-trace backbones for ncbi-backbone models if (structureSet->isAlphaOnly) { if (settings->proteinBackbone.type == StyleSettings::ePartial || settings->proteinBackbone.type == StyleSettings::eComplete) { settings->proteinBackbone.type = StyleSettings::eTrace; } if (settings->nucleotideBackbone.type == StyleSettings::ePartial || settings->nucleotideBackbone.type == StyleSettings::eComplete) { settings->nucleotideBackbone.type = StyleSettings::eTrace; } } return true;}const double UNKNOWN_HYDROPHOBICITY = -1.0;// return a hydrophobicity value from [0..1]double GetHydrophobicity(char code){ // Amino acid scale: Normalized consensus hydrophobicity scale. // Author(s): Eisenberg D., Schwarz E., Komarony M., Wall R. // Reference: J. Mol. Biol. 179:125-142(1984). // Amino acid scale values: (normalized to [0..1]) switch (code) { case 'A': return ( 0.620 + 2.530) / (1.380 + 2.530); case 'R': return (-2.530 + 2.530) / (1.380 + 2.530); case 'N': return (-0.780 + 2.530) / (1.380 + 2.530); case 'D': return (-0.900 + 2.530) / (1.380 + 2.530); case 'C': return ( 0.290 + 2.530) / (1.380 + 2.530); case 'Q': return (-0.850 + 2.530) / (1.380 + 2.530); case 'E': return (-0.740 + 2.530) / (1.380 + 2.530); case 'G': return ( 0.480 + 2.530) / (1.380 + 2.530); case 'H': return (-0.400 + 2.530) / (1.380 + 2.530); case 'I': return ( 1.380 + 2.530) / (1.380 + 2.530); case 'L': return ( 1.060 + 2.530) / (1.380 + 2.530); case 'K': return (-1.500 + 2.530) / (1.380 + 2.530); case 'M': return ( 0.640 + 2.530) / (1.380 + 2.530); case 'F': return ( 1.190 + 2.530) / (1.380 + 2.530); case 'P': return ( 0.120 + 2.530) / (1.380 + 2.530); case 'S': return (-0.180 + 2.530) / (1.380 + 2.530); case 'T': return (-0.050 + 2.530) / (1.380 + 2.530); case 'W': return ( 0.810 + 2.530) / (1.380 + 2.530); case 'Y': return ( 0.260 + 2.530) / (1.380 + 2.530); case 'V': return ( 1.080 + 2.530) / (1.380 + 2.530); } return UNKNOWN_HYDROPHOBICITY;}int GetCharge(char code){ switch (code) { case 'R': case 'H': case 'K': return 1; case 'D': case 'E': return -1; } return 0;}#define ATOM_NOT_DISPLAYED do { \ atomStyle->style = eNotDisplayed; \ return true; } while (0)// get display style for atom, including show/hide status.// May want to cache this eventually, since a// particular atom's style may be queried several times per render (once for// drawing atoms, and once for each bond to the atom).bool StyleManager::GetAtomStyle(const Residue *residue, const AtomPntr& atom, const AtomCoord *coord, AtomStyle *atomStyle, const StyleSettings::BackboneStyle* *saveBackboneStyle, const StyleSettings::GeneralStyle* *saveGeneralStyle) const{ if (!residue || !atomStyle) { ERRORMSG("StyleManager::GetAtomStyle() got NULL residue or atomStyle"); return false; } atomStyle->isHighlighted = false; // queried sometimes even if atom not displayed const Molecule *molecule; if (!residue->GetParentOfType(&molecule)) return false; const StructureObject *object; if (!molecule->GetParentOfType(&object)) return false; const StyleSettings& settings = GetStyleForResidue(object, atom.mID, atom.rID); const Residue::AtomInfo *info = residue->GetAtomInfo(atom.aID); if (!info) ATOM_NOT_DISPLAYED; // set up some pointers for more convenient access to style settings const StyleSettings::BackboneStyle *backboneStyle = NULL; const StyleSettings::GeneralStyle *generalStyle = NULL; if (info->classification == Residue::eAlphaBackboneAtom || info->classification == Residue::ePartialBackboneAtom || info->classification == Residue::eCompleteBackboneAtom) { if (residue->IsAminoAcid()) backboneStyle = &(settings.proteinBackbone); else backboneStyle = &(settings.nucleotideBackbone); } else if (info->classification == Residue::eSideChainAtom) { if (residue->IsAminoAcid()) generalStyle = &(settings.proteinSidechains); else generalStyle = &(settings.nucleotideSidechains); } else { // Residue::eUnknownAtom if (molecule->IsSolvent()) generalStyle = &(settings.solvents); else if (molecule->IsHeterogen()) generalStyle = &(settings.heterogens); else { ERRORMSG("StyleManager::GetAtomStyle() - confused about molecule/atom classification"); return false; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -