default_policy.cpp
来自「ncbi源码」· C++ 代码 · 共 1,851 行 · 第 1/5 页
CPP
1,851 行
const CLayoutFeat* feat = dynamic_cast<const CLayoutFeat*> (obj); const CLayoutAlign* align = dynamic_cast<const CLayoutAlign*> (obj); const CLayoutAlignSmear* smear = dynamic_cast<const CLayoutAlignSmear*>(obj); const CLayoutProtProd* prot = dynamic_cast<const CLayoutProtProd*> (obj); const CLayoutGraph* graph = dynamic_cast<const CLayoutGraph*> (obj); const CLayoutFeatLabel* label = dynamic_cast<const CLayoutFeatLabel*> (obj); const CLayoutComment* comm = dynamic_cast<const CLayoutComment*> (obj); const CLayoutFeatPack* pack = dynamic_cast<const CLayoutFeatPack*> (obj); const CLayoutHistogram* hist = dynamic_cast<const CLayoutHistogram*> (obj); const CLayoutSeqMap* seg = dynamic_cast<const CLayoutSeqMap*> (obj); const CLayoutSequence* seqs = dynamic_cast<const CLayoutSequence*> (obj); const CLayoutMatePair* pair = dynamic_cast<const CLayoutMatePair*> (obj); const CLayoutPWAlign* pw_align = dynamic_cast<const CLayoutPWAlign*> (obj); switch (mode) { case eDrawObjectGrid: x_DrawGridLine(pane, obj, row_y); break; case eDrawObjectLines: case eDrawObjectQuads: case eDrawObjectLabel: if (comm) { x_DrawComments(pane, comm, row_y, mode, selected); } else if (seg) { x_DrawSeqSegment(pane, seg, row_y, mode, selected); } else if (pw_align) { x_DrawPWAlign(pane, pw_align, row_y, mode, selected); } else if (seqs) { x_DrawSequence(pane, seqs, row_y, mode, selected); } else if (hist) { x_DrawHistogram(pane, hist, row_y, mode, selected); } else if (label != NULL) { x_DrawFeatLabel(pane, label, row_y, mode, selected); } else if (prot != NULL) { if (mode == eDrawObjectLabel) { x_DrawProteinProduct(pane, prot, row_y, eProteinSeq, selected); } else { x_DrawFeature(pane, prot, row_y, mode, selected); } } else if (feat != NULL) { x_DrawFeature(pane, feat, row_y, mode, selected); const CSeqFeatData& data = feat->GetFeature().GetData(); if (mode == eDrawObjectLabel && data.Which() == CSeqFeatData::e_Cdregion) { x_DrawProteinProduct(pane, feat, row_y, eTranslatedSeq, selected); } } else if (align != NULL) { x_DrawAlignment(pane, align, row_y, mode, selected); } else if (smear != NULL) { x_DrawAlignmentSmear(pane, smear, row_y, mode, selected); } else if (graph != NULL) { x_DrawSeqGraph(pane, graph, row_y, mode, selected); } else if (pack != NULL) { x_DrawFeatPack(pane, pack, row_y, mode, selected); } else if (pair != NULL) { x_DrawMatePair(pane, pair, row_y, mode, selected); } break; case eCalcObjectRows: break; case eGetHTMLAreas: x_GetHTMLActiveAreas(pane, obj, row_y, selected); break; case eObjectHitTest: if (label) { return x_IsFeatLabelClicked(pane, label, row_y); } else { return x_IsObjectClicked(pane, obj, row_y, selected); } break; default: break; } return false;}void CDefaultPolicy::x_GetHTMLActiveAreas(CGlPane& pane, const CLayoutObject* obj, GLfloat row_y, bool selected) const{ string title, tooltip; const CLayoutFeatLabel* label = dynamic_cast<const CLayoutFeatLabel*> (obj); const CLayoutMatePair* mpair = dynamic_cast<const CLayoutMatePair*> (obj); if (!m_ActiveAreas || label) { return; } if (mpair) { const CLayoutMatePair::TAlignList& pw_aligns = mpair->GetSeqAligns(); ITERATE(CLayoutMatePair::TAlignList, iter, pw_aligns) { GetTitle(iter->GetPointer(), &title, CLabel::eDefault); GetTitle(iter->GetPointer(), &tooltip, CLabel::eTooltipDetailed); x_AddGetHTMLActiveElement(title, tooltip, pane, iter->GetPointer(), row_y, selected); } } else { GetTitle(obj, &title, CLabel::eDefault); GetTitle(obj, &tooltip, CLabel::eTooltipDetailed); x_AddGetHTMLActiveElement(title, tooltip, pane, obj, row_y, selected); }}void CDefaultPolicy::x_AddGetHTMLActiveElement(string title, string tooltip, CGlPane& pane, const CLayoutObject* obj, GLfloat row_y, bool selected) const{ TSeqRange r = obj->GetLocation().GetTotalRange(); TVPUnit x1 = pane.ProjectX (r.GetFrom()); TVPUnit x2 = pane.ProjectX (r.GetTo() ); TVPUnit y1 = TVPUnit(row_y); TVPUnit y2 = TVPUnit(row_y + GetRowHeight(pane, obj, selected)); x1 = max(0, x1); x2 = min(pane.GetViewport().Right(), x2); //cout << x1 << "\t" << x2 << "\t" << y1 << "\t" << y2 << endl; CHTMLActiveArea area(CHTMLActiveArea::eCheckBox, TVPRect(x1, y2, x2, y1), title, tooltip, "toggle_select"); /*pane.OpenPixels(); glColor3f(0.0f, 0.0f, 0.0f); // Black glBegin(GL_LINE_LOOP); glVertex2f(rc_bounds.Left(), pane.GetViewport().Height()-rc_bounds.Top()+5); glVertex2f(rc_bounds.Right(), pane.GetViewport().Height()-rc_bounds.Top()+5); glVertex2f(rc_bounds.Right(), pane.GetViewport().Height()-rc_bounds.Bottom()+5); glVertex2f(rc_bounds.Left(), pane.GetViewport().Height()-rc_bounds.Bottom()+5); glEnd(); pane.Close();*/ m_ActiveAreas->push_back(area);}bool CDefaultPolicy::x_IsSeqLettersFit(CGlPane& pane) const{ return pane.GetScaleX() <= 1.0f / kPixPerBase4Sequence;}void CDefaultPolicy::x_DrawGridLine(CGlPane& pane, const CLayoutObject* obj, GLfloat row_y) const{ const TModelRect& rc = pane.GetModelLimitsRect(); glVertex2f(rc.Left() - pane.GetOffsetX(), row_y - pane.GetOffsetY() ); glVertex2f(rc.Right() - pane.GetOffsetX(), row_y - pane.GetOffsetY() );}TModelUnit CDefaultPolicy::GetRowHeight(CGlPane& pane, const CLayoutObject* obj, bool selected) const{ const CLayoutComment* comm = dynamic_cast<const CLayoutComment*> (obj); const CLayoutFeat* feat = dynamic_cast<const CLayoutFeat*> (obj); const CLayoutAlign* align = dynamic_cast<const CLayoutAlign*> (obj); const CLayoutAlignSmear* smear = dynamic_cast<const CLayoutAlignSmear*> (obj); const CLayoutProtProd* prot = dynamic_cast<const CLayoutProtProd*> (obj); const CLayoutGraph* graph = dynamic_cast<const CLayoutGraph*> (obj); const CLayoutFeatLabel* label = dynamic_cast<const CLayoutFeatLabel*> (obj); const CLayoutFeatPack* pack = dynamic_cast<const CLayoutFeatPack*> (obj); const CLayoutHistogram* hist = dynamic_cast<const CLayoutHistogram*> (obj); const CLayoutSeqMap* seg = dynamic_cast<const CLayoutSeqMap*> (obj); const CLayoutSequence* seqs = dynamic_cast<const CLayoutSequence*> (obj); const CLayoutMatePair* pair = dynamic_cast<const CLayoutMatePair*> (obj); const CLayoutPWAlign* pw_aln = dynamic_cast<const CLayoutPWAlign*> (obj); if (pw_aln) return x_GetRowHeight(pane, pw_aln,selected); if (seqs) return x_GetRowHeight(pane, seqs, selected); if (comm) return x_GetRowHeight(pane, comm, selected); if (label) return x_GetRowHeight(pane, label, selected); if (align) return x_GetRowHeight(pane, align, selected); if (smear) return x_GetRowHeight(pane, smear, selected); if (prot) return x_GetRowHeight(pane, prot, selected); if (graph) return x_GetRowHeight(pane, graph, selected); if (feat) return x_GetRowHeight(pane, feat, selected); if (pack) return x_GetRowHeight(pane, pack, selected); if (hist) return x_GetRowHeight(pane, hist, selected); if (seg) return x_GetRowHeight(pane, seg, selected); if (pair) return x_GetRowHeight(pane, pair, selected); return 0;}void CDefaultPolicy::GetTitle(const CLayoutObject* obj, string* title, CLabel::ELabelType type) const { const CLayoutFeat* feat = dynamic_cast<const CLayoutFeat*> (obj); const CLayoutAlign* align = dynamic_cast<const CLayoutAlign*> (obj); //const CLayoutProtProd* prot = dynamic_cast<const CLayoutProtProd*> (obj); const CLayoutGraph* graph = dynamic_cast<const CLayoutGraph*> (obj); //const CLayoutFeatLabel* label = dynamic_cast<const CLayoutFeatLabel*> (obj); const CLayoutFeatPack* pack = dynamic_cast<const CLayoutFeatPack*> (obj); const CLayoutHistogram* hist = dynamic_cast<const CLayoutHistogram*> (obj); const CLayoutSeqMap* seg = dynamic_cast<const CLayoutSeqMap*> (obj); const CLayoutSequence* seqs = dynamic_cast<const CLayoutSequence*> (obj); const CLayoutMatePair* pair = dynamic_cast<const CLayoutMatePair*> (obj); const CLayoutPWAlign* pw_aln = dynamic_cast<const CLayoutPWAlign*> (obj); if (pw_aln) { x_GetTitle(pw_aln, title, type); } else if (align) { x_GetTitle(align, title, type); } else if (graph) { x_GetTitle(graph, title, type); } else if (feat) { x_GetTitle(feat, title, type); } else if (pack) { x_GetTitle(pack, title, type); } else if (hist) { x_GetTitle(hist, title, type); } else if (seg) { x_GetTitle(seg, title, type); } else if (seqs) { x_GetTitle(seqs, title, type); } else if (pair) { x_GetTitle(pair, title, type); }}void CDefaultPolicy::x_GetTitle(const CLayoutSeqMap* seg, string* title, CLabel::ELabelType type) const{ if (title) { title->erase(); CLabel::GetLabel(seg->GetSeqID(), title, type, &m_Handle.GetScope()); }}void CDefaultPolicy::x_GetTitle(const CLayoutSequence* seqs, string* title, CLabel::ELabelType type) const{ *title = seqs->GetSequence(); //"Sequence Bar";}void CDefaultPolicy::x_GetTitle(const CLayoutHistogram* hist, string* title, CLabel::ELabelType type) const{ *title = "Distribution Histogram for " + GetFeatConfigList()-> GetDescription(hist->Which(), hist->Subtype()) + "(s)";}void CDefaultPolicy::x_GetTitle(const CLayoutFeatPack* pack, string* title, CLabel::ELabelType type) const{ *title = "";}void CDefaultPolicy::x_GetTitle(const CLayoutFeat* feat, string* title, CLabel::ELabelType type) const{ string tmp_type, tmp_content; x_GetLabels(feat->GetFeature(), m_Handle.GetScope(), &tmp_type, &tmp_content, title);}void CDefaultPolicy::x_GetTitle(const CLayoutPWAlign* pw_aln, string* title, CLabel::ELabelType type) const{ title->erase(); const CAlnVec& aln_mgr = pw_aln->GetAlignMgr(); // display the name of the seconds sequence (not the master seq.) CAlnMap::TNumrow row = m_Handle.IsSynonym(aln_mgr.GetSeqId(0)) ? 1 : 0; CLabel::GetLabel(aln_mgr.GetSeqId(row), title, type, &m_Handle.GetScope());}void CDefaultPolicy::x_GetTitle(const CLayoutAlign* align, string* title, CLabel::ELabelType type) const{ const CAlnVec& aln_mgr = align->GetAlignMgr(); title->erase(); // otherwise display the row count *title = "[Alignment] " + NStr::UIntToString(aln_mgr.GetNumRows()) + " sequences";}void CDefaultPolicy::x_GetTitle(const CLayoutGraph* graph, string* title, CLabel::ELabelType type) const{ const CMappedGraph& gr = graph->GetGraph(); *title = gr.IsSetTitle() ? gr.GetTitle() : ""; }void CDefaultPolicy::x_GetTitle(const CLayoutMatePair* pr, string* title, CLabel::ELabelType type) const{ // It's a vector of CRefs const CLayoutMatePair::TAlignList& pw_aligns = pr->GetSeqAligns(); *title = "Mate Pair: "; string tmp = ""; ITERATE(CLayoutMatePair::TAlignList, iter, pw_aligns) { if (tmp.length() > 0) *title = *title + " / "; tmp.erase(); x_GetTitle(iter->GetPointer(), &tmp, type); *title = *title + tmp; }}TModelUnit CDefaultPolicy::x_GetRowHeight(CGlPane& pane, const CLayoutMatePair* pr, bool selected) const{ if (m_ConfigSettings->GetShowPWAlignLabels()) { return m_Font_Helv10.TextHeight() + 4 + m_Font_Helv8.TextHeight() + kSpacerSize; } else { return m_Font_Helv8.TextHeight() + kSpacerSize; }}TModelUnit CDefaultPolicy::x_GetRowHeight(CGlPane& pane, const CLayoutSequence* seqs, bool selected) const{ return 20.0f + kSpacerSize;}TModelUnit CDefaultPolicy::x_GetRowHeight(CGlPane& pane, const CLayoutHistogram* hist, bool selected) const{ return 20.0f + kSpacerSize;}TModelUnit CDefaultPolicy::x_GetRowHeight(CGlPane& pane, const CLayoutSeqMap* seg, bool selected) const{ return 3.0f + kSpacerSize;}TModelUnit CDefaultPolicy::x_GetRowHeight(CGlPane& pane, const CLayoutComment* comm,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?