NCBI C++ ToolKit
vcf_glyph.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: vcf_glyph.cpp 47485 2023-05-02 14:46:59Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Mike DiCuccio, Liangshou Wu
27  *
28  * File Description:
29  * CVcfGlyph
30  */
31 
32 #include <ncbi_pch.hpp>
39 
40 #include <gui/widgets/gl/ruler.hpp>
42 #include <gui/objutils/utils.hpp>
44 #include <gui/objutils/tooltip.hpp>
45 #include <gui/objutils/snp_gui.hpp>
47 #include <gui/opengl/irender.hpp>
48 
59 
60 #include <objmgr/util/sequence.hpp>
64 
66 #include <corelib/ncbi_stack.hpp>
67 #include <math.h>
68 
71 
72 /// feature ruler height.
73 static const int kRulerHeight = 16;
74 
75 /// vertical space between elements.
76 static const int kVertSpace = 2;
77 
78 /// Restriction sites marker height (relative to the height of the bar)
79 static const TModelUnit kRSiteMarkerHeight = 0.5;
80 
81 /// Restriction sites marker width (absolute)
82 static const TModelUnit kRSiteMarkerWidth = 0.4;
83 
84 /// Restriction sites marker visibility threshold (ie if the marker's width is smaller then the threshold, markers are not drawn)
86 
87 /// Shoudl match feature_ds.cpp::kMinScaleForMapping
88 /// i.e. what mapping is not created then do not show ruler labels
89 static const float kMinScaleForRulerLabels = 16.;
90 
91 
92 // #define DEBUG_INFO_ON_SCREEN 1
93 
94 
95 //
96 // CVcfGlyph::CVcfGlyph()
97 //
98 
100  const string& sID,
101  size_t pos,
102  const string& ref_allele,
103  const string& alt_alleles) :
104  m_Object(new CVcfVariant(seq_id, sID, pos, ref_allele, alt_alleles))
105 {
106 // LOG_POST(Trace << "<<<< CVcfGlyph(" << sID << "/" << NStr::NumericToString(pos));
107  m_Intervals.push_back(GetRange());
108 }
109 
110 CVcfGlyph::CVcfGlyph(const CVcfVariant *object) :
111  m_Object(object)
112 {
113 // LOG_POST(Trace << "<<<< CVcfGlyph(object " << (!object ? string("NULL") : object->GetID() + "/" + NStr::NumericToString(object->GetPos())));
114  m_Intervals.push_back(GetRange());
115 }
116 
117 bool CVcfGlyph::NeedTooltip(const TModelPoint& /*p*/, ITooltipFormatter& /*tt*/, string& t_title) const
118 {
119  return true;
120 }
121 
123 {
124  // Disable HTML encoding for SV generated links
125  tooltip.SetTrustedData(true);
126  tooltip.AddRow("ClinVar Variation ID:", tooltip.CreateNcbiLink(m_Object->GetID(), NSnpGui::ClinVarIdURL + m_Object->GetID()));
127 
128  const auto &info_fields = m_Object->GetInfoColumns();
129  auto it = info_fields.find("RS");
130  if (it != info_fields.end()) {
131  tooltip.AddRow("SNP ID:", tooltip.CreateNcbiLink("rs"+it->second, NSnpGui::snpURL + it->second));
132  }
133  tooltip.SetTrustedData(false);
134  string str_buff;
135  it = info_fields.find("CLNSIG");
136  if (it != info_fields.end()) {
137  string clinsig = it->second;
138  NStr::ReplaceInPlace(clinsig, "|", ";");
139  tooltip.AddRow("ClinVar interpretation:", NStr::Replace(clinsig, "_", " ", str_buff));
140  }
141  it = info_fields.find("CLNREVSTAT");
142  if (it != info_fields.end()) {
143  NStr::Replace(it->second, "_", " ", str_buff);
144  if (!str_buff.empty()) {
145  str_buff[0] = toupper(str_buff[0]);
146  } else {
147  str_buff = "None";
148  }
149  tooltip.AddRow("Review status:", str_buff);
150  }
151 
152  str_buff.clear();
153  it = info_fields.find("CLNVCSO");
154  if (it != info_fields.end()) {
155  static const map<string, string> sm_CLNVCSO2Type = {
156  {"SO:0000159", "Deletion"},
157  {"SO:1000035", "Duplication"},
158  {"SO:1000032", "DELINS"},
159  {"SO:0000667", "Insertion"},
160  {"SO:1000036", "Inversion"},
161  {"SO:0000289", "Microsatellite"},
162  {"SO:0001563", "Structural variant"},
163  {"SO:1000173", "Tandem_duplication"},
164  {"SO:0001059", "Sequence alteration"},
165  {"SO:0000199", "Translocation"},
166  {"SO:0001742", "Copy number gain"},
167  {"SO:0001743", "Copy number loss"},
168  {"SO:0001483", "SNV"},
169  {"SO:0001013", "MNP"}
170  };
171  auto clnvcso_it = sm_CLNVCSO2Type.find(it->second);
172  if (clnvcso_it != sm_CLNVCSO2Type.end())
173  str_buff = clnvcso_it->second;
174  }
175  if (str_buff.empty()) {
176  it = info_fields.find("CLNVC");
177  if (it != info_fields.end() && it->second.empty() == false) {
178  NStr::Replace(it->second, "_", " ", str_buff);
179  str_buff[0] = toupper(str_buff[0]);
180  }
181  }
182  if (str_buff.empty())
183  str_buff = m_Object->GetVariationTypeAsString();
184 
185  if (!str_buff.empty()) {
186  tooltip.AddRow("Variation type:", str_buff);
187  }
188 
189  string allele;
190  if (!m_Object->GetAltAlleles_display().empty() && m_Object->GetAltAlleles_display().front() != ".")
191  allele = m_Object->GetAltAlleles_display().front();
192  else
193  allele = m_Object->GetRefAllele_display();
194 
195  tooltip.AddRow("ClinVar allele:", allele);
196 
197  it = info_fields.find("MC");
198  if (it != info_fields.end()) {
199  vector<string> v;
200  NStr::Split(it->second, ",", v, NStr::fSplit_Tokenize);
201  string a, b;
202  vector<string> o;
203  for (const auto& s : v) {
204  if (NStr::SplitInTwo(s, "|", a, b) && !b.empty()) {
205  o.push_back(NStr::Replace(b, "_", " ", str_buff));
206  }
207  }
208  if (!o.empty()) {
209  tooltip.AddRow("Molecular consequence:", NStr::Join(o, ","));
210  }
211  }
212 
213  str_buff.clear();
215 
216  if (strand == eNa_strand_minus) {
217  str_buff = "complement(";
218  }
219  str_buff += NStr::NumericToString(m_Object->GetPos() + 1, NStr::fWithCommas);
220  if (m_Object->GetLen() > 1) {
221  str_buff += "..";
222  str_buff += NStr::NumericToString(m_Object->GetPos() + m_Object->GetLen(), NStr::fWithCommas);
223  }
224  if (strand == eNa_strand_minus) {
225  str_buff += ")";
226  }
227  tooltip.AddRow("Location:", str_buff);
228 }
229 
230 
231 void CVcfGlyph::GetTooltip(const TModelPoint& p, ITooltipFormatter& tooltip, string& t_title) const
232 {
233  t_title = m_Object->GetID();
234 
235  if (m_Object->IsClinVar()) {
236  x_GetClinVarToolTip(tooltip);
237  } else {
238  const auto &info_fields = m_Object->GetInfoColumns();
239  tooltip.AddRow("Variation ID:", m_Object->GetID());
240  if (m_Object->IsDbVar() == false) {
241  tooltip.AddRow("Alleles:", m_Object->GetAllAlleles_display());
242  bool all_alt_alleles_same_len(true);
243  int allele_len = m_Object->GetLongestAlleleLen(all_alt_alleles_same_len);
244  if (allele_len > 0) {
245  tooltip.AddRow(string(all_alt_alleles_same_len ? "A" : "Longest a") + "llele length:", NStr::NumericToString(allele_len, NStr::fWithCommas));
246  }
247  }
248  bool var_type_shown{ false };
249 
250  if (info_fields.size() > 0) {
251  if (info_fields.count("SVTYPE")) {
252  static const map<string, string> labels{
253  { "DEL", "Deletion" },
254  { "INS", "Insertion" },
255  { "DUP", "Duplication" },
256  { "INV", "Inversion" },
257  { "CNV", "Copy number variation" },
258  { "BND", "Translocation" }
259  };
260  string svtype = info_fields.at("SVTYPE");
261  NStr::ToUpper(svtype);
262  if (labels.count(svtype) > 0) {
263  tooltip.AddRow("Variant Type:", labels.at(svtype));
264  var_type_shown = true;
265  }
266  }
267  if (info_fields.count("END"))
268  tooltip.AddRow("Endpoint:", info_fields.at("END"));
269  if (info_fields.count("CIPOS"))
270  tooltip.AddRow("Confidence intervals around POS:", info_fields.at("CIPOS"));
271  if (info_fields.count("CIEND"))
272  tooltip.AddRow("Confidence intervals around END:", info_fields.at("CIEND"));
273  if (info_fields.count("SVLEN")) {
274  string svlen = info_fields.at("SVLEN");
275  if (svlen.size() > 0) {
276  if (svlen[0] == '-')
277  svlen.erase(0, 1);
278  tooltip.AddRow("Variant length:", svlen);
279  }
280  }
281  }
282  if (!var_type_shown) {
283  tooltip.AddRow("Variant Type:", m_Object->GetVariationTypeAsString());
284  }
285  tooltip.AddRow("Position:", NStr::SizetToString(m_Object->GetPos() + 1, NStr::fWithCommas));
286  }
287  {
288  const auto &info_fields = m_Object->GetInfoColumns();
289  if (info_fields.count("DBVARID")) {
290  tooltip.AddLinksTitle("Links");
291  auto dbvarid = info_fields.at("DBVARID");
292  string dbvar_link{ "https://www.ncbi.nlm.nih.gov/dbvar/variants/" };
293  if (dbvarid == kEmptyStr)
294  dbvarid = m_Object->GetID();
295  dbvar_link += NStr::HtmlEncode(dbvarid);
296  tooltip.AddLinkRow("dbVar:", dbvarid, dbvar_link);
297  }
298  }
299 }
300 
301 
303 {
304  TSeqRange SeqRange(static_cast<TSeqPos>(m_Object->GetPos()), static_cast<TSeqPos>(m_Object->GetPos() + m_Object->GetLen() - 1));
305  return SeqRange;
306 }
307 
308 
310 {
311  while (m_CustomColorIsSet == false) {
312  m_CustomColorIsSet = true;
314  if (m_Object->IsClinVar()) {
315  const auto &info_fields = m_Object->GetInfoColumns();
316  auto clnsig_it = info_fields.find("CLNSIG");
317  string clinsig = "other";
318  if (clnsig_it != info_fields.end()) {
319  clinsig = NSnpGui::SelectClinSigTerm(clnsig_it->second);
320  }
321 
322  CRegistryReadView ColorView(CSGConfigUtils::GetColorReadView(registry, "GBPlugins.ClinVarFeature", "Default", m_Config->m_ColorTheme));
323  m_CustomColorPtr.reset(new CRgbaColor(0.349f, 0.349f, 0.349f)); // grey
324  CSGConfigUtils::GetColor(ColorView, clinsig, *m_CustomColorPtr);
325  break;
326 
327  } else if (m_Object->IsDbVar()) {
328  const auto &info_fields = m_Object->GetInfoColumns();
329  auto svtype_it = info_fields.find("SVTYPE");
330  CRegistryReadView ColorView(CSGConfigUtils::GetColorReadView(registry, "GBPlugins.dbVarFeature", "Default", m_Config->m_ColorTheme));
331  m_CustomColorPtr.reset(new CRgbaColor(0.788f, 0.788f, 0.788f)); // light grey
332  CSGConfigUtils::GetColor(ColorView, svtype_it->second, *m_CustomColorPtr);
333  break;
334  }
335 
336  CRegistryReadView ColorView(CSGConfigUtils::GetColorReadView(registry, "GBPlugins.SnpTrack", "Default", m_Config->m_ColorTheme));
337  string sColorKey("Default");
338 
339  switch(m_Object->GetVariationType()) {
341  sColorKey = "SingleBase";
342  break;
344  sColorKey = "MultiBase";
345  break;
347  sColorKey = "Insertion";
348  break;
350  sColorKey = "Deletion";
351  break;
353  sColorKey = "Dips";
354  break;
355  default:
356  break;
357  }
358  if(sColorKey != "Default") {
359  m_CustomColorPtr.reset(new CRgbaColor);
360  CSGConfigUtils::GetColor(ColorView, sColorKey, *m_CustomColorPtr);
361  }
362  }
363  if (m_CustomColorPtr) {
364  color.Set(m_CustomColorPtr->GetRed(), m_CustomColorPtr->GetGreen(), m_CustomColorPtr->GetBlue());
365  return true;
366  }
367  return false;
368 }
369 
370 
371 void CVcfGlyph::GetLabel(string& label, CLabel::ELabelType label_type) const
372 {
373  m_Object->GetLabel(label, label_type);
374 }
375 
377 {
378 // string sLabel;
379 // GetLabel(sLabel, CLabel::eContent);
380 // LOG_POST(Trace << "<<<< CVcfGlyph::GetHTMLActiveAreas() " << this << " \"" << sLabel << " isDbVar: " << IsDbVar(GetFeature()));
381 
382  CHTMLActiveArea area;
384  area.m_PositiveStrand = true;
385 
386  area.m_Signature = GetSignature();
387 
388  // a tooltip should be generated for VCF records to avoid an additional roundtrip and reloading of VCF blob
389  string s;
390  string title;
392  tooltip->SetTrustedData(false);
393  GetTooltip(TModelPoint(-1, -1), *tooltip, title);
394  s = tooltip->Render();
395  string text = NStr::Replace(s, "\n", "<br/>");
396  area.m_Descr = text;
397  p_areas->push_back(area);
398 // LOG_POST(Trace << ">>>> CVcfGlyph::GetHTMLActiveAreas() area with signature \"" << area.m_Signature << "\" generated for \"" << sLabel <<
399 // "\", rect: " << area.m_Bounds.Left() << ":" << area.m_Bounds.Right() << ":" << area.m_Bounds.Top() << ":" << area.m_Bounds.Bottom());
400 }
401 
402 
404 {
405  return true;
406 }
407 
408 
410 {
411 // LOG_POST(Trace << "==== CVcfGlyph::SetSelected() " << this << " from " << IsSelected() << " to " << f);
412  if (f != IsSelected()) {
414  }
415  return false;
416 }
417 
419 {
421 }
422 
424 {
426 }
427 
428 
430 {
431  m_HideLabel = b;
432 }
433 
434 
436 {
438 }
439 
440 /// some features may have additional info on the right (currently alleles for variations)
441 /// that will be shown at the same time as labels
442 void CVcfGlyph::GetAdditionalInfo(string& sAdditionalInfo) const
443 {
444  if (m_Object->IsClinVar()) {
445  if (!m_Object->GetAltAlleles_display().empty() && m_Object->GetAltAlleles_display().front() != ".")
446  sAdditionalInfo = m_Object->GetAltAlleles_display().front();
447  else
448  sAdditionalInfo = m_Object->GetRefAllele_display();
449  } else if (m_Object->IsDbVar()) {
450  sAdditionalInfo.clear();
451  } else {
452  sAdditionalInfo = m_Object->GetRefAllele_display() + "/" + NStr::Join(m_Object->GetAltAlleles_display(), "/");
453  }
454 }
455 
457 {
458  return true;
459 }
460 
461 void CVcfGlyph::x_Draw() const
462 {
464 /*
465  LOG_POST(Trace << "<<<<");
466 // print drawing info
467  {
468  string sLabel;
469  GetLabel(sLabel, CLabel::eContent);
470  LOG_POST(Trace << "Attempting to draw " << this << " \"" << sLabel << "\" x_isDrawn: " << x_isDrawn() <<
471  ", m_Height: " << GetHeight() << ", m_Width: " << GetWidth() <<
472  ", m_Pos.m_X: " << GetLeft() << ", m_Pos.m_Y: " << GetTop());
473  }
474 */
475  if (GetHeight() == 0 || m_Context->IntersectVisible(GetRange()).Empty() || !x_isDrawn()) {
476 // LOG_POST(Trace << ">>>> no draw");
477  return;
478  }
479  // for debugging
480  /*
481  CScope& scope = GetMappedFeature().GetAnnot().GetScope();
482  string sig = CObjFingerprint::GetFeatSignature(GetFeature(), &scope, m_sFilter);
483  int subtype;
484  CSeq_id_Handle id;
485  TSeqPos f, t;
486  CObjFingerprint::EObjectType type;
487  Uint4 fingerprint;
488  CObjFingerprint::ParseSignature(sig, id, f, t, type, subtype, fingerprint);
489  cout << ", From: " << f
490  << ", To: " << t
491  << ", Subtype: " << subtype << endl;
492  */
493  TModelUnit base = GetTop();
494 
495  TModelUnit bar_height = x_GetBarHeight();
496  x_MaybeDrawLabelAbove(base);
497  base += bar_height * 0.5; // bar center
498 
499  x_DrawVariationBar(base);
500 
502  x_DrawAdditionalInfo(base);
503 
504  if (IsSelected()) {
506  }
507 // LOG_POST(Trace << ">>>> draw done");
508 }
509 
511 {
513  // LOG_POST(Trace << "<<<<");
514 
515  if(x_isDrawn()) {
516  TSeqRange SeqRange = GetRange();
517  TModelUnit bar_height = x_GetBarHeight();
518  SetHeight(bar_height);
519  SetWidth(SeqRange.GetLength());
520  SetLeft(SeqRange.GetFrom());
521 
522  bool showLabel = x_ShowLabel();
523 
524  // we preserve label space if it fits either on side or above
525  if (showLabel) {
526  IRender& gl = GetGl();
527 
528  const CGlTextureFont& font = m_Config->m_LabelFont;
530  string label;
532  TModelUnit text_w_px = min(gl.TextWidth(&font, label.c_str()), m_Context->GetMaxLabelWidth(font));
534  SetWidth(GetWidth() + text_w_pos);
535  TModelUnit min_text_w_pos = m_Context->GetMinLabelWidthPos(font);
536 
537  if (x_LabelOnLeft()) {
538  SetLeft(GetLeft() - text_w_pos);
539  TModelRange visible_range_pos = m_Context->IntersectVisible(this);
540 
541  if (GetLeft() < 0) {
542  if (visible_range_pos.GetLength() < min_text_w_pos) {
543  // Can't even show the minimal length of label
544  SetWidth(GetWidth() + GetLeft());
545  SetLeft(0.0);
546  }
547  }
548  }
549  // also reserve some space for additional info
550  string sAdditionalInfo;
551  GetAdditionalInfo(sAdditionalInfo);
552  if (!sAdditionalInfo.empty()) {
553  TModelUnit info_width_px = min(gl.TextWidth(&font, sAdditionalInfo.c_str()), m_Context->GetMaxLabelWidth(font));
554  TModelUnit info_width_pos = m_Context->ScreenToSeq(info_width_px + CRenderingContext::kLabelSpacePx);
555  SetWidth(GetWidth() + info_width_pos);
556  if(!x_LabelOnLeft()) {
557  SetLeft(GetLeft() - info_width_pos);
558  if (GetLeft() < 0) {
559  SetWidth(GetWidth() + GetLeft());
560  SetLeft(0.0);
561  }
562  }
563  }
565  SetHeight(GetHeight() + gl.TextHeight(&font) + kVertSpace + 1);
566  }
567  }
568  } else {
569  SetHeight(0);
570  SetWidth(0);
571  SetLeft(0.0);
572  SetTop(0.0);
573  }
574  // print bounding box info
575 // {
576 // string sLabel;
577 // GetLabel(sLabel, CLabel::eContent);
578 // LOG_POST(Trace << "Bounding box for " << this << " \"" << sLabel << "\" x_isDrawn: " << x_isDrawn() <<
579 // ", m_Height: " << GetHeight() << ", m_Width: " << GetWidth() <<
580 // ", m_Pos.m_X: " << GetLeft() << ", m_Pos.m_Y: " << GetTop());
581 // LOG_POST(Trace << "Call stack for " << this << ": " << CStackTrace());
582 
583 // LOG_POST(Trace << ">>>>");
584 // }
585 }
586 
587 bool CVcfGlyph::x_RedundantLabelCheck(const string& label) const
588 {
589  // If label is redundant with the title (is contained in the title) for the
590  // track, and all glyphs in the track are the same type, do not display the label.
591  // This only applies though if the label for the track starts with '[' and ends with ']'
592  const CSeqGlyph* parent = m_Parent;
593  bool redundant = false;
594  bool all_same_type = false;
595 
596  if (label.length() > 0 && label[0] == '[' && label[label.size()-1] == ']') {
597  while (parent != NULL) {
598  const CLayoutGroup* lg = dynamic_cast<const CLayoutGroup*>(parent);
599  if (lg != NULL) {
600  all_same_type = lg->AllChildrenSameType();
601  }
602 
603  const CLayoutTrack* lt = dynamic_cast<const CLayoutTrack*>(parent);
604  if (lt != NULL) {
605  // trim blanks, brackets etc from glyph display string - e.g. [intron] to intron
606  string track_title = lt->GetFullTitle();
607  size_t start_idx = label.find_first_not_of(" ()[]'\" <>,.@#$&*");
608  size_t stop_idx = label.find_last_not_of(" ()[]'\" <>,.@#$&*");
609  size_t len = stop_idx-start_idx;
610 
611  if (len > 0 &&
612  NStr::FindNoCase(track_title, label.substr(start_idx, len)) != NPOS) {
613  redundant = true;
614  }
615  break;
616  }
617  parent = parent->GetParent();
618  }
619  }
620 
621  return (all_same_type && redundant);
622 }
623 
624 
626 {
627  return true;
628 }
629 
631 {
633  return;
634  }
636 }
637 
639 {
640  if ( !x_ShowLabel()) {
641  return;
642  }
644  return;
645 
647 }
648 
649 
650 
652 {
654  return;
655  }
656  IRender& gl = GetGl();
657 
658  // visible part of the whole glyph (feature bar + label + additional info)
659  TModelRange visible_range = m_Context->IntersectVisible(this);
660 
661  const CGlTextureFont& font = m_Config->m_LabelFont;
662  TModelUnit font_height = gl.TextHeight(&font);
663 
664  if (m_Context->WillLabelFit(visible_range)) {
665  // label text that will be shown
666  string sLabelTextOut;
667 
668  GetLabel(sLabelTextOut, CLabel::eContent);
669  // shorten the text if it is wider than visible range
670  sLabelTextOut = font.Truncate(sLabelTextOut.c_str(), m_Context->SeqToScreen(visible_range.GetLength()));
671 
672  // both above and inside labels should be centered relatively to feature bar on x axis
673  TModelUnit LabelX = visible_range.GetFrom() + visible_range.GetLength() * 0.5;
674  TModelUnit LabelY = base;
676  // move the base to give space for the text above the feature bar
677  base += font_height;
678  LabelY = base;
679  base += kVertSpace + 1;
680  }
681  if (IsSelected()) {
685  } else {
687  }
688  m_Context->TextOut(&font, sLabelTextOut.c_str(), LabelX, LabelY, true, true);
689  }
690 }
691 
692 void CVcfGlyph::x_DrawInnerLabels(TModelUnit base, vector<TModelRange> *labels_range, TSeqRange* interval) const
693 {
694  if (m_HideLabel)
695  return;
697  return;
698  TSeqRange exon_int;
699  if (interval) {
700  exon_int = interval->IntersectionWith(m_Context->GetVisSeqRange());
701  if (exon_int.Empty())
702  return;
703  }
704 
705  // visible part of the whole glyph (feature bar + label + additional info)
706  TModelRange visible_range = m_Context->IntersectVisible(this);
707 
708  const CGlTextureFont &font = m_Config->m_LabelFont;
709 
710  // location of feature bar, must not be overwritten by the label
711  TSeqRange FeatureBarRange(GetRange());
712  TModelUnit FeatureBarLeft(FeatureBarRange.GetFrom());
713  TModelUnit FeatureBarRight(FeatureBarRange.GetToOpen());
714 
715  bool side_lbl{ false };
717  // how much of the space (in sequence coords) is available for the label
718  TModelUnit LabelVisibleWidth{ 0 };
719  if (x_LabelOnLeft()) {
720  LabelVisibleWidth = (FeatureBarLeft < visible_range.GetFrom() ? 0 : FeatureBarLeft - visible_range.GetFrom());
721  }
722  else {
723  LabelVisibleWidth = (FeatureBarRight > visible_range.GetTo() ? 0 : visible_range.GetTo() - FeatureBarRight);
724  }
725  side_lbl = (LabelVisibleWidth >= m_Context->GetMinLabelWidthPos());
726  }
727 
728  string fl_content;
729  GetLabel(fl_content, CLabel::eContent);
730 
731  CRgbaColor inner_color(m_Config->m_fgColor);
732  GetCustomColor(inner_color);
733  inner_color = inner_color.ContrastingColor();
734 
735  bool inside_only = m_Config->m_LabelPos == CFeatureParams::ePos_Inside;
736  CSeqGlyph::x_DrawInnerLabels(base, fl_content, inner_color, font, side_lbl, inside_only, labels_range, exon_int.Empty() ? nullptr : &exon_int);
737 }
738 
740 {
742 
743  IRender& gl = GetGl();
744 
745  // visible part of the whole glyph (feature bar + label + additional info)
746  TModelRange visible_range_pos = m_Context->IntersectVisible(this);
747 
748  const CGlTextureFont &font = m_Config->m_LabelFont;
749  TModelUnit font_height = gl.TextHeight(&font);
750 
751  // location of feature bar, must not be overwritten by the label
752  TSeqRange FeatureBarRange(GetRange());
753  TModelUnit FeatureBarLeft(FeatureBarRange.GetFrom());
754  // this is an open position i.e. +1 of the real end pos
755  TModelUnit FeatureBarRight(FeatureBarRange.GetToOpen());
756 
757  // how much of the space (in sequence position coords) is available for the label
758  TModelUnit AvailableLabelVisibleWidthPos(x_LabelOnLeft() ?
759  (FeatureBarLeft < visible_range_pos.GetFrom() ? 0 : FeatureBarLeft - visible_range_pos.GetFrom())
760  :
761  (FeatureBarRight > visible_range_pos.GetToOpen() ? 0 : visible_range_pos.GetToOpen() - FeatureBarRight));
762 
763  string fl_content;
764  GetLabel(fl_content, CLabel::eContent);
765 
766  CRgbaColor inner_color(m_Config->m_fgColor);
767  GetCustomColor(inner_color);
768  inner_color = inner_color.ContrastingColor();
769 
770 
771  if (AvailableLabelVisibleWidthPos < m_Context->GetMinLabelWidthPos(font)) {
772  return;
773  }
774 
775  // these widths are in screen pixels
776  TModelUnit label_width_px = gl.TextWidth(&font, fl_content.c_str());
777  TModelUnit max_width_px = min(m_Context->SeqToScreen(AvailableLabelVisibleWidthPos),
778  m_Context->GetMaxLabelWidth(font));
779  if (label_width_px > max_width_px) {
780  label_width_px = max_width_px;
781  fl_content = font.Truncate(fl_content.c_str(), label_width_px);
782  if ((string::npos != fl_content.find("...")) && (fl_content.length() <= 5))
783  return;
784  }
785  // convert back to sequence position coords
786  TModelUnit label_width_pos = m_Context->ScreenToSeq(label_width_px);
787  TModelUnit label_x_pos = 0.0;
788  TModelUnit label_base = base;
789  TModelUnit label_clear_base = base;
790  TModelUnit label_clear_height = font_height;
791  label_base += (font_height * 0.5);
792 
793  // draw background - larger of font height or
794  // bar height (if label on same line, e.g. not label first)
795  TModelUnit bar_height = m_Config->m_BarHeight;
796  label_clear_base = label_base;
797  if (bar_height > font_height) {
798  label_clear_height = bar_height;
799  label_clear_base = floor(base) + (label_clear_height * 0.5);
800  }
801  if (x_LabelOnLeft()) {
802  label_x_pos = visible_range_pos.GetFrom();
803  if (label_x_pos > GetLeft()) {
806  TModelRect(label_x_pos, label_clear_base + 1, label_x_pos + label_width_pos,
807  label_clear_base - label_clear_height - 1), 0);
808  }
809  } else {
810  label_x_pos = visible_range_pos.GetToOpen() - label_width_pos;
811  if (visible_range_pos.GetTo() < GetRight()) {
814  TModelRect(label_x_pos, label_clear_base + 1, visible_range_pos.GetToOpen(),
815  label_clear_base - label_clear_height - 1), 0);
816  }
817  }
818  gl.ColorC(IsSelected() ?
820 
821  m_Context->TextOut(&font, fl_content.c_str(), label_x_pos,
822  label_base, false, true);
823 }
824 
826 {
827  if ( !x_ShowLabel() ) {
828  return;
829  }
830 
832  return;
833 
834  string sAdditionalInfo;
835  GetAdditionalInfo(sAdditionalInfo);
836  if (sAdditionalInfo.empty())
837  return;
838 
839  // visible part of the whole glyph (feature bar + label + additional info)
840  TModelRange visible_range = m_Context->IntersectVisible(this);
841  const CGlTextureFont& font = m_Config->m_LabelFont;
842 
843  // location of feature bar, must not be overwritten by the additional info
844  TSeqRange FeatureBarRange(GetRange());
845  TModelUnit FeatureBarLeft(FeatureBarRange.GetFrom());
846  TModelUnit FeatureBarRight(FeatureBarRange.GetToOpen());
847 
848  // how much of the space (in sequence coords) is available for the additional info
849  // left/right location of additional info is complementary to that of the label
850  TModelUnit AvailableAdditionalInfoVisibleWidthPos(!x_LabelOnLeft() ?
851  (FeatureBarLeft < visible_range.GetFrom() ? 0 : FeatureBarLeft - visible_range.GetFrom())
852  :
853  (FeatureBarRight > visible_range.GetToOpen() ? 0 : visible_range.GetToOpen() - FeatureBarRight));
854 
855  // add CRenderingContext::kLabelSpacePx(5px) to make sure that single letter labels exceed MinLabelWidth
856  AvailableAdditionalInfoVisibleWidthPos += m_Context->ScreenToSeq(5);
857  if(AvailableAdditionalInfoVisibleWidthPos < m_Context->GetMinLabelWidthPos(font)) {
858  return;
859  }
860 
861  IRender& gl = GetGl();
862  TModelUnit font_height = gl.TextHeight(&font);
863 // LOG_POST(Trace << "sAdditionalInfo: " << sAdditionalInfo);
864 // LOG_POST(Trace << "AvailableAdditionalInfoVisibleWidthPos: " << AvailableAdditionalInfoVisibleWidthPos);
865  // widths are in screen pixels
866  TModelUnit info_width_px = gl.TextWidth(&font, sAdditionalInfo.c_str());
867 // LOG_POST(Trace << "initial info_width_px: " << info_width_px);
868 
869  TModelUnit max_width_px = min(m_Context->SeqToScreen(AvailableAdditionalInfoVisibleWidthPos),
870  m_Context->GetMaxLabelWidth(font));
871 // LOG_POST(Trace << "max_width_px: " << max_width_px);
872  if (info_width_px > max_width_px) {
873  info_width_px = max_width_px;
874  sAdditionalInfo = font.Truncate(sAdditionalInfo.c_str(), info_width_px);
875  }
876 // LOG_POST(Trace << "modified sAdditionalInfo: " << sAdditionalInfo << " and info_width_px: " << info_width_px);
877  // convert back to sequence coords
878  TModelUnit info_width_pos = m_Context->ScreenToSeq(info_width_px);
879  TModelUnit info_x_pos = 0.0;
880  TModelUnit info_base = base;
881  TModelUnit info_clear_base = base;
882  TModelUnit info_clear_height = font_height;
883  info_base += (font_height * 0.5);
884 
885 // LOG_POST(Trace << "info_width_pos: " << info_width_pos);
886  // draw background - larger of font height or
887  // bar height (if label on same line, e.g. not label first)
888  TModelUnit bar_height = m_Config->m_BarHeight;
889  info_clear_base = info_base;
890  if (bar_height > font_height) {
891  info_clear_height = bar_height;
892  info_clear_base = floor(base) + (info_clear_height * 0.5);
893  }
894  if (!x_LabelOnLeft()) {
895  info_x_pos = visible_range.GetFrom();
896  if (info_x_pos > GetLeft()) {
897 // LOG_POST(Trace << " drawing background at left: " << info_x_pos << " with offset: " << m_Context->GetOffset());
900  TModelRect(info_x_pos, info_clear_base + 1, info_x_pos + info_width_pos,
901  info_clear_base - info_clear_height - 1), 0);
902  }
903  } else {
904  info_x_pos = visible_range.GetToOpen() - info_width_pos;
905  if (visible_range.GetTo() < GetRight()) {
906 // LOG_POST(Trace << " drawing background at right: " << info_x_pos << " with offset: " << m_Context->GetOffset());
909  TModelRect(info_x_pos, info_clear_base + 1, visible_range.GetToOpen(),
910  info_clear_base - info_clear_height - 1), 0);
911  }
912  }
914 
915 // LOG_POST(Trace << "info_x_pos: " << info_x_pos);
916  m_Context->TextOut(&font, sAdditionalInfo.c_str(), info_x_pos, info_base, false, true);
917 }
918 
919 
920 void CVcfGlyph::x_DrawInsertion(TModelUnit SeqPosTriangleMidPointX,
921  TModelUnit BoundaryYLow,
922  TModelUnit BoundaryYHigh,
923  TModelUnit YCenterLine) const
924 {
925  // half the insertion triangle width in sequence coordinates
926  TModelUnit SeqTriangleHalf = m_Context->ScreenToSeq(4.0);
927 
928  TModelUnit TriangleOffsetY = 1.0;
929  m_Context->DrawLine(SeqPosTriangleMidPointX, BoundaryYLow, SeqPosTriangleMidPointX, BoundaryYHigh);
930  m_Context->DrawTriangle(SeqPosTriangleMidPointX, YCenterLine,
931  SeqPosTriangleMidPointX + SeqTriangleHalf, BoundaryYLow - TriangleOffsetY,
932  SeqPosTriangleMidPointX - SeqTriangleHalf, BoundaryYLow - TriangleOffsetY);
933  m_Context->DrawTriangle(SeqPosTriangleMidPointX, YCenterLine,
934  SeqPosTriangleMidPointX + SeqTriangleHalf, BoundaryYHigh + TriangleOffsetY,
935  SeqPosTriangleMidPointX - SeqTriangleHalf, BoundaryYHigh + TriangleOffsetY);
936 }
937 
938 void CVcfGlyph::x_DrawDeletion(TModelUnit SeqPosTriangleMidPointX,
939  TModelUnit BoundaryYLow,
940  TModelUnit BoundaryYHigh) const
941 {
942  // half the insertion triangle width in sequence coordinates
943  TModelUnit SeqTriangleHalf = m_Context->ScreenToSeq(4.0);
944 
945  TModelUnit TriangleOffsetY = 1.0;
946 // IRender& gl = GetGl();
947 // gl.ShadeModel(GL_SMOOTH);
948  m_Context->DrawTriangle(SeqPosTriangleMidPointX, BoundaryYHigh + TriangleOffsetY,
949  SeqPosTriangleMidPointX + SeqTriangleHalf, BoundaryYLow - TriangleOffsetY,
950  SeqPosTriangleMidPointX - SeqTriangleHalf, BoundaryYLow - TriangleOffsetY);
951 // gl.ShadeModel(GL_FLAT);
952 
953 }
954 
956 {
957  return CSeqGlyph::HitTestHor(x, obj);
958 }
959 
960 bool CVcfGlyph::LessBySeqPos(const CSeqGlyph& obj) const
961 {
962  // use default, compare by SeqRanges
963  return CSeqGlyph::LessBySeqPos(obj);
964 }
965 
967 {
968  IRender& gl = GetGl();
969 
970  TModelUnit bar_height = m_Config->m_BarHeight;
972  bar_height = floor(bar_height * m_Config->m_OverviewFactor);
973  }
974  TModelUnit YCenterLine = base;
975  TModelUnit BoundaryYLow = YCenterLine - bar_height * 0.5f;
976  TModelUnit BoundaryYHigh = YCenterLine + bar_height * 0.5f;
977 
979  if ( !GetCustomColor(color) ) {
981  }
982  // a lighter version of color
983  CRgbaColor color_t = color;
984  if (m_Object->IsClinVar() == false && m_Object->IsDbVar() == false)
985  color_t.SetAlpha(0.35f);
986 
987  // Draw variation bar
988  TSeqRange SeqRange = GetRange();
989  TSeqPos SeqPosFrom = SeqRange.GetFrom();
990  TSeqPos SeqPosTo = SeqRange.GetTo();
991  x_IntersectVisible<TSeqPos>(SeqRange, SeqPosFrom, SeqPosTo);
992 
993  if (SeqRange.GetLength() > m_Context->ScreenToSeq(2.0)) { // At least 2 pixel
994  if (m_Object->IsClinVar()) {
995  gl.ColorC(color_t);
996  m_Context->DrawQuad(SeqPosFrom, BoundaryYLow, (SeqPosTo >= m_Context->GetVisibleTo()) ? SeqPosTo : SeqPosTo + 1.0, BoundaryYHigh);
997  } else {
998  m_Context->Draw3DQuad(SeqPosFrom, BoundaryYLow, SeqPosTo, BoundaryYHigh, color);
999  }
1000 
1001  if (m_Object->GetVariationType() == CVariation_inst::eType_ins) {
1002  // draw insertion
1003  CRgbaColor color_insert;
1005  gl.ColorC(color_insert);
1006  x_DrawInsertion((SeqPosFrom + SeqPosTo) * 0.5 + 0.5, BoundaryYLow, BoundaryYHigh, YCenterLine);
1007  } else if (m_Object->GetVariationType() == CVariation_inst::eType_del) {
1008  static CRgbaColor color_delete("black");
1009  gl.ColorC(color_delete);
1010  x_DrawDeletion((SeqPosFrom + SeqPosTo) * 0.5 + 0.5, BoundaryYLow, BoundaryYHigh);
1011  }
1012  gl.ColorC(color_t);
1013  x_DrawInnerLabels(base);
1014  } else {
1015  if (m_Object->IsClinVar()) {
1016  gl.ColorC(color_t);
1017  m_Context->DrawQuad(SeqPosFrom, BoundaryYLow, SeqPosTo, BoundaryYHigh, true);
1018  } else
1019  m_Context->Draw3DQuad(SeqPosFrom, BoundaryYLow, SeqPosTo, BoundaryYHigh, color, true);
1020  }
1021 }
1022 
1023 
1025 {
1026  TModelUnit height = m_Config->GetBarHeight(
1028 
1029  return height;
1030 }
1031 
1032 
1033 
1035 {
1036  bool shown = false;
1039  // in MSA context, the whole range can be very small and label can be skipped altogether
1040  //if (m_Context->WillLabelFit(m_Context->GetVisibleRange())) {
1041  shown = !m_HideLabel;
1042  //}
1043  } else { // can be either ePos_Above or ePos_Inside
1045  if (m_Context->WillLabelFit(r)) {
1046  shown = !m_HideLabel || IsSelected();
1047  }
1048  if (shown) {
1049  string fl_content;
1050  GetLabel(fl_content, CLabel::eContent);
1051  IRender& gl = GetGl();
1052  TModelUnit available_width = m_Context->SeqToScreen(r.GetLength());
1053  TModelUnit label_width = gl.TextWidth(&(m_Config->m_LabelFont), fl_content.c_str());
1054  if (label_width > available_width) {
1055  fl_content = m_Config->m_LabelFont.Truncate(fl_content.c_str(), available_width);
1056  if ((string::npos != fl_content.find("...")) && (fl_content.length() <= 5))
1057  shown = false;
1058  }
1059  }
1060  }
1061 
1062  // Check if label is redudant with track name and if so, hide:
1063  if (shown) {
1064  string fl_content;
1065  GetLabel(fl_content, CLabel::eContent);
1066  if (x_RedundantLabelCheck(fl_content))
1067  shown = false;
1068  }
1069  }
1070  return shown;
1071 }
1072 
1073 
1075 {
1076  return m_Object->GetLocation();
1077 }
1078 
1079 
1081 {
1082  return m_Object;
1083 }
1084 
1085 
1086 void CVcfGlyph::GetObjects(vector<CConstRef<CObject> >& objs) const
1087 {
1088  objs.push_back(m_Object);
1089 }
1090 
1091 
1093 {
1094  return m_Object == obj;
1095 }
1096 
1098 {
1100  return sig;
1101 }
1102 
1103 
1105 {
1106  return m_Intervals;
1107 }
1108 
1109 
1110 
1111 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
static void redundant(Char *flag)
Definition: bzip2.c:1670
CRgbaColor m_LabelColor
CRgbaColor m_bgColor
TModelUnit m_OverviewFactor
ratio to bar height
CRgbaColor m_fgColor
CGlTextureFont m_LabelFont
TModelUnit GetBarHeight(bool overview) const
ELabelPosition m_LabelPos
TModelUnit m_BarHeight
absolute size (in pixel)
@ ePos_NoLabel
no label
@ ePos_Side
always on 5' side
@ ePos_Inside
inside the rendered bar
@ ePos_Above
above the rendered bar
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
string m_Descr
description that can be used as label or tooltip
bool m_PositiveStrand
the default is true
CLayoutGroup is a container of CSeqGlyphs (layout objects).
bool AllChildrenSameType() const
Return true if there are 0 or 1 children, or all children are features of the same type (e....
File Description:
static string GetVcfVariantSignature(const objects::CVcfVariant &vcf_variant, objects::CScope *scope)
CObject –.
Definition: ncbiobj.hpp:180
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
void TextOut(const CGlTextureFont *font, const char *text, TModelUnit x, TModelUnit y, bool center, bool adjust_flip=true) const
static const int kLabelSpacePx
extra space for side labeling, in screen pixels
void DrawTriangle(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2, TModelUnit x3, TModelUnit y3, bool border=false) const
void DrawHighlight(const TModelRect &rect, const CRgbaColor *color=0) const
const TSeqRange & GetVisSeqRange() const
TModelRange IntersectVisible(const CSeqGlyph *obj) const
TModelUnit GetMinLabelWidthPos() const
void DrawLine(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2) const
objects::CScope & GetScope()
TModelUnit GetVisibleTo() const
void DrawQuad(const TModelRect &rc, bool border=false) const
void DrawSelection(const TModelRect &rc) const
TModelUnit SeqToScreen(const TModelUnit &size) const
convert from sequence positions to screen pixels
TModelUnit GetMaxLabelWidth(const CGlBitmapFont &font) const
In screen pixel..
TModelUnit ScreenToSeq(const TModelUnit &size) const
convert from screen pixels to sequence positions
bool IsOverviewMode() const
const CRgbaColor & GetSelLabelColor() const
bool WillLabelFit(const TModelRect &rc) const
void Draw3DQuad(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2, const CRgbaColor &color, bool border=false) const
void DrawBackground(const TModelRect &rcm, TModelUnit border) const
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
static CRegistryReadView GetColorReadView(const CGuiRegistry &reg, const string &base_key, const string &sect, const string &key, const string &def_sect="")
Create a read view specifically for 'Color' section.
static void GetColor(const CRegistryReadView &view, const string &key, CRgbaColor &color)
class CSeqGlyph defines an interface that wraps a rectilinear abstract object.
Definition: seq_glyph.hpp:82
void x_InitHTMLActiveArea(CHTMLActiveArea &area) const
initialize the basic information for a given active area.
Definition: seq_glyph.cpp:380
CRenderingContext * m_Context
the rendering context
Definition: seq_glyph.hpp:346
virtual bool HitTestHor(TSeqPos x, const CObject *obj)
Definition: seq_glyph.cpp:115
virtual void x_OnLayoutChanged()
update the layout.
Definition: seq_glyph.cpp:353
virtual void SetHeight(TModelUnit h)
Definition: seq_glyph.hpp:650
const CRenderingContext * GetRenderingContext() const
Get the rendering context.
Definition: seq_glyph.hpp:690
virtual TModelUnit GetRight() const
Definition: seq_glyph.hpp:603
void x_DrawInnerLabels(TModelUnit base, const string &label, const CRgbaColor &color, const CGlTextureFont &font, bool side_label_visible, bool inside_only, vector< TModelRange > *labels_ranges=nullptr, TSeqRange *interval=nullptr, bool XOR_mode=false) const
Definition: seq_glyph.cpp:224
virtual void SetWidth(TModelUnit w)
Definition: seq_glyph.hpp:646
bool IsSelected() const
Definition: seq_glyph.hpp:573
CSeqGlyph * m_Parent
parent/child relationships for this feature
Definition: seq_glyph.hpp:345
virtual void SetLeft(TModelUnit l)
Definition: seq_glyph.hpp:654
virtual TModelUnit GetTop() const
Definition: seq_glyph.hpp:599
virtual TModelUnit GetHeight() const
Definition: seq_glyph.hpp:587
virtual bool LessBySeqPos(const CSeqGlyph &obj) const
compare this object to another based on glyph sequence position.
Definition: seq_glyph.hpp:534
virtual void SetTop(TModelUnit b)
Definition: seq_glyph.hpp:658
virtual bool SetSelected(bool flag)
Select or deselect this glyph.
Definition: seq_glyph.hpp:525
virtual TModelUnit GetWidth() const
Definition: seq_glyph.hpp:591
virtual TModelUnit GetLeft() const
Definition: seq_glyph.hpp:595
TModelRect GetModelRect() const
get the bounding box.
Definition: seq_glyph.hpp:562
vector< CHTMLActiveArea > TAreaVector
Definition: seq_glyph.hpp:84
const CSeqGlyph * GetParent(void) const
Definition: seq_glyph.hpp:622
void GetLabel(string &label, CLabel::ELabelType type) const
retrieve label for a given type
Definition: vcf_glyph.cpp:371
CConstRef< objects::CVcfVariant > m_Object
Definition: vcf_glyph.hpp:176
void x_DrawDeletion(TModelUnit SeqPosTriangleMidPointX, TModelUnit BoundaryYLow, TModelUnit BoundaryYHigh) const
Definition: vcf_glyph.cpp:938
virtual void GetObjects(vector< CConstRef< CObject > > &objs) const
retrieve CObjects corresponding to this CSeqGlyph.
Definition: vcf_glyph.cpp:1086
virtual const TIntervals & GetIntervals(void) const
access sub-intervals (if any).
Definition: vcf_glyph.cpp:1104
void GetAdditionalInfo(string &sAdditionalInfo) const
variation additional info on the right (alleles)
Definition: vcf_glyph.cpp:442
bool x_LabelOnLeft() const
true if a label should be placed to the left of the feature bar (provided that it is ePos_Side)
Definition: vcf_glyph.cpp:625
bool m_CustomColorIsSet
Definition: vcf_glyph.hpp:181
void x_DrawLabelWithYPinned(TModelUnit base) const
Definition: vcf_glyph.cpp:739
virtual void GetTooltip(const TModelPoint &p, ITooltipFormatter &tt, string &t_title) const
Get the tooltip if available.
Definition: vcf_glyph.cpp:231
virtual void x_Draw() const
The default renderer for this layout object.
Definition: vcf_glyph.cpp:461
TIntervals m_Intervals
Definition: vcf_glyph.hpp:178
void x_DrawInsertion(TModelUnit SeqPosTriangleMidPointX, TModelUnit BoundaryYLow, TModelUnit BoundaryYHigh, TModelUnit YCenterLine) const
Definition: vcf_glyph.cpp:920
void LayoutChanged()
update the layout for everything encompassing this glyph
Definition: vcf_glyph.cpp:418
void x_DrawAdditionalInfo(TModelUnit base) const
Definition: vcf_glyph.cpp:825
TModelUnit x_GetBarHeight() const
Definition: vcf_glyph.cpp:1024
virtual void GetHTMLActiveAreas(TAreaVector *p_areas) const
Get html active areas.
Definition: vcf_glyph.cpp:376
void x_DrawLabelWithXPinned(TModelUnit &base) const
Definition: vcf_glyph.cpp:651
virtual bool HitTestHor(TSeqPos x, const CObject *obj)
Definition: vcf_glyph.cpp:955
virtual void SetHideLabel(bool b)
Force to hide label.
Definition: vcf_glyph.cpp:429
bool x_RedundantLabelCheck(const string &label) const
Definition: vcf_glyph.cpp:587
bool x_isDrawn() const
determines whether the glyph should be drawn or not at all (currently children of unselected parents ...
Definition: vcf_glyph.cpp:456
virtual void x_DrawHighlight() const
Definition: vcf_glyph.cpp:423
virtual const objects::CSeq_loc & GetLocation(void) const
access the position of this object.
Definition: vcf_glyph.cpp:1074
virtual bool IsClickable() const
Query if this glyph is clickable.
Definition: vcf_glyph.cpp:403
virtual bool LessBySeqPos(const CSeqGlyph &obj) const
compare this object to another based on glyph sequence position.
Definition: vcf_glyph.cpp:960
void x_GetClinVarToolTip(ITooltipFormatter &tooltip) const
Definition: vcf_glyph.cpp:122
void x_MaybeDrawLabelAbove(TModelUnit &base) const
Definition: vcf_glyph.cpp:630
virtual string GetSignature() const
return signature for this glyph.
Definition: vcf_glyph.cpp:1097
bool GetCustomColor(CRgbaColor &color) const
Get the customized color for a given feature.
Definition: vcf_glyph.cpp:309
bool m_HideLabel
Definition: vcf_glyph.hpp:173
bool x_ShowLabel() const
Definition: vcf_glyph.cpp:1034
virtual bool NeedTooltip(const TModelPoint &, ITooltipFormatter &, string &) const
Check if need to show tooltip.
Definition: vcf_glyph.cpp:117
void x_DrawInnerLabels(TModelUnit base, vector< TModelRange > *labels_range=nullptr, TSeqRange *interval=nullptr) const
Definition: vcf_glyph.cpp:692
virtual CConstRef< CObject > GetObject(TSeqPos pos) const
access our core component - we wrap an object(s) of some sort.
Definition: vcf_glyph.cpp:1080
virtual bool HasSideLabel() const
Query if there is label and label is on the side.
Definition: vcf_glyph.cpp:435
CVcfGlyph(objects::CSeq_id &seq_id, const string &sID, size_t pos, const string &ref_allele, const string &alt_alleles)
alternative alleles separated by /
virtual bool HasObject(CConstRef< CObject > obj) const
check if the wrapped object(s) is the one.
Definition: vcf_glyph.cpp:1092
void x_DrawVariationBar(TModelUnit base) const
Definition: vcf_glyph.cpp:966
virtual void x_UpdateBoundingBox()
Update the bounding box assuming children's sizes are fixed if any.
Definition: vcf_glyph.cpp:510
void x_MaybeDrawLabelOthers(TModelUnit base) const
Definition: vcf_glyph.cpp:638
CConstRef< CFeatureParams > m_Config
Definition: vcf_glyph.hpp:172
virtual bool SetSelected(bool f)
Select or deselect this glyph.
Definition: vcf_glyph.cpp:409
unique_ptr< CRgbaColor > m_CustomColorPtr
Definition: vcf_glyph.hpp:182
virtual TSeqRange GetRange(void) const
get the total range of this object.
Definition: vcf_glyph.cpp:302
vector< TSeqRange > TIntervals
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
static CMemoryRegistry registry
Definition: cn3d_tools.cpp:81
bool Empty(const CNcbiOstrstream &src)
Definition: fileutil.cpp:523
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define NULL
Definition: ncbistd.hpp:225
GLdouble TModelUnit
Definition: gltypes.hpp:48
IRender & GetGl()
convenience function for getting current render manager
virtual TModelUnit TextHeight(const CGlTextureFont *font) const =0
virtual TModelUnit TextWidth(const CGlTextureFont *font, const char *text) const =0
CGlRect< TModelUnit > TModelRect
Definition: gltypes.hpp:54
CGlPoint< TModelUnit > TModelPoint
Definition: gltypes.hpp:51
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
string Truncate(const char *text, TModelUnit w, ETruncate trunc=eTruncate_Ellipsis) const
Truncate text to the secified width.
CRgbaColor ContrastingColor(bool onlyBW=true) const
Return a color guaranteed to contrast nicely with this color.
static const string snpURL
Definition: snp_gui.hpp:180
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
static string SelectClinSigTerm(const string &clinsig)
returns the term with the highest pathogenicity if the CLNSIG string has multiple parts (terms)
Definition: snp_gui.cpp:282
void SetAlpha(float r)
Definition: rgba_color.cpp:287
static CIRef< ITooltipFormatter > CreateTooltipFormatter(ETooltipFormatters)
factory for requested tooltip formatter creation
Definition: tooltip.cpp:40
virtual void AddLinksTitle(const string &sTitle)=0
add a row with the links title
virtual void SetTrustedData(bool trusted_data)
indicates whether the data is coming from a trusted source
Definition: tooltip.hpp:227
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)=0
add a row with two columns
static const string ClinVarIdURL
standard NCBI resourse URLs
Definition: snp_gui.hpp:179
ELabelType
Definition: label.hpp:60
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const =0
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
@ eTooltipFormatter_CSSTable
generated table is CSS based, generated NCBI URLs are paths (recommended for SViewer)
Definition: tooltip.hpp:59
@ eContent
Definition: label.hpp:62
ENa_strand GetStrand(const CSeq_loc &loc, CScope *scope=0)
Returns eNa_strand_unknown if multiple Bioseqs in loc Returns eNa_strand_other if multiple strands in...
position_type GetLength(void) const
Definition: range.hpp:158
TThisType IntersectionWith(const TThisType &r) const
Definition: range.hpp:312
position_type GetToOpen(void) const
Definition: range.hpp:138
bool Empty(void) const
Definition: range.hpp:148
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2751
#define kEmptyStr
Definition: ncbistr.hpp:123
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3457
static SIZE_TYPE FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
Definition: ncbistr.cpp:2989
static string HtmlEncode(const CTempString str, THtmlEncode flags=fHtmlEnc_EncodeAll)
Encode a string for HTML.
Definition: ncbistr.cpp:4118
#define NPOS
Definition: ncbistr.hpp:133
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3310
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3550
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3401
static string & ToUpper(string &str)
Convert string to upper case – string& version.
Definition: ncbistr.cpp:424
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2508
@ fWithCommas
Use commas as thousands separator.
Definition: ncbistr.hpp:254
static const char label[]
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ eType_snv
delta=[morph of length 1] NOTE: this is snV not snP; the latter requires frequency-based validation t...
@ eType_mnp
delta=[morph of length >1]
@ eType_delins
delta=[del, ins]
n background color
int len
static void text(MDB_val *v)
Definition: mdb_dump.c:62
unsigned int a
Definition: ncbi_localip.c:102
int toupper(Uchar c)
Definition: ncbictype.hpp:73
T min(T x_, T y_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define _ASSERT
static const float kMinScaleForRulerLabels
Shoudl match feature_ds.cpp::kMinScaleForMapping i.e.
Definition: vcf_glyph.cpp:89
USING_SCOPE(objects)
static const TModelUnit kRSiteMarkerThreshold
Restriction sites marker visibility threshold (ie if the marker's width is smaller then the threshold...
Definition: vcf_glyph.cpp:85
static const int kVertSpace
vertical space between elements.
Definition: vcf_glyph.cpp:76
static const TModelUnit kRSiteMarkerWidth
Restriction sites marker width (absolute)
Definition: vcf_glyph.cpp:82
static const int kRulerHeight
feature ruler height.
Definition: vcf_glyph.cpp:73
static const TModelUnit kRSiteMarkerHeight
Restriction sites marker height (relative to the height of the bar)
Definition: vcf_glyph.cpp:79
Modified on Thu Nov 30 04:53:43 2023 by modify_doxy.py rev. 669887