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

Go to the SVN repository for this file.

1 /* $Id: cross_panel_ir.cpp 42767 2019-04-10 20:59:16Z katargir $
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: Vlad Lebedev
27  *
28  */
29 
30 
31 #include <ncbi_pch.hpp>
33 #include <objmgr/seq_vector.hpp>
34 #include <gui/objutils/utils.hpp>
35 #include <gui/utils/intersect.hpp>
36 #include <corelib/ncbitime.hpp>
37 #include <gui/opengl/irender.hpp>
38 
39 
43 
44 static const TModelUnit kSeqMapBarHeight = 3.0f;
45 static const int sc_StepK[] = { 2, 5, 10 };
46 static const TModelUnit kClipMultiple = 5.0;
47 
48 
50  : m_Font_Fixed12(CGlTextureFont::eFontFace_Fixed, 12)
51 {
52 }
53 
54 
56 {
57 }
58 
59 
60 
62 {
63  m_RCM1 = rcm1;
64  m_RCV1 = rcv1;
65  m_RCM2 = rcm2;
66  m_RCV2 = rcv2;
67 }
68 
69 
70 
72 {
74 }
75 
76 
78 {
79  /*m_ColorScoreId = score_id;
80 
81  if(m_DS) {
82  m_Graph.AssignColorsByScore(score_id);
83  }*/
84 }
85 
86 
88 {
89  m_DS = ds;
90 
92 
93  if(m_DS) {
96  //const CDenseSegHit* hit = *it;
97  //cout << "Q Start " << hit.GetQueryStart() << ", Subj Start " << hit.GetSubjectStart() << endl;
98  m_Graph.CreateGlyph(**it);
99  }
100  }
102 }
103 
104 
106 {
107  pane.OpenOrtho();
108 
109  IRender& gl = GetGl();
110 
111  gl.Disable(GL_CULL_FACE);
112  gl.Disable(GL_DEPTH_TEST);
113  gl.Disable(GL_LIGHTING);
114  gl.Enable(GL_BLEND);
115  gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
116  gl.Enable(GL_LINE_SMOOTH);
117  gl.Hint(GL_LINE_SMOOTH_HINT, GL_NICEST);
118 
119  gl.Enable(GL_POLYGON_SMOOTH);
120  gl.Hint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
121 
122  gl.LineWidth(1.5f);
123 
124  x_DrawCrossAlignment(pane); // Draw our quads
125 
126  x_DrawSequence(pane); // Draw some sequence letters
127 
128  gl.Disable(GL_BLEND);
129  gl.Disable(GL_LINE_SMOOTH);
130  gl.Disable(GL_POLYGON_SMOOTH);
131  gl.LineWidth(1.0f);
132 
133  pane.Close();
134 }
135 
136 
137 TModelRect CCrossPanelIR::HitTest(CGlPane& pane, int x, int y, bool select)
138 {
139  const TModelRect& rcV = pane.GetVisibleRect();
140 
143 
144  CRange<TModelUnit> rcv1_clip(rcv1.GetFrom() - rcv1.GetLength() * kClipMultiple,
145  rcv1.GetTo() + rcv1.GetLength() * kClipMultiple);
146  CRange<TModelUnit> rcv2_clip(rcv2.GetFrom() - rcv2.GetLength() * kClipMultiple,
147  rcv2.GetTo() + rcv2.GetLength() * kClipMultiple);
148 
149  ITERATE(THitGlyphVector, it, m_Graph.GetGlyphs()) { // for each Hit
150  const CHitGlyph::TElemGlyphCont& elems = (*it)->GetElems();
151  const IHitElement& first_elem = elems.front().GetHitElem();
152  const IHitElement& last_elem = elems.back().GetHitElem();
153 
154  TSignedSeqPos from1 = first_elem.GetQueryStart();
155  TSignedSeqPos from2 = first_elem.GetSubjectStart();
156  TSignedSeqPos to1 = last_elem.GetQueryStart() + last_elem.GetQueryLength();
157  TSignedSeqPos to2 = last_elem.GetSubjectStart() + last_elem.GetSubjectLength();
158 
159  if ( (to1 < m_RCV1.Left() && to2 < m_RCV2.Left()) ||
160  (from1 > m_RCV1.Right() && from1 > m_RCV2.Right()) ) {
161  continue;
162  }
163  if ( (to1 < rcv1_clip.GetFrom() && from2 > rcv2_clip.GetTo()) ||
164  (from1 > rcv1_clip.GetTo() && to2 < rcv2_clip.GetFrom()) ) {
165  continue;
166  }
167 
168 
169  /// some part of the range intersects the visible area
170  /// now we start back with the first element
171  ITERATE (CHitGlyph::TElemGlyphCont, itE, elems) {
172  const IHitElement& elem = itE->GetHitElem();
173 
174  from1 = elem.GetQueryStart();
175  from2 = elem.GetSubjectStart();
176  if (from1 == -1 || from2 == -1) {
177  continue;
178  }
179 
180  to1 = from1 + elem.GetQueryLength();
181  to2 = from2 + elem.GetSubjectLength();
182 
183  /// perform our clipping again
184  if ( (to1 < m_RCV1.Left() && to2 < m_RCV2.Left()) ||
185  (from1 > m_RCV1.Right() && from1 > m_RCV2.Right()) ) {
186  continue;
187  }
188  if ( (to1 < rcv1_clip.GetFrom() && from2 > rcv2_clip.GetTo()) ||
189  (from1 > rcv1_clip.GetTo() && to2 < rcv2_clip.GetFrom()) ) {
190  continue;
191  }
192 
193  TModelUnit x_from1 = x_Seq2Lim1(from1);
194  TModelUnit x_to1 = x_Seq2Lim1(to1);
195  TModelUnit x_from2 = x_Seq2Lim2(from2);
196  TModelUnit x_to2 = x_Seq2Lim2(to2);
197 
198  TModelUnit x_x = pane.UnProjectX(x);
199  TModelUnit x_y = pane.UnProjectY(y);
200 
201  CVect3<TModelUnit> orig(x_x, x_y, 1.0);
202  CVect3<TModelUnit> dir(0.0, 0.0, -2.0);
203  CVect3<TModelUnit> vert0(x_from1, rcV.Top(), 0.0);
204  CVect3<TModelUnit> vert1(x_to1, rcV.Top(), 0.0);
205  CVect3<TModelUnit> vert2(x_to2, rcV.Bottom(), 0.0);
206  CVect3<TModelUnit> vert3(x_from2, rcV.Bottom(), 0.0);
208 
209  if (IntersectRayQuad(orig,dir,vert0, vert1, vert2, vert3, pt) == eIntersects) {
210  if (select) { // select the Glyph
211  //m_Graph.SelectGlyph(**it);
212  CHitElemGlyph& heg = const_cast<CHitElemGlyph&>(*itE);
213  heg.SetSelected(true);
214  }
215  return TModelRect(from1, from2, to1, to2);
216  }
217  }
218  }
219 
220  return TModelRect(0, 0, 0, 0); // empty
221 }
222 
223 
224 
226 {
228  ITERATE(THitGlyphVector, it, m_Graph.GetGlyphs()) // for each Hit
229  {
230  const CHitGlyph::TElemGlyphCont& elems = (*it)->GetElems();
231  ITERATE(CHitGlyph::TElemGlyphCont, itE, elems) { // for each Hit Element
232  const CHitElemGlyph& gl_elem = *itE;
233  if (gl_elem.IsSelected()) {
234  CHitElemGlyph& the_elem = *const_cast<CHitElemGlyph*>(&gl_elem);
235  the_elem.SetSelected(false);
236  }
237  }
238  }
239 }
240 
241 
243 {
244  set<const CSeq_align*> aligns; // selected aligns
245 
246  const TElemGlyphSet& glyphs = m_Graph.GetSelectedGlyphs();
247 
248  // build a set of CSeq_aligns corresponding to selected glyphs
249  ITERATE(TElemGlyphSet, it_G, glyphs) {
250  const IHitElement& elem = (*it_G)->GetHitElem();
251  const IHit& hit = elem.GetHit();
252  aligns.insert(hit.GetSeqAlign());
253  }
254 
255  objs.reserve(aligns.size());
256  ITERATE(set<const CSeq_align*>, it_align, aligns) {
257  objs.push_back(CConstRef<CObject>(*it_align));
258  }
259 }
260 
261 void CCrossPanelIR::SetObjectSelection(const vector<const CSeq_align*> sel_aligns)
262 {
264 
265  typedef CHitMatrixGraph::THitGlyphVector TGlyphs;
266  const TGlyphs& glyphs = m_Graph.GetGlyphs();
267  ITERATE(TGlyphs, it_G, glyphs) {
268  const CHitGlyph& glyph = **it_G;
269  const CSeq_align* align = glyph.GetHit().GetSeqAlign();
270 
271  if(std::find(sel_aligns.begin(), sel_aligns.end(), align)
272  != sel_aligns.end()) {
273  m_Graph.SelectGlyph(glyph);
274  }
275  }
276 }
277 
278 
280 {
281  const TVPRect& rcP = pane.GetViewport();
282 
283  bool seq_fit1 = x_IsSeqLettersFit1();
284  bool seq_fit2 = x_IsSeqLettersFit2();
285 
287  TModelUnit y1 = pane.UnProjectY(rcP.Top() - font_h - 1);
288  TModelUnit y2 = pane.UnProjectY(rcP.Bottom() + 3);
289 
290  char bases[2];
291  bases[1] = '\0';
292  string seq1, seq2;
293 
294  IRender& gl = GetGl();
295 
296  gl.Color3f(0.0f, 0.0f, 0.0f);
297 
298  if (seq_fit1 && m_DS->GetQueryHandle()) { // sequence 1 fit
299  TSeqPos l1 = TSeqPos( m_RCV1.Left () );
300  TSeqPos r1 = TSeqPos( m_RCV1.Right() );
301 
302  x_GetSequence(m_DS->GetQueryHandle(), l1, r1, seq1);
303 
304  for (TSeqPos bp = 0; bp != seq1.length(); bp++) {
305  bases[0] = seq1[bp];
306  TModelUnit x1 = (float) x_Seq2Lim1(l1 + bp + 0.25);
307  m_Font_Fixed12.TextOut(x1, y1, bases);
308  }
309  }
310 
311  if (seq_fit2 && m_DS->GetSubjectHandle()) { // sequence 2 fit
312  TSeqPos l2 = TSeqPos( m_RCV2.Left () );
313  TSeqPos r2 = TSeqPos( m_RCV2.Right() );
314 
315  x_GetSequence(m_DS->GetSubjectHandle(), l2, r2, seq2);
316 
317  for (TSeqPos bp = 0; bp != seq2.length(); bp++) {
318  bases[0] = seq2[bp];
319  TModelUnit x2 = x_Seq2Lim2(l2 + bp + 0.25);
320  m_Font_Fixed12.TextOut(x2, y2, bases);
321  }
322  }
323 
324  // 4) Highlight mismatches (and draw connection lines)
325  if (seq_fit1 && seq_fit2 &&
326  m_DS->GetQueryHandle() && m_DS->GetSubjectHandle()) { // not yet
328  TModelUnit font_height = pane.UnProjectHeight(value);
329 
332 
333  CRange<TModelUnit> rcv1_clip(rcv1.GetFrom() - rcv1.GetLength() * kClipMultiple,
334  rcv1.GetTo() + rcv1.GetLength() * kClipMultiple);
335  CRange<TModelUnit> rcv2_clip(rcv2.GetFrom() - rcv2.GetLength() * kClipMultiple,
336  rcv2.GetTo() + rcv2.GetLength() * kClipMultiple);
337 
338  ITERATE(THitGlyphVector, it, m_Graph.GetGlyphs()) { // for each Hit
339  const CHitGlyph::TElemGlyphCont& elems = (*it)->GetElems();
340  const IHitElement& first_elem = elems.front().GetHitElem();
341  const IHitElement& last_elem = elems.back().GetHitElem();
342 
343  TSignedSeqPos from1 = first_elem.GetQueryStart();
344  TSignedSeqPos from2 = first_elem.GetSubjectStart();
345  TSignedSeqPos to1 = last_elem.GetQueryStart() + last_elem.GetQueryLength();
346  TSignedSeqPos to2 = last_elem.GetSubjectStart() + last_elem.GetSubjectLength();
347 
348  /// first test: clip for things entirely off screen
349  if ( (to1 < m_RCV1.Left() && to2 < m_RCV2.Left()) ||
350  (from1 > m_RCV1.Right() && from1 > m_RCV2.Right()) ) {
351  continue;
352  }
353 
354  /// second test: clip items that cross too obliquely
355  if ( (to1 < rcv1_clip.GetFrom() && from2 > rcv2_clip.GetTo()) ||
356  (from1 > rcv1_clip.GetTo() && to2 < rcv2_clip.GetFrom()) ) {
357  continue;
358  }
359 
360 
361  /// some part of the range intersects the visible area
362  /// now we start back with the first element
363  ITERATE (CHitGlyph::TElemGlyphCont, itE, elems) {
364  const IHitElement& elem = itE->GetHitElem();
365 
366  from1 = elem.GetQueryStart();
367  from2 = elem.GetSubjectStart();
368 
369  if (from1 == -1 || from2 == -1) {
370  continue;
371  }
372 
373  to1 = from1 + elem.GetQueryLength();
374  to2 = from2 + elem.GetSubjectLength();
375 
376  /// perform our clipping again
377  if ( (to1 < m_RCV1.Left() && to2 < m_RCV2.Left()) ||
378  (from1 > m_RCV1.Right() && from1 > m_RCV2.Right()) ) {
379  continue;
380  }
381  if ( (to1 < rcv1_clip.GetFrom() && from2 > rcv2_clip.GetTo()) ||
382  (from1 > rcv1_clip.GetTo() && to2 < rcv2_clip.GetFrom()) ) {
383  continue;
384  }
385 
386  seq1.erase();
387  seq2.erase();
388  x_GetSequence(m_DS->GetQueryHandle(), from1, to1, seq1);
389  x_GetSequence(m_DS->GetSubjectHandle(), from2, to2, seq2);
390 
391  TSeqPos bp = 0;
392  //TODO - Length on query and Subject can be different
393  for (TSeqPos pos = 0; pos != elem.GetQueryLength(); pos++) {
394  //TModelUnit x1 = x_Seq2Lim1(from1 + pos + 0.25);
395  //TModelUnit x2 = x_Seq2Lim2(from2 + pos + 0.25);
396 
397  // Draw lines to connect mismatches
398  gl.Color3f(0.0f, 0.0f, 0.0f); // black
399  if (seq1[bp] != seq2[bp] || (from1 + pos) % 10 == 0) {
400  TModelUnit lx1 = from1 + pos + 0.5; // centered
401  TModelUnit lx2 = from2 + pos + 0.5;
402  float alpha = 0.5f;
403  if (lx1 < m_RCV1.Left() || lx1 > m_RCV1.Right() ||
404  lx2 < m_RCV2.Left() || lx2 > m_RCV2.Right() )
405  {
406  alpha = 0.08f;
407  }
408  if (seq1[bp] != seq2[bp]) {
409  gl.Color4f(1.0f, 0.0f, 0.0f, alpha);
410  } else {
411  gl.Color4f(0.7f, 0.7f, 0.7f, alpha);
412  }
413  gl.Begin(GL_LINES);
414  gl.Vertex2d(x_Seq2Lim1(lx1), y1);
415  gl.Vertex2d(x_Seq2Lim2(lx2), y2 + font_height);
416  gl.End();
417  }
418  bp++;
419  } // for: pos
420  }
421  }
422  }
423 }
424 
425 
427  TSeqPos from, TSeqPos to, string& buffer) const
428 {
429  buffer.erase();
430  CSeqVector s_vec =
432 
433  s_vec.GetSeqData(from, to, buffer);
434 }
435 
436 
438  TModelUnit x_from1, TModelUnit x_to1,
439  TModelUnit x_from2, TModelUnit x_to2)
440 {
441  const TModelRect& rcV = pane.GetVisibleRect();
442  TModelUnit x_offs = pane.GetOffsetX();
443  float alpha = 0.1f;
444 
445  IRender& gl = GetGl();
446 
447  gl.Color4f(color.GetRed(), color.GetGreen(), color.GetBlue(), alpha);
448 
449  /// gap is not too small
450  /// render the previous element, save the current
451  if (fabs(x_from1 - x_to1) < pane.GetScaleX() &&
452  fabs(x_from2 - x_to2) < pane.GetScaleX()) {
453 
454  gl.Begin(GL_LINES);
455  gl.Vertex2d(x_from1 - x_offs, rcV.Top());
456  gl.Vertex2d(x_from2 - x_offs, rcV.Bottom());
457  gl.End();
458  } else {
459  gl.Begin(GL_TRIANGLE_STRIP);
460  gl.Vertex2d(x_from1 - x_offs, rcV.Top());
461  gl.Vertex2d(x_to1 - x_offs, rcV.Top());
462  gl.Vertex2d(x_from2 - x_offs, rcV.Bottom());
463  gl.Vertex2d(x_to2 - x_offs, rcV.Bottom());
464  gl.End();
465  }
466 }
467 
468 
470 {
471  CStopWatch sw;
472  sw.Start();
473  //const TModelRect& rcV = pane.GetVisibleRect();
474 
475  //TModelUnit rcv1_inv = 1.0f / m_RCV1.Width();
476  //TModelUnit rcv2_inv = 1.0f / m_RCV2.Width();
477 
478  size_t clip_bounds = 0;
479  size_t clip_cross = 0;
480  size_t elements_rendered = 0;
481 
482  ///
483  /// this code makes use of CRange<> as a temporary storage for standardization
484  ///
485 
486  /// we compute two ranges: the visible range and a related clip range
487 
488  /// first sequence ranges
490  CRange<TModelUnit> rcv1_clip
491  (rcv1.GetFrom() - rcv1.GetLength() * kClipMultiple,
492  rcv1.GetTo() + rcv1.GetLength() * kClipMultiple);
493 
494  /// second sequence ranges
496  CRange<TModelUnit> rcv2_clip
497  (rcv2.GetFrom() - rcv2.GetLength() * kClipMultiple,
498  rcv2.GetTo() + rcv2.GetLength() * kClipMultiple);
499 
500  CRgbaColor sel_color(0.0f, 0.0f, 1.0f);
501  CRgbaColor plus_color(1.0f, 0.0f, 0.0f);
502  CRgbaColor minus_color(1.0f, 0.8f, 0.0f);
503 
504  ITERATE(THitGlyphVector, it, m_Graph.GetGlyphs()) { // for each Hit
505  const CHitGlyph::TElemGlyphCont& elems = (*it)->GetElems();
506 
507  const IHitElement& first_elem = elems.front().GetHitElem();
508  const IHitElement& last_elem = elems.back().GetHitElem();
509  bool is_mixed =
510  (first_elem.GetQueryStrand() != first_elem.GetSubjectStrand());
511 
512  /// we consider the entire range at first
513  CRange<TModelUnit> range1(first_elem.GetQueryStart(),
514  last_elem.GetQueryStart() + last_elem.GetQueryLength());
515  CRange<TModelUnit> range2(first_elem.GetSubjectStart(),
516  last_elem.GetSubjectStart() + last_elem.GetSubjectLength());
517 
518  /// clipping:
519 
520  /// first test:
521  /// - is the panel entirely off the screen (left or right)?
522  if ( (range1.GetTo() < rcv1.GetFrom() && range2.GetTo() < rcv2.GetFrom()) ||
523  (range1.GetFrom() > rcv1.GetTo() && range2.GetFrom() > rcv2.GetTo()) ) {
524  /// off screen, not crossing
525  ++clip_bounds;
526  continue;
527  }
528 
529  /// second test:
530  /// - does the panel cross left -> right or right -> left at
531  /// so steep an angle as to be worthless information?
532  if ( !range1.IntersectingWith(rcv1_clip) &&
533  !range2.IntersectingWith(rcv2_clip)) {
534  ++clip_cross;
535  continue;
536  }
537 
538  TModelUnit x_from1 = x_Seq2Lim1(range1.GetFrom());
539  TModelUnit x_to1 = x_Seq2Lim1(range1.GetTo());
540  TModelUnit x_from2 = x_Seq2Lim2(range2.GetFrom());
541  TModelUnit x_to2 = x_Seq2Lim2(range2.GetTo());
542 
543  /// we will only iterate the elements in this hit if the entire hit
544  /// occupies more than one pixel
545  if (fabs(x_from1 - x_to1) > pane.GetScaleX() ||
546  fabs(x_from2 - x_to2) > pane.GetScaleX()) {
547 
548  /// some part of the range intersects the visible area
549  /// now we start back with the first element
550  CHitGlyph::TElemGlyphCont::const_iterator itE = elems.begin();
551  CHitGlyph::TElemGlyphCont::const_iterator itE_end = elems.end();
552 
553  range1.SetTo(itE->GetHitElem().GetQueryStart() +
554  itE->GetHitElem().GetQueryLength());
555  range2.SetTo(itE->GetHitElem().GetSubjectStart() +
556  itE->GetHitElem().GetSubjectLength());
557 
558  x_to1 = x_Seq2Lim1(range1.GetTo());
559  x_to2 = x_Seq2Lim2(range2.GetTo());
560 
561  for ( ; itE != itE_end; ++itE) {
562  const IHitElement& elem = itE->GetHitElem();
563  if (elem.GetQueryStart() == -1 ||
564  elem.GetSubjectStart() == -1) {
565  continue;
566  }
567 
568  ///
569  /// compute sequence and model coordinates for this element's
570  /// starting and ending coordinates
571  ///
572 
573  //TODO - don't we need to subtract 1 from start + len?
574  CRange<TModelUnit> elem_range1(elem.GetQueryStart(),
575  elem.GetQueryStart() + elem.GetQueryLength());
576  CRange<TModelUnit> elem_range2(elem.GetSubjectStart(),
577  elem.GetSubjectStart() + elem.GetSubjectLength());
578 
579  /// check to see if the starting point of this element is
580  /// mergeable with the ending point of the previous element
581  TModelUnit x_elem1_start = x_Seq2Lim1(elem_range1.GetFrom());
582  TModelUnit x_elem1_stop = x_Seq2Lim1(elem_range1.GetTo());
583  TModelUnit x_elem2_start = x_Seq2Lim2(elem_range2.GetFrom());
584  TModelUnit x_elem2_stop = x_Seq2Lim2(elem_range2.GetTo());
585 
586  /// merge this element if the gap space is too small
587  if (fabs(x_elem1_start - x_to1) < pane.GetScaleX() &&
588  fabs(x_elem2_start - x_to2) < pane.GetScaleX()) {
589  range1 += elem_range1;
590  range2 += elem_range2;
591 
592  x_to1 = x_elem1_stop;
593  x_to2 = x_elem2_stop;
594  continue;
595  }
596 
597  ///
598  /// unmerged element
599  /// render it as a panel
600  ///
601  if (range1.IntersectingWith(rcv1_clip) ||
602  range2.IntersectingWith(rcv2_clip)) {
603  CRgbaColor& clr = itE->IsSelected() ? sel_color :
604  (is_mixed ? minus_color : plus_color);
605  x_DrawCrossedPanel(pane, clr, x_elem1_start, x_elem1_stop,
606  x_elem2_start, x_elem2_stop);
607  ++elements_rendered;
608  }
609 
610  range1 = elem_range1;
611  range2 = elem_range2;
612 
613  x_from1 = x_elem1_start;
614  x_from2 = x_elem2_start;
615  x_to1 = x_elem1_stop;
616  x_to2 = x_elem2_stop;
617  }
618  }
619 
620  if (is_mixed) {
621  x_DrawCrossedPanel(pane, minus_color,
622  x_from1, x_to1, x_from2, x_to2);
623  } else {
624  x_DrawCrossedPanel(pane, plus_color,
625  x_from1, x_to1, x_from2, x_to2);
626  }
627  ++elements_rendered;
628  }
629 
630  /**
631  LOG_POST(Error << "CCrossPanelIR::x_DrawCrossAlignment(): finish: "
632  << sw.Elapsed() << ": "
633  << clip_bounds << " bound / "
634  << clip_cross << " cross / "
635  << elements_rendered << " rendered");
636  **/
637 }
638 
639 
640 
641 double CCrossPanelIR::x_SelectBaseStep(double MinV, double MaxV) const
642 {
643  double Range = MaxV - MinV;
644  double logRange = log10(Range);
645  logRange = ceil(logRange) - 1;
646  double Step = pow(10.0, logRange);
647 
648  // selcting BaseStep as step divided by 1, 2 or 5
649  double BaseStep = Step;
650  double nTicks = Range / BaseStep;
651  int i=0;
652  while( nTicks < 8 )
653  {
654  BaseStep = Step / sc_StepK[i++];
655  nTicks = Range / BaseStep;
656  }
657  return BaseStep;
658 }
659 
660 
661 
662 // Convert sequence to limits
664 {
665  return (seq - m_RCV1.Left()) / m_RCV1.Width();
666 }
667 
668 
670 {
671  return (seq - m_RCV2.Left()) / m_RCV2.Width();
672 }
673 
674 
675 // Convert limits to sequence
677 {
678  return lim;
679 }
680 
681 
683 {
684  return lim;
685 }
686 
687 
689 {
690  return m_RCV1.Width() / m_RCM1.Width() <= 1.0f / 6.0f;
691 }
692 
694 {
695  return m_RCV2.Width() / m_RCM2.Width() <= 1.0f / 6.0f;
696 }
697 
698 
CBioseq_Handle –.
void SetObjectSelection(const vector< const objects::CSeq_align * > sel_aligns)
virtual ~CCrossPanelIR(void)
double x_SelectBaseStep(double MinV, double MaxV) const
void x_DrawCrossedPanel(CGlPane &pane, const CRgbaColor &color, TModelUnit x_from1, TModelUnit x_to1, TModelUnit x_from2, TModelUnit x_to2)
void GetObjectSelection(TConstObjects &objs) const
void x_DrawCrossAlignment(CGlPane &pane)
void x_GetSequence(const objects::CBioseq_Handle &handle, TSeqPos from, TSeqPos to, string &buffer) const
TModelUnit x_Seq2Lim1(TModelUnit seq)
void SetDataSource(ICrossAlnDataSource *ds)
void ResetObjectSelection()
CConstRef< objects::CObject_id > m_ColorScoreId
CIRef< ICrossAlnDataSource > m_DS
TModelRect m_RCV2
TModelUnit x_Lim2Seq2(TModelUnit lim)
TModelRect m_RCV1
void x_DrawSequence(CGlPane &pane)
void ColorBySegments()
TModelUnit x_Lim2Seq1(TModelUnit lim)
virtual void Render(CGlPane &pane)
CHitMatrixGraph m_Graph
bool x_IsSeqLettersFit1() const
void ColorByScore(CConstRef< objects::CObject_id > score_id)
CHitMatrixGraph::THitGlyphVector THitGlyphVector
TModelRect HitTest(CGlPane &pane, int x, int y, bool select=false)
CGlTextureFont m_Font_Fixed12
TModelUnit x_Seq2Lim2(TModelUnit seq)
bool x_IsSeqLettersFit2() const
void SetLimits(TVPRect rcm1, TModelRect rcv1, TVPRect rcm2, TModelRect rcv2)
class CGlPane
Definition: glpane.hpp:62
CHitElemGlyph is a simple graphical object representing a Hit Element.
void SetSelected(bool b_set)
bool IsSelected() const
CHitGlyph is a simple graphical object representing a Hit as a set of corresponding Hit Elements.
const IHit & GetHit() const
vector< CHitElemGlyph > TElemGlyphCont
const TElemGlyphSet & GetSelectedGlyphs() const
void SelectGlyph(const CHitGlyph &glyph)
virtual void DeleteGlyphs()
const THitGlyphVector & GetGlyphs() const
virtual void CreateGlyph(const IHit &hit_elem)
vector< CHitGlyph * > THitGlyphVector
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CSeqVector –.
Definition: seq_vector.hpp:65
CStopWatch –.
Definition: ncbitime.hpp:1937
Definition: vect3.hpp:48
IHitElement.
Definition: hit.hpp:50
virtual TSeqPos GetQueryLength() const =0
virtual const IHit & GetHit() const =0
virtual TSignedSeqPos GetQueryStart() const =0
virtual TSeqPos GetSubjectLength() const =0
virtual objects::ENa_strand GetSubjectStrand() const =0
virtual objects::ENa_strand GetQueryStrand() const =0
virtual TSignedSeqPos GetSubjectStart() const =0
IHitMatrixDataSource - abstract Data Source for Hit Matrix Widget.
virtual const THitAdapterCont & GetHits() const =0
vector< IHit * > THitAdapterCont
IHit.
Definition: hit.hpp:69
virtual const objects::CSeq_align * GetSeqAlign() const =0
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
size_type size() const
Definition: set.hpp:132
USING_SCOPE(objects)
static const TModelUnit kSeqMapBarHeight
static const int sc_StepK[]
static const TModelUnit kClipMultiple
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
GLdouble TModelUnit
Definition: gltypes.hpp:48
virtual void Enable(GLenum glstate)=0
bool OpenOrtho()
Definition: glpane.hpp:427
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.
void Color3f(GLfloat r, GLfloat g, GLfloat b)
Definition: irender.hpp:95
T Bottom() const
Definition: glrect.hpp:82
T Width() const
Definition: glrect.hpp:86
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
TModelUnit UnProjectX(TVPUnit m_x) const
Definition: glpane.cpp:706
T Left() const
Definition: glrect.hpp:81
virtual void End()=0
Finish rendering (create buffer and send to renderer)
void Close(void)
Definition: glpane.cpp:178
TModelUnit UnProjectHeight(TVPUnit vp_h) const
Definition: glpane.cpp:768
TModelUnit UnProjectY(TVPUnit m_y) const
Definition: glpane.cpp:722
int TVPUnit
Definition: gltypes.hpp:47
void Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
Definition: irender.hpp:97
virtual TModelUnit TextHeight(void) const
virtual void TextOut(const char *text) const
TextOut interface Write the specified text and set up state and transformation as needed.
TModelRect & GetVisibleRect(void)
Definition: glpane.hpp:357
CGlRect< TModelUnit > TModelRect
Definition: gltypes.hpp:54
virtual void Disable(GLenum glstate)=0
glDisable()
virtual void Hint(GLenum target, GLenum mode)=0
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
vector< CConstRef< CObject > > TConstObjects
Definition: objects.hpp:64
CSeqVector GetSeqVector(EVectorCoding coding, ENa_strand strand=eNa_strand_plus) const
Get sequence: Iupacna or Iupacaa if use_iupac_coding is true.
@ eCoding_Iupac
Set coding to printable coding (Iupacna or Iupacaa)
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
Definition: seq_vector.cpp:304
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
position_type GetLength(void) const
Definition: range.hpp:158
bool IntersectingWith(const TThisType &r) const
Definition: range.hpp:331
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
void Start(void)
Start the timer.
Definition: ncbitime.hpp:2764
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
static CStopWatch sw
n background color
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
int i
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define fabs(v)
Definition: ncbi_dispd.c:46
Defines: CTimeFormat - storage class for time format.
T log10(T x_)
static uint8_t * buffer
Definition: pcre2test.c:1016
static const sljit_gpr r1
static const sljit_gpr r2
@ eIntersects
intersection found
Definition: intersect.hpp:45
EIntersectResult IntersectRayQuad(const CVect3< Data > &origin, const CVect3< Data > &dir, const CVect3< Data > &vert0, const CVect3< Data > &vert1, const CVect3< Data > &vert2, const CVect3< Data > &vert3, CVect3< Data > &intersect_pt, bool cull_test=false)
IntersectRayQuad() computes the intersection point of a ray collided with a quad.
Definition: intersect.hpp:140
Modified on Fri Sep 20 14:58:21 2024 by modify_doxy.py rev. 669887