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

Go to the SVN repository for this file.

1 /* $Id: align_row.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: Andrey Yazhuk, Anatoliy Kuznetsov, Victor Joukov, Andrei Shkeda
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34 #include <corelib/ncbitime.hpp>
35 
36 #include <math.h>
37 #include <gui/types.hpp>
38 #include <gui/objutils/label.hpp>
39 #include <gui/opengl/glhelpers.hpp>
42 #include <gui/opengl/irender.hpp>
43 
44 #include <objmgr/graph_ci.hpp>
45 #include <objmgr/seqdesc_ci.hpp>
46 #include <objmgr/util/sequence.hpp>
51 
53 
58 
60 
61 #include <objmgr/util/sequence.hpp>
62 #include <gui/objutils/tooltip.hpp>
64 #include <wx/richmsgdlg.h>
65 
68 
69 
70 // need to keep m_RenderingCtx.pane pointing to m_TrackPane
71 // as it's used in in track handlers
73 {
74  SRenderingContextGuard(const function<void()>& f) : m_f(f) {}
76  function<void()> m_f;
77 };
78 
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// CAlnRowState
82 
84 : m_RowState(0)
85 {}
86 
88 {
89  return m_RowState;
90 }
91 
92 void CAlnRowState::SetRowState(int mask, bool b_set)
93 {
94  if(b_set) {
95  m_RowState |= mask;
96  } else {
97  m_RowState &= ~mask;
98  }
99 }
100 
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// CAlnVecRow
105 : m_Handle(handle),
106  m_ConsensusRow(NULL),
107  m_Host(NULL),
108  m_Height(0),
109  m_BaseHeight(0),
110  //m_TaxId(0),
111  //m_fTaxLabelInit(false),
112  m_bExpanded(false),
113  m_fExtOrgLookup(true),
114  m_Style(NULL),
115  m_Cache(NULL),
116  m_PixLeft(-1), m_PixRight(-1), m_ModelLeft(-1), m_ModelRight(-1)
117 {
118 }
119 
120 
123  &CAlnVecRow::x_OnGraphContentChanged)
125  &CAlnVecRow::x_OnGraphSizeChanged)
127 
128 
130 {
131  m_Style = NULL; //do not delete
132 }
133 
134 
136 {
137  m_Cache = cache;
138 }
139 
140 static void s_PrepareTrackPane(TModelUnit aln_from, TModelUnit aln_to, TModelUnit seq_from, TModelUnit seq_to,
141  const IAlignRowHandle& row_handle,
142  const CGlPane& source_pane,
143  CGlPane& target_pane)
144 {
145  TModelUnit start = seq_from;
146  TModelUnit stop = seq_to;
147  if (start > stop) {
148  swap(start, stop);
149  }
150  if (start != stop) { // if not empty
151  if (aln_from > aln_to)
152  swap(aln_from, aln_to);
153  aln_from = floor(aln_from);
154  aln_to = floor(aln_to );
155 
156  const TModelRect& source_rc_vis = source_pane.GetVisibleRect();
157  int rc_right = floor(source_rc_vis.Right());
158  int rc_left = floor(source_rc_vis.Left());
159  if (row_handle.IsNegativeStrand()) {
160  if (aln_to == rc_right) {
161  TModelUnit offset = source_rc_vis.Right() - rc_right;
162  start += (1. - offset);
163  }
164 
165  if (aln_from == rc_left) {
166  TModelUnit offset = source_rc_vis.Left() - rc_left;
167  stop += (1. - offset);
168  } else {
169  stop += 1.;
170  }
171  } else {
172  if (aln_from == rc_left) {
173  TModelUnit offset = source_rc_vis.Left() - rc_left;
174  start += offset;
175  }
176  if (aln_to == rc_right) {
177  TModelUnit offset = source_rc_vis.Right() - rc_right;
178  stop += offset;
179  } else {
180  stop += 1.;
181  }
182  }
183  } else {
184  stop += 1;
185  }
186 
187  if (row_handle.IsNegativeStrand())
188  swap(start, stop);
189  TModelRect rc_vis = target_pane.GetVisibleRect();
190  rc_vis.SetHorz(start, stop);
191  target_pane.SetModelLimitsRect(rc_vis);
192  target_pane.SetVisibleRect(rc_vis);
193 }
194 
195 
196 
198 {
199  string s_row = NStr::IntToString(m_Handle.GetRowNum());
201  const auto& rc = m_RenderCtx.m_Viewport;
202  switch(col_type) {
203  case eDescr:
204  areas.emplace_back(CAlnMultiRenderer::eHtmlArea_Link, rc, s_row, m_Handle.GetText(), "row description");
205  break;
206  case eIcons: { // generate click-able button for expanding/collapsing row
207  areas.emplace_back(CAlnMultiRenderer::eHtmlArea_Link,
209  s_row, m_Handle.IsNegativeStrand() ? "-" : "+",
210  "Strand");
211  if (!IsExpandable())
212  break;
213  areas.emplace_back(CAlnMultiRenderer::eHtmlArea_CheckBox,
215  s_row, "Click to expand/collapse", "toggle_expand");
216  break;
217  }
218  case eSeqStart: {
221  string s_num = NStr::IntToString(pos);
222  areas.emplace_back(CAlnMultiRenderer::eHtmlArea_Link, rc, s_row, s_num, "Seq Start");
223  break;
224  }
225  case eSeqEnd: {
228  string s_num = NStr::IntToString(pos);
229  areas.emplace_back(CAlnMultiRenderer::eHtmlArea_Link, rc, s_row, s_num, "Seq End");
230  break;
231  }
232  case eTaxLabel:
233  areas.emplace_back(CAlnMultiRenderer::eHtmlArea_Link, rc, s_row, m_Handle.GetOrgLabel(m_fExtOrgLookup), "Organism");
234  break;
235  case eAlignment: { // create area for alignment
236  /*
237  if (IsExpanded()) {
238  // setup CGlPane for the graph
239  CGlPane track_pane(CGlPane::eAlwaysUpdate);
240  x_InitTrackPane(pane, track_pane);
241 
242 
243  TModelRect rc_vis = track_pane.GetVisibleRect();
244  // prepare context for data update
245  TModelUnit seq_from = m_Handle.GetSeqPosFromAlnPos(rc_vis.Left(), IAlnExplorer::eRight);
246  TModelUnit seq_to = m_Handle.GetSeqPosFromAlnPos(rc_vis.Right(), IAlnExplorer::eLeft);
247 
248  s_PrepareTrackPane(rc_vis.Left(), rc_vis.Right(), seq_from, seq_to, m_Handle.IsNegativeStrand(), pane, track_pane);
249 
250  TModelRect rc_model = track_pane.GetModelLimitsRect();
251  rc_model.SetHorz(m_Handle.GetSeqStart(), m_Handle.GetSeqStop());
252  track_pane.SetModelLimitsRect(rc_model);
253 
254  // track_pane.SetViewport(track_pane.GetViewport());
255  m_RenderingCtx.PrepareContext(track_pane, true, m_Handle.IsNegativeStrand());
256  TAreaVector track_areas;
257  m_TrackPanel->GetHTMLActiveAreas(&track_areas);
258  for (auto&& area : track_areas) {
259  area.m_ID = s_row;
260  areas.push_back(area);
261  }
262  }
263  */
264 
265  /* It's not used by any clients, don't generate it
266  const TModelRect& rc_vis = pane.GetVisibleRect();
267  TSignedSeqPos vis_start = (TSignedSeqPos) floor(rc_vis.Left());
268  TSignedSeqPos vis_stop = (TSignedSeqPos) ceil(rc_vis.Right());
269 
270  TSignedSeqPos start = max(m_Handle.GetSeqAlnStart(), vis_start);
271  TSignedSeqPos stop = min(m_Handle.GetSeqAlnStop(), vis_stop);
272 
273  pane.OpenOrtho();
274  pane.Close();
275 
276  TVPUnit vp_start = pane.ProjectX(start);
277  TVPUnit vp_stop = pane.ProjectX(stop);
278  TVPRect rc = pane.GetViewport();
279  rc.SetHorz(vp_start, vp_stop);
280 
281  CHTMLActiveArea area(CAlnMultiRenderer::eHtmlArea_Link, rc,
282  s_row, m_Text, "whole alignment");
283  areas.push_back(area);
284 
285  // generate HTML areas representing segments
286  TSignedRange range(start, stop);
287  IAlnSegmentIterator::EFlags flags = IAlnSegmentIterator::eSkipInserts;
288  unique_ptr<IAlnSegmentIterator> p_it(m_Handle.CreateSegmentIterator(range, flags));
289 
290  for ( IAlnSegmentIterator& it(*p_it); it; ++it ) {
291  const IAlnSegment& seg = *it;
292  const TSignedSeqRange& R = seg.GetAlnRange();
293  start = max(R.GetFrom(), vis_start);
294  stop = min(R.GetToOpen(), vis_stop);
295  vp_start = pane.ProjectX(start);
296  vp_stop = pane.ProjectX(stop);
297  rc.SetHorz(vp_start, vp_stop);
298 
299  CHTMLActiveArea sg_area(CAlnMultiRenderer::eHtmlArea_Link, rc, s_row,
300  m_Text, "alignment section");
301  areas.push_back(sg_area);
302  }
303  */
304  }
305  break;
306  default:
307  break;
308  };
309 }
310 
311 
312 /// height of "white-space" between row borders and alignment band
313 static const int kAlignSpace = 1;
314 
315 /// vertical offset from the border of the alignment band to the border of gap band
316 static const int kGapOffset = 4;
317 
318 static const int kTextVertSpace = 2;
319 static const int kSeqVertSpace = kAlignSpace + 2;
320 
321 
323 {
324  m_Style = style;
326 }
327 
328 
330 {
332  if (m_bExpanded && m_TrackPanel) {
334  }
335 }
336 
338 {
339  m_NeedUpdateLayout = true;
340 }
341 
342 
343 void CAlnVecRow::Update(const CGlPane& pane, bool layout_only)
344 {
345  const TModelRect& rc_vis = pane.GetVisibleRect();
346  bool updated = (m_ModelLeft != rc_vis.Left() || m_ModelRight != rc_vis.Right());
347  m_ModelLeft = rc_vis.Left();
348  m_ModelRight = rc_vis.Right();
349  const auto& vp = pane.GetViewport();
350  m_PixLeft = vp.Left();
351  m_PixRight = vp.Right();
352 
353  m_NeedUpdateLayout = true;
354  m_NeedUpdateSelection = true;
355  if (m_bExpanded && m_TrackPanel) {
356  m_NeedUpdateContent = updated;
357  }
358 }
359 
361 {
362  int h = 0;
364  TModelUnit h1 = kTextVertSpace * 2;
365  TModelUnit h2 = kSeqVertSpace * 2;
366  h1 += m_Style->GetTextFont().TextHeight();
367  h2 += m_Style->GetSeqFont().TextHeight();
368  h = (int) max(h1, h2);
369  }
370  return h;
371 }
372 
373 
375 {
376  return m_Style;
377 }
378 
379 
381 {
382  m_Host = host;
383 }
384 
385 
387 {
388  return m_Handle.GetRowNum();
389 }
390 
391 
393 {
394  return m_Height;
395 }
396 
397 static
399 {
400  switch (col_type) {
402  case IAlignRow::eStart:
403  case IAlignRow::eEnd:
404  case IAlignRow::eSeqEnd:
409  case IAlignRow::eCountry:
411  case IAlignRow::eHost:
413  return IGlFont::eAlign_Left;
417  //case IAlignRow::eAlignmentScore:
418  return IGlFont::eAlign_Right;
419  default:
420  break;
421  }
422  return IGlFont::eAlign_Left;
423 }
424 
426 {
427  string error;
429  if (m_Style) try {
430  //CGlAttrGuard AttrGuard(GL_POLYGON_MODE | GL_LINE_BIT);
431  auto state = m_RenderCtx.m_State;
433 
434  switch (col_type) {
435  case eDescr: x_RenderDescr(); break;
436  case eIcons: x_RenderIcons(); break;
437  case eIconStrand:x_RenderIconStrand(); break;
438  case eIconExpand:x_RenderIconExpand(); break;
439  case eAlignment: x_RenderAlign(); break;
440 
441  case eSeqStart:
442  case eStart:
443  case eEnd:
444  case eSeqEnd:
445  case eSeqLength:
446  case eTaxLabel:
447  case eIsolationSource:
448  case eCountry:
449  case eCollectionDate:
450  case eHost:
451  case ePctIdentity:
452  case ePctCoverage:
453  case eMismatches:
454  //case eAlignmentScore:
455  case eGeneSymbol: {
456  string text;
458  break;
459  }
460  default:
461  NCBI_ASSERT(0, "Unknown column type");
462  break; // unknown column
463  } // switch
464  } catch(CException& e) {
465  error = e.GetMsg();
466  } catch(std::exception& e) {
467  error = e.what();
468  }
469  if (!error.empty()) {
470  ERR_POST("CAlnVecRow::RenderColumn() " << error);
471  }
472 }
473 
474 string& CAlnVecRow::GetColumnText(TColumnType col_type, string& text, bool for_printer) const
475 {
476  text.clear();
477  switch (col_type) {
478  case eDescr:
479  text = m_Handle.GetText();
480  if (for_printer) {
481  text += " (";
482  text += (m_Handle.IsNegativeStrand()) ? "-" : "+";
483  text += ")";
484  }
485  break;
486  case eSeqStart: {
488  break;
489  }
490  case eStart: {
491  int aln_pos = (int)floor(m_RenderCtx.m_Pane->GetVisibleRect().Left());
493  break;
494  }
495  case eEnd: {
496  int aln_pos = -1 + (int) ceil(m_RenderCtx.m_Pane->GetVisibleRect().Right());
498  break;
499  }
500  case eSeqEnd:
502  break;
503  case eSeqLength:
505  break;
506  case eTaxLabel:
508  break;
509  case eIsolationSource:
511  break;
512  case eCountry:
514  break;
515  case eCollectionDate:
517  break;
518  case eHost:
520  break;
521  case ePctIdentity:
523  break;
524  case ePctCoverage:
526  break;
527  case eMismatches:
529  break;
530  //case eAlignmentScore:
531  // break;
532  case eGeneSymbol:
534  break;
535 
536  default:
537  break; // unknown column
538  } // switch
539  return text;
540 }
541 
542 void CAlnVecRow::OnMouseEvent(wxMouseEvent& event, TColumnType col_type, CGlPane& pane)
543 {
544  event.Skip(true);
545  wxEventType type = event.GetEventType();
546  if (type == wxEVT_LEFT_DOWN && (col_type == IAlignRow::eIconExpand || col_type == IAlignRow::eIcons)) {
547  wxPoint pos = event.GetPosition();
549  int shift = ((col_type == IAlignRow::eIconExpand) ? 0 : 1);
550  auto row_top = x_GetHost()->ARH_GetRowTop(this);
551  PrepareRendering(pane, row_top, shift);
552  TVPRect rc_btn = x_GetButtonRect(eExpand, shift);
553  if(rc_btn.PtInRect(pt)) {
554  event.Skip(false);
555  x_OnClickExpandBtn(pane);
556  return;
557  }
558  }
560  wxPoint pos = event.GetPosition();
562  TModelPoint hit_point;
563  CRef<CSeqGlyph> glyph = x_HitTest(pt, pane, hit_point);
564  //m_LastHitGlyph.Reset(glyph.GetPointer());
566  m_TrackHandler->ProcessEvent(event);
567  bool skipped = event.GetSkipped() || dynamic_cast<CLayoutTrack*>(glyph.GetPointer()) == nullptr;
568  if (skipped) {
569  if (glyph && glyph->IsClickable()) {
570  if (type == wxEVT_LEFT_DOWN) {
571  skipped = glyph->OnLeftDown(hit_point);
572  } else if (type == wxEVT_LEFT_UP) {
573  skipped = glyph->OnLeftUp(hit_point);
574  const IObjectBasedGlyph* obj = dynamic_cast<const IObjectBasedGlyph*>(&*glyph);
575  if (obj) {
577  CConstRef<CObject> sel_obj = obj->GetObject(hit_point.m_X);
578  if (sel_visitor->IsObjectSelected(sel_obj)) {
579  sel_visitor->DeSelectObject(sel_obj);
580  } else {
581  if (!event.CmdDown()) {
582  if (sel_visitor->HasSelectedObjects())
583  sel_visitor->Clear();
584  }
585  sel_visitor->SelectObject(sel_obj, true);
586  }
587  skipped = true;
588  m_NeedUpdateSelection = true;
590  }
591  } else if (type == wxEVT_LEFT_DCLICK) {
592  skipped = glyph->OnLeftDblClick(hit_point);
593  }
594  }
595  }
596  event.Skip(skipped);
597  }
598 }
599 
600 
601 static const int kTooltipMaxLines = 5;
602 static const int kMaxSeqInTooltip = 20;
603 
604 
605 void CAlnVecRow::GetTooltip(const TVPPoint& vp_pt, TColumnType col_type,
606  CGlPane& pane, ITooltipFormatter& tooltip)
607 {
608  switch(col_type) {
609  case eDescr:
610  x_GetDescrTooltip(vp_pt, pane, tooltip);
611  break;
612  case eIcons:
613  x_GetIconsTooltip(vp_pt, pane, tooltip);
614  break;
615  case eSeqStart:
616  tooltip.AddRow("First position in sequence coordinates");
617  break;
618  case eStart:
619  tooltip.AddRow("First visible position in alignment coordinates");
620  break;
621  case eAlignment:
622  x_GetAlignmentTooltip(vp_pt, pane, tooltip);
623  break;
624  case eEnd:
625  tooltip.AddRow("Last visible position in alignment coordinates");
626  break;
627  case eSeqEnd:
628  tooltip.AddRow("Last position in sequence");
629  break;
630  case eSeqLength:
631  tooltip.AddRow("Sequence length");
632  break;
633  case eTaxLabel:
634  tooltip.AddRow("Organism name");
635  break;
636  default:
637  break;
638  }
639 }
640 
641 
642 void CAlnVecRow::x_GetDescrTooltip(const TVPPoint& /*vp_pt*/, CGlPane& /*pane*/, ITooltipFormatter& tooltip)
643 {
644  // first, the text for our row
645  tooltip.AddRow(m_Handle.GetText());
646  string type;
647 
650  // next, title of the bioseq
651  tooltip.AddRow(sequence::CDeflineGenerator().GenerateDefline(handle));
652 
653  // org info
654  try {
655  const COrg_ref& ref = sequence::GetOrg_ref(handle);
656  string str;
657  ref.GetLabel(&str);
658  tooltip.AddRow("Organism:", str);
659  } catch (CException&) {
660  }
661 
662  /// sequence length information
663  if (handle.IsNa()) {
664  type = " bases";
665  } else {
666  type = " residues";
667  }
668  tooltip.AddRow("Sequence length:", NStr::IntToString(handle.GetBioseqLength(), NStr::fWithCommas) + type);
669 
670  }
671  tooltip.AddRow("Aligned length:", NStr::IntToString(m_Handle.GetSeqStop() - m_Handle.GetSeqStart() + 1, NStr::fWithCommas) + type);
672 }
673 
675 {
676  _ASSERT(x_GetHost());
677  string s_tip;
678 
679  EButtons btn = x_HitTestButton(pane, vp_pt);
680  switch(btn) {
681  case eStrandMarker: {
682  s_tip = "Strand - ";
683  s_tip += m_Handle.IsNegativeStrand() ? "Negative" : "Positive";
684  }; break;
685  case eExpand: {
686  if(IsExpandable()) {
687  s_tip = "Graphs: Click to ";
688  s_tip += m_bExpanded ? "collapse" : "expand";
689  } else {
690  s_tip = "No graphs available - nothing to expand";
691  }
692  }; break;
693  //case eSetupGraphs: s_tip = "Setup Graphs"; break;
694  default: break;
695  }
696  tooltip.AddRow(s_tip);
697 }
698 
699 
700 #define TOOLTIP_RANGE_PIX 3
701 
703 {
704  string s = NStr::IntToString(from + 1, NStr::fWithCommas);
705  s += "-";
706  s += NStr::IntToString(to + 1, NStr::fWithCommas);
707  return s;
708 }
709 
710 
712  const CGlPane& src_pane,
713  CGlPane& target_pane,
714  const function <bool(CGlPane& pane)>& f)
715 {
716  TModelUnit offset_x = src_pane.GetOffsetX();
717  TModelUnit scale_x = src_pane.GetScaleX();
718  TVPRect viewport = target_pane.GetViewport();
719  TVPUnit left = viewport.Left();
720  TVPUnit right = viewport.Right();
721 
723  unique_ptr<IAlnSegmentIterator> align_it(m_Handle.CreateSegmentIterator(range, flags));
724  using TRangeData = tuple < IAlnExplorer::TSignedRange, IAlnExplorer::TSignedRange, COpenRange<double> >;
725  vector <TRangeData> render_list;
726  int index = -1;
727  for (; *align_it; ++(*align_it)) {
728  const IAlnSegment& seg = **align_it;
729  if (!seg.IsAligned())
730  continue;
731  auto& seq_range = seg.GetRange();
732  if (seq_range.Empty())
733  continue;
734  auto& aln_range = seg.GetAlnRange();
735  if (aln_range.Empty())
736  continue;
737 
738  //TSignedSeqPos aln_from = m_Handle.GetAlnPosFromSeqPos(seq_range.GetFrom(), IAlnExplorer::eRight);
739 // TSignedSeqPos aln_to = m_Handle.GetAlnPosFromSeqPos(seq_range.GetTo(), IAlnExplorer::eLeft);
740 // IAlnExplorer::TSignedRange aln_range(aln_from, aln_to);
741  double x1 = aln_range.GetFrom();
742  double x2 = aln_range.GetTo();
743  if (x1 > x2)
744  swap(x1, x2);
745  x1 = (x1 - offset_x) / scale_x;
746  x2 = (x2 - offset_x + 1) / scale_x;
747  x1 = max<TModelUnit>(x1 + left, left);
748  x2 = min<TModelUnit>(x2 + left, right);
749  /*
750  // x1 - prev x2
751  if (index >= 0 && floor(x1 - get<2>(render_list[index]).GetTo()) <= 1.0) {
752  auto& data = render_list[index];
753  get<0>(data).SetTo(seq_range.GetTo());
754  if (m_Handle.IsNegativeStrand())
755  get<1>(data).SetTo(aln_range.GetTo());
756  else
757  get<1>(data).SetFrom(aln_range.GetFrom());
758  get<2>(data).SetTo(x2);
759  } else
760  */
761  {
762  render_list.emplace_back(seq_range, aln_range, COpenRange<double>(x1, x2));
763  ++index;
764  }
765  }
766  for (auto& data : render_list) {
767  auto& seq_range = get<0>(data);
768  auto& aln_range = get<1>(data);
769  auto& view_range = get<2>(data);
770  viewport.SetHorz(view_range.GetFrom(), view_range.GetTo());
771  if (abs(viewport.Width()) <= 1)
772  continue;
773  auto l = view_range.GetFrom(), r = view_range.GetTo();
774  if (l > r) swap(l, r);
775  if (m_PixRight <= l || m_PixLeft >= r)
776  continue;
777  auto len = (r - l) + 1;
778  if (len < 2)
779  continue;
780 
781  IRender& gl = GetGl();
782  if (gl.IsPrinterFriendly()) {
783  gl.BeginClippingRect(viewport.Left(), viewport.Top(), viewport.Width(), viewport.Height());
784  }
785  target_pane.SetViewport(viewport);
786  s_PrepareTrackPane(aln_range.GetFrom(), aln_range.GetTo(),
787  seq_range.GetFrom(), seq_range.GetTo(),
788  m_Handle, src_pane, target_pane);
789  bool error = f(target_pane);
790  if (gl.IsPrinterFriendly()) {
791  gl.EndClippingRect();
792  }
793  if (error)
794  break;
795  }
796 }
797 
799 {
800  /*
801  // need to keep m_RenderingCtx.pane pointing to m_TrackPane
802  // as it's used in in track handlers
803  struct SRenderingContextGuard
804  {
805  SRenderingContextGuard(const function<void()>& f) : m_f(f) {}
806  ~SRenderingContextGuard() { m_f(); }
807  function<void()> m_f;
808  };
809  */
810  SRenderingContextGuard ctx_guard([&]() {
811  m_RenderingCtx->SetRenderingFlags(0);
812  m_RenderingCtx->PrepareContext(*m_TrackPane, true, m_Handle.IsNegativeStrand());
813  });
814 
815  // First check if there is a hit for TrackPane
816  // which covers the whole track area
817  // and return if mouse hits a track container.
818  // In this case we're intersted in track title bar and icon controls hits
819  // for all other objects we check the hits within each alignment segment
820  CRef<CSeqGlyph> glyph;
821 
822  CGlPane track_pane(CGlPane::eAlwaysUpdate);
823  if (!x_InitTrackPane(pane, track_pane))
824  return glyph;
825 
826  const TModelRect& rc_vis = track_pane.GetVisibleRect();
827  m_RenderingCtx->SetRenderingFlags(0);
828 
829  TSignedSeqRange range(rc_vis.Left(), rc_vis.Right());
832  s_PrepareTrackPane(rc_vis.Left(), rc_vis.Right(), seq_from, seq_to,
833  m_Handle, pane, track_pane);
836  m_RenderingCtx->PrepareContext(track_pane, true, m_Handle.IsNegativeStrand());
837 
838  {
839  CGlPaneGuard GUARD(track_pane, CGlPane::eOrtho);
840  hit_point = track_pane.UnProject(vp_pt.X(), vp_pt.Y());
841  }
842  //m_TrackPanel->Update(true);
843  CRef<CSeqGlyph> layout_track_hit = m_TrackPanel->HitTest(hit_point);
844  if (dynamic_cast<CLayoutTrack*>(layout_track_hit.GetPointer()) != 0)
845  m_LastHitTrack.Reset(dynamic_cast<CLayoutTrack*>(layout_track_hit.GetPointer()));
846  // a title/icons bar or any glyph if it's a master row
847  if (m_Handle.IsAnchor() || dynamic_cast<CLayoutTrack*>(layout_track_hit.GetPointer()) != 0)
848  return layout_track_hit;
849  {
850  // get hit_point.m_X from the alignment row pane
851  // to avoid rounding discrepancies
852  // when the pos is uprojected from track_pane
853  // hit_point.m_Y is unprojected from m_TrackPane
854  CGlPaneGuard GUARD(pane, CGlPane::eOrtho);
855  TSeqPos pos = (TSeqPos)pane.UnProjectX(vp_pt.X());
856  hit_point.m_X = m_Handle.GetSeqPosFromAlnPos(pos);
857  }
858 
859  if (hit_point.m_X < 0)
860  return glyph;
861 
862  if (m_NeedUpdateSelection) {
864  sel_visitor->UpdateSelection(&*m_TrackPanel);
865  }
867 
868  x_ForEachAlnSeg(range, pane, track_pane, [&](CGlPane& track_pane) {
869  m_RenderingCtx->PrepareContext(track_pane, true, m_Handle.IsNegativeStrand());
870  if (!m_RenderingCtx->IsInVisibleRange(hit_point.m_X))
871  return false;
872  m_TrackPanel->Update(true);
873  glyph = m_TrackPanel->CGlyphContainer::HitTest(hit_point);
874  if (dynamic_cast<CLayoutTrack*>(glyph.GetPointer()) != 0)
875  m_LastHitTrack.Reset(dynamic_cast<CLayoutTrack*>(glyph.GetPointer()));
876  return glyph != 0;
877  });
878  return glyph;
879 
880 }
881 
883 {
884  pane.OpenOrtho();
885  pane.Close();
886  double w_x = pane.UnProjectX(vp_pt.X());
887  double pix_w = pane.UnProjectWidth(TOOLTIP_RANGE_PIX);
888  TSeqPos pos = (TSeqPos)w_x;
889 
890  if (m_bExpanded && m_TrackPanel) {
891  // m_PixLeft, m_PixRight are not initialized in sviewer context
892  if (m_PixLeft <0 || m_PixRight < 0) {
893  const auto& vp = pane.GetViewport();
894  m_PixLeft = vp.Left();
895  m_PixRight = vp.Right();
896  }
897 
898  TModelPoint hit_point;
899  CRef<CSeqGlyph> glyph = x_HitTest(vp_pt, pane, hit_point);
900  //m_LastHitGlyph.Reset(glyph.GetPointer());
901  if (glyph) {
902  string s_tip;
904  glyph->GetTooltip(hit_point, *track_tooltip, s_tip);
905  if (!track_tooltip->IsEmpty()) {
906  // Show only feat panel tooltip for title bars and menu icons
907  // otherwise combine track panel and aligmnet tooltips
908  if (dynamic_cast<CLayoutTrack*>(glyph.GetPointer()) != nullptr) {
909  m_LastHitTrack.Reset(dynamic_cast<CLayoutTrack*>(glyph.GetPointer()));
910  tooltip.Append(*track_tooltip);
911  return;
912  }
913  s_tip = m_Handle.GetText();
915  s_tip += ", Negative Strand";
916  tooltip.AddRow(s_tip);
917  tooltip.AddRow("Alignment Pos:", NStr::IntToString(pos + 1, NStr::fWithCommas));
918  tooltip.AddRow(NcbiEmptyString);
919  tooltip.Append(*track_tooltip);
920  return;
921  }
922  }
923  }
924  // Append information on gaps and inserts
925  TSeqPos start = (TSeqPos)floor(w_x - pix_w / 2);
926  TSeqPos end = (TSeqPos)ceil(w_x + pix_w / 2);
927  //TSeqPos start = (TSeqPos)floor(w_x);
928  TSignedRange range(start, end);
929  x_GetAlignmentTooltip_Helper(pos, range, tooltip);
930 }
931 
932 
934 {
935  TSignedRange range(pos-half_width, pos+half_width);
937  x_GetAlignmentTooltip_Helper(pos, range, *formatter);
938  return formatter->Render();
939 }
940 
942 {
943  x_GetAlignmentTooltip_General(pos, tooltip);
944  {
946  //IAlnSegmentIterator::EFlags flags = IAlnSegmentIterator::eAllSegments;
947  unique_ptr<IAlnSegmentIterator> p_it(m_Handle.CreateSegmentIterator(range, flags));
948  for (IAlnSegmentIterator& it = *p_it; it; ++it) {
949  const IAlnSegment& seg = *it;
950  if (seg.GetRange().Empty())
951  continue;
952  const TSignedSeqRange& aln_r = it->GetAlnRange();
953  const TSignedSeqRange& seq_r = it->GetRange();
954  x_GetAlignmentTooltip_Insert(aln_r, seq_r, tooltip);
955  return;
956  }
957  }
958 
959 
960  // obtain segments in the range [start, end]
962  unique_ptr<IAlnSegmentIterator> p_it(m_Handle.CreateSegmentIterator(range, flags));
963  IAlnSegmentIterator& it = *p_it;
964 
965  if(it) {
966  // last positions on the last aligned segment
967  TSignedSeqPos prev_to = -2, prev_aln_to = -2;
968  const int kMaxRegions = 5; // max inserts or unaligned regions reported
969  int n_regions = 0;
970 
971  for (int i = 0; it && i < kTooltipMaxLines; i++, ++it ) {
972  const TSignedSeqRange& aln_r = it->GetAlnRange();
974  break;
976  const TSignedSeqRange& seq_r = it->GetRange();
977 
978  bool aligned = (type & IAlnSegment::fAligned) && ! aln_r.Empty();
979  bool insert = (type & IAlnSegment::fAligned) && aln_r.Empty();
980  bool gap = (type & IAlnSegment::fGap) && aln_r.GetLength() > 0;
981 
982  if(insert) {
983  if(n_regions < kMaxRegions) {
984  x_GetAlignmentTooltip_Insert(aln_r, seq_r, tooltip);
985  }
986  n_regions++;
987  } else if (gap) {
988  if(n_regions < kMaxRegions) {
989  auto seq_from = m_Handle.GetSeqPosFromAlnPos(pos, IAlnExplorer::eLeft);
991  if (seq_from > seq_to)
992  swap(seq_from, seq_to);
993 
994  auto aln_from = m_Handle.GetAlnPosFromSeqPos(seq_from, IAlnExplorer::eLeft) + 1;
995  auto aln_to = m_Handle.GetAlnPosFromSeqPos(seq_to, IAlnExplorer::eRight) - 1;
996  if (aln_from > aln_to)
997  swap(aln_from, aln_to);
998 
999  x_GetAlignmentTooltip_Gap(TSignedSeqRange(aln_from, aln_to), TSignedSeqRange(seq_from, seq_to), tooltip);
1000  //x_GetAlignmentTooltip_Gap(aln_r, seq_r, tooltip);
1001  }
1002  n_regions++;
1003  } else if(aligned) {
1004  if(aln_r.GetFrom() == prev_aln_to + 1 && seq_r.GetFrom() > prev_to + 1) {
1005  // there is an unaligned region
1006  if(n_regions < kMaxRegions) {
1007  x_GetAlignmentTooltip_Unaligned(prev_aln_to, aln_r.GetFrom(),
1008  prev_to, seq_r.GetFrom(),
1009  tooltip);
1010  }
1011  n_regions++;
1012  }
1013 
1014  prev_aln_to = aln_r.GetTo();
1015  prev_to = seq_r.GetTo();
1016  }
1017  }
1018 
1019  if(n_regions > kMaxRegions)
1020  tooltip.AddRow("total: ", NStr::IntToString(n_regions));
1021  }
1022 }
1023 
1024 
1025 // Sequence title: descr / title
1026 static string s_GetTitle(const CSeq_descr &descr)
1027 {
1028  string res;
1029  for (auto seqdesc : descr.Get()) {
1030  if (seqdesc->IsTitle()) {
1031  res = seqdesc->GetTitle();
1032  break;
1033  }
1034  }
1035  return res;
1036 }
1037 
1038 
1039 // Source subtypes: descr / source / subtype / subtype *
1040 static string s_GetSourceSubtype(const CSeq_descr &descr, CSubSource::ESubtype subtype)
1041 {
1042  string res;
1043  for (auto seqdesc : descr.Get()) {
1044  if (seqdesc->IsSource()) {
1045  const CBioSource &bs = seqdesc->GetSource();
1046  if (bs.IsSetSubtype()) {
1047  for (auto subsrc : bs.GetSubtype()) {
1048  if (subsrc->IsSetSubtype() && subsrc->GetSubtype() == subtype) {
1049  return subsrc->GetName();
1050  }
1051  }
1052  }
1053  }
1054  }
1055  return res;
1056 }
1057 
1058 
1059 // Host: descr / source / org / orgname / mod / subtype nat-host
1060 static string s_GetOrgModNatHost(const CSeq_descr &descr)
1061 {
1062  string res;
1063  for (auto seqdesc : descr.Get()) {
1064  if (seqdesc->IsSource()) {
1065  const CBioSource &bs = seqdesc->GetSource();
1066  if (bs.IsSetOrgname()) {
1067  const COrgName& on = bs.GetOrgname();
1068  if (on.CanGetMod()) {
1069  for (auto orgmod : on.GetMod()) {
1070  if (orgmod->IsSetSubtype() &&
1071  orgmod->GetSubtype() == COrgMod::eSubtype_nat_host)
1072  {
1073  return orgmod->GetSubname();
1074  }
1075  }
1076  }
1077  }
1078  }
1079  }
1080  return res;
1081 }
1082 
1083 
1085 {
1086  // append Name and Position
1087  string s_tip = m_Handle.GetText();
1088  if (m_Handle.CanGetBioseqHandle()) {
1089 
1090  const CBioseq_Handle &bsh = m_Handle.GetBioseqHandle();
1091 
1092  if (bsh.IsAa()) {
1093  try {
1094  string title = sequence::GetProteinName(bsh);
1095  if (!title.empty()) {
1096  s_tip += ", ";
1097  s_tip += title;
1098  }
1099  } catch (const CException&) {
1100 
1101  }
1102  }
1103 
1104  s_tip += " (";
1106  if (bsh.IsAa())
1107  s_tip += " residues)";
1108  else
1109  s_tip += " bases)";
1110 
1111  if (m_Handle.IsNegativeStrand())
1112  s_tip += ", Negative Strand";
1113 
1114  tooltip.AddRow(s_tip);
1115 
1116  // Format taxonomy information
1117  string taxonomy;
1118  GetTaxonomy(taxonomy);
1119  tooltip.AddRow("Organism:", taxonomy);
1120 
1121  } else {
1122  if (m_Handle.IsNegativeStrand())
1123  s_tip += ", Negative Strand";
1124  tooltip.AddRow(s_tip);
1125  }
1126 
1127 
1128  // Insert here fields from MSA-404
1129  // Sequence title: descr / title
1130  // Country: descr / source / subtype / subtype country
1131  // Host: descr / source / org / orgname / mod / subtype nat-host
1132  // Isolation source: descr / source / subtype / subtype isolation-source
1133  // Collection date: descr / source / subtype / subtype collection-date
1134  if (m_Handle.CanGetBioseqHandle()) {
1135  const CBioseq_Handle &bsh = m_Handle.GetBioseqHandle();
1136  if (bsh.CanGetDescr()) {
1137  const CSeq_descr &descr = bsh.GetDescr();
1138  string s;
1139  s = s_GetTitle(descr);
1140  if (!s.empty()) tooltip.AddRow("Sequence title:", s);
1142  if (!s.empty()) tooltip.AddRow("Country:", s);
1143 
1144 
1145  s = s_GetOrgModNatHost(descr);
1146  if (!s.empty()) tooltip.AddRow("Host:", s);
1147 
1149  if (!s.empty()) tooltip.AddRow("Isolation source:", s);
1151  if (!s.empty()) tooltip.AddRow("Collection date:", s);
1152  }
1153  }
1154 
1155  tooltip.AddRow("Alignment Pos:", NStr::IntToString(pos + 1, NStr::fWithCommas));
1156 
1158  auto base_width = m_Handle.UsesAATranslation() && m_Handle.IsNucProtAlignment() ? 3 : 1;
1159  seq_pos /= base_width;
1160  if (seq_pos >= 0)
1161  tooltip.AddRow("Sequence Pos:", NStr::IntToString(seq_pos + 1, NStr::fWithCommas));
1162 }
1163 
1164 
1165 
1166 void CAlnVecRow::GetTaxonomy(string& taxonomy) const
1167 {
1169 }
1170 
1172  const TSignedSeqRange& seq_r,
1173  ITooltipFormatter& tooltip)
1174 {
1175  TSeqPos aln_left = aln_r.GetTo(); // a bit of hack
1176 
1177  string s_tip = x_GetTooltipSequence(seq_r.GetFrom(), seq_r.GetTo());
1178  s_tip += "<br>[coordinates ";
1179  s_tip += FormatRange(seq_r.GetFrom(), seq_r.GetTo() + 1);
1180  s_tip += "]";
1181  tooltip.AddRow("Insertion:", s_tip);
1182 }
1183 
1184 
1186  const TSignedSeqRange& seq_r,
1187  ITooltipFormatter& tooltip)
1188 {
1189  //string s_tip = "Gap ";
1190  //s_tip += FormatRange(aln_r.GetFrom() + 1, aln_r.GetTo() + 1);
1191  //s_tip += ", on Sequence ";
1192  //s_tip += FormatRange(seq_r.GetFrom() + 1, seq_r.GetTo() + 1);
1193  //tooltip.AddRow(s_tip);
1194 
1195  int gap_len = aln_r.GetLength();
1196  if (seq_r.GetLength() > 0) {
1197  string s_tip = NStr::NumericToString(aln_r.GetLength());
1198  if (m_Handle.UsesAATranslation()) {
1199  s_tip += " residue";
1200  } else {
1201  s_tip += " base";
1202  }
1203  if (gap_len > 1)
1204  s_tip += "s";
1205  tooltip.AddRow("Gap:", s_tip);
1206  }
1207 
1208 }
1209 
1210 
1212  TSignedSeqPos aln_from,
1213  TSignedSeqPos prev_to,
1214  TSignedSeqPos from,
1215  ITooltipFormatter& tooltip)
1216 {
1217  string s_tip = "Unaligned region - ";
1218 
1219  s_tip += NStr::IntToString(aln_prev_to + 1, NStr::fWithCommas);
1220  s_tip += "][";
1221  s_tip += NStr::IntToString(aln_from + 1, NStr::fWithCommas);
1222 
1223  s_tip += ", on Sequence [";
1224  s_tip += FormatRange(prev_to + 1, from - 1);
1225  s_tip += "] : ";
1226 
1227  s_tip += x_GetTooltipSequence(prev_to + 1, from - 1);
1228  tooltip.AddRow(s_tip);
1229 }
1230 
1231 
1233 {
1234  string seq;
1235  TSeqRange seq_text_r(from, to);
1236 
1237  if((int) seq_text_r.GetLength() > kMaxSeqInTooltip) { // to long to be displayed
1238  // get kMaxSeqInTooltip / 2 bases on the left and on the right
1239  TSeqPos left = seq_text_r.GetFrom();
1240  TSeqRange part_r(left, left + kMaxSeqInTooltip / 2);
1241 
1242  m_Handle.GetSeqString(seq, part_r);
1243 
1244  TSeqPos to_open = to + 1;
1245  part_r.Set(to_open - kMaxSeqInTooltip / 2, to_open -1);
1246  string right_seq;
1247  m_Handle.GetSeqString(right_seq, part_r);
1248 
1249  seq += "..." + right_seq;
1250  } else {
1251  m_Handle.GetSeqString(seq, seq_text_r);
1252  }
1253  return seq;
1254 }
1255 
1256 
1258 {
1259  wxBusyCursor wait;
1260 
1261  Expand(! IsExpanded(), pane);
1262 }
1263 
1264 
1266 {
1267  IRender& gl = GetGl();
1268  gl.Vertex2d(x1, y1);
1269  gl.Vertex2d(x2, y2);
1270 }
1271 
1272 
1273 const static TModelUnit kScoreMinScale = 0.5;
1274 
1275 
1276 /// Renders graphical part of the row
1278 {
1279  _ASSERT(m_Style);
1280 
1281  IRender& gl = GetGl();
1282  CGlPane& pane = *m_RenderCtx.m_Pane;
1283  pane.EnableOffset();
1284 
1285  const TModelRect& rc_lim = (*m_RenderCtx.m_Pane).GetModelLimitsRect();
1286  const TModelRect& rc_model = (*m_RenderCtx.m_Pane).GetVisibleRect();
1287  m_ModelLeft = rc_model.Left();
1288  m_ModelRight = rc_model.Right();
1289  {
1290  const auto& vp = (*m_RenderCtx.m_Pane).GetViewport();
1291  m_PixLeft = vp.Left();
1292  m_PixRight = vp.Right();
1293  }
1294  // now render segments actually present
1295  int left = (int) floor(rc_model.Left());
1296  int right = int(ceil(rc_model.Right())) - 1;
1297 
1298  TSignedRange range(left, right);
1299  int shown = m_Style->GetShownElements();
1300  if (shown & CRowDisplayStyle::fShown_Alignment) {
1301  TModelUnit offset_y = m_RenderCtx.m_Viewport.Top();
1302  TModelUnit y2 = rc_lim.Top() + kAlignSpace - offset_y;
1303  TModelUnit y1 = y2 + m_BaseHeight - 1 - (kAlignSpace * 2);
1304  TModelUnit scale_x = 1.;
1305  {
1306  CGlPaneGuard GUARD(pane, CGlPane::eOrtho);
1307  scale_x = pane.GetScaleX();
1308  }
1309 
1310  IScoringMethod* method = m_Cache ? m_Cache->GetScoringMethod() : nullptr;
1311  bool averageable = method && method->IsAverageable();
1312 
1313  /// Render Alignment segments & Gaps
1314  bool has_scores = m_Cache && m_Cache->HasScores();
1315  bool can_render_scores = averageable || scale_x < kScoreMinScale; // resolution permits rendering
1316  gl.LineWidth(1.0f);
1318  // render aligned segments
1320  unique_ptr<IAlnSegmentIterator> p_it(m_Handle.CreateSegmentIterator(range, flags));
1321  IAlnSegmentIterator& it = *p_it;
1322 
1323  if (has_scores && can_render_scores) {
1324  // render parts of segments accordingly to scores
1325  x_RenderAlignScores(it, (int)y1, (int)y2, averageable);
1326  } else {
1327  // scores cannot be rendered
1331  const CRgbaColor& color = m_Style->GetColor(type);
1332  x_RenderAlignSegments(pane, it, y1, y2, color);
1333  }
1334 
1335  {
1336  CGlPaneGuard GUARD(pane, CGlPane::eOrtho);
1337 
1338  GLint orig_vp[4];
1339  if (gl.IsPrinterFriendly()) {
1340  gl.GetViewport(orig_vp);
1341 
1342  const TVPRect *clip = pane.GetClipRect();
1343  if (clip) {
1344  gl.Viewport(orig_vp[0], clip->Bottom(), orig_vp[2], clip->Height() + 1);
1345  }
1347  gl.BeginClippingRect(vp.Left(), vp.Top(), vp.Width(), vp.Height());
1348  }
1349 
1350  /// Render Inserts
1351  x_RenderInserts(pane, left, right, y1, y2);
1352  x_RenderUnaligned(pane, left, right, y1, y2);
1353  /// Render Sequence
1354  if (x_CanRenderSeq(pane)) {
1355  int start = (left < floor(rc_model.Left())) ? left + 1 : left;
1356  int stop = (int)ceil(rc_model.Right());
1357  if (stop + 1 > rc_model.Right()) {
1358  stop--;
1359  }
1360  x_RenderSequence(pane, y1, y2, start, stop);
1361  }
1362 
1363  if (gl.IsPrinterFriendly()) {
1364  gl.Viewport(orig_vp[0], orig_vp[1], orig_vp[2], orig_vp[3]);
1365  gl.EndClippingRect();
1366  }
1367  }
1368  }
1369 
1370  if (shown & CRowDisplayStyle::fShown_Track) {
1371  /// Render Graph
1372  if (IsExpanded())
1374  }
1375 
1376  if (!m_Style->IsWebRendering()) {
1377  // table cell frame
1378  CGlPaneGuard GUARD(pane, CGlPane::ePixels);
1379  gl.LineWidth(1.0f);
1381  const auto& rc_vp = m_RenderCtx.m_Viewport;
1382  gl.Begin(GL_LINES);
1383  gl.Vertex2f((float)rc_vp.Right(), (float)rc_vp.Top() + 1);
1384  gl.Vertex2f((float)rc_vp.Right(), (float)rc_vp.Bottom() - 1);
1385  gl.End();
1386  }
1387 
1388 }
1389 
1390 
1391 inline double CompressLength(double len)
1392 {
1393  if(len <= 10.0) {
1394  return len;
1395  } else {
1396  double log = log10(len) * 10;
1397  return log;
1398  }
1399 }
1400 
1401 
1402 void CAlnVecRow::x_RenderInserts(CGlPane& pane, int from, int to,
1403  TModelUnit top_y, TModelUnit bottom_y)
1404 {
1405  IRender& gl = GetGl();
1406 
1407  TSignedRange range(from, to);
1408  TModelUnit offset_x = pane.GetOffsetX();
1409 
1410  static CRgbaColor cl_insert(0.0f, 0.0f, 1.0f);
1411  static CRgbaColor cl_unaligned(0.0f, 0.5f, 0.0f);
1412  gl.Begin(GL_LINES);
1413 
1415  unique_ptr<IAlnSegmentIterator> p_it_2(m_Handle.CreateSegmentIterator(range, flags));
1416 
1417  const TModelUnit kMinLen = pane.GetScaleX() * 3; // 3 pixels in model units
1418  int row_start = m_Handle.GetSeqAlnStart() - offset_x;
1419  int row_stop = m_Handle.GetSeqAlnStop() - offset_x;
1420 
1421  for( IAlnSegmentIterator& it_2 = *p_it_2; it_2; ++it_2 ) {
1422  TModelUnit ins_pos = it_2->GetAlnRange().GetFrom() - offset_x;
1423  if (ins_pos < row_start || ins_pos > row_stop)
1424  continue;
1425  // CAligData_DS returns both unaligned and indel for IAlnSegmentIterator::eInsertsOnly flag
1426  if (it_2->GetType() & IAlnSegment::fUnaligned) {
1427  gl.ColorC(cl_unaligned);
1428  } else {
1429  gl.ColorC(cl_insert);
1430  }
1431  TModelUnit len = it_2->GetRange().GetLength();
1432  TModelUnit log_len = CompressLength(len);
1433  log_len = max(log_len, kMinLen);
1434  TModelUnit x1 = ins_pos - log_len / 2;
1435  TModelUnit x2 = x1 + log_len;
1436 
1437  // assuming glBegin(GL_LINES)
1438  glLined(ins_pos, top_y - 1, ins_pos, bottom_y - 1);
1439  glLined(x1, top_y - 1, x2, top_y - 1);
1440  glLined(x1, bottom_y, x2, bottom_y);
1441  }
1442  gl.End();
1443  if (1==0) {
1445  unique_ptr<IAlnSegmentIterator> p_it(m_Handle.CreateSegmentIterator(range, flags));
1446  int row_start = m_Handle.GetSeqAlnStart();
1447  int row_stop = m_Handle.GetSeqAlnStop();
1448 
1449  const TModelUnit kMinLen = pane.GetScaleX() * 3; // 3 pixels in model units
1450 
1451  CRgbaColor blue("black");
1452 
1453  vector<TSeqRange> gaps;
1454 
1455  for (IAlnSegmentIterator& it_seg = *p_it; it_seg; ++it_seg) {
1456  // get the intersection of the score and align intervals
1457  const IAlnSegment& seg = *it_seg;
1458  if (seg.IsAligned())
1459  continue;
1460  TSignedSeqRange r = seg.GetAlnRange();
1461  if (r.Empty())
1462  continue;
1463  bool empty_seg = (r.GetFrom() < row_start || r.GetTo() > row_stop);
1464  if (empty_seg)
1465  continue;
1466  if (!seg.GetRange().GetToOpen() == 0)
1467  continue;
1468  if (gaps.empty())
1469  gaps.emplace_back(r.GetFrom(), r.GetTo());
1470  else {
1471  if (r.GetFrom() - gaps.back().GetTo() == 1) {
1472  gaps.back().SetTo(r.GetTo());
1473  }
1474  else {
1475  gaps.emplace_back(r.GetFrom(), r.GetTo());
1476  }
1477  }
1478  }
1479  if (!gaps.empty()) {
1480  gl.Enable(GL_BLEND);
1481  gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1482  gl.Begin(GL_LINES);
1483  for (const auto& r : gaps) {
1484  double pix_len = r.GetLength();
1485  pix_len /= pane.GetScaleX();
1486  if (pix_len < 1.5) {
1487  auto pos = r.GetFrom() - offset_x;
1488  float alpha = 0.25 + r.GetLength() * 0.75;
1489  blue.SetAlpha(alpha);
1490  gl.ColorC(blue);
1491  gl.Vertex2d(pos, bottom_y);
1492  gl.Vertex2d(pos, top_y - 2);
1493  }
1494  }
1495  gl.End();
1496  gl.Disable(GL_BLEND);
1497  }
1498 
1499  }
1500 }
1501 
1502 
1503 void CAlnVecRow::x_RenderUnaligned(CGlPane& pane, int from, int to,
1504  TModelUnit top_y, TModelUnit bottom_y)
1505 {
1506  IRender& gl = GetGl();
1507 
1508  TSignedRange range(from, to);
1509  TModelUnit offset_x = pane.GetOffsetX();
1510 
1511  CRgbaColor cl_unaligned(0.0f, 0.5f, 0.0f);
1512  gl.ColorC(cl_unaligned);
1513  gl.Begin(GL_LINES);
1514 
1516  unique_ptr<IAlnSegmentIterator> p_it_2(m_Handle.CreateSegmentIterator(range, flags));
1517 
1518  const TModelUnit kMinLen = pane.GetScaleX() * 3; // 3 pixels in model units
1519 
1520  TSignedSeqPos prev_pos = -2, prev_aln_pos = -2;
1521  for( IAlnSegmentIterator& it_2 = *p_it_2; it_2; ++it_2 ) {
1522  const TSignedRange& aln_r = it_2->GetAlnRange();
1523  const TSignedRange& r = it_2->GetRange();
1524  if (aln_r.GetFrom() == prev_aln_pos + 1 && r.GetFrom() > prev_pos + 1) {
1525  TModelUnit ins_pos = aln_r.GetFrom() - offset_x;
1526  TModelUnit len = it_2->GetRange().GetLength();
1527  TModelUnit log_len = CompressLength(len);
1528  log_len = max(log_len, kMinLen);
1529  TModelUnit x1 = ins_pos - log_len / 2;
1530  TModelUnit x2 = x1 + log_len;
1531 
1532  // assuming gl.Begin(GL_LINES)
1533  glLined(ins_pos, top_y, ins_pos, bottom_y);
1534  glLined(x1, top_y, x2, top_y);
1535  glLined(x1, bottom_y, x2, bottom_y);
1536  }
1537 
1538  prev_aln_pos = aln_r.GetTo();
1539  prev_pos = r.GetTo();
1540  }
1541  gl.End();
1542 }
1543 
1544 
1546 {
1547  void operator()(float& dst, const float& src, float fraction, bool long_seg)
1548  {
1549  dst += src * fraction;
1550  }
1551 };
1552 
1553 
1555  TModelUnit top_y, TModelUnit bottom_y,
1556  const CRgbaColor& color)
1557 {
1558  IRender& gl = GetGl();
1559 
1560  const auto& rc_vp = m_RenderCtx.m_Viewport;
1561  //CGlPane& pane = *m_RenderCtx.m_Pane;
1562  const TModelRect& rc_vis = pane.GetVisibleRect();
1563 
1564  /// Render Segments
1565  CGlPaneGuard GUARD(pane, CGlPane::ePixels);
1566 
1567  /// Rasterize segments - raster represents density of pixel coverage by segments
1568  typedef CRasterizer<float> TR;
1569  TR rasterizer(rc_vp.Left(), rc_vp.Right(), rc_vis.Left(), rc_vis.Right());
1570 
1571  FWeightedSum f_sum;
1572  for( ; it; ++it ) {
1573  const IAlnSegment& seg = *it;
1574  if(seg.IsAligned()) {
1575  const TSignedSeqRange& r = seg.GetAlnRange();
1576  rasterizer.AddInterval(r.GetFrom(), r.GetToOpen(), 1.0, f_sum); /* NCBI_FAKE_WARNING: WorkShop */
1577  }
1578  }
1579 
1580  TVPUnit vp_top_y = rc_vp.Top();
1581  TVPUnit vp_bottom_y = vp_top_y - (m_BaseHeight - 1) + kAlignSpace;
1582 
1583  const TR::TRaster& raster = rasterizer.GetRaster();
1584 
1585  //CGlAttrGuard guard(GL_LINE_BIT | GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT );
1586  gl.Enable(GL_BLEND);
1587  gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1588 
1589  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1590 
1591  int off_x = rc_vp.Left();
1592  static const float eps = 0.001f;
1593 
1594  TModelRange model_range(m_ModelLeft, m_ModelRight);
1596 
1597  row_range.IntersectWith(model_range);
1598 
1599  if (!row_range.Empty()) {
1600  // render a single line for all possible Gaps
1601  TVPUnit y_c = floor((float(vp_top_y + vp_bottom_y) / 2) + 0.5);
1602 
1603  TModelUnit row_start = rasterizer.Project(row_range.GetFrom());
1604  TModelUnit row_stop = rasterizer.Project(row_range.GetTo());
1605 
1606  gl.Begin(GL_LINES);
1607  gl.ColorC(color);
1608  glLined(row_start + off_x, y_c, row_stop + off_x, y_c);
1609  gl.End();
1610  }
1611 
1612  CRgbaColor cl(color);
1613  for( size_t i = 0; i < raster.size(); ) {
1614  size_t start = i;
1615  float v = raster[i];
1616  while(i < raster.size() && raster[i] == v) {
1617  i++;
1618  }
1619 
1620  if(v > eps) { /// otherwise consider it to be transparent
1621  /// use density as a measure of transparency
1622  // v is distributed in [0, 1], however Aplha channel needs to be in
1623  // [0.25, 1.0] range
1624  double alpha = 0.25 + v * 0.75;
1625  cl.SetAlpha((float) alpha);
1626  gl.ColorC(cl);
1627  gl.Rectd(start + off_x, vp_top_y, i + off_x, vp_bottom_y);
1628  }
1629  }
1630 }
1631 
1632 
1633 /// represents a pixel with a score, if several intervals cover a pixel, the interval
1634 /// with the maximum coverage will "own" the pixel (i.e. the pixel will be colored
1635 /// according to the score of this interval)
1636 /// This is used for non-averageable scores.
1637 struct SScPix {
1638  float m_Score; /// score assigned to the pixel
1639  float m_MaxCoverage; /// fraction of the pixel corresponding to the m_Score
1640  bool m_Gap; /// true if this is a gap interval
1641 
1642  bool operator==(const SScPix& other) const
1643  {
1644  return m_Score == other.m_Score && m_MaxCoverage == other.m_MaxCoverage
1645  && m_Gap == other.m_Gap;
1646  }
1647 };
1648 
1649 
1650 /// a pixel with the Max coverage (fraction) overrides all attributes
1651 static void FSetPixMaxCoverage(SScPix& dst, const SScPix& src, float fraction, bool long_seg)
1652 {
1653  if(fraction > dst.m_MaxCoverage) {
1654  dst.m_Score = src.m_Score;
1655  dst.m_Gap = src.m_Gap;
1656  dst.m_MaxCoverage = fraction;
1657  }
1658 }
1659 
1660 
1661 void CAlnVecRow::x_RenderAlignScores(IAlnSegmentIterator& it_seg, int /*top_y*/, int /*bottom_y*/, bool averageable)
1662 {
1663  IRender& gl = GetGl();
1664 
1665  typedef CScoreCache::TScore TScore;
1666  const auto& rc_vp = m_RenderCtx.m_Viewport;
1667  CGlPane& pane = *m_RenderCtx.m_Pane;
1668 
1669  CGlPaneGuard GUARD(pane, CGlPane::ePixels);
1670 
1671  const TModelRect& rc_vis = pane.GetVisibleRect();
1672 
1673  //gl.Translated(0.0, rc_vp.Top(), 0.0); // to make the display list "scrollable" vertically
1674 
1675  //if horz projection has changed - invalidate display list
1676  if(m_PixLeft != rc_vp.Left() || m_PixRight != rc_vp.Right()
1677  || m_ModelLeft != rc_vis.Left() || m_ModelRight != rc_vis.Right()) {
1678  m_PixLeft = rc_vp.Left();
1679  m_PixRight = rc_vp.Right();
1680  m_ModelLeft = rc_vis.Left();
1681  m_ModelRight = rc_vis.Right();
1682  }
1683 
1684  //CGlAttrGuard guard(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT );
1685  gl.Enable(GL_BLEND);
1686  gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1687 
1688  TVPUnit vp_top_y = rc_vp.Top();
1689  TVPUnit vp_bottom_y = vp_top_y - (m_BaseHeight - 1) + kAlignSpace;
1690 
1691  // obtain Score Collection and setup iterators
1692  int range_from = (int) (floor(rc_vis.Left()));
1694  CScoreCache::TScoreColl::const_iterator it = ScoreColl.begin();
1695  const CScoreCache::TScoreColl::const_iterator it_end = ScoreColl.end();
1696  it = ScoreColl.find(it, it_end, range_from);
1697 
1698  if(averageable) {
1699  x_RenderAveragableScores(pane, it_seg, it, it_end, vp_top_y, vp_bottom_y);
1700  } else {
1701  x_RenderNonAveragableScores(pane, it_seg, it, it_end, vp_top_y, vp_bottom_y);
1702  }
1703 }
1704 
1705 
1706 /// represents a pixel with two scores, one corresponds to a gap interval, another -
1707 /// to an aligned segment.
1708 struct SScPix2 {
1709  float m_IntScore;
1710  float m_IntLen;
1711  float m_GapScore;
1712  float m_GapLen;
1713  float m_MinScore;
1714  bool m_Init;
1715 
1716  bool operator==(const SScPix2& other) const
1717  {
1718  return m_IntScore == other.m_IntScore && m_IntLen == other.m_IntLen &&
1719  m_GapScore == other.m_GapScore && m_GapLen == other.m_GapLen &&
1720  m_MinScore == other.m_MinScore;
1721  }
1722 };
1723 
1725 {
1726 public:
1727  FSetPix2(bool sequence_level) :
1728  m_SequenceLevel(sequence_level)
1729  {
1730  }
1731 
1732  /// accumulate weighted scores
1733  void operator()(SScPix2& dst, const SScPix2& src, float fraction, bool long_seg)
1734  {
1737  dst.m_IntScore = src.m_IntScore;
1738  dst.m_IntLen = src.m_IntLen;
1739  } else {
1740  dst.m_IntScore += src.m_IntScore * fraction;
1741  dst.m_IntLen += src.m_IntLen * fraction;
1742  }
1743  dst.m_GapScore += src.m_GapScore * fraction;
1744  dst.m_GapLen += src.m_GapLen * fraction;
1745 
1746  if( ! long_seg) {
1747  // only for small segments
1748  static const float eps = 0.00001f;
1749  if( ! dst.m_Init) {
1751  dst.m_MinScore = src.m_IntScore;
1752  dst.m_Init = true;
1753  } else if(src.m_GapLen > eps) {
1754  dst.m_MinScore = src.m_GapScore;
1755  dst.m_Init = true;
1756  }
1757  } else {
1759  dst.m_MinScore = min(dst.m_MinScore, src.m_IntScore);
1760  }
1761  if(src.m_GapLen > eps) {
1762  dst.m_MinScore = min(dst.m_MinScore, src.m_GapScore);
1763  }
1764  }
1765  }
1766  }
1767 protected:
1768  bool m_SequenceLevel = false;
1769 };
1770 
1771 
1772 
1773 
1775  CScoreCache::TScoreColl::const_iterator it,
1776  const CScoreCache::TScoreColl::const_iterator it_end,
1777  int vp_top_y, int vp_bottom_y)
1778 {
1779  IRender& gl = GetGl();
1780 
1781  const TVPRect& rc_vp = pane.GetViewport();
1782  const TModelRect& rc_vis = pane.GetVisibleRect();
1783 
1784  int row_start = m_Handle.GetSeqAlnStart();
1785  int row_stop = m_Handle.GetSeqAlnStop();
1786 
1787  static const float eps = 0.001f;
1788 
1789  typedef CRasterizer<SScPix2> TR;
1790  TR rasterizer(rc_vp.Left(), rc_vp.Right(), rc_vis.Left(), rc_vis.Right());
1792  FSetPix2 f_sum(pane.GetScaleX() <= 1.f/8.f);
1793 
1794  while(it_seg && it != it_end && it->GetFrom() <= rc_vis.Right()) {
1795  // get the intersection of the score and align intervals
1796  const IAlnSegment& seg = *it_seg;
1797  const TSignedSeqRange& r = seg.GetAlnRange();
1798  int from = std::max<int>(r.GetFrom(), it->GetFrom());
1799  int to = std::min<int>(r.GetTo(), it->GetTo());
1800 
1801  /// apply attributes to the intersection
1802  SScPix2 pix = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, false };
1803  bool empty_seg = (from < row_start || to > row_stop);
1804  if(seg.IsAligned()) {
1805  pix.m_IntLen = 1.0;
1806  pix.m_IntScore = it->GetAttr();
1808  if (pix.m_IntScore < value_limits.GetFrom())
1809  value_limits.SetFrom(pix.m_IntScore);
1810  else if (pix.m_IntScore > value_limits.GetTo())
1811  value_limits.SetTo(pix.m_IntScore);
1812  }
1813  rasterizer.AddInterval(from, to + 1, pix, f_sum);
1814  } else if (!empty_seg && ((to - from) + 1) > 0) {
1815  pix.m_GapLen = 1.;
1816  pix.m_GapScore = 0;//it->GetAttr();
1817  pix.m_IntLen = 0;
1818  rasterizer.AddInterval(from, to + 1, pix, f_sum);
1819  }
1820 
1821  /// advance iterators
1822  if(to == r.GetTo())
1823  ++it_seg;
1824  if(to == (int) it->GetTo())
1825  ++it;
1826  }
1827 
1828  // Rendering
1829  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1830  const TR::TRaster& raster = rasterizer.GetRaster();
1831 
1832  int shift_x = rc_vp.Left();
1833  float value_scale = value_limits.GetTo() - value_limits.GetFrom();
1834  if (value_scale <= 0)
1835  value_scale = 1;
1836  TVPUnit y_c = floor((float(vp_top_y + vp_bottom_y ) / 2) + 0.5);
1837 
1838  for( size_t i = 0; i < raster.size(); ) {
1839  auto x1 = i + shift_x;
1840  const SScPix2& sc_pix = raster[i];
1841  while (i < raster.size() && raster[i] == sc_pix) {
1842  ++i;
1843  }
1844  auto x2 = i + shift_x;
1845  if (sc_pix.m_IntLen > eps) {
1846  double sc = sc_pix.m_IntScore / sc_pix.m_IntLen;
1847  CRgbaColor color;
1849  static const CRgbaColor kAmbiguousResidueColor("darkgrey");
1850  color = kAmbiguousResidueColor;
1851  } else {
1853  //double alpha = 0.25 + sc_pix.m_IntLen * 0.75;
1854  //gl.Color4f(color.GetRed(), color.GetGreen(), color.GetBlue(), alpha);
1855  if (sc_pix.m_Init) {
1856  sc = min(1.0, max<double>(0., ((sc - value_limits.GetFrom()) / value_scale)));
1858  float alpha = 1.0f - sc * 0.75f;
1859  color = CRgbaColor::Interpolate(color2, color, alpha);
1860  }
1861  }
1862  gl.ColorC(color);
1863  gl.Rectd(x1, vp_top_y, x2, vp_bottom_y);
1864  } else if (sc_pix.m_GapLen > eps) {
1865  //float sc = sc_pix.m_GapScore / sc_pix.m_GapLen;
1866  const CRgbaColor& color =
1868  //double alpha = 0.25 + sc_pix.m_GapLen * 0.75;
1869  //gl.Color4f(color.GetRed(), color.GetGreen(), color.GetBlue(), alpha);
1870  gl.ColorC(color);
1871  gl.Rectd(x1, y_c - 1, x2, y_c + 1);
1872  } else {
1873  // use previously set color to paint the remaining area
1874  // Fix for MSA-381. This was an attempt to fix one pixel gap,
1875  // which instead removed flanking gaps altogether. I'm keeping
1876  // it here in case pixel gap problem arises.
1877  //gl.Rectd(x1, vp_top_y, x2, vp_bottom_y + 1);
1878  }
1879  }
1880 }
1881 
1882 
1884  CScoreCache::TScoreColl::const_iterator it,
1885  const CScoreCache::TScoreColl::const_iterator it_end,
1886  int vp_top_y, int vp_bottom_y)
1887 {
1888  IRender& gl = GetGl();
1889 
1890  const TVPRect& rc_vp = pane.GetViewport();
1891  const TModelRect& rc_vis = pane.GetVisibleRect();
1892 
1893  //LOG_POST("CAlnVecRow::x_RenderNonAveragableScores() " << rc_vis.Left() << " " << rc_vis.Right());
1894  int row_start = m_Handle.GetSeqAlnStart();
1895  int row_stop = m_Handle.GetSeqAlnStop();
1896 
1897  typedef CRasterizer<SScPix> TR;
1898  TR rasterizer(rc_vp.Left(), rc_vp.Right(), rc_vis.Left(), rc_vis.Right());
1899  SScPix pix = { 0.0f, 0.0f, false };
1900 
1901  while(it_seg && it != it_end && it->GetFrom() <= rc_vis.Right()) {
1902  // get the intersection of the score and align intervals
1903  const IAlnSegment& seg = *it_seg;
1904  const TSignedSeqRange& r = seg.GetAlnRange();
1905  int from = std::max<int>(r.GetFrom(), it->GetFrom());
1906  int to = std::min<int>(r.GetTo(), it->GetTo());
1907 
1908  /// apply attributes to the intersection
1909  bool empty_seg = (from < row_start || to > row_stop);
1910  if(! empty_seg) {
1911  pix.m_Score = it->GetAttr();
1912  pix.m_Gap = ! seg.IsAligned();
1913 
1914  rasterizer.AddInterval(from, to + 1, pix, FSetPixMaxCoverage);
1915  }
1916 
1917  /// advance iterators
1918  if(to == r.GetTo()) {
1919  ++it_seg;
1920  }
1921  if(to == (int) it->GetTo()) {
1922  ++it;
1923  }
1924  }
1925 
1926  // Rendering
1927  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
1928  const TR::TRaster& raster = rasterizer.GetRaster();
1929 
1930  TVPUnit y_c = floor((float(vp_top_y + vp_bottom_y ) / 2) + 0.5);
1931  static float eps = 0.0001f;
1932 
1933  int shift_x = rc_vp.Left();
1934  for( size_t i = 0; i < raster.size(); ) {
1935  size_t start = i;
1936  const SScPix& sc_pix = raster[i];
1937  while(++i < raster.size() && raster[i] == sc_pix) ;
1938 
1939  if(sc_pix.m_MaxCoverage > eps) {
1940  const CRgbaColor& color =
1942  gl.ColorC(color);
1943 
1944  if (sc_pix.m_Gap) {
1945  gl.Rectd(start + shift_x, y_c - 1 , i + shift_x, y_c + 1);
1946  } else {
1947  gl.Rectd(start + shift_x, vp_top_y, i + shift_x, vp_bottom_y + 1);
1948  }
1949 
1950  //LOG_POST("Start " << start << ", end " << i << ", color " << color.ToString()
1951  // << ", c_pix.m_MaxCoverage " << sc_pix.m_MaxCoverage
1952  // << ", sc_pix.m_Score " << sc_pix.m_Score);
1953  }
1954  }
1955 }
1956 
1957 #define SEQ_OFF_VERT 0
1958 #define SEQ_OFF_HORZ 0
1959 
1960 
1961 /// Checks if sequence can be drawn.
1962 
1964 {
1965  if(m_Style) {
1967  double scale_x = pane.GetScaleX();
1968  return min_w >= scale_x;
1969  } else return false;
1970 }
1971 
1972 
1973 bool IfDash(char ch) { return ch == '-'; }
1974 
1975 
1976 // renders a row of seq symbols in the range [Start, Stop]
1978  int start, int stop)
1979 {
1980  _ASSERT(m_Style);
1981  unique_ptr<IAlnSegmentIterator> p_it(
1983  if (!*p_it)
1984  return;
1985 
1986  IRender& gl = GetGl();
1987  auto base_width = m_Handle.GetBaseWidth();
1988  //auto base_width = m_Handle.UsesAATranslation() && m_Handle.IsNucProtAlignment() ? 3 : 1;
1989  const CGlTextureFont& font = m_Style->GetSeqFont();
1990  TModelUnit H = font.TextHeight();
1991 
1992  TModelUnit sc_x = pane.GetScaleX();
1993  TModelUnit off_y = ((abs(bottom_y) - abs(top_y) + 1) - H);
1994  off_y = floor(off_y/2. + 0.5);
1995 
1996  // Get half-character offset in world coords
1997  // (use 'A' as stand in for any capital character)
1998  TModelUnit off_x = (font.TextWidth("A") * sc_x) * 0.5;
1999 
2000  //TModelUnit y = bottom_y + H;
2001  TModelUnit y = top_y - off_y;
2002  bool render_scores = false;
2003  if (m_Cache && m_Cache->HasScores()) {
2005  render_scores = method &&
2007  }
2008  if (!render_scores)
2010 
2011  pane.EnableOffset(false);
2012  if (!m_SequenceRenderingCtx.get()) {
2014  }
2015  m_SequenceRenderingCtx->PrepareContext(pane, true, m_Handle.IsNegativeStrand());
2016  pane.EnableOffset(true);
2017 
2018  for (IAlnSegmentIterator& seg_it(*p_it); seg_it; ++seg_it) {
2019  const IAlnSegment& seg = *seg_it;
2020  if (!seg.IsAligned())
2021  continue;
2022  auto& aln_r = seg.GetAlnRange();
2023  start = aln_r.GetFrom();
2024  stop = aln_r.GetTo();
2025  if (start > stop)
2026  continue;
2027  auto& seq_r = seg.GetRange();
2028  auto sStart = seq_r.GetFrom();
2029  auto sStop = seq_r.GetTo();
2030  TSeqPos frame_shift_f = 0;
2031  TSeqPos frame_shift_t = 0;
2032  if (base_width == 3) {
2033  frame_shift_f = sStart % base_width;
2034  frame_shift_t = 2 - sStop % base_width;
2035  }
2036  string seq;
2037  m_Handle.GetAlnSeqString(seq, TSignedRange(start - frame_shift_f, stop + frame_shift_t));
2038  // replace gap symbols with spaces
2039  //replace_if(seq.begin(), seq.end(), IfDash, ' ');
2040 
2041  //TModelUnit x = (start * base_width) + 0.5 - pane.GetOffsetX();
2042  TModelUnit x = start - pane.GetOffsetX() + 0.5;
2043  if (base_width == 3) {
2044  x += 1;
2045  x -= frame_shift_f;
2046  }
2047 
2049  vector<CRgbaColor*> colors;
2050  if (render_scores) {
2051  /// need to draw colored sequence on colored background
2053  CScoreCache::TScoreColl::const_iterator it = ScoreColl.begin();
2054  const CScoreCache::TScoreColl::const_iterator it_end = ScoreColl.end();
2055  it = ScoreColl.find(it, it_end, start);
2056 
2057  int len = stop - start + 1;
2058  _ASSERT(len >= 0);
2059  if (len > 0) {
2060  colors.resize(len); // create vector of the required length
2061  std::fill_n(colors.begin(), len, &default_color);
2062 
2063  for (; it != it_end; ++it) {
2064  TSeqPos from = max(it->GetFrom(), (TSeqPos)start);
2065  TSeqPos to = min(it->GetTo(), (TSeqPos)stop);
2066  if (to >= from) {
2067  IScoringMethod::TScore score = it->GetAttr();
2068  CRgbaColor& cl = const_cast<CRgbaColor&>(
2070  std::fill_n(colors.begin() + (from - start), to - from + 1, &cl);
2071  }
2072  }
2073  }
2074  }
2075 
2076  // Check if there is a consensus sequence and, if so, get the sequence chars
2077  string consensus;
2078  bool has_consensus = false;
2080  m_ConsensusRow->GetAlnSeqString(consensus, TSignedRange(start - frame_shift_f, stop + frame_shift_t));
2081 
2083  (consensus.length() == seq.length())) {
2084  has_consensus = true;
2085  }
2086  }
2087 
2088  bool has_colors = (colors.size() == seq.length());
2089 
2090  TModelUnit radius = (std::abs(top_y - bottom_y) / 2.0) + 0.5;
2091  string text_char(" ");
2092  TModelUnit center_y = (top_y + bottom_y) * 0.5 + 0.5;
2093 
2094  double base_h = double(base_width)/2.;
2095  // Iterate over the characters drawing glyphs when consensus is matched
2096  // (except for the consensus sequence itself).
2097  CRgbaColor current_color;
2098 
2099  for (size_t i = 0; i < seq.size(); ++i) {
2100  current_color = has_colors ? *colors[i] : default_color;
2101  if (has_consensus && seq[i] != 'X' && consensus[i] == seq[i]) {
2102  bool render_dot = m_SequenceRenderingCtx->GetScale() <= 1./16.; // sequence level
2103  if (render_dot) {
2104  auto dot_texture = m_Style->GetDotTexture();
2105  render_dot = dot_texture.NotEmpty();
2106  if (render_dot) {
2107  CGlAttrGuard AttrGuard(GL_LINE_BIT);
2108  gl.Enable(GL_TEXTURE_2D);
2109  // gl.Enable(GL_BLEND);
2110  // gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2111 
2112  double w = dot_texture->GetImage()->GetWidth();
2113  dot_texture->MakeCurrent();
2114  TModelRect rc_coord(0.0, 0., 1.0, 1.0);
2115  w *= 0.5;
2116  auto r = min(0.5, m_SequenceRenderingCtx->ScreenToSeq(w ));
2117  TModelRect rc_rbn(x - r, bottom_y, x + r, top_y);
2118  m_SequenceRenderingCtx->DrawTexture(rc_rbn, rc_coord);
2119  // gl.Disable(GL_BLEND);
2120  gl.Disable(GL_TEXTURE_2D);
2121  }
2122  }
2123 
2124  if (!render_dot) {
2125  current_color.Lighten(0.65f);
2126  gl.ColorC(current_color);
2127  gl.LineWidth(2.0);
2128  gl.Begin(GL_LINES);
2129  gl.Vertex2d(x - sc_x, center_y);
2130  gl.Vertex2d(x + sc_x, center_y);
2131  gl.End();
2132  }
2133  }
2134  else {
2135  gl.ColorC(current_color);
2136  text_char[0] = seq[i];
2137  gl.BeginText(&font, current_color);
2138  gl.WriteText(x - off_x, y, text_char.c_str());
2139  gl.EndText();
2140  }
2141  x += base_width;
2142  }
2143  }
2144 }
2145 static const int kTextOffsetY = 0;
2146 static const int kTextOffsetX = 2;
2147 static const int kPosOffsetX = 4;
2148 
2149 
2151 {
2152  _ASSERT(m_Style);
2154 
2155  IRender& gl = GetGl();
2156  if (gl.IsPrinterFriendly()) {
2157  bool selected = (m_RenderCtx.m_State & fItemSelected) != 0;
2158  const auto& rc_vp = m_RenderCtx.m_Viewport;
2159  string s = "(";
2160  s += (m_Handle.IsNegativeStrand()) ? "-" : "+";
2161  s += ")";
2163  TModelUnit x = rc_vp.Left() + kTextOffsetX * 2;
2164  TModelUnit y = rc_vp.Top() - m_BaseHeight;
2165  TModelUnit w = rc_vp.Width() - kTextOffsetX * 4;
2168  gl.EndText();
2169  }
2170 }
2171 
2172 
2173 bool CAlnVecRow::x_InitTrackPane(const CGlPane& row_pane, CGlPane& track_pane) {
2174 
2175  track_pane.EnableOffset(true);
2176  int base_height = 0;
2177  int shown = m_Style->GetShownElements();
2178  if (shown & CRowDisplayStyle::fShown_Alignment) {
2179  base_height = m_BaseHeight;
2180  }
2181 
2182  TVPRect rc_vp = row_pane.GetViewport();
2183  auto height = abs(rc_vp.Height()) - 1;
2184  int row_top = m_RenderCtx.m_Top;
2185  auto offset_top = (rc_vp.Top() - row_top);
2186  auto top = rc_vp.Top();
2187  if (offset_top >= 0) {
2188  top -= (offset_top + base_height);
2189  offset_top = 0;
2190  }
2191  TModelUnit model_height = 0;
2192  if (top < 0) { // Track pane is not visible
2193  top = 0;
2194  } else {
2195  _ASSERT(offset_top <= 0);
2196  model_height = m_TrackPanel->GetHeight() + offset_top;
2197  }
2198 // auto bottom = top - model_height;
2199 // if (offset_top != 0)
2200 // bottom -= base_height;
2201 // double offset_bottom = 0;
2202  TModelUnit bottom = max<int>(0, m_RenderCtx.m_Viewport.Bottom());
2203  //if (bottom < bottom_line) {
2204  // offset_bottom = -bottom;
2205  // bottom = bottom_line;
2206  // }
2207  _ASSERT(top >=0);
2208  _ASSERT(bottom >=0);
2209  rc_vp.SetVert(bottom, top);
2210  _ASSERT(rc_vp.Height() >= 0);
2211  track_pane.SetViewport(rc_vp);
2212 
2213  TModelRect rc_vis = row_pane.GetVisibleRect();
2214  _ASSERT(offset_top <= 0);
2215  double model_top = abs(offset_top);
2216  double model_bottom = model_top + rc_vp.Height();
2217 // double model_bottom = model_top + model_height;
2218  rc_vis.SetVert(model_bottom, model_top);
2219  track_pane.SetVisibleRect(rc_vis);
2220 
2221  TModelRect rc_limits = row_pane.GetModelLimitsRect();
2222  rc_limits.SetVert(m_TrackPanel->GetHeight(), 0);
2223  track_pane.SetModelLimitsRect(rc_limits);
2224  return model_height > 0;
2225 }
2226 
2227 
2229 {
2231  if (!IsExpanded())
2232  return;
2233  CGlPane& pane = *m_RenderCtx.m_Pane;
2234  CGlPane saved_pane(pane);
2235  if (!x_InitTrackPane(pane, *m_TrackPane))
2236  return;
2237  SRenderingContextGuard ctx_guard([&]() {
2238  m_RenderingCtx->SetRenderingFlags(0);
2239  m_RenderingCtx->PrepareContext(*m_TrackPane, true, m_Handle.IsNegativeStrand());
2240  });
2241 
2242 
2243  auto orig_height = m_TrackPanel->GetHeight();
2244 
2245  TVPRect rc_vp = m_RenderCtx.m_Viewport;
2246  //rc_vp.SetTop(rc_vp.Top() - m_BaseHeight);
2247 
2248  //rc_vp.SetTop(rc_vp.Top() - m_BaseHeight);
2249  TVPRect rc_clip_gr = rc_vp;
2250  const TVPRect* rc_clip = pane.GetClipRect();
2251  if (rc_clip)
2252  rc_clip_gr.IntersectWith(*rc_clip);
2253  m_TrackPane->SetClipRect(&rc_clip_gr);
2254 
2255  const TModelRect& rc_vis = m_TrackPane->GetVisibleRect();
2256  // prepare context for data update
2259  s_PrepareTrackPane(rc_vis.Left(), rc_vis.Right(), seq_from, seq_to,
2260  m_Handle, pane, *m_TrackPane);
2261 
2262  TModelRect rc_model = m_TrackPane->GetModelLimitsRect();
2264  m_TrackPane->SetModelLimitsRect(rc_model);
2265 
2266  m_RenderingCtx->PrepareContext(*m_TrackPane, true, m_Handle.IsNegativeStrand());
2267  if (m_NeedUpdateContent) {
2268  m_TrackPanel->Update(false);
2269  m_NeedUpdateContent = false;
2270  } else if (m_NeedUpdateLayout) {
2271  m_TrackPanel->Update(true);
2272  }
2273  if (m_NeedUpdateSelection) {
2275  sel_visitor->UpdateSelection(&*m_TrackPanel);
2276  }
2277  int max_height = 0;
2278  m_RenderingCtx->SetRenderingFlags(0);
2279  if (!m_Handle.IsAnchor()) {
2280 
2281  // First draw alignment segments areas
2282  // skipping title bars and icon controls
2283  if (!GetGl().IsPrinterFriendly()) {
2285  }
2286  else {
2287  // Don't render grid when exporting image
2289  }
2290  CGlPane segments_pane(*m_TrackPane);
2291  x_ForEachAlnSeg(range, pane, segments_pane, [&](CGlPane& track_pane) {
2292  m_RenderingCtx->PrepareContext(track_pane, true, m_Handle.IsNegativeStrand());
2293  m_TrackPanel->Update(true);
2294  max_height = max<int>(max_height, m_TrackPanel->GetHeight());
2295  m_TrackPanel->Draw();
2296  return false;
2297  });
2298  m_RenderingCtx->PrepareContext(*m_TrackPane, true, m_Handle.IsNegativeStrand());
2299  // Draw title bars and icon controls
2300  // skipping grid and features
2302  }
2303  m_TrackPanel->Update(true);
2304  //m_TrackPanel->SetHeight(orig_height);
2305 
2306  //x_InitTrackPane(saved_pane, *m_TrackPane);
2307  //m_RenderingCtx->PrepareContext(*m_TrackPane, true, m_Handle.IsNegativeStrand());
2308  m_TrackPanel->Draw();
2309  //m_RenderingCtx->SetRenderingFlags(0);
2310 // cout << "TP height after:" << m_TrackPanel->GetHeight() << ", before:" << orig_height << ", Viewport H:" << m_TrackPane->GetViewport().Height() << endl;
2311 
2312  //m_TrackPanel->SetHeight(orig_height);
2313  //{
2314  // auto vr = m_TrackPane->GetVisibleRect();
2315 // vr.SetVert(orig_height, 0);
2316  // m_TrackPane->SetVisibleRect(vr);
2317 // }
2319  m_TrackPane->SetClipRect(nullptr);
2320 }
2321 
2323 {
2324  if(IsExpanded())
2326 }
2327 
2328 
2329 const static int kButtonOffset = 2;
2330 const static int kButtonSize = 11;
2331 const static int kButtonSignSize = 7;
2332 
2333 
2334 // Returns buttons bounds in screen coordinates, "pane" parameter specifies
2335 // CGlPane corresponding to "Icons" column
2337 {
2338  const auto& rc_vp = m_RenderCtx.m_Viewport;
2339  // when shown flag is set not to show the alignments
2340  // m_BaseHeight can be less than kButtonSize
2341  // in this cases we still want to create a valid rectangle
2342  // to provide information for this row in htmlareas
2343  auto h = (m_BaseHeight > kButtonSize) ? (m_BaseHeight - kButtonSize) / 2 : 0;
2344 
2345  int btn_space = kButtonSize + kButtonOffset;
2346  int x = rc_vp.Left() + kButtonOffset + ((int)btn * btn_space * shift);
2347  int y_top = rc_vp.Top() - h;
2348 
2349  TVPRect rc(x, y_top - kButtonSize + 1, x + kButtonSize - 1, y_top);
2350  //TVPRect rc(x, y_top - (kButtonSize - 1), x + (kButtonSize - 1), y_top);
2351  return rc;
2352 }
2353 
2354 
2357 {
2358  const TVPRect& rc_vp = pane.GetViewport();
2359  //int y_top = rc_vp.Top() - (m_BaseHeight - kButtonSize) / 2;
2360 
2361  //if(vp_pt.Y() <= y_top && vp_pt.Y() >= y_top - kButtonSize + 1) { // vertical hit
2362  int left = rc_vp.Left() + kButtonOffset;
2363  for( int i = 0; i < 3; i++ ) {
2364  if(vp_pt.X() >= left && vp_pt.X() < left + kButtonSize) {
2365  return (EButtons) i;
2366  }
2367  left += kButtonSize + kButtonOffset;
2368  }
2369  //}
2370  return eInvalid;
2371 }
2372 
2373 
2375 {
2376  _ASSERT(m_Style);
2377 
2378  IRender& gl = GetGl();
2379  // If ExactOrthoProjection is set, the expand (+/-) box
2380  // occasionally rendered incorrectly depending on the window size
2381  // Its height fluctuates...
2382  // The workaround is to disable ExactOrthoProjection
2386 
2387  const auto& rc_vp = m_RenderCtx.m_Viewport;
2388 
2389  bool wid_focused = (m_RenderCtx.m_State & fWidgetFocused) != 0;
2390  bool selected = (m_RenderCtx.m_State & fItemSelected) != 0;
2391  if (selected) { //draw background
2394  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
2395  gl.Rectd(rc_vp.Left(), rc_vp.Bottom(), rc_vp.Right(), rc_vp.Top());
2396  }
2397 
2398  x_RenderEmptyBox();
2399 
2400  // draw strand marker
2402  int y_c = rc_btn.CenterPoint().Y();
2403  int half = rc_btn.Height() / 2;
2404  int x1 = rc_btn.Left();
2405  int x2 = rc_btn.Right();
2406 
2407  if(m_Handle.IsNegativeStrand()) {
2408  swap(x1, x2);
2409  }
2410 
2411 
2412  gl.Disable(GL_LINE_SMOOTH);
2413  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
2414  gl.Color3d(0.0, 0.5, 0.0);
2415  gl.Begin(GL_TRIANGLES); // render triangle
2416  gl.Vertex2d(x1, y_c - half);
2417  gl.Vertex2d(x2, y_c);
2418  gl.Vertex2d(x1, y_c + half);
2419  gl.End();
2420 
2421  // draw "Expand" button
2422  if (IsExpandable()) {
2423  gl.LineWidth(1.0f);
2424 
2425  rc_btn = x_GetButtonRect(eExpand);
2426 
2429 
2430  gl.PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
2431  gl.Rectd(rc_btn.Left(), rc_btn.Bottom(), rc_btn.Right(), rc_btn.Top());
2432  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
2433  int offset = (kButtonSize - kButtonSignSize) / 2;
2434  TVPPoint pt_c = rc_btn.CenterPoint();
2435  // render "+" or "-"
2436  gl.Begin(GL_LINES);
2437  gl.Vertex2d(rc_btn.Left() + offset, pt_c.Y());
2438  gl.Vertex2d(rc_btn.Left() + offset + kButtonSignSize, pt_c.Y());
2439  if (!m_bExpanded) {
2440  gl.Vertex2d(pt_c.X(), rc_btn.Bottom() + offset);
2441  gl.Vertex2d(pt_c.X(), rc_btn.Bottom() + offset + kButtonSignSize);
2442  }
2443  gl.End();
2444  }
2445  // draw focus frame
2446  /*
2447  if (wid_focused && (m_RenderCtx.m_State & fItemFocused)) {
2448  gl.LineWidth(1.0f);
2449 
2450  gl.Begin(GL_LINE_LOOP);
2451  gl.Vertex2d(rc_vp.Left(), rc_vp.Bottom() + 1);
2452  gl.Vertex2d(rc_vp.Right() - 1, rc_vp.Bottom() + 1);
2453  gl.Vertex2d(rc_vp.Right() - 1, rc_vp.Top());
2454  gl.Vertex2d(rc_vp.Left(), rc_vp.Top());
2455  gl.End();
2456  }
2457  */
2458 
2459  /**
2460  if(m_GraphCont && m_GraphCont->HasData()) { // draw "Graph" button
2461  rc_btn = x_GetButtonRect(pane, eSetupGraphs);
2462  gl.Rectd(rc_btn.Left(), rc_btn.Bottom(), rc_btn.Right(), rc_btn.Top());
2463 
2464  m_Style->GetTextFont().TextOut(rc_btn.Left() + 1, rc_btn.Bottom() + 1,
2465  kButtonSize - 2, kButtonSize - 2, "...", IGlFont::eAlign_Center);
2466  }
2467  **/
2468 
2469 // pane.Close();
2470 }
2471 
2472 
2474 {
2475  _ASSERT(m_Style);
2476 
2477  IRender& gl = GetGl();
2479 
2480  // draw strand marker
2481  TVPRect rc_btn = x_GetButtonRect(eExpand);
2482  int y_c = rc_btn.CenterPoint().Y();
2483  int half = rc_btn.Height() / 2;
2484  int x1 = rc_btn.Left();
2485  int x2 = rc_btn.Right();
2486 
2487  if(m_Handle.IsNegativeStrand()) {
2488  swap(x1, x2);
2489  }
2490 
2491  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
2492  gl.Color3d(0.0, 0.5, 0.0);
2493  gl.Begin(GL_TRIANGLES); // render triangle
2494  gl.Vertex2d(x1, y_c - half);
2495  gl.Vertex2d(x2, y_c);
2496  gl.Vertex2d(x1, y_c + half);
2497  gl.End();
2498 }
2499 
2501 {
2502  _ASSERT(m_Style);
2503  if (!IsExpandable())
2504  return;
2505  IRender& gl = GetGl();
2506 
2508 
2509  // draw "Expand" button
2511 
2513  gl.PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
2514  gl.LineWidth(1.0f);
2515  gl.Disable(GL_LINE_SMOOTH);
2516 
2517  rc_btn = x_GetButtonRect(eExpand, 0);
2518  gl.Rectd(rc_btn.Left(), rc_btn.Bottom(), rc_btn.Right(), rc_btn.Top());
2519  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
2520 
2521  int offset = (kButtonSize - kButtonSignSize) / 2;
2522  TVPPoint pt_c = rc_btn.CenterPoint();
2523 
2524  // render "+" or "-"
2525  gl.Begin(GL_LINES);
2526  gl.Vertex2d(rc_btn.Left() + offset, pt_c.Y());
2527  gl.Vertex2d(rc_btn.Left() + offset + kButtonSignSize, pt_c.Y());
2528  if (!m_bExpanded) {
2529  gl.Vertex2d(pt_c.X(), rc_btn.Bottom() + offset);
2530  gl.Vertex2d(pt_c.X(), rc_btn.Bottom() + offset + kButtonSignSize);
2531  }
2532  gl.End();
2533 
2534  /**
2535  if(m_GraphCont && m_GraphCont->HasData()) { // draw "Graph" button
2536  rc_btn = x_GetButtonRect(pane, eSetupGraphs);
2537  gl.Rectd(rc_btn.Left(), rc_btn.Bottom(), rc_btn.Right(), rc_btn.Top());
2538 
2539  m_Style->GetTextFont().TextOut(rc_btn.Left() + 1, rc_btn.Bottom() + 1,
2540  kButtonSize - 2, kButtonSize - 2, "...", IGlFont::eAlign_Center);
2541  }
2542  **/
2543 }
2544 
2545 
2546 
2548 {
2549  const char *s_marker = "";
2550 
2551  int seq_pos = m_Handle.GetSeqPosFromAlnPos(aln_pos);
2552  if(seq_pos == -1) {
2553  seq_pos = m_Handle.GetSeqPosFromAlnPos(aln_pos, dir);
2554  switch(dir) {
2555  case IAlnExplorer::eRight: s_marker = ">> "; break;
2556  case IAlnExplorer::eLeft: s_marker = "<< "; break;
2557  default: break;
2558  }
2559  }
2560  label.clear();
2561  label.append(s_marker);
2562  label.append(CTextUtils::FormatSeparatedNumber(seq_pos + 1));
2563 }
2564 
2565 
2566 // generates text label for given position in alignment
2568 {
2569  string label;
2570  x_GetAlnPosLabel(aln_pos, dir, label);
2572 }
2573 
2574 
2576 {
2577  _ASSERT(m_Style);
2578 
2579  IRender& gl = GetGl();
2580  bool selected = (m_RenderCtx.m_State & fItemSelected) != 0;
2581  bool wid_focused = (m_RenderCtx.m_State & fWidgetFocused) != 0;
2582  const auto& rc_vp = m_RenderCtx.m_Viewport;
2583 
2585 
2586  if (selected) { //draw background
2589  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
2590  gl.Rectd(rc_vp.Left(), rc_vp.Bottom(), rc_vp.Right(), rc_vp.Top());
2591  }
2592  x_RenderEmptyBox();
2593 
2594  // draw text label
2597  TModelUnit x = rc_vp.Left() + kTextOffsetX * 2;
2598  TModelUnit y = rc_vp.Top() - m_BaseHeight;
2599  TModelUnit w = rc_vp.Width() - kTextOffsetX * 4;
2600 
2603  gl.EndText();
2604 }
2605 
2606 
2608 {
2609  IRender& gl = GetGl();
2610 
2612  const auto& rc_vp = m_RenderCtx.m_Viewport;
2613  gl.LineWidth(1.0);
2614  //gl.PolygonMode(GL_FRONT_AND_BACK, GL_LINE);
2615  //gl.Rectf((float)rc_vp.Left() - 1, rc_vp.Bottom() - 1, rc_vp.Right(), rc_vp.Top());
2616 
2617  gl.Begin(GL_LINES);
2618  gl.Vertex2d(rc_vp.Right(), rc_vp.Top());
2619  gl.Vertex2d(rc_vp.Right(), rc_vp.Bottom());
2620  gl.Vertex2d(rc_vp.Left(), rc_vp.Bottom());
2621  gl.Vertex2d(rc_vp.Right(), rc_vp.Bottom());
2622  gl.End();
2623 
2624 }
2625 
2626 
2628 {
2629  return m_Handle.CanGetBioseqHandle();
2630 }
2631 
2632 
2634 {
2635  return m_bExpanded;
2636 }
2637 
2639 {
2640  const CBioseq_Handle& bsh = m_Handle.GetBioseqHandle();
2641  if (!bsh)
2642  return;
2643 
2644  auto gConfig = m_Style->GetSeqGraphicConfig();
2645  // Setup rendering context
2646  CRef<CSGSequenceDS> sequence_ds(new CSGSequenceDS(bsh.GetScope(), *bsh.GetSeqId()));
2647  m_RenderingCtx.reset(new CRenderingContext);
2648  m_RenderingCtx->SetSeqDS(&*sequence_ds);
2649  m_RenderingCtx->SetOverviewCutoff(gConfig->GetOverviewCutoff());
2650 
2651  m_TrackPane.reset(new CGlPane(pane));
2652  TModelRect rc = m_TrackPane->GetVisibleRect();
2655 
2656 // rc.SetHorz(seq_from, seq_to);
2657 // m_TrackPane->SetVisibleRect(rc);
2658  s_PrepareTrackPane(rc.Left(), rc.Right(), seq_from, seq_to, m_Handle, pane, *m_TrackPane);
2659 
2661  m_TrackPane->SetModelLimitsRect(rc);
2662  m_RenderingCtx->PrepareContext(*m_TrackPane, true, m_Handle.IsNegativeStrand());
2663 
2665  m_TrackHandler->SetHost(this);
2666  //m_TrackHandler->SetDraggable(false); // turn of drag&drop
2668 
2670  m_TrackPanel->SetConfig(gConfig);
2672  m_TrackPanel->SetProfile(gConfig->GetTrackProfile());
2673  if (!m_Style->GetTrackSettings().empty()) {
2675  }
2676 
2678  m_TrackPanel->SetDSContext(&*m_ds_ctx);
2679 
2680  SConstScopedObject input_obj(bsh.GetSeqId(), &bsh.GetScope());
2681  m_TrackPanel->SetInputObject(input_obj);
2682  m_TrackPanel->SetHost(this);
2683  {
2684  // set minumum height
2685  TModelUnit icon_s = gConfig->GetIconSize();
2686  m_TrackPanel->SetHeight(icon_s * 1.5);
2687  }
2688 
2689  x_InitTrackPane(pane, *m_TrackPane);
2690 
2692  m_TrackPanel->Update(false);
2693  m_NeedUpdateContent = false;
2694  }
2695 }
2696 
2698 {
2700  try {
2702  sel_visitor->ResetObjectSelection(&*m_TrackPanel);
2704  auto gConfig = m_Style->GetSeqGraphicConfig();
2705  if (gConfig)
2706  gConfig->GetHistParamsManager()->SaveSettings(gConfig->GetColorTheme(), gConfig->GetSizeLevel());
2707  } catch (exception& e) {
2708  ERR_POST(Error << e.what());
2709  }
2710  m_TrackHandler.reset(0);
2711  m_TrackPanel.Reset(0);
2712  m_TrackPane.reset();
2713  m_RenderingCtx.reset();
2714 }
2715 
2716 
2717 void CAlnVecRow::Expand(bool b_exp, CGlPane& pane)
2718 {
2719  if (IsExpandable() && IsExpanded() != b_exp) {
2720  if (b_exp) {
2721  if (!m_TrackPanel) {
2722  x_CreateTrackPanel(pane);
2723  if (m_TrackPanel)
2725  }
2726  } else {
2727  if (m_TrackPanel)
2729  }
2730  m_bExpanded = b_exp;
2732  if (x_GetHost()) {
2733  x_GetHost()->ARH_OnRowChanged(this);
2734  }
2735  }
2736 }
2737 
2739 {
2740  if (!IsExpandable())
2741  return 0;
2742  if (!m_TrackPanel) {
2743  x_CreateTrackPanel(pane);
2744  if (m_TrackPanel)
2746  }
2748 }
2749 
2751 {
2752  m_fExtOrgLookup = f;
2753 }
2754 
2755 
2757 {
2759  if (m_bExpanded && m_TrackPanel) {
2761  m_NeedUpdateContent = false;
2763  }
2764 
2765 }
2766 
2768 {
2769  //return m_GraphCont ? m_GraphCont->GetProperties() : NULL;
2770  return nullptr;
2771 }
2772 
2773 
2775 {
2776 /*
2777  if(m_GraphCont) {
2778  m_GraphCont->SetProperties(props);
2779 
2780  m_Height = m_BaseHeight;
2781  if(m_GraphCont->IsCreated()) {
2782  m_Height += m_GraphCont->PreferredSize().Y();
2783  }
2784  }
2785 */
2786 }
2787 
2788 
2790 {
2791  TSeqPos pos = (TSeqPos) -1;
2792  switch(type) {
2793  case eStart: {
2794  int aln_pos = (int) floor(rc_vis.Left());
2796  break;
2797  }
2798  case eEnd: {
2799  int aln_pos = -1 + (int) ceil(rc_vis.Right());
2801  break;
2802  }
2803  case eSeqStart:
2804  pos = m_Handle.IsNegativeStrand() ?
2806  break;
2807  case eSeqEnd:
2808  pos = m_Handle.IsNegativeStrand() ?
2810  break;
2811  case eSeqLength:
2812  pos = m_Handle.GetSeqLength();
2813  break;
2814  case eMismatches:
2815  pos = m_Handle.GetMismatches();
2816  break;
2817  default:
2818  break;
2819  }
2820  return pos;
2821 }
2822 
2824 {
2825  float val = 0.f;
2826  switch (col_type) {
2827  case ePctIdentity:
2829  break;
2830  case ePctCoverage:
2832  break;
2833  //case eAlignmentScore:
2834  // val = m_Handle.GetAlignmentScore();
2835  // break;
2836  default:
2837  break;
2838  } // switch
2839  return val;
2840 
2841 }
2842 
2843 
2844 
2845 string& CAlnVecRow::GetAlnSeqString( string &buffer, const IAlnExplorer::TSignedRange &aln_rng ) const
2846 {
2847  return m_Handle.GetAlnSeqString( buffer, aln_rng );
2848 }
2849 
2850 
2851 string& CAlnVecRow::GetStringAtPos(string& buffer, TSignedSeqPos aln_pos) const
2852 {
2854  auto pos = m_Handle.GetSeqPosFromAlnPos(aln_pos, IAlnExplorer::eRight);
2855  pos = (pos / 3) * 3;
2856  return m_Handle.GetSeqString(buffer, IAlnExplorer::TRange(pos, pos + 3));
2857  } else {
2858  return GetAlnSeqString(buffer, IAlnExplorer::TSignedRange(aln_pos, aln_pos));
2859  }
2860 
2861 }
2862 
2863 
2864 
2866 {
2869 
2870  TSignedRange alrange;
2871  if( alstart < alstop ){
2872  alrange.Set( alstart, alstop);
2873  } else {
2874  alrange.Set( alstop, alstart);
2875  }
2876 
2877  int aligned = 0;
2878  int gap = 0;
2879  int indel = 0;
2880  int unaligned = 0;
2881 
2883  unique_ptr<IAlnSegmentIterator> p_it(m_Handle.CreateSegmentIterator(alrange, flags));
2884 
2885  TSignedSeqPos prev_seq_to = -2, prev_aln_to = -2;
2886 
2887  for( IAlnSegmentIterator& it(*p_it); it; ++it ){
2888  const IAlnSegment& seg = *it;
2889  auto& aln_r = seg.GetAlnRange();
2890  auto& seq_r = seg.GetRange();
2891 
2892  auto type = seg.GetType();
2893 
2894  if( type & IAlnSegment::fAligned ){
2895  if (!aln_r.Empty()) {
2896  aligned += seq_r.GetLength();
2897  if (aln_r.GetFrom() == prev_aln_to + 1 && seq_r.GetFrom() > prev_seq_to + 1) {
2898  unaligned += seq_r.GetFrom() - prev_seq_to;
2899  }
2900  } else {
2901  indel += seq_r.GetLength();
2902  }
2903  prev_aln_to = aln_r.GetTo();
2904  prev_seq_to = seq_r.GetTo();
2905  }
2906  if( type & IAlnSegment::fGap ){
2907  gap += aln_r.GetLength();
2908  }
2909  if( type & IAlnSegment::fIndel ){
2910  indel += aln_r.GetLength();
2911  }
2912  if( type & IAlnSegment::fUnaligned ){
2913  unaligned += aln_r.GetLength();
2914  }
2915  }
2916 
2917 // int start = m_Handle.GetSeqStart();
2918 // int stop = m_Handle.GetSeqStop();
2919 
2920  int start = m_Handle.GetSeqPosFromAlnPos(alstart, IAlnExplorer::eRight);
2921  int stop = m_Handle.GetSeqPosFromAlnPos(alstop, IAlnExplorer::eLeft);
2922 
2923  bool is_aa = UsesAATranslation();
2924  int base_width = (is_aa && m_Handle.IsNucProtAlignment()) ? 3 : 1;
2925  start /= base_width;
2926  stop /= base_width;
2927 
2928  string aln_str = "Sequence is aligned from ";
2929  aln_str += (is_aa) ? "residues " : "bases ";
2930  aln_str += NStr::IntToString(start + 1, NStr::fWithCommas);
2931  aln_str += " to ";
2932  aln_str += NStr::IntToString(stop + 1, NStr::fWithCommas);
2933  tooltip.AddRow(aln_str);
2934 
2935  string bases = is_aa ? "Residues" : "Bases";
2936  tooltip.AddRow(bases + " aligned:", NStr::IntToString(aligned / base_width, NStr::fWithCommas));
2937  tooltip.AddRow(bases + " through gaps:", NStr::IntToString(gap / base_width, NStr::fWithCommas));
2938  tooltip.AddRow(bases + " in indels:", NStr::IntToString(indel / base_width, NStr::fWithCommas));
2939  tooltip.AddRow(bases + " unaligned:", NStr::IntToString(unaligned / base_width, NStr::fWithCommas));
2940 }
2941 
2943 {
2944  return m_Handle.UsesAATranslation();
2945 }
2946 
2948 {
2949  return m_Handle.IsNucProtAlignment();
2950 }
2951 
2953 {
2954  //LOG_POST("CAlnVecRow::x_OnGraphContentChanged");
2956  if (m_Host) {
2957  m_Host->ARH_OnRowChanged(this);
2958  }
2959 }
2960 
2961 
2963 {
2964  //LOG_POST("CAlnVecRow::x_OnGraphSizeChanged");
2966  if (m_Host) {
2967  m_Host->ARH_OnRowChanged(this);
2968  }
2969 }
2970 
2972 {
2973  CRef<CLayoutTrack> track;
2974 /*
2975  CWeakRef<CSeqGlyph>::TRefType last_hit_glyph = m_LastHitGlyph.Lock();
2976  CRef<CLayoutTrack> track(dynamic_cast<CLayoutTrack*>(last_hit_glyph.GetPointer()));
2977  if (track)
2978  m_LastHitTrack.Reset(track.GetPointer());
2979  if (last_hit_glyph) {
2980  track.Reset(dynamic_cast<CLayoutTrack*>(last_hit_glyph.GetPointer()));
2981  } else {
2982  track.Reset(dynamic_cast<CLayoutTrack*>(m_TrackPanel.GetPointer()));
2983  }
2984  return track;
2985  */
2987  track.Reset(last_hit_track.GetPointer());
2988  return track;
2989 
2990 }
2991 
2993 {
2994  if (!m_Host)
2995  return TModelPoint(0, 0);
2996  if (!m_TrackPanel)
2997  return TModelPoint(0, 0);
2999  return m_TrackPane->UnProject(p.X(), p.Y());
3000 }
3001 
3003 {
3004  IGenericHandlerHost* h = dynamic_cast<IGenericHandlerHost*>(m_Host);
3005  if (h)
3006  h->GHH_Redraw();
3007 }
3008 
3009 void CAlnVecRow::GHH_SetCursor(const wxCursor &cursor)
3010 {
3011  IGenericHandlerHost* h = dynamic_cast<IGenericHandlerHost*>(m_Host);
3012  if (h)
3013  h->GHH_SetCursor(cursor);
3014 }
3016 {
3017  IGenericHandlerHost* h = dynamic_cast<IGenericHandlerHost*>(m_Host);
3018  if (h)
3019  h->GHH_CaptureMouse();
3020 }
3022 {
3023  IGenericHandlerHost* h = dynamic_cast<IGenericHandlerHost*>(m_Host);
3024  if (h)
3025  h->GHH_ReleaseMouse();
3026 }
3027 
3029 {
3030  if (m_bExpanded && m_TrackPanel) {
3032  int max_height = 0;
3033  auto&& rc_vis = m_TrackPane->GetVisibleRect();
3034  auto f = m_ModelLeft;
3035  auto t = m_ModelRight;
3036  if (f > t) swap(f, t);
3037  TSignedRange range(f, t);
3038  CGlPane track_pane(*m_TrackPane);
3039  auto vr = m_TrackPane->GetVisibleRect();
3040  vr.SetHorz(f, t);
3041  track_pane.SetVisibleRect(vr);
3042  track_pane.EnableOffset(false);
3043 
3044  auto vp = m_TrackPane->GetViewport();
3045  vp.SetHorz(m_PixLeft, m_PixRight);
3046  track_pane.SetViewport(vp);
3047 
3048  if (m_NeedUpdateSelection) {
3050  sel_visitor->UpdateSelection(&*m_TrackPanel);
3051  }
3052 
3053  x_ForEachAlnSeg(range, track_pane, track_pane, [&](CGlPane& track_pane) {
3054  m_RenderingCtx->PrepareContext(track_pane, true, m_Handle.IsNegativeStrand());
3055  m_TrackPanel->Update(true);
3056  max_height = max<int>(max_height, m_TrackPanel->GetHeight());
3057  return false;
3058  });
3059  if (max_height > 0) {
3060  m_RenderingCtx->PrepareContext(*m_TrackPane, true, m_Handle.IsNegativeStrand());
3061  m_TrackPanel->SetHeight(max_height);
3062  //auto vr = m_TrackPane->GetVisibleRect();
3063  //vr.SetVert(max_height, 0);
3064  //m_TrackPane->SetVisibleRect(vr);
3065  }
3066  }
3068  if (m_Host) {
3069  m_Host->ARH_OnRowChanged(this);
3070  }
3071  //if (m_TrackPanel && m_TrackPanel->AllJobsFinished())
3072 // m_TrackPanel->SaveTrackConfig();
3073 }
3074 
3075 void CAlnVecRow::LTH_PopupMenu(wxMenu* menu)
3076 {
3077  CGlWidgetPane* widget = dynamic_cast<CGlWidgetPane*>(m_Host);
3078  if (widget) {
3079  widget->SetPopupMenuDisplayed(true);
3080  widget->PopupMenu(menu);
3081  widget->SetPopupMenuDisplayed(false);
3082  }
3083 }
3084 
3085 
3087 {
3088  CGlWidgetPane* widget = dynamic_cast<CGlWidgetPane*>(m_Host);
3089  if (widget) {
3090  widget->PushEventHandler(handler);
3091  }
3092 }
3093 
3094 
3096 {
3097  CGlWidgetPane* widget = dynamic_cast<CGlWidgetPane*>(m_Host);
3098  if (widget) {
3099  widget->PopEventHandler();
3100  }
3101 }
3102 
3103 void CAlnVecRow::LTH_ConfigureTracksDlg(const string& category)
3104 {
3105  ConfigureTracksDialog(category);
3106 }
3107 
3109 {
3110  if (m_bExpanded && m_TrackPanel) {
3111 
3113  m_TrackHandler->SetHost(this);
3114  //m_TrackHandler->SetDraggable(false); // turn of drag&drop
3116 
3118  }
3119 }
3120 
3121 void CAlnVecRow::ConfigureTracksDialog(const string& category)
3122 {
3123  if (!(m_bExpanded && m_TrackPanel))
3124  return;
3126 
3127 }
3128 
3130 {
3131  if (!(m_bExpanded && m_TrackPanel))
3132  return;
3133  if (reset) {
3134  string default_profile = CSGConfigUtils::DefTrackProfile();
3135  m_TrackPanel->SetProfile(default_profile);
3136  CTrackConfigManager::TTrackProxies empty_settings;
3137  m_TrackPanel->SetTrackConfig(empty_settings);
3138  auto gConfig = m_Style->GetSeqGraphicConfig();
3139  gConfig->SetTrackProfile(default_profile);
3140  gConfig->SetDirty(true);
3141  }
3143 
3144 }
3145 
3147 {
3148  if (!(m_bExpanded && m_TrackPanel))
3149  return;
3151 
3152 }
3153 
3154 
3156 {
3157  m_RenderCtx.m_Pane = &pane;
3159  m_RenderCtx.m_Top = row_top;
3161  auto top = m_RenderCtx.m_Viewport.Top() - offset;
3162  auto bottom = top - (m_Height - 1);
3163  m_RenderCtx.m_Viewport.SetVert(bottom, top);
3165 }
static IGlFont::EAlignMode s_GetColumnAlignemnt(int col_type)
Definition: align_row.cpp:398
bool IfDash(char ch)
Definition: align_row.cpp:1973
double CompressLength(double len)
Definition: align_row.cpp:1391
static string s_GetSourceSubtype(const CSeq_descr &descr, CSubSource::ESubtype subtype)
Definition: align_row.cpp:1040
static string s_GetTitle(const CSeq_descr &descr)
Definition: align_row.cpp:1026
static const int kTextOffsetY
Definition: align_row.cpp:2145
static const int kAlignSpace
height of "white-space" between row borders and alignment band
Definition: align_row.cpp:313
static const int kSeqVertSpace
Definition: align_row.cpp:319
static const int kTextVertSpace
Definition: align_row.cpp:318
USING_SCOPE(ncbi::objects)
static const int kTooltipMaxLines
Definition: align_row.cpp:601
ON_EVENT(CGraphNotification, CGraphNotification::eContentChanged, &CAlnVecRow::x_OnGraphContentChanged) ON_EVENT(CGraphNotification
static const int kMaxSeqInTooltip
Definition: align_row.cpp:602
static const int kTextOffsetX
Definition: align_row.cpp:2146
static const int kButtonSignSize
Definition: align_row.cpp:2331
string FormatRange(TSignedSeqPos from, TSignedSeqPos to)
Definition: align_row.cpp:702
#define TOOLTIP_RANGE_PIX
Definition: align_row.cpp:700
static const int kGapOffset
vertical offset from the border of the alignment band to the border of gap band
Definition: align_row.cpp:316
static const TModelUnit kScoreMinScale
Definition: align_row.cpp:1273
static void s_PrepareTrackPane(TModelUnit aln_from, TModelUnit aln_to, TModelUnit seq_from, TModelUnit seq_to, const IAlignRowHandle &row_handle, const CGlPane &source_pane, CGlPane &target_pane)
Definition: align_row.cpp:140
static const int kButtonSize
Definition: align_row.cpp:2330
static const int kButtonOffset
Definition: align_row.cpp:2329
static void FSetPixMaxCoverage(SScPix &dst, const SScPix &src, float fraction, bool long_seg)
a pixel with the Max coverage (fraction) overrides all attributes
Definition: align_row.cpp:1651
void glLined(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2)
Definition: align_row.cpp:1265
static string s_GetOrgModNatHost(const CSeq_descr &descr)
Definition: align_row.cpp:1060
static const int kPosOffsetX
Definition: align_row.cpp:2147
ncbi::TMaskedQueryRegions mask
virtual int GetRowState() const
Returns row state (combination of EState flags)
Definition: align_row.cpp:87
CAlnRowState()
CAlnRowState.
Definition: align_row.cpp:83
virtual void SetRowState(int mask, bool b_set)
Set/Clear Row State.
Definition: align_row.cpp:92
class CAlnVecRow - implementation of IAlignRow for CAlnVec-based alignments.
Definition: align_row.hpp:82
const CRowDisplayStyle * m_Style
Definition: align_row.hpp:285
const IAlignRowHandle & m_Handle
Definition: align_row.hpp:269
int m_BaseHeight
Definition: align_row.hpp:276
void x_ForEachAlnSeg(const IAlnExplorer::TSignedRange &range, const CGlPane &src_pane, CGlPane &target_pane, const function< bool(CGlPane &pane)> &f)
Definition: align_row.cpp:711
virtual int GetRowNum() const
Returns index of row in IAlnMultiDataSource.
Definition: align_row.cpp:386
void ConfigureTracks(bool reset=false)
Definition: align_row.cpp:3129
virtual void x_RenderIconStrand()
Definition: align_row.cpp:2473
virtual void x_RenderAlign()
Renders graphical part of the row.
Definition: align_row.cpp:1277
void LoadDefaultTracks()
Definition: align_row.cpp:3108
TVPUnit m_PixLeft
Graphics caching.
Definition: align_row.hpp:301
void x_RenderTracks(CGlPane &pane, const TSignedRange &range)
Definition: align_row.cpp:2228
virtual void UpdateOnStyleChanged()
Definition: align_row.cpp:329
bool m_NeedUpdateLayout
Definition: align_row.hpp:294
virtual TSeqPos GetColumnAsSeqPos(TColumnType type, const TModelRect &rc_vis) const
Definition: align_row.cpp:2789
virtual void x_RenderNonAveragableScores(CGlPane &pane, IAlnSegmentIterator &it_seg, TScoreConstIterator it, const TScoreConstIterator it_end, int vp_top_y, int vp_bottom_y)
Definition: align_row.cpp:1883
virtual void GetHTMLActiveAreas(TColumnType col_type, CGlPane &pane, TAreaVector &areas)
Definition: align_row.cpp:197
virtual void x_OnClickExpandBtn(CGlPane &pane)
Definition: align_row.cpp:1257
virtual TVPRect x_GetButtonRect(EButtons btn, int shift=1)
Definition: align_row.cpp:2336
virtual void OnMouseEvent(wxMouseEvent &event, TColumnType col_type, CGlPane &pane)
Definition: align_row.cpp:542
void x_GetAlnPosLabel(TSeqPos aln_pos, IAlnExplorer::ESearchDirection dir, string &label) const
Definition: align_row.cpp:2547
virtual void x_RenderAveragableScores(CGlPane &pane, IAlnSegmentIterator &it_seg, TScoreConstIterator it, const TScoreConstIterator it_end, int vp_top_y, int vp_bottom_y)
Definition: align_row.cpp:1774
virtual void x_RenderGraph(const TSignedRange &range)
Definition: align_row.cpp:2322
string x_GetTooltipSequence(TSeqPos from, TSeqPos to)
Definition: align_row.cpp:1232
void GetTaxonomy(string &taxonomy) const
Definition: align_row.cpp:1166
virtual void x_GetIconsTooltip(const TVPPoint &pt, CGlPane &pane, ITooltipFormatter &tooltip)
Definition: align_row.cpp:674
void x_GetAlignmentTooltip_Gap(const TSignedSeqRange &aln_r, const TSignedSeqRange &seq_r, ITooltipFormatter &tooltip)
Definition: align_row.cpp:1185
virtual float GetColumnAsFloat(TColumnType type) const
Definition: align_row.cpp:2823
virtual void x_UpdateRowHeight()
Definition: align_row.cpp:2756
virtual bool x_CanRenderSeq(CGlPane &pane)
Checks if sequence can be drawn.
Definition: align_row.cpp:1963
virtual void x_RenderIconExpand()
Definition: align_row.cpp:2500
void x_GetAlignmentTooltip_Insert(const TSignedSeqRange &aln_r, const TSignedSeqRange &seq_r, ITooltipFormatter &tooltip)
Definition: align_row.cpp:1171
virtual void UseExternalOrganismLookup(bool f)
Definition: align_row.cpp:2750
virtual void x_RenderDescr()
Definition: align_row.cpp:2150
virtual void LTH_ConfigureTracksDlg(const string &category)
Definition: align_row.cpp:3103
CRef< CFeaturePanel > m_TrackPanel
Definition: align_row.hpp:292
void ConfigureTracksDialog(const string &category=NcbiEmptyString)
Definition: align_row.cpp:3121
TModelUnit m_ModelLeft
Definition: align_row.hpp:302
virtual void x_CreateTrackPanel(CGlPane &pane)
Definition: align_row.cpp:2638
virtual void GetTooltip(const TVPPoint &vp_pt, TColumnType col_type, CGlPane &pane, ITooltipFormatter &tooltip)
returns tooltip text by point in the viewport coordinates
Definition: align_row.cpp:605
AutoPtr< CLayoutTrackHandler > m_TrackHandler
Definition: align_row.hpp:296
virtual void UpdateOnAnchorChanged()
Definition: align_row.cpp:337
virtual bool IsExpanded() const
Definition: align_row.cpp:2633
CRef< CSeqGlyph > x_HitTest(const TVPPoint &vp_pt, CGlPane &pane, TModelPoint &hit_point)
Definition: align_row.cpp:798
bool m_NeedUpdateSelection
Definition: align_row.hpp:295
unique_ptr< CGlPane > m_TrackPane
Definition: align_row.hpp:291
virtual void LTH_PushEventHandler(wxEvtHandler *handler)
Definition: align_row.cpp:3086
virtual string & GetColumnText(TColumnType col_type, string &text, bool for_printer=false) const
Definition: align_row.cpp:474
unique_ptr< CRenderingContext > m_RenderingCtx
Definition: align_row.hpp:289
virtual void GHH_Redraw()
redraws the Host and the handler
Definition: align_row.cpp:3002
IAlignRowHost * m_Host
Definition: align_row.hpp:273
void x_GetAlignmentTooltip_Unaligned(TSignedSeqPos aln_prev_to, TSignedSeqPos aln_from, TSignedSeqPos prev_to, TSignedSeqPos from, ITooltipFormatter &tooltip)
Definition: align_row.cpp:1211
virtual EButtons x_HitTestButton(CGlPane &pane, const TVPPoint &pt)
Definition: align_row.cpp:2356
virtual void GHH_ReleaseMouse()
releases captured mouse
Definition: align_row.cpp:3021
virtual int x_GetBaseHeight() const
Definition: align_row.cpp:360
virtual void GHH_CaptureMouse()
captures mouse events in the hosting window for D&D
Definition: align_row.cpp:3015
virtual void x_RenderSequence(CGlPane &pane, TModelUnit top_y, TModelUnit bottom_y, int start, int stop)
Definition: align_row.cpp:1977
virtual void GHH_SetCursor(const wxCursor &cursor)
changes the cursor in the hosting window
Definition: align_row.cpp:3009
virtual void PrepareRendering(CGlPane &pane, TVPUnit row_top, int state)
Definition: align_row.cpp:3155
bool m_bExpanded
Definition: align_row.hpp:282
virtual void Update(const CGlPane &pane, bool layout_only=false)
Definition: align_row.cpp:343
virtual void SetDisplayStyle(const CRowDisplayStyle *style)
Definition: align_row.cpp:322
virtual void LTH_OnLayoutChanged()
provides mouse coords in OpenGL viewport coord system
Definition: align_row.cpp:3028
virtual bool IsExpandable() const
Definition: align_row.cpp:2627
virtual void LTH_PopEventHandler()
Definition: align_row.cpp:3095
virtual bool IsNucProtAlignment() const
Definition: align_row.cpp:2947
virtual void SetHost(IAlignRowHost *host)
Definition: align_row.cpp:380
void x_OnGraphSizeChanged(CEvent *evt)
Definition: align_row.cpp:2962
virtual void SetScoreCache(CScoreCache *cache)
Definition: align_row.cpp:135
virtual const IAlnRowGraphProperties * GetProperties() const
Definition: align_row.cpp:2767
virtual void x_GetDescrTooltip(const TVPPoint &pt, CGlPane &pane, ITooltipFormatter &tooltip)
Definition: align_row.cpp:642
virtual string & GetAlnSeqString(string &buffer, const IAlnExplorer::TSignedRange &aln_rng) const
Definition: align_row.cpp:2845
CWeakRef< CLayoutTrack > m_LastHitTrack
Definition: align_row.hpp:298
virtual void x_RenderAlignSegments(CGlPane &pane, IAlnSegmentIterator &it_seg, TModelUnit top_y, TModelUnit bottom_y, const CRgbaColor &color)
Definition: align_row.cpp:1554
virtual void x_RenderIcons()
Definition: align_row.cpp:2374
virtual void x_GetAlignmentTooltip(const TVPPoint &pt, CGlPane &pane, ITooltipFormatter &tooltip)
Definition: align_row.cpp:882
virtual void x_RenderAlnPos(TSeqPos aln_pos, IAlnExplorer::ESearchDirection dir)
Definition: align_row.cpp:2567
virtual TModelPoint THH_GetModelByWindow(const wxPoint &pt)
Definition: align_row.cpp:2992
virtual string GetAlignmentTooltip(TSeqPos pos, TSeqPos half_width)
Definition: align_row.cpp:933
IAlignRowHost * x_GetHost()
Definition: align_row.hpp:252
virtual void x_ResetTrackPanel()
Definition: align_row.cpp:2697
virtual void x_RenderAlignScores(IAlnSegmentIterator &it_seg, int top_y, int bottom_y, bool averageable)
Definition: align_row.cpp:1661
void x_OnGraphContentChanged(CEvent *evt)
Definition: align_row.cpp:2952
virtual void x_RenderInserts(CGlPane &pane, int from, int to, TModelUnit top_y, TModelUnit bottom_y)
Definition: align_row.cpp:1402
bool m_fExtOrgLookup
Definition: align_row.hpp:283
TModelUnit m_ModelRight
Definition: align_row.hpp:302
virtual bool UsesAATranslation() const
Definition: align_row.cpp:2942
virtual void x_RenderTextCell(const string &text, IGlFont::TAlign align)
Definition: align_row.cpp:2575
bool x_InitTrackPane(const CGlPane &row_pane, CGlPane &track_pane)
Definition: align_row.cpp:2173
IAlnExplorer::TSignedRange TSignedRange
Definition: align_row.hpp:84
virtual void SetProperties(IAlnRowGraphProperties *props)
Definition: align_row.cpp:2774
virtual void RenderColumn(TColumnType col_type)
Renders a row cell corresponding to column specified by "col_type".
Definition: align_row.cpp:425
bool m_NeedUpdateContent
Definition: align_row.hpp:293
void x_GetAlignmentTooltip_Helper(TSeqPos pos, TSignedRange &range, ITooltipFormatter &tooltip)
Definition: align_row.cpp:941
virtual void x_RenderEmptyBox()
Definition: align_row.cpp:2607
size_t GetTrackCount(CGlPane &pane)
Definition: align_row.cpp:2738
CAlnVecRow(const IAlignRowHandle &handle)
CAlnVecRow.
Definition: align_row.cpp:104
virtual void LTH_PopupMenu(wxMenu *menu)
show track-specific context menu.
Definition: align_row.cpp:3075
void x_GetAlignmentTooltip_General(TSeqPos pos, ITooltipFormatter &tooltip)
Definition: align_row.cpp:1084
virtual string & GetStringAtPos(string &buffer, TSignedSeqPos aln_pos) const
Definition: align_row.cpp:2851
virtual void x_RenderUnaligned(CGlPane &pane, int from, int to, TModelUnit top_y, TModelUnit bottom_y)
Definition: align_row.cpp:1503
CConsensusRow * m_ConsensusRow
Definition: align_row.hpp:271
CScoreCache * m_Cache
row display style
Definition: align_row.hpp:287
unique_ptr< CRenderingContext > m_SequenceRenderingCtx
Definition: align_row.hpp:290
virtual const CRowDisplayStyle * GetDisplayStyle()
Definition: align_row.cpp:374
virtual void GetRowStatistics(ITooltipFormatter &tooltip) const
Definition: align_row.cpp:2865
TVPUnit m_PixRight
Definition: align_row.hpp:301
virtual void Expand(bool b_exp, CGlPane &pane)
Definition: align_row.cpp:2717
virtual CRef< CLayoutTrack > THH_GetLayoutTrack()
Get the layout track under the current mouse position.
Definition: align_row.cpp:2971
virtual int GetHeightPixels() const
Returns height of the row in pixels.
Definition: align_row.cpp:392
void SaveTrackConfig()
Definition: align_row.cpp:3146
const COrgName & GetOrgname(void) const
Definition: BioSource.cpp:410
bool IsSetOrgname(void) const
Definition: BioSource.cpp:405
CBioseq_Handle –.
const IAlignRowHandle & GetHandle() const
virtual string & GetAlnSeqString(string &buffer, const IAlnExplorer::TSignedRange &aln_rng) const
bool IsValid() const
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
void SaveTrackConfig()
void SetInputObject(SConstScopedObject &obj)
void SetConfigKey(const string &config_key)
virtual void Update(bool layout_only)
Update content and layout including the bounding box.
virtual CRef< CSeqGlyph > HitTest(const TModelPoint &p)
Hit testing.
void LoadDefaultTracks()
Reset tracks to the original default track list.
void ShowConfigureTracksDlg(const string &category)
void SetTrackConfig(const TTrackSettingsSet &settings_set)
void SetDSContext(ISGDataSourceContext *ds_ctx)
void ConfigureTracks()
CGlAttrGuard - guard class for restoring OpenGL attributes.
Definition: glutils.hpp:130
class CGlPane
Definition: glpane.hpp:62
CGlWidgetPane represent a window component residing in CGlWidgetBase client area.
void SetPopupMenuDisplayed(bool b)
const CLayoutGroup & GetGroup() const
void SaveSettings(const string &curr_color, const string &curr_size) const
size_t GetChildrenNum() const
Get total number of children.
CLayoutTrackHandler - is the handler for handling the user interactions on layout tracks.
void Render(CGlPane &pane)
void SetHost(ITrackHandlerHost *host)
CLayoutTrackHandler inline methods.
virtual void SetPane(CGlPane *pane)
File Description:
void SetConfig(CRef< CSeqGraphicConfig > conf)
void SetProfile(const string &preset_style)
CLayoutTrack inline method implmentation.
void SetHost(ILayoutTrackHost *host)
void GetLabel(string *label) const
Definition: Org_ref.cpp:57
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
@ fSkipGrid
track frame will be rendered when triggered.
@ fSkipTitleBar
can be collpased and expanded.
@ fSkipControls
track frame will be rendered when triggered.
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CRowDisplayStyle is a base class representing a display style for IAlignRow.
CRef< CSeqGraphicConfig > GetSeqGraphicConfig() const
CRef< CGlTexture > GetDotTexture() const
virtual const CRgbaColor & GetColor(TColorType type) const
int GetShownElements() const
const string & GetTrackConfigKey() const
virtual bool GetShowIdenticalBases(void) const
const CTrackConfigManager::TTrackProxies & GetTrackSettings() const
bool IsWebRendering() const
virtual const CGlTextureFont & GetTextFont(void) const
virtual const CGlTextureFont & GetSeqFont(void) const
static const string & DefTrackProfile()
static bool IsBackgroundJob()
bool HasScores() const
returns "true" if CalculateScores() did produce results
const TScoreColl & GetScores(TNumrow row) const
IScoringMethod::TScore TScore
IScoringMethod * GetScoringMethod()
const CRgbaColor & GetColorForScore(TScore score, IScoringMethod::EColorType type) const
class CSelectionVisitor is a concrete glyph visitor for selection traversal and deselection traversal...
void UpdateSelection(CSeqGlyph *glyph)
void ResetObjectSelection(CSeqGlyph *glyph)
void SelectObject(const CObject *obj, bool verified)
bool IsObjectSelected(const CObject *obj)
void DeSelectObject(const CObject *obj)
bool HasSelectedObjects() const
virtual void SetHeight(TModelUnit h)
Definition: seq_glyph.hpp:650
virtual bool IsClickable() const
Query if this glyph is clickable.
Definition: seq_glyph.hpp:195
virtual void GetTooltip(const TModelPoint &, ITooltipFormatter &tt, string &t_title) const
Get the tooltip if available.
Definition: seq_glyph.cpp:136
virtual bool OnLeftUp(const TModelPoint &)
Definition: seq_glyph.cpp:70
virtual bool OnLeftDblClick(const TModelPoint &)
Definition: seq_glyph.cpp:76
virtual TModelUnit GetHeight() const
Definition: seq_glyph.hpp:587
virtual bool OnLeftDown(const TModelPoint &)
Definition: seq_glyph.cpp:64
void Draw() const
render the layout.
Definition: seq_glyph.cpp:92
CRef< CHistParamsManager > GetHistParamsManager() const
Get histogram config manager.
void SetTrackProfile(const string &profile)
bool GetCgiMode() const
@Seq_descr.hpp User-defined methods of the data storage class.
Definition: Seq_descr.hpp:55
CTempTrackProxy::TTrackProxies TTrackProxies
CWeakRef –.
Definition: ncbiobj.hpp:2658
@ eAlignSegsNoScores
this color is used when scoring is enabled but
FSetPix2(bool sequence_level)
Definition: align_row.cpp:1727
void operator()(SScPix2 &dst, const SScPix2 &src, float fraction, bool long_seg)
accumulate weighted scores
Definition: align_row.cpp:1733
bool m_SequenceLevel
Definition: align_row.cpp:1768
IAlignRowHandle provides an abstract way to access alignment row data.
Definition: alnmulti_ds.hpp:59
virtual bool UsesAATranslation() const =0
virtual int GetMismatches() const
virtual TSignedSeqPos GetSeqStart() const =0
virtual void GetHost(string &value) const
virtual bool CanGetBioseqHandle() const =0
virtual bool IsAnchor() const
virtual const string & GetOrgLabel(bool fExtOrgLookup=false) const
virtual TSignedSeqPos GetSeqAlnStart() const =0
virtual const objects::CBioseq_Handle & GetBioseqHandle() const =0
virtual void GetCountry(string &value) const
virtual double GetPctCoverage() const
virtual bool IsNucProtAlignment() const =0
virtual double GetPctIdentity() const
virtual size_t GetBaseWidth() const =0
virtual IAlnExplorer::TSignedRange GetSeqAlnRange() const =0
virtual TSeqPos GetSeqLength() const
virtual TSignedSeqPos GetSeqPosFromAlnPos(TSeqPos aln_pos, IAlnExplorer::ESearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const =0
virtual TNumrow GetRowNum() const =0
virtual string & GetAlnSeqString(string &buffer, const IAlnExplorer::TSignedRange &aln_rng) const =0
virtual TSignedSeqPos GetSeqAlnStop() const =0
virtual TSignedSeqPos GetSeqStop() const =0
virtual void GetCollectionDate(string &value) const
virtual string & GetSeqString(string &buffer, const IAlnExplorer::TRange &seq_rng) const =0
virtual void GetIsolationSource(string &value) const
virtual bool IsNegativeStrand() const =0
virtual void GetTaxonomy(string &taxonomy, bool fExtOrgLookup=false) const
virtual TSignedSeqPos GetAlnPosFromSeqPos(TSeqPos seq_pos, IAlnExplorer::ESearchDirection dir=IAlnExplorer::eNone, bool try_reverse_dir=true) const =0
virtual IAlnSegmentIterator * CreateSegmentIterator(const IAlnExplorer::TSignedRange &range, IAlnSegmentIterator::EFlags flags) const =0
virtual void GetGeneSymbol(string &value) const
virtual const string & GetText() const =0
IAlignRowHost represents a context in which IAlignRow lives.
Definition: ialign_row.hpp:192
virtual void ARH_OnSelectionChanged()=0
notifies a host about selection change
virtual CSelectionVisitor * ARH_GetSelectionVisitor()=0
notifies a host about selection change
virtual int ARH_GetRowTop(IAlignRow *p_row)=0
Returns Y-pos for row.
virtual TVPPoint ARH_GetVPPosByWindowPos(const wxPoint &pos)=0
provides mouse coords in OpenGL viewport coord system
virtual void ARH_OnRowChanged(IAlignRow *row)=0
notifies a host about changes the row
int TColumnType
Definition: ialign_row.hpp:70
@ fWidgetFocused
it isn'e exactly a row state;
Definition: ialign_row.hpp:106
vector< CHTMLActiveArea > TAreaVector
Definition: ialign_row.hpp:69
SRenderCtx m_RenderCtx
Definition: ialign_row.hpp:183
@ ePctIdentity
% identity to consensus or anchor
Definition: ialign_row.hpp:91
@ eIsolationSource
Definition: ialign_row.hpp:87
@ eIconStrand
Icon for Positive/Negative (Mixed?) strand.
Definition: ialign_row.hpp:84
@ eIconExpand
Icon for expand (+) button.
Definition: ialign_row.hpp:85
@ eIcons
Strand + Expand icons.
Definition: ialign_row.hpp:77
@ eCollectionDate
Definition: ialign_row.hpp:89
@ ePctCoverage
% coverage to anchor
Definition: ialign_row.hpp:92
@ eMismatches
% number of mismatches to anchor/consensus
Definition: ialign_row.hpp:93
ESearchDirection
Position search options.
@ eRight
Towards higher aln coord (always to the right)
@ eLeft
Towards lower aln coord (always to the left)
IAlnRowGraphProperties.
Alignment segment iterator interface.
EFlags
Iterator options.
@ eSkipInserts
Iterate segments where at least some rows are aligned (including gap segments)
@ eInsertsOnly
Iterate only ranges not participating in the alignment (unaligned segments)
@ eAllSegments
Iterate all segments.
@ eSkipGaps
Skip gap segments (show only aligned ranges)
Alignment segment interface.
virtual const TSignedRange & GetRange(void) const =0
Get the selected row range.
@ fAligned
Aligned segment.
@ fIndel
Either anchor or the selected row is not present in the segment.
@ fUnaligned
The range on the selected sequence does not participate in the alignment (the alignment range of the ...
@ fGap
Both anchor row and the selected row are not included in the segment (some other row is present and t...
virtual TSegTypeFlags GetType(void) const =0
Get current segment type.
bool IsAligned(void) const
virtual const TSignedRange & GetAlnRange(void) const =0
Get alignment range for the segment.
unsigned TSegTypeFlags
static const int kAmbiguousResidueScore
IGenericHandlerHost.
virtual void GHH_ReleaseMouse()=0
releases captured mouse
virtual void GHH_Redraw()=0
redraws the Host and the handler
virtual void GHH_CaptureMouse()=0
captures mouse events in the hosting window for D&D
virtual void GHH_SetCursor(const wxCursor &cursor)=0
changes the cursor in the hosting window
File Description:
virtual CConstRef< CObject > GetObject(TSeqPos pos) const =0
access our core component - we wrap an object(s) of some sort.
IScoringMethod represents an abstract algorithm for calculating alignment scores and assigning colors...
virtual int GetSupportedColorTypes() const =0
returns a combination of EColorType flags
virtual bool IsAverageable() const =0
return "true" if scores could be averaged
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
static const Colors colors
Definition: cn3d_colors.cpp:50
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
Include a standard set of the NCBI C++ Toolkit most basic headers.
static uch flags
#define H(x, y, z)
Definition: md4.c:180
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
static int type
Definition: getdata.c:31
static const char * str(char *buf, int n)
Definition: stats.c:84
int offset
Definition: replacements.h:160
char data[12]
Definition: iconv.c:80
void reset(element_type *p=0, EOwnership ownership=eTakeOwnership)
Reset will delete the old pointer (if owned), set content to the new value, and assume the ownership ...
Definition: ncbimisc.hpp:480
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_ASSERT(expr, mess)
Definition: ncbidbg.hpp:130
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
CGlRect & IntersectWith(const CGlRect &r)
Definition: glrect.hpp:194
GLdouble TModelUnit
Definition: gltypes.hpp:48
void SetModelLimitsRect(const TModelRect &R)
Definition: glpane.hpp:342
T X() const
Definition: glpoint.hpp:59
virtual void Viewport(GLint x, GLint y, GLsizei width, GLsizei height)=0
T Height() const
Definition: glrect.hpp:90
void SetViewport(const TVPRect &R)
Definition: glpane.cpp:96
virtual void Enable(GLenum glstate)=0
bool OpenOrtho()
Definition: glpane.hpp:427
EAlignMode
alignment modes
Definition: glfont.hpp:100
virtual void Begin(GLenum mode)=0
Start rendering.
T Top() const
Definition: glrect.hpp:84
virtual void BlendFunc(GLenum sfactor, GLenum dfactor)=0
Options to be used when GL_BLEND is enabled.
virtual void BeginClippingRect(GLint x, GLint y, GLsizei width, GLsizei height)=0
T Bottom() const
Definition: glrect.hpp:82
TModelUnit UnProjectWidth(TVPUnit vp_w) const
Definition: glpane.cpp:755
TModelPoint UnProject(TVPUnit m_x, TVPUnit m_y) const
Definition: glpane.cpp:738
T Width() const
Definition: glrect.hpp:86
void Color3d(GLdouble r, GLdouble g, GLdouble b)
Definition: irender.hpp:100
IRender & GetGl()
convenience function for getting current render manager
void Vertex2d(GLdouble x, GLdouble y)
Definition: irender.hpp:185
T Right() const
Definition: glrect.hpp:83
TVPRect & GetViewport(void)
Definition: glpane.hpp:332
virtual void BeginText(const CGlTextureFont *font, const CRgbaColor &color)=0
Text is drawn is pixel coordinates.
virtual TModelUnit GetFontDescender() const
static string FormatSeparatedNumber(int number, bool b_postfix=false)
virtual void EndText()=0
Pops matrices and attributes after writing text.
const TVPRect * GetClipRect() const
returns clipping rect or NULL (if there is no clipping)
Definition: glpane.hpp:400
TModelUnit UnProjectX(TVPUnit m_x) const
Definition: glpane.cpp:706
CGlPoint< T > CenterPoint() const
Definition: glrect.hpp:94
TModelRect & GetModelLimitsRect(void)
Definition: glpane.hpp:347
T Left() const
Definition: glrect.hpp:81
T Y() const
Definition: glpoint.hpp:60
virtual void EndClippingRect()=0
bool PtInRect(T x, T y) const
Definition: glrect.hpp:154
virtual bool IsPrinterFriendly() const =0
virtual void End()=0
Finish rendering (create buffer and send to renderer)
void Close(void)
Definition: glpane.cpp:178
virtual void PolygonMode(GLenum face, GLenum mode)=0
Set the polygon rasterization mode.
int TVPUnit
Definition: gltypes.hpp:47
void SetVert(T bottom, T top)
Definition: glrect.hpp:123
void SetVisibleRect(const TModelRect &R)
Definition: glpane.cpp:113
virtual TModelUnit GetMetric(EMetric metric, const char *text=NULL, int len=-1) const
virtual void WriteText(TModelUnit x, TModelUnit y, const char *text, TModelUnit rotate_degrees=0.0)=0
Write text at specified model coords.
virtual TModelUnit TextWidth(const char *text) const
Compute and return font metrics.
virtual TModelUnit TextHeight(void) const
TModelRect & GetVisibleRect(void)
Definition: glpane.hpp:357
void Vertex2f(GLfloat x, GLfloat y)
Definition: irender.hpp:182
virtual void Disable(GLenum glstate)=0
glDisable()
virtual void LineWidth(GLfloat w)=0
Set line width for drawing: glLineWidth()
TModelUnit GetScaleX(void) const
Definition: glpane.cpp:118
TModelUnit GetOffsetX() const
Definition: glpane.hpp:410
void SetExactOrthoProjection(bool exact_projection)
Definition: glpane.hpp:509
void SetHorz(T left, T right)
Definition: glrect.hpp:117
CGlPoint< TModelUnit > TModelPoint
Definition: gltypes.hpp:51
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
void Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
Definition: irender.hpp:193
int TAlign
Definition: glfont.hpp:113
void EnableOffset(bool b_en=true)
Offset is used as a workaround for OpenGL precision problems emerging when size of visible range is s...
Definition: glpane.hpp:405
virtual void GetViewport(GLint *params)=0
@ eAlign_Right
Definition: glfont.hpp:104
@ eAlign_Left
Definition: glfont.hpp:102
@ eAlign_VCenter
Definition: glfont.hpp:108
@ eAlign_HCenter
Definition: glfont.hpp:103
@ ePixels
Definition: glpane.hpp:67
@ eOrtho
Definition: glpane.hpp:66
@ eMetric_MaxCharWidth
Definition: glfont.hpp:86
@ eAlwaysUpdate
Definition: glpane.hpp:85
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
const_iterator end() const
void SetAlpha(float r)
Definition: rgba_color.cpp:287
void Lighten(float scale)
Definition: rgba_color.cpp:463
static CIRef< ITooltipFormatter > CreateTooltipFormatter()
Definition: tooltip.cpp:264
static CRgbaColor Interpolate(const CRgbaColor &color1, const CRgbaColor &color2, float alpha)
Interpolate two colors.
Definition: rgba_color.cpp:444
#define END_EVENT_MAP()
Ends definition of Command Map.
const_iterator find(position_type pos) const
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
virtual void Append(const ITooltipFormatter &tooltip)=0
appends another formatter to this one
const_iterator begin() const
string GetProteinName(const CBioseq_Handle &seq)
Return protein name from corresponding Prot-ref feature.
Definition: sequence.cpp:356
const COrg_ref & GetOrg_ref(const CBioseq_Handle &handle)
Return the org-ref associated with a given sequence.
Definition: sequence.cpp:264
TSeqPos GetBioseqLength(void) const
bool IsAa(void) const
CConstRef< CSeq_id > GetSeqId(void) const
Get id which can be used to access this bioseq handle Throws an exception if none is available.
const TDescr & GetDescr(void) const
CScope & GetScope(void) const
Get scope this handle belongs to.
bool IsNa(void) const
bool CanGetDescr(void) const
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:726
TRefType Lock(void) const
Lock the object and return reference to it.
Definition: ncbiobj.hpp:2713
void Reset(void)
Reset the containing pointer to null.
Definition: ncbiobj.hpp:2722
position_type GetLength(void) const
Definition: range.hpp:158
TThisType & IntersectWith(const TThisType &r)
Definition: range.hpp:317
TThisType IntersectionWith(const TThisType &r) const
Definition: range.hpp:312
position_type GetToOpen(void) const
Definition: range.hpp:138
TThisType & Set(position_type from, position_type to)
Definition: range.hpp:188
bool Empty(void) const
Definition: range.hpp:148
CRange< TSignedSeqPos > TSignedSeqRange
Definition: range.hpp:420
#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 DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
Definition: ncbistr.hpp:5187
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
#define NcbiEmptyString
Definition: ncbistr.hpp:122
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
@ fWithCommas
Use commas as thousands separator.
Definition: ncbistr.hpp:254
static const char label[]
const TSubtype & GetSubtype(void) const
Get the Subtype member data.
Definition: BioSource_.hpp:539
bool IsSetSubtype(void) const
Check if a value has been assigned to Subtype data member.
Definition: BioSource_.hpp:527
@ eSubtype_collection_date
DD-MMM-YYYY format.
Definition: SubSource_.hpp:114
void SetFrom(TFrom value)
Assign a value to From data member.
Definition: Range_.hpp:231
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
void SetTo(TTo value)
Assign a value to To data member.
Definition: Range_.hpp:278
const TMod & GetMod(void) const
Get the Mod member data.
Definition: OrgName_.hpp:839
bool CanGetMod(void) const
Check if it is safe to call GetMod method.
Definition: OrgName_.hpp:833
@ eSubtype_nat_host
natural host of this specimen
Definition: OrgMod_.hpp:104
const Tdata & Get(void) const
Get the member data.
Definition: Seq_descr_.hpp:166
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
n background color
int i
if(yy_accept[yy_current_state])
int len
static void text(MDB_val *v)
Definition: mdb_dump.c:62
range(_Ty, _Ty) -> range< _Ty >
#define abs(a)
Definition: ncbi_heapmgr.c:130
EIPRangeType t
Definition: ncbi_localip.c:101
Defines: CTimeFormat - storage class for time format.
T max(T x_, T y_)
T log10(T x_)
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
static pcre_uint8 * buffer
Definition: pcretest.c:1051
void operator()(float &dst, const float &src, float fraction, bool long_seg)
Definition: align_row.cpp:1547
SRenderingContextGuard(const function< void()> &f)
Definition: align_row.cpp:74
function< void()> m_f
Definition: align_row.cpp:76
represents a pixel with two scores, one corresponds to a gap interval, another - to an aligned segmen...
Definition: align_row.cpp:1708
float m_MinScore
Definition: align_row.cpp:1713
float m_IntScore
Definition: align_row.cpp:1709
bool operator==(const SScPix2 &other) const
Definition: align_row.cpp:1716
bool m_Init
Definition: align_row.cpp:1714
float m_IntLen
Definition: align_row.cpp:1710
float m_GapScore
Definition: align_row.cpp:1711
float m_GapLen
Definition: align_row.cpp:1712
represents a pixel with a score, if several intervals cover a pixel, the interval with the maximum co...
Definition: align_row.cpp:1637
float m_MaxCoverage
score assigned to the pixel
Definition: align_row.cpp:1639
bool m_Gap
fraction of the pixel corresponding to the m_Score
Definition: align_row.cpp:1640
float m_Score
Definition: align_row.cpp:1638
bool operator==(const SScPix &other) const
true if this is a gap interval
Definition: align_row.cpp:1642
Definition: type.c:6
#define _ASSERT
Modified on Wed Apr 17 13:08:12 2024 by modify_doxy.py rev. 669887