default_policy.cpp
来自「ncbi源码」· C++ 代码 · 共 1,851 行 · 第 1/5 页
CPP
1,851 行
glVertex2f(from - offsetX + 1, yy - offsetY + kPWAlignHeight * 0.5f); glVertex2f(to - offsetX, yy - offsetY + kPWAlignHeight * 0.5f); } break; case eDrawObjectQuads: // Highlight background based on Library ID if (pr->GetLibraryId() > 0) { CGlColor color = m_ColorTable.GetColor(pr->GetLibraryId()); glColor4f(color.GetRed(), color.GetGreen(), color.GetBlue(), 0.1f); TModelUnit h = x_GetRowHeight(pane, pr, selected); x_DrawQuad(pane, from, row_y, to, row_y + h); } case eDrawObjectLabel: if (mode == eDrawObjectLabel && inrc.Width() > pane.UnProjectWidth(m_MinLabelWidth) && m_ConfigSettings->GetShowPWAlignLabels() ) { string title; x_GetTitle(pr, &title); string out = m_Font_Helv10.Truncate(title.c_str(), inrc.Width() / scaleX); GLfloat xM = x_CenterText(pane, inrc, m_Font_Helv10.TextWidth(out.c_str())); x_Color(selected ? CSeqGraphicColorConfig::eSelLabel_MatePair : CSeqGraphicColorConfig::eLabel_MatePair); GLfloat title_y = row_y + m_Font_Helv10.TextHeight() + 1; m_Font_Helv10.TextOut(xM - offsetX, title_y - offsetY, out.c_str()); } ITERATE(CLayoutMatePair::TAlignList, iter, pw_aligns) { x_DrawPWAlignElem(pane, iter->GetPointer(), row_y, mode, selected, c_fg, c_seq, c_mis); } break; } }// Placeholder. Used in genome-scale viewvoid CDefaultPolicy::x_DrawFeatPack(CGlPane&, const CLayoutFeatPack*, GLfloat, EObj_IterMode, bool) const{}void CDefaultPolicy::x_DrawFeatLabel(CGlPane& pane, const CLayoutFeatLabel* feat, GLfloat row_y, EObj_IterMode mode, bool selected) const{ const TModelRect& rcV = pane.GetVisibleRect(); const TModelRect& rcM = pane.GetModelLimitsRect(); TModelUnit offsetX = pane.GetOffsetX(); TModelUnit offsetY = pane.GetOffsetY(); GLfloat th = m_Font_Helv10.TextHeight(); GLfloat title_y = row_y + th + 1; GLfloat off = rcM.Top() > 0 ? th - 1 : 0; switch (mode) { default: case eDrawObjectLines: case eDrawObjectQuads: break; case eDrawObjectLabel: string content; feature::GetLabel(feat->GetFeature(), &content, feature::eContent, &m_Handle.GetScope()); if (selected) x_Color(CSeqGraphicColorConfig::eSelLabel_Feature); else x_Color(CSeqGraphicColorConfig::eLabel_Feature); TModelUnit col_width = pane.UnProjectWidth(kLabelsColWidth); TModelUnit col_offset = col_width * feat->GetColumn(); // Trim label to fit in kLabelsColWidth string out; out = m_Font_Helv10.Truncate(content.c_str(), kLabelsMaxWidth); m_Font_Helv10.TextOut(rcV.Left() - offsetX + col_offset, title_y - off - offsetY, out.c_str()); break; }}//// draw a given feature in a given mode//void CDefaultPolicy::x_DrawFeature(CGlPane& pane, const CLayoutFeat* feat, GLfloat row_y, EObj_IterMode mode, bool selected) const{ const TModelRect& rcV = pane.GetVisibleRect(); const TModelRect& rcM = pane.GetModelLimitsRect(); TModelUnit offsetX = pane.GetOffsetX(); TModelUnit offsetY = pane.GetOffsetY(); TSeqPos from = feat->GetLocation().GetTotalRange().GetFrom(); TSeqPos to = feat->GetLocation().GetTotalRange().GetTo(); TModelRect frc; frc.SetLeft(from); frc.SetRight(to); TModelRect inrc = frc.IntersectWith(rcV); GLfloat scaleX = pane.GetScaleX(); GLfloat th = m_Font_Helv10.TextHeight(); GLfloat title_y = row_y + th + 1; GLfloat line_y1 = title_y + 3; GLfloat line_y2 = line_y1 + th + 2; GLfloat line_ym = line_y1 + (th + 2) / 2; GLfloat strand_y = line_y1 + th; GLfloat off = rcM.Top() > 0 ? th - 1 : 0; bool neg_strand = (sequence::GetStrand(feat->GetLocation()) == eNa_strand_minus); switch (mode) { default: break; case eDrawObjectLines: x_SetFeatureColor(feat); if (true/*kShowIntrons*/) { // ^ line GLfloat prev_to_x = 0.0f; bool first_pass = true; ITERATE (vector<TSeqRange>, iter, feat->GetIntervals()) { const TSeqRange& curr = *iter; TModelUnit from_x, to_x; if (neg_strand) { from_x = curr.GetTo()+1; to_x = curr.GetFrom(); } else { from_x = curr.GetFrom(); to_x = curr.GetTo()+1; } if (!first_pass) { GLfloat middle_x = prev_to_x + (from_x - prev_to_x) / 2.0f; glVertex2f(prev_to_x - offsetX, line_ym - offsetY); glVertex2f(middle_x - offsetX, line_y1 - offsetY); glVertex2f(middle_x - offsetX, line_y1 - offsetY); glVertex2f(from_x - offsetX, line_ym - offsetY); } prev_to_x = to_x; first_pass = false; } } else { // straight line glVertex2f(from - offsetX, line_ym - offsetY); glVertex2f(to - offsetX, line_ym - offsetY); } // Draw selection if (selected) { x_Color(CSeqGraphicColorConfig::eSelection_Feature); x_DrawSelection(pane, from, line_y1, to, line_y2); } break; case eDrawObjectQuads: // Highlight named Seq Annotations if (feat->GetMappedFeature().GetAnnot().IsNamed()) { CSeq_annot_Handle annot = feat->GetMappedFeature().GetAnnot(); size_t idx = x_GetSeqAnnotIndex(annot); TModelUnit h = x_GetRowHeight(pane, feat, selected);// * kOneRowHeight; CGlColor color = m_ColorTable.GetColor(idx); glColor4f(color.GetRed(), color.GetGreen(), color.GetBlue(), 0.1f); // add small overhang of 5 pixels (left and right) TModelUnit over = pane.UnProjectWidth(5); x_DrawQuad(pane, from - over, row_y, to + over + 1, row_y + h); } x_SetFeatureColor(feat); // quad for each interval (exon) ITERATE (vector<TSeqRange>, iter, feat->GetIntervals()) { const TSeqRange& curr = *iter; TModelUnit f = curr.GetFrom(); TModelUnit t = curr.GetTo()+1;// + (neg_strand ? 0.0f : 1.0f); if (pane.ProjectX(t) - pane.ProjectX(f) <= 1.0f) { t = f + pane.UnProjectWidth(1); } x_DrawQuad(pane, f, line_y1, t, line_y2); } break; case eDrawObjectLabel: // do not even try to draw labels if less than 1 letter width if (inrc.Width() <= pane.UnProjectWidth(m_MinLabelWidth)) { break; } string fl_both; string fl_type; string fl_content; string fl_out; x_GetLabels(feat->GetFeature(), m_Handle.GetScope(), &fl_type, &fl_content, &fl_both); GLfloat widthP = inrc.Width() / scaleX; // width in pixels GLfloat lw_type = m_Font_Helv10.TextWidth(fl_type.c_str() ); if ( lw_type * 3 < widthP) { // 3 widths of eType label width fl_out = m_Font_Helv10.Truncate(fl_both.c_str(), widthP); } else { fl_out = m_Font_Helv10.Truncate(fl_content.c_str(), widthP); } if (selected) { x_Color(CSeqGraphicColorConfig::eSelLabel_Feature); } else { x_Color(CSeqGraphicColorConfig::eLabel_Feature); } GLfloat xM = x_CenterText(pane, inrc, m_Font_Helv10.TextWidth(fl_out.c_str())); m_Font_Helv10.TextOut(xM - offsetX, title_y - off - offsetY, fl_out.c_str()); // draw strand indicator xM = x_CenterText(pane, inrc, m_Font_Helv10.TextWidth("<")); glColor3f(0.0f, 0.0f, 0.0f); // strand Black m_Font_Helv10.TextOut(xM - offsetX, strand_y - off - offsetY, neg_strand ? "<" : ">"); break; }}void CDefaultPolicy::x_DrawPWAlignElem(CGlPane& pane, const CLayoutPWAlign* pw_aln, GLfloat row_y, EObj_IterMode mode, bool selected, CSeqGraphicColorConfig::EDisplayElement c_fg, CSeqGraphicColorConfig::EDisplayElement c_seq, CSeqGraphicColorConfig::EDisplayElement c_mis) const{ const CAlnVec& aln_mgr = pw_aln->GetAlignMgr(); CAlnMap::TNumrow anchor = aln_mgr.GetAnchor(); TSignedSeqRange range(aln_mgr.GetAlnStart(), aln_mgr.GetAlnStop()); TSeqPos from = pw_aln->GetLocation().GetTotalRange().GetFrom(); TSeqPos to = pw_aln->GetLocation().GetTotalRange().GetTo(); TModelUnit offsetX = pane.GetOffsetX(); TModelUnit offsetY = pane.GetOffsetY(); const TModelRect& rcV = pane.GetVisibleRect(); TModelRect frc; frc.SetLeft(from); frc.SetRight(to); TModelRect inrc = frc.IntersectWith(rcV); GLfloat yy; if (m_ConfigSettings->GetShowPWAlignLabels()) { yy = row_y + m_Font_Helv10.TextHeight() + 4; } else { yy = row_y + 2; } GLfloat height = x_GetRowHeight(pane, pw_aln, selected); GLfloat scaleX = pane.GetScaleX(); CAlnMap::TNumrow row = 0; bool neg_strand = aln_mgr.IsNegativeStrand(anchor == 0 ? 1 : 0); switch (mode) { default: break; case eDrawObjectLines: { TSeqPos f = aln_mgr.GetSeqStart(anchor); TSeqPos t = aln_mgr.GetSeqStop(anchor); x_Color(c_fg); if (scaleX < 2) { TModelUnit over8 = pane.UnProjectWidth(7); TModelUnit over2 = pane.UnProjectWidth(2); if (neg_strand) { glVertex2f(f - offsetX - over2, yy - offsetY + kPWAlignHeight * 0.5f); glVertex2f(t - offsetX + 1, yy - offsetY + kPWAlignHeight * 0.5f); } else { glVertex2f(f - offsetX, yy - offsetY + kPWAlignHeight * 0.5f); glVertex2f(t - offsetX + over2 + 1, yy - offsetY + kPWAlignHeight * 0.5f); } glEnd(); glBegin(GL_TRIANGLES); if (neg_strand) { glVertex2f(f - offsetX - over8, yy - offsetY + kPWAlignHeight * 0.5f); glVertex2f(f - offsetX - over2, yy - offsetY - 1); glVertex2f(f - offsetX - over2, yy - offsetY + kPWAlignHeight + 1); } else { glVertex2f(t - offsetX + 1 + over8, yy - offsetY + kPWAlignHeight * 0.5f); glVertex2f(t - offsetX + 1 + over2, yy - offsetY - 1); glVertex2f(t - offsetX + 1 + over2, yy - offsetY + kPWAlignHeight + 1); } glEnd(); glBegin(GL_LINES); } else { glVertex2f(f - offsetX, yy - offsetY + kPWAlignHeight * 0.5f); glVertex2f(t - offsetX + 1, yy - offsetY + kPWAlignHeight * 0.5f); } } // Draw selection if (selected) { x_Color(CSeqGraphicColorConfig::eSelection_PWAlign); x_DrawSelection(pane, from, row_y, to, row_y + height); } break; case eDrawObjectQuads: case eDrawObjectLabel: // Draw Strand Indicator (do not draw labels if less than 1 letter width) // do not draw strand when sequence is shown if (mode == eDrawObjectLabel && inrc.Width() > pane.UnProjectWidth(m_MinLabelWidth) && scaleX > 1.0f / 6.0f) { GLfloat xM = x_CenterText(pane, inrc, m_Font_Helv10.TextWidth("<")); glColor3f(0.0f, 0.0f, 0.0f); // Black m_Font_Helv10.TextOut(xM - offsetX, yy + m_Font_Helv10.TextHeight() - offsetY - 2, neg_strand ? "<" : ">"); } // Should we draw sequence? if (mode == eDrawObjectLabel && scaleX > 1.0f / 6.0f) { return; // sequence would not fit } // Draw Sequence and quads for segments for ( ; row < aln_mgr.GetNumRows(); ++row) { if (row == anchor) { continue; // skip master seq } CRef<CAlnVec::CAlnChunkVec> aln_chunks (aln_mgr.GetAlnChunks(row, range, CAlnVec::fSeqOnly | CAlnVec::fChunkSameAsSeg)); for (int i = 0; i < aln_chunks->size(); ++i) { CConstRef<CAlnVec::CAlnChunk> chunk((*aln_chunks)[i]); TSeqPos start = chunk->GetRange().GetFrom(); start = aln_mgr.GetSeqPosFromSeqPos(anchor, row, start); TSeqPos stop = chunk->GetRange().GetTo(); stop = aln_mgr.GetSeqPosFromSeqPos(anchor, row, stop); if (start > stop) { swap(start, stop); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?