📄 show_hide_manager.cpp
字号:
info->parentIndexes.push_back(moleculeIndex); structureInfo.push_back(info); } } } } } }}void ShowHideManager::GetShowHideInfo( vector < string > *names, vector < bool > *visibilities) const{ names->resize(structureInfo.size()); visibilities->resize(structureInfo.size()); for (int i=0; i<structureInfo.size(); ++i) { structureInfo[i]->GetLabel(&((*names)[i])); (*visibilities)[i] = structureInfo[i]->IsVisible(this); }}void ShowHideManager::ShowHideCallbackFunction(const vector < bool >& itemsEnabled){ if (itemsEnabled.size() != structureInfo.size()) { ERRORMSG("ShowHideManager::ShowHideCallbackFunction() - wrong size list"); return; } for (int i=0; i<itemsEnabled.size(); ++i) structureInfo[i]->Show(this, itemsEnabled[i]); TRACEMSG("entities hidden: " << entitiesHidden.size());}bool ShowHideManager::SelectionChangedCallback( const vector < bool >& original, vector < bool >& itemsEnabled){ // count number of changes int i, nChanges = 0, itemChanged, nEnabled = 0, itemEnabled; for (i=0; i<itemsEnabled.size(); ++i) { if (itemsEnabled[i] != original[i]) { ++nChanges; itemChanged = i; } if (itemsEnabled[i]) { ++nEnabled; itemEnabled = i; } } // if change was a single de/selection, then turn off/on the children of that item bool anyChange = false; if (nChanges == 1 || nEnabled == 1) { int item = (nChanges == 1) ? itemChanged : itemEnabled; for (i=item+1; i<structureInfo.size(); ++i) { for (int j=0; j<structureInfo[i]->parentIndexes.size(); ++j) { if (structureInfo[i]->parentIndexes[j] == item) { if (itemsEnabled[i] != itemsEnabled[item]) { itemsEnabled[i] = itemsEnabled[item]; anyChange = true; } } } } } // check all items to make sure that when an object is on, its parents are also on for (i=0; i<itemsEnabled.size(); ++i) { if (itemsEnabled[i]) { for (int j=0; j<structureInfo[i]->parentIndexes.size(); ++j) { if (!itemsEnabled[structureInfo[i]->parentIndexes[j]]) { itemsEnabled[structureInfo[i]->parentIndexes[j]] = true; anyChange = true; } } } } return anyChange;}void ShowHideManager::MakeAllVisible(void){ while (entitiesHidden.size() > 0) Show(entitiesHidden.begin()->first, true);}void ShowHideManager::ShowAlignedDomains(const StructureSet *set){ MakeAllVisible(); StructureSet::ObjectList::const_iterator o, oe = set->objects.end(); for (o=set->objects.begin(); o!=oe; ++o) { ChemicalGraph::MoleculeMap::const_iterator m, me = (*o)->graph->molecules.end(); for (m=(*o)->graph->molecules.begin(); m!=me; ++m) { if (m->second->IsNucleotide()) { // hide all nucleotides Show(m->second, false); continue; } if (!m->second->IsProtein()) continue; // but leave all hets/solvents visible if (!set->alignmentManager->IsInAlignment(m->second->sequence)) { Show(m->second, false); continue; } map < int, bool > domains; Molecule::ResidueMap::const_iterator r, re = m->second->residues.end(); // first pass determines which domains have any aligned residues for (r=m->second->residues.begin(); r!=re; ++r) if (set->alignmentManager->IsAligned(m->second->sequence, r->first - 1)) domains[m->second->residueDomains[r->first - 1]] = true; // second pass does hides domains not represented for (r=m->second->residues.begin(); r!=re; ++r) if (domains.find(m->second->residueDomains[r->first - 1]) == domains.end()) Show(r->second, false); } }}void ShowHideManager::PrivateShowResidues(const StructureSet *set, bool showAligned){ StructureSet::ObjectList::const_iterator o, oe = set->objects.end(); for (o=set->objects.begin(); o!=oe; ++o) { ChemicalGraph::MoleculeMap::const_iterator m, me = (*o)->graph->molecules.end(); for (m=(*o)->graph->molecules.begin(); m!=me; ++m) { if (m->second->IsNucleotide()) { // hide all nucleotides Show(m->second, false); continue; } if (!m->second->IsProtein()) continue; // but leave all hets/solvents visible if (!set->alignmentManager->IsInAlignment(m->second->sequence)) { if (showAligned) Show(m->second, false); continue; } Molecule::ResidueMap::const_iterator r, re = m->second->residues.end(); for (r=m->second->residues.begin(); r!=re; ++r) { bool aligned = set->alignmentManager->IsAligned(m->second->sequence, r->first - 1); if ((showAligned && !aligned) || (!showAligned && aligned)) Show(r->second, false); } } }}void ShowHideManager::ShowResidues(const StructureSet *set, bool showAligned){ MakeAllVisible(); PrivateShowResidues(set, showAligned);}void ShowHideManager::ShowUnalignedResiduesInAlignedDomains(const StructureSet *set){ ShowAlignedDomains(set); PrivateShowResidues(set, false);}void ShowHideManager::ShowSelectedResidues(const StructureSet *set){ MakeAllVisible(); if (!GlobalMessenger()->IsAnythingHighlighted()) return; StructureSet::ObjectList::const_iterator o, oe = set->objects.end(); for (o=set->objects.begin(); o!=oe; ++o) { bool anyResidueInObjectVisible = false; ChemicalGraph::MoleculeMap::const_iterator m, me = (*o)->graph->molecules.end(); for (m=(*o)->graph->molecules.begin(); m!=me; ++m) { Molecule::ResidueMap::const_iterator r, re = m->second->residues.end(); bool anyResidueInMoleculeVisible = false; for (r=m->second->residues.begin(); r!=re; ++r) { if (!GlobalMessenger()->IsHighlighted(m->second, r->first)) Show(r->second, false); else anyResidueInMoleculeVisible = anyResidueInObjectVisible = true; } if (!anyResidueInMoleculeVisible) { for (r=m->second->residues.begin(); r!=re; ++r) Show(r->second, true); // un-flag individual residues Show(m->second, false); // flag whole molecule as hidden } } if (!anyResidueInObjectVisible) { for (m=(*o)->graph->molecules.begin(); m!=me; ++m) Show(m->second, true); // un-flag individual molecules Show(*o, false); // flag whole object as hidden } }}void ShowHideManager::ShowDomainsWithHighlights(const StructureSet *set){ // first, show all highlighted stuff MakeAllVisible(); if (!GlobalMessenger()->IsAnythingHighlighted()) return; ShowSelectedResidues(set); // then, also show all domains that contain highlighted residues StructureSet::ObjectList::const_iterator o, oe = set->objects.end(); for (o=set->objects.begin(); o!=oe; ++o) { ChemicalGraph::MoleculeMap::const_iterator m, me = (*o)->graph->molecules.end(); for (m=(*o)->graph->molecules.begin(); m!=me; ++m) { Molecule::ResidueMap::const_iterator r, re = m->second->residues.end(); // find domains in this molecule that have highlights map < int , bool > domains; int domain; for (r=m->second->residues.begin(); r!=re; ++r) { if (GlobalMessenger()->IsHighlighted(m->second, r->first)) { domain = m->second->residueDomains[r->first - 1]; if (domain != Molecule::NO_DOMAIN_SET) domains[domain] = true; } } // now show all residues in these domains for (r=m->second->residues.begin(); r!=re; ++r) { domain = m->second->residueDomains[r->first - 1]; if (domain != Molecule::NO_DOMAIN_SET && domains.find(domain) != domains.end()) Show(r->second, true); } } }}END_SCOPE(Cn3D)/** ---------------------------------------------------------------------------* $Log: show_hide_manager.cpp,v $* Revision 1000.2 2004/06/01 18:29:21 gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.23** Revision 1.23 2004/05/21 21:41:40 gorelenk* Added PCH ncbi_pch.hpp** Revision 1.22 2004/03/15 18:32:03 thiessen* prefer prefix vs. postfix ++/-- operators** Revision 1.21 2004/02/19 17:05:13 thiessen* remove cn3d/ from include paths; add pragma to disable annoying msvc warning** Revision 1.20 2003/02/03 19:20:06 thiessen* format changes: move CVS Log to bottom of file, remove std:: from .cpp files, and use new diagnostic macros** Revision 1.19 2002/11/10 20:32:04 thiessen* show/hide optimizations, esp. show domains with highlights** Revision 1.18 2002/10/28 21:36:01 thiessen* add show domains with highlights** Revision 1.17 2002/06/21 14:40:15 thiessen* fix show/hide of nucleotides** Revision 1.16 2001/10/08 14:18:33 thiessen* fix show/hide dialog under wxGTK** Revision 1.15 2001/08/10 15:01:57 thiessen* fill out shortcuts; add update show/hide menu** Revision 1.14 2001/07/12 17:35:15 thiessen* change domain mapping ; add preliminary cdd annotation GUI** Revision 1.13 2001/06/21 02:02:34 thiessen* major update to molecule identification and highlighting ; add toggle highlight (via alt)** Revision 1.12 2001/06/02 17:22:46 thiessen* fixes for GCC** Revision 1.11 2001/05/31 18:47:09 thiessen* add preliminary style dialog; remove LIST_TYPE; add thread single and delete all; misc tweaks** Revision 1.10 2001/05/17 18:34:26 thiessen* spelling fixes; change dialogs to inherit from wxDialog** Revision 1.9 2001/03/09 15:49:05 thiessen* major changes to add initial update viewer** Revision 1.8 2001/03/01 20:15:51 thiessen* major rearrangement of sequence viewer code into base and derived classes** Revision 1.7 2001/01/25 20:21:18 thiessen* fix ostrstream memory leaks** Revision 1.6 2000/12/29 19:23:39 thiessen* save row order** Revision 1.5 2000/12/19 16:39:09 thiessen* tweaks to show/hide** Revision 1.4 2000/12/15 15:51:47 thiessen* show/hide system installed** Revision 1.3 2000/12/01 19:35:57 thiessen* better domain assignment; basic show/hide mechanism** Revision 1.2 2000/08/17 18:33:12 thiessen* minor fixes to StyleManager** Revision 1.1 2000/08/03 15:13:59 thiessen* add skeleton of style and show/hide managers**/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -