⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 style_manager.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            // atom2 is CD and is visible            else if (info2->code == " CD " && atomStyle2.style != eNotDisplayed && info1->code == " N  ")            {                generalStyle1 = generalStyle2;                backboneStyle1 = NULL;                atomStyle1.isHighlighted = GlobalMessenger()->IsHighlighted(molecule, info1->residue->id);                bondStyle->end1.atomCap = true;                isSpecial = true;            }        }        // will show half-bonds in trace backbones        if (bond->order == Bond::eVirtual)            isSpecial = true;   // will set up style stuff later        // otherwise, don't show the bond at all when one atom is hidden        if (!isSpecial)            BOND_NOT_DISPLAYED;    }    // use connection style if bond is between molecules    if (atom1.mID != atom2.mID && bond->order != Bond::eRealDisulfide && bond->order != Bond::eVirtualDisulfide) {        if (globalStyle.connections.isOn == false)            BOND_NOT_DISPLAYED;        bondStyle->end1.color = bondStyle->end2.color = globalStyle.connections.userColor;        if (globalStyle.connections.style == StyleSettings::eWire)            bondStyle->end1.style = bondStyle->end2.style = eLineBond;        else if (globalStyle.connections.style == StyleSettings::eTubes) {            bondStyle->end1.style = bondStyle->end2.style = eCylinderBond;            bondStyle->end1.radius = bondStyle->end2.radius = globalStyle.tubeRadius;            bondStyle->end1.atomCap = bondStyle->end2.atomCap = true;        } else {            ERRORMSG("StyleManager::GetBondStyle() - invalid connection style");            return false;        }    }    // otherwise, need to query atom style to figure bond style parameters    else {        const StyleSettings&            settings1 = GetStyleForResidue(object, atom1.mID, atom1.rID),            settings2 = GetStyleForResidue(object, atom2.mID, atom2.rID);        StyleSettings::eDrawingStyle style1;        if (backboneStyle1)            style1 = backboneStyle1->style;        else            style1 = generalStyle1->style;        if (!SetBondStyleFromResidueStyle(style1, settings1, &(bondStyle->end1)))            return false;        StyleSettings::eDrawingStyle style2;        if (backboneStyle2)            style2 = backboneStyle2->style;        else            style2 = generalStyle2->style;        if (!SetBondStyleFromResidueStyle(style2, settings2, &(bondStyle->end2)))            return false;        // special handling of alpha virtual bonds        if (bond->order == Bond::eVirtual) {            if (backboneStyle1->type != StyleSettings::eTrace || atomStyle1.style == eNotDisplayed)                bondStyle->end1.style = eNotDisplayed;            if (backboneStyle2->type != StyleSettings::eTrace || atomStyle2.style == eNotDisplayed)                bondStyle->end2.style = eNotDisplayed;            if (atomStyle1.style == eNotDisplayed || atomStyle2.style == eNotDisplayed)                bondStyle->midCap = true;            // set worm tension, tighter for smaller protein alpha-helix            if (info1->residue->IsAminoAcid())                bondStyle->tension = -0.8;            else                bondStyle->tension = -0.4;        }        // special case coloring and rendering for disulfides        if (bond->order == Bond::eVirtualDisulfide) {            if (backboneStyle1->type != StyleSettings::eTrace || backboneStyle2->type != StyleSettings::eTrace ||                !settings1.virtualDisulfidesOn || !settings2.virtualDisulfidesOn)                    BOND_NOT_DISPLAYED;            // don't use worms for disulfides            if (bondStyle->end1.style == eLineWormBond) bondStyle->end1.style = eLineBond;            else if (bondStyle->end1.style == eThickWormBond) bondStyle->end1.style = eCylinderBond;            if (bondStyle->end2.style == eLineWormBond) bondStyle->end2.style = eLineBond;            else if (bondStyle->end2.style == eThickWormBond) bondStyle->end2.style = eCylinderBond;            bondStyle->end1.color = settings1.virtualDisulfideColor;            bondStyle->end2.color = settings2.virtualDisulfideColor;        }        // use atom color for all else        else {            bondStyle->end1.color = atomStyle1.color;            bondStyle->end2.color = atomStyle2.color;        }        // special case for bonds between side chain and residue - make whole bond        // same style/color as side chain side, and add endCap if atom is of lesser radius        if (info2->classification == Residue::eSideChainAtom &&            (info1->classification == Residue::eAlphaBackboneAtom ||             info1->classification == Residue::ePartialBackboneAtom ||             info1->classification == Residue::eCompleteBackboneAtom)           ) {            bondStyle->end1.style = bondStyle->end2.style;            bondStyle->end1.color = bondStyle->end2.color;            bondStyle->end1.radius = bondStyle->end2.radius;            if (atomStyle1.radius < bondStyle->end1.radius)                bondStyle->end1.atomCap = true;        }        else if (info1->classification == Residue::eSideChainAtom &&                 (info2->classification == Residue::eAlphaBackboneAtom ||                  info2->classification == Residue::ePartialBackboneAtom ||                  info2->classification == Residue::eCompleteBackboneAtom)                ) {            bondStyle->end2.style = bondStyle->end1.style;            bondStyle->end2.color = bondStyle->end1.color;            bondStyle->end2.radius = bondStyle->end1.radius;            if (atomStyle2.radius < bondStyle->end2.radius)                bondStyle->end2.atomCap = true;        }        // add midCap if style or radius for two sides of bond is different;        if (bondStyle->end1.style != bondStyle->end2.style || bondStyle->end1.radius != bondStyle->end2.radius)            bondStyle->midCap = true;        // atomCaps needed at ends of thick worms when at end of chain, or if internal residues        // are hidden or of a different style, or when missing coords of prev/next bond        if (bondStyle->end1.style == eThickWormBond || bondStyle->end2.style == eThickWormBond) {            const Residue::AtomInfo *infoV;            AtomStyle atomStyleV;            const StyleSettings::BackboneStyle *backboneStyleV;            const StyleSettings::GeneralStyle *generalStyleV;            const AtomSet *atomSet;            if (!coord1->GetParentOfType(&atomSet))                return false;            bool overlayConfs = atomSet->parentSet->showHideManager->OverlayConfEnsembles();            if (bondStyle->end1.style == eThickWormBond &&                    (!bond->previousVirtual ||                    !(infoV = object->graph->GetAtomInfo(bond->previousVirtual->atom1)) ||                    !GetAtomStyle(infoV->residue, bond->previousVirtual->atom1, NULL,                        &atomStyleV, &backboneStyleV, &generalStyleV) ||                    atomStyleV.style == eNotDisplayed ||                    backboneStyleV->style != style1 ||                    !atomSet->GetAtom(bond->previousVirtual->atom1, overlayConfs, true)))                bondStyle->end1.atomCap = true;//            if (bondStyle->end1.atomCap)//                TRACEMSG("bondStyle->end1.atomCap true at rID " << atom1.rID);            if (bondStyle->end2.style == eThickWormBond &&                    (!bond->nextVirtual ||                    !(infoV = object->graph->GetAtomInfo(bond->nextVirtual->atom2)) ||                    !GetAtomStyle(infoV->residue, bond->nextVirtual->atom2, NULL,                        &atomStyleV, &backboneStyleV, &generalStyleV) ||                    atomStyleV.style == eNotDisplayed ||                    backboneStyleV->style != style2 ||                    !atomSet->GetAtom(bond->nextVirtual->atom2, overlayConfs, true)))                bondStyle->end2.atomCap = true;//            if (bondStyle->end2.atomCap)//                TRACEMSG("bondStyle->end2.atomCap true at rID " << atom2.rID);        }    }    // if atom is larger than half bond length, don't show that half of the bond    bondLength /= 2;    if (atomStyle1.radius > bondLength) {        bondStyle->end1.style = eNotDisplayed;        bondStyle->midCap = true;    }    if (atomStyle2.radius > bondLength) {        bondStyle->end2.style = eNotDisplayed;        bondStyle->midCap = true;    }    // set highlighting color if necessary    if (atomStyle1.isHighlighted) bondStyle->end1.color = GlobalColors()->Get(Colors::eHighlight);    if (atomStyle2.isHighlighted) bondStyle->end2.color = GlobalColors()->Get(Colors::eHighlight);    return true;}bool StyleManager::GetObjectStyle(const StructureObject *object, const Object3D& object3D,    const StyleSettings::GeneralStyle& generalStyle, ObjectStyle *objectStyle) const{    // check to see if any residue covered by the object is visible    bool anyResidueVisible = false;    const Molecule *molecule = object->graph->molecules.find(object3D.moleculeID)->second;    for (int r=object3D.fromResidueID; r<=object3D.toResidueID; ++r) {        if (object->parentSet->showHideManager->IsVisible(molecule->residues.find(r)->second)) {            anyResidueVisible = true;            break;        }    }    if (!anyResidueVisible) {        objectStyle->style = eNotDisplayed;        return true;    }    // set drawing style    if (generalStyle.style == StyleSettings::eWithArrows) {        objectStyle->style = eObjectWithArrow;    } else if (generalStyle.style == StyleSettings::eWithoutArrows) {        objectStyle->style = eObjectWithoutArrow;    } else {        WARNINGMSG("StyleManager::GetObjectStyle() - invalid 3d-object style");        return false;    }    // set color    switch (generalStyle.colorScheme) {        case StyleSettings::eMolecule:            objectStyle->color = GlobalColors()->Get(Colors::eCycle1, object3D.moleculeID - 1);            break;        case StyleSettings::eObject:            objectStyle->color = GlobalColors()->Get(Colors::eCycle1, object->id - 1);            break;        case StyleSettings::eDomain:            {                int domainID = molecule->residueDomains[object3D.fromResidueID - 1];                if (domainID == Molecule::NO_DOMAIN_SET)                    objectStyle->color = GlobalColors()->Get(Colors::eNoDomain);                else                    objectStyle->color = GlobalColors()->Get(Colors::eCycle1, domainID - 1);            }            break;        case StyleSettings::eUserSelect:            objectStyle->color = generalStyle.userColor;            break;        case StyleSettings::eSecondaryStructure:            // set by caller            break;        default:            ERRORMSG("StyleManager::GetObjectStyle() - inappropriate color scheme for 3d-object");            return false;    }    return true;}bool StyleManager::GetHelixStyle(const StructureObject *object,    const Helix3D& helix, HelixStyle *helixStyle) const{    // use style of first associated residue    const StyleSettings&        settings = GetStyleForResidue(object, helix.moleculeID, helix.fromResidueID);    if (!settings.helixObjects.isOn) {        helixStyle->style = eNotDisplayed;        return true;    }    if (!GetObjectStyle(object, helix, settings.helixObjects, helixStyle))        return false;    // helix-specific settings    helixStyle->radius = settings.helixRadius;    if (settings.helixObjects.style == StyleSettings::eWithArrows) {        helixStyle->arrowLength = 4.0;        helixStyle->arrowBaseWidthProportion = 1.2;        helixStyle->arrowTipWidthProportion = 0.4;    }    if (settings.helixObjects.colorScheme == StyleSettings::eSecondaryStructure)        helixStyle->color = GlobalColors()->Get(Colors::eHelix);    return true;}bool StyleManager::GetStrandStyle(const StructureObject *object,    const Strand3D& strand, StrandStyle *strandStyle) const{    // use style of first associated residue    const StyleSettings&        settings = GetStyleForResidue(object, strand.moleculeID, strand.fromResidueID);    if (!settings.strandObjects.isOn) {        strandStyle->style = eNotDisplayed;        return true;    }    if (!GetObjectStyle(object, strand, settings.strandObjects, strandStyle))        return false;    // strand-specific settings    strandStyle->width = settings.strandWidth;    strandStyle->thickness = settings.strandThickness;    if (settings.strandObjects.style == StyleSettings::eWithArrows) {        strandStyle->arrowLength = 2.8;        strandStyle->arrowBaseWidthProportion = 1.6;    }    if (settings.strandObjects.colorScheme == StyleSettings::eSecondaryStructure)        strandStyle->color = GlobalColors()->Get(Colors::eStrand);    return true;}const StyleSettings& StyleManager::GetStyleForResidue(const StructureObject *object,    int moleculeID, int residueID) const{    const Molecule *molecule = object->graph->molecules.find(moleculeID)->second;    // find the highest priority (lowest index) annotation in the list of displayed annotations,    // that also covers this residue    const StyleSettings *style = &globalStyle;    for (int d=0; d<userAnnotationsDisplayed.size(); ++d) {        // check to see if the annotation covers this residue        ResidueMap::const_iterator            residues = userAnnotationsDisplayed[d]->residues.find(molecule->identifier);        if (residues != userAnnotationsDisplayed[d]->residues.end() &&            residues->second[residueID - 1] == true) {            style = &(userStyles.find(userAnnotationsDisplayed[d]->styleID)->second);            break;        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -