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

Go to the SVN repository for this file.

1 /* $Id: rendering_ctx.cpp 47036 2022-05-24 18:52:09Z evgeniev $
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: Liangshou Wu
27  *
28  * File Description:
29  *
30  */
31 
32 
33 #include <ncbi_pch.hpp>
34 #include <corelib/ncbistd.hpp>
35 #include <serial/iterator.hpp>
36 #include <gui/objutils/utils.hpp>
37 #include <gui/opengl/glpane.hpp>
38 #include <gui/opengl/glutils.hpp>
39 #include <gui/opengl/irender.hpp>
40 #include <gui/opengl/glresmgr.hpp>
43 
44 #include <math.h>
45 
46 
48 
49 static const float kMinBarHeight = 2.f;
50 
51 /// extra space for side labeling, in screen pixels
53 
55  : m_Pane(NULL)
56  , m_HighlightsColor(0.4f, 0.4f, 0.4f, 1.0f)
57  , m_MinLabelSizePos(1.0)
58  , m_Offset(0.0)
59  , m_Scale(1.0)
60  , m_ScaleInv(1.0)
61  , m_ViewWidth(0)
62  , m_bHorz(true)
63  , m_bFlipped(false)
64  , m_Font_Helv10(CGlBitmapFont::eHelvetica10)
65 {}
66 
68 {
69  m_Pane = NULL;
70 }
71 
73 {
74  if (!m_GlyphGeom.IsNull())
75  return;
76 
77  m_GlyphGeom.Reset(CGlResMgr::Instance().CreateVboGeom(GL_TRIANGLE_STRIP, ""));
78 
79  vector<CVect2<float> > vb;
80 
81  float step = 3.141592653589793238463f / 8;
82  float f = step;
83 
84  vb.push_back(CVect2<float>(1.0f, 0.0f));
85  for (int i = 0; i < 7; ++i) {
86  float cosf = cos(f), sinf = sin(f);
87  vb.push_back(CVect2<float>(cosf, sinf));
88  vb.push_back(CVect2<float>(cosf, -sinf));
89  f += step;
90  }
91  vb.push_back(CVect2<float>(-1.0f, 0.0f));
92 
93  m_GlyphGeom->SetVertexBuffer2D(vb);
94 }
95 
96 void CRenderingContext::PrepareContext(CGlPane& pane, bool horz, bool flipped)
97 {
98  m_Pane = &pane;
99  m_bHorz = horz;
100  m_bFlipped = flipped;
101 
102  m_Offset = horz ? pane.GetOffsetX() : pane.GetOffsetY();
103  m_Scale = fabs(horz ? pane.GetScaleX() : pane.GetScaleY());
104  m_ScaleInv = 1.0 / m_Scale;
105 
106  TModelRect rcV = pane.GetVisibleRect();
107  TModelRect rcM = pane.GetModelLimitsRect();
108  if (horz) {
109  if (flipped) {
110  m_VisRange.Set(rcV.Right(), rcV.Left());
111  m_LimitRange.Set(rcM.Right(), rcM.Left());
112  } else {
113  m_VisRange.Set(rcV.Left(), rcV.Right());
114  m_LimitRange.Set(rcM.Left(), rcM.Right());
115  }
116  } else {
117  if (flipped) {
118  m_VisRange.Set(rcV.Top(), rcV.Bottom());
119  m_LimitRange.Set(rcM.Top(), rcM.Bottom());
120  } else {
121  m_VisRange.Set(rcV.Bottom(), rcV.Top());
122  m_LimitRange.Set(rcM.Bottom(), rcM.Top());
123  }
124  }
125 
127  (TSeqPos)(m_VisRange.GetFrom() + 0.5), (TSeqPos)(m_VisRange.GetTo() + 0.5));
128 
130 }
131 
132 
134 {
135  TModelRange vert_range(m_Pane->GetVisibleRect().Top(),
137  return vert_range.IntersectionWith(r);
138 }
139 
140 
142  TModelUnit x2, TModelUnit y2,
143  bool border) const
144 {
145  // If x1 and x2 are projected onto the same pixel on screen.
146  // We simply draw aline instead of a quad.
147  IRender& gl = GetGl();
148  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
149 
150  if (fabs(x2-x1) < GetScale()) {
151  TModelUnit mid = (x2+x1)/TModelUnit(2.0);
152  x1 = mid-GetScale()/(TModelUnit)2.0;
153  x2 = mid+GetScale()/(TModelUnit)2.0;
154  }
155  gl.Rectd(x1 - m_Offset, y1, x2 - m_Offset, y2);
156 
157  if (border) {
158  DrawRect(x1, y1, x2, y2);
159  }
160 }
161 
162 
164  const CRgbaColor& c1,
165  const CRgbaColor& c2,
166  bool shade_vert) const
167 {
168  IRender& gl = GetGl();
169  if (gl.IsSimplified()) {
170  gl.ShadeModel(GL_FLAT);
171  gl.ColorC(c1);
172  DrawQuad(rcm.Left(), rcm.Top(), rcm.Right() + 1 , rcm.Bottom());
173  return;
174  }
175 
176  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
177 
178 
179  gl.ShadeModel(GL_SMOOTH);
180  gl.Begin(GL_QUADS);
181  if (shade_vert) {
182  gl.ColorC(c1);
183  gl.Vertex3d(rcm.Right() - m_Offset + 1, rcm.Top(), 0.0);
184  gl.Vertex3d(rcm.Left() - m_Offset, rcm.Top(), 0.0);
185  gl.ColorC(c2);
186  gl.Vertex3d(rcm.Left() - m_Offset, rcm.Bottom(), 0.0);
187  gl.Vertex3d(rcm.Right() - m_Offset + 1, rcm.Bottom(), 0.0);
188  } else {
189  gl.ColorC(c1);
190  gl.Vertex3d(rcm.Left() - m_Offset, rcm.Top(), 0.0);
191  gl.Vertex3d(rcm.Left() - m_Offset, rcm.Bottom(), 0.0);
192  gl.ColorC(c2);
193  gl.Vertex3d(rcm.Right() - m_Offset + 1, rcm.Bottom(), 0.0);
194  gl.Vertex3d(rcm.Right() - m_Offset + 1, rcm.Top(), 0.0);
195  }
196  gl.End();
197  gl.ShadeModel(GL_FLAT);
198 
199 }
200 
203  const CRgbaColor& color,
204  bool neg_strand) const
205 {
206  TModelUnit size_x = ScreenToSeq(size);
207  TModelUnit f = neg_strand ? p.X() - size_x : p.X();
208  TModelUnit t = neg_strand ? p.X() - 1.0 : p.X() + size_x - 1.0;
209  Draw3DQuad(f, p.Y() - size * 0.5f, t, p.Y() + size * 0.5f, color, true);
210 }
211 
212 
214  TModelUnit r,
215  GLint from, GLint to) const
216 {
217  IRender& gl = GetGl();
218 
219  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
220 
221  const double PI_180 = 3.1415926 / 180.0;
222  TModelUnit f = from * PI_180;
223  TModelUnit t = to * PI_180;
224  TModelUnit r_x = ScreenToSeq(r);
225  gl.Begin(GL_TRIANGLE_FAN);
226  gl.Vertex2d(p.X() - m_Offset, p.Y());
227  TModelUnit step = (t - f) * 0.02;
228  for (; f < t + step * 0.02; f += step) {
229  gl.Vertex2d(p.X() - m_Offset + r_x * cos(f),
230  p.Y() - r * sin(f));
231  }
232  gl.End();
233 }
234 
236  TModelUnit radius,
237  const CRgbaColor& color,
238  bool neg_strand) const
239 {
240  IRender& gl = GetGl();
241 
242  TModelUnit add = ScreenToSeq(radius);
243  add = neg_strand ? -add : add;
244  TModelPoint center(p.X() + add*TModelUnit(0.5), p.Y());
245 
246  CRgbaColor color2 = color;
247  color2.Lighten(0.5f);
248  CRgbaColor color3 = color;
249  color3.SetAlpha(0.3f);
250 
251  radius *= TModelUnit(0.5);
252 
253  // if blend is explicitly enabled, reset it at the end
254  bool blend_enabled = gl.GetState()->IsEnabled(GL_BLEND);
255 
256  // Largest circle (to get darker outside border):
257  gl.Disable(GL_BLEND);
258  gl.ColorC(color);
259  DrawDisk(center, radius - TModelUnit(0.5));
260 
261  // To anti-alias the edge a little:
262  gl.Enable(GL_BLEND);
263  gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
264  gl.ColorC(color3);
265  DrawDisk(center, radius);
266 
267  // Inner circle (lighter):
268  gl.Disable(GL_BLEND);
269  gl.ColorC(color2);
270  DrawDisk(center, radius - TModelUnit(1.5));
271 
272  if (blend_enabled)
273  gl.Enable(GL_BLEND);
274 }
275 
279 {
280  x_CreateGlyphs();
281 
282  IRender& gl = GetGl();
283 
284  TModelUnit add = ScreenToSeq(size);
285 
286  TModelPoint center(p.X() + add*TModelUnit(0.5), p.Y());
287 
288  gl.Enable(GL_BLEND);
289  gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
290 
291  // This is a radius:
292  size = size/2.0;
293 
294  gl.Color4fv(color.GetColorArray());
295  gl.PolygonMode(GL_FRONT, GL_FILL);
296 
297  CMatrix4<float> m, pos;
298  m.Identity();
299  m(0, 0) = (float)ScreenToSeq(size - 0.5);
300  m(1, 1) = (float)(size - 0.5);
301  m(2, 2) = 1.0f;
302  m(0, 3) = center.X() - m_Offset;
303  m(1, 3) = center.Y();
304 
305  CMatrix4<float> current_mat = gl.GetModelViewMatrix();
306  pos = current_mat*m;
307  pos.Transpose();
308 
309  m_GlyphGeom->Render(pos.GetData());
310 
311 
312  m(0, 0) = (float)ScreenToSeq(size);
313  m(1, 1) = (float)size;
314 
315  color.SetAlpha(color.GetAlpha()*0.75f);
316  gl.Color4fv(color.GetColorArray());
317  pos = current_mat*m;
318  pos.Transpose();
319  m_GlyphGeom->Render(pos.GetData());
320 }
321 
322 
323 
325  const CRgbaColor& color, bool neg_strand,
326  bool need_neck) const
327 {
328  TModelUnit off_x = ScreenToSeq(size);
329  TModelUnit off_y = size;
330  TModelUnit add_x = neg_strand ? off_x : (-off_x);
331 
332  CRgbaColor color2 = color;
333  color2.Lighten(0.5);
334 
335  IRender& gl = GetGl();
336 
337  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
338 
339  gl.ColorC(color);
340  // draw "neck"
341  if (need_neck) {
342  DrawLine(p.X() + add_x/*+ 1*/, p.Y(),
343  p.X() + add_x * 1.5 /*+1*/, p.Y());
344  }
345 
346  gl.ShadeModel(GL_SMOOTH);
347  gl.Begin(GL_TRIANGLES);
348 
349  TModelPoint p0(p.X() + add_x, p.Y());
350  TModelPoint p1(p.X(), p.Y());
351  TModelPoint p2(p.X() + add_x, p.Y() - off_y);
352  TModelPoint p3(p.X() + add_x, p.Y() + off_y);
353 
354  gl.ColorC(color2);
355  gl.Vertex2d(p0.X() - m_Offset, p0.Y());
356  gl.Vertex2d(p1.X() - m_Offset, p1.Y());
357  gl.ColorC(color);
358  gl.Vertex2d(p2.X() - m_Offset, p2.Y());
359 
360  gl.ColorC(color2);
361  gl.Vertex2d(p0.X() - m_Offset, p0.Y());
362  gl.Vertex2d(p1.X() - m_Offset, p1.Y());
363  gl.ColorC(color);
364  gl.Vertex2d(p3.X() - m_Offset, p3.Y());
365 
366  gl.End();
367  gl.ShadeModel(GL_FLAT);
368 
369 }
370 
371 
373  TModelUnit size, bool neg_strand) const
374 {
375  TModelUnit off_x = ScreenToSeq(size);
376  TModelUnit add_x = neg_strand ? off_x : (-off_x);
377  TModelUnit off_y = size;
378  DrawLine(p.X(), p.Y(), p.X() + add_x, p.Y() - off_y);
379  DrawLine(p.X(), p.Y(), p.X() + add_x, p.Y() + off_y);
380  DrawLine(p.X(), p.Y(), p.X() + add_x * 1.5, p.Y());
381 }
382 
383 
385  TModelUnit line_center, TModelUnit bar_h,
386  TModelUnit head_h) const
387 {
388  IRender& gl = GetGl();
389 
390 
391  if (x1 != x2) {
392  gl.Begin(GL_TRIANGLE_STRIP);
393  gl.Vertex2d(x1 - m_Offset, line_center - bar_h);
394  gl.Vertex2d(x2 - m_Offset, line_center - bar_h);
395  gl.Vertex2d(x1 - m_Offset, line_center + bar_h);
396  gl.Vertex2d(x2 - m_Offset, line_center + bar_h);
397  gl.End();
398  }
399 
400  gl.Begin(GL_TRIANGLES);
401  gl.Vertex2d(x2 - m_Offset, line_center + head_h);
402  gl.Vertex2d(x3 - m_Offset, line_center);
403  gl.Vertex2d(x2 - m_Offset, line_center - head_h);
404  gl.End();
405 
406 }
407 
408 
410  TModelUnit line_center, TModelUnit bar_h,
411  TModelUnit head_h) const
412 {
413  IRender& gl = GetGl();
415 
416  gl.Begin(GL_LINE_LOOP);
417  gl.Vertex2d(x1 - m_Offset, line_center + bar_h);
418  gl.Vertex2d(x2 - m_Offset, line_center + bar_h);
419  gl.Vertex2d(x2 - m_Offset, line_center + head_h);
420  gl.Vertex2d(x3 - m_Offset, line_center);
421  gl.Vertex2d(x2 - m_Offset, line_center - head_h);
422  gl.Vertex2d(x2 - m_Offset, line_center - bar_h);
423  gl.Vertex2d(x1 - m_Offset, line_center - bar_h);
424  gl.End();
425 
427 }
428 
429 
430 
432  TModelUnit bar_h, bool negative) const
433 {
434  TModelUnit size = bar_h * 0.5;
435  if (bar_h >= 8.0) {
436  size -= 1.0;
437  }
438  TModelUnit x_off = ScreenToSeq((negative ? -1.0 : 1.0) * size * 0.5);
439  IRender& gl = GetGl();
440 
441  gl.Begin(GL_LINES);
442  gl.Vertex2d(x - m_Offset - x_off, y + size);
443  gl.Vertex2d(x - m_Offset + x_off, y);
444  gl.Vertex2d(x - m_Offset + x_off, y);
445  gl.Vertex2d(x - m_Offset - x_off, y - size);
446  gl.End();
447 
448 }
449 
450 
451 
453  TModelUnit x2, TModelUnit y2,
454  const CRgbaColor& color, bool border) const
455 {
456  if (x2 == m_VisRange.GetTo())
457  x2 -= 1;
458  IRender& gl = GetGl();
459  if (gl.IsSimplified())
460  {
461  gl.ColorC(color);
462  gl.ShadeModel(GL_FLAT);
463  DrawQuad(x1, y1, x2 + 1, y2, border);
464  return;
465  }
466  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
467 
468  // If x1 and x2 get projected onto the same pixel on screen.
469  // we simply draw a vertical line to represent a quad.
470  if (x2 - x1 + 1.0 < GetScale()) {
471  gl.ColorC(color);
472  CGlAttrGuard AttrGuard(GL_LINE_BIT);
473  gl.Disable(GL_LINE_SMOOTH);
474  // HACK, mesa somehow projects y differently for drawling a line
475  // and drawing a quad. We add an slight y offset to make this work.
476  TModelUnit y_off = 0.0001;
477  DrawLine(x1, y1 + y_off, x1, y2 + y_off);
478  //gl.Enable(GL_LINE_SMOOTH);
479  } else {
480  TModelUnit xx1 = x1 - m_Offset;
481  TModelUnit yy1 = y1;
482  TModelUnit xx2 = x2 - m_Offset;
483  TModelUnit yy2 = y2;
484  TModelUnit mid = y1 + (y2 - y1) * 0.5f;
485 // LOG_POST(Trace << " drawing 3DQuad at left: " << xx1 << " and right: " << xx2);
486 
487  CRgbaColor color2 = color;
488  color2.Lighten(0.5);
489 
490  gl.ShadeModel(GL_SMOOTH);
491  gl.Begin(GL_TRIANGLE_STRIP);
492 
493  gl.ColorC(color);
494  gl.Vertex2d(xx1, yy1);
495  gl.Vertex2d(xx2 + 1, yy1);
496 
497  gl.ColorC(color2);
498  gl.Vertex2d(xx1, mid);
499  gl.Vertex2d(xx2 + 1, mid);
500 
501  gl.ColorC(color);
502  gl.Vertex2d(xx1, yy2);
503  gl.Vertex2d(xx2 + 1, yy2);
504  gl.End();
505  gl.ShadeModel(GL_FLAT);
506 
507  if (border) {
508  gl.ColorC(color);
509  DrawRect(x1, y1, x2 + 1.0, y2);
510  }
511  }
512 }
513 
515  TModelUnit x2, TModelUnit y2,
516  const CRgbaColor& color, bool border) const
517 {
518  IRender& gl = GetGl();
519 
520  // If x1 and x2 get projected onto the same pixel on screen.
521  // we simply draw a vertical line to represent a quad.
522  if (x2 - x1 + 1.0 < GetScale()) {
523  gl.ColorC(color);
524  CGlAttrGuard AttrGuard(GL_LINE_BIT);
525  gl.Disable(GL_LINE_SMOOTH);
526  // HACK, mesa somehow projects y differently for drawling a line
527  // and drawing a quad. We add an slight y offset to make this work.
528  TModelUnit y_off = 0.0001;
529  DrawLine(x1, y1 + y_off, x1, y2 + y_off);
530  } else {
531  TModelUnit xx1 = x1 - m_Offset;
532  TModelUnit yy1 = y1;
533  TModelUnit xx2 = x2 - m_Offset;
534 
535  CRgbaColor color2 = color;
536  color2.Lighten(0.5);
537  CVect4<float> c1(color.GetRed(), color.GetGreen(), color.GetBlue(), color.GetAlpha());
538  CVect4<float> c2(color2.GetRed(), color2.GetGreen(), color2.GetBlue(), color2.GetAlpha());
539 
540  TModelUnit delta(2.0);
541  int steps = (y2-y1)/delta;
542  TModelUnit ydelta = (y2-y1)/TModelUnit(steps);
543  CVect4<float> color_delta = (c2-c1)/(float)(steps/2);
544 
545  gl.LineWidth(1.0f);
546  gl.Disable(GL_LINE_SMOOTH);
547 
548  gl.Begin(GL_LINES);
549  for (int i=0; i<steps; i++) {
550  gl.Color4f(c1.X(), c1.Y(), c1.Z(), c1.W());
551 
552  if (i<steps/2)
553  c1 += color_delta;
554  else
555  c1 -= color_delta;
556 
557  double yval = yy1+ydelta*(TModelUnit)i;
558 
559  gl.Vertex3d(xx1, yval, 0.0);
560  gl.Vertex3d(xx2, yval, 0.0);
561  }
562  gl.End();
563  }
564 
565  if (border) {
566  gl.ColorC(color);
567  DrawRect(x1, y1, x2, y2);
568  }
569 
570 }
571 
573  TModelUnit line_y2, TModelUnit tail_height,
574  const CRgbaColor& color, bool neg_strand) const
575 {
576  IRender& gl = GetGl();
577 
578  TModelUnit off = ScreenToSeq(tail_height);
579  TModelUnit mid = line_y1 + (line_y2 - line_y1) * 0.5f;
580  TModelUnit add = neg_strand ? -off : off;
581 
582  CRgbaColor color2 = color;
583  color2.Lighten(0.5);
584 
585  gl.ShadeModel(GL_SMOOTH);
586  gl.Begin(GL_TRIANGLES);
587 
588  // p0 is a start point
589  TModelPoint p0(pos_x + add, mid);
590  TModelPoint p1(pos_x + add, line_y1);
591  TModelPoint p2(pos_x , line_y1);
592  TModelPoint p3(pos_x + add, line_y2);
593  TModelPoint p4(pos_x , line_y2);
594 
595  gl.ColorC(color2);
596  gl.Vertex2d(p0.X() - m_Offset, p0.Y());
597  gl.ColorC(color);
598  gl.Vertex2d(p1.X() - m_Offset, p1.Y());
599  gl.Vertex2d(p2.X() - m_Offset, p2.Y());
600 
601  gl.ColorC(color2);
602  gl.Vertex2d(p0.X() - m_Offset, p0.Y());
603  gl.ColorC(color);
604  gl.Vertex2d(p3.X() - m_Offset, p3.Y());
605  gl.Vertex2d(p4.X() - m_Offset, p4.Y());
606  gl.End();
607  gl.ShadeModel(GL_FLAT);
608 
609  gl.ColorC(color);
610  gl.LineWidth(1.5f);
611  // draw border
612  DrawLine(pos_x, line_y1, pos_x + add, line_y1);
613  DrawLine(pos_x, line_y1, pos_x + add, mid);
614 
615  DrawLine(pos_x, line_y2, pos_x + add, line_y2);
616  DrawLine(pos_x, line_y2, pos_x + add, mid);
617  gl.LineWidth(1.0f);
618 
619 }
620 
621 
623  TModelUnit x2, TModelUnit y2) const
624 {
625  IRender& gl = GetGl();
626 
627  // expand 1 pix on each side
628  TModelUnit padding_y = 1.0;
629  TModelUnit padding_x = ScreenToSeq(padding_y);
630  gl.ColorC(m_SelColor);
631  gl.LineWidth(1.5f);
632  DrawRect(x1 - padding_x, y1 + padding_y, x2 + padding_x, y2 - padding_y);
633  gl.LineWidth(1.0f);
634 
635 }
636 
637 
639  TModelUnit x2, TModelUnit y2) const
640 {
641  IRender& gl = GetGl();
643 
644  gl.Begin(GL_LINE_LOOP);
645  gl.Vertex2d(x1 - m_Offset, y1);
646  gl.Vertex2d(x1 - m_Offset, y2);
647  gl.Vertex2d(x2 - m_Offset, y2);
648  gl.Vertex2d(x2 - m_Offset, y1);
649  gl.End();
650 
652 }
653 
654 
656  TModelUnit border) const
657 {
658  IRender& gl = GetGl();
659 
660  TModelRect rect(rcm);
661  TModelUnit border_x = ScreenToSeq(border);
662  // bottom > top which is the reverse of CGlRect
663  rect.Inflate(border_x, -border);
664 
665  gl.Rectd(rect.Left() - m_Offset, rect.Bottom(), rect.Right() - m_Offset, rect.Top());
666 // LOG_POST(Trace << " drawing background rect at left: " << (rect.Left() - m_Offset) << " and right: " << (rect.Right() - m_Offset));
667 }
668 
669 
671  TModelUnit length,
672  TModelUnit apart,
674  const CRgbaColor& color,
675  bool neg_strand,
676  bool avoid_center,
677  bool single_indicator_center,
678  const vector<TModelRange> *labels_ranges) const
679 {
680  IRender& gl = GetGl();
681 
682  // adjust the start and lenght to ensure only draw indicators
683  // inside the visible range
684  TModelUnit start_x(start.X());
685  TModelUnit start_y(start.Y());
686  TModelUnit min_v = m_VisRange.GetFrom();
687  TModelUnit max_v = m_VisRange.GetTo();
688  if (start_x < min_v) {
689  start_x = min_v;
690  length -= start_x - start.X();
691  }
692  if (start_x + length > max_v) {
693  length = max_v - start_x;
694  }
695 
696  int strand_sign = neg_strand ? -1 : 1;
697  TModelUnit w1 = 0.2 * size * m_Scale;
698  TModelUnit w2 = 4.0 * w1;
699  TModelUnit half = 0.4 * size;
700 
701  TModelUnit size_x1 = strand_sign * w1;
702  TModelUnit size_x2 = strand_sign * w2;
703  TModelUnit size_y1 = half;
704  TModelUnit size_y2 = half * 2.0;
705 
706  int num = (int)floor(length / apart - 0.15) + 1;
707  TModelUnit off = (length - apart * (num - 1)) * 0.5 - strand_sign * w2 * 0.5;
708 
709  TModelUnit off_x = off - m_Offset + start_x;
710  TModelUnit off_y = start_y + 0.1 * size;
711 
712  gl.ShadeModel(GL_FLAT);
714  for (int i = 0; i < num; ++i) {
715  CRgbaColor curr_color(color.GetRed(), color.GetGreen(),
716  color.GetBlue(), color.GetAlpha());
717 
718  // if caller specified single_indicator_center center arrow will be drawn
719  // Only if there is just 1 arrow. Otherwise it will be avoided
720  if (num % 2 == 1 && i == (num - 1) / 2) {
721  if (avoid_center || (single_indicator_center && num > 1)) {
722  off_x += apart;
723  continue;
724  }
725 
726  if (!single_indicator_center) {
727  curr_color.Darken(i % 3 * 0.12f);
728  }
729  else {
730  curr_color.Darken(0.12f);
731  }
732  }
733  else {
734  curr_color.Darken(i % 3 * 0.12f);
735  }
736  if (labels_ranges) {
737  bool skip = false;
738  ITERATE(vector<TModelRange>, it_rng, *labels_ranges) {
739  TModelUnit ind_from = off_x + m_Offset;
740  TModelUnit ind_to = off_x + size_x2 + m_Offset;
741  TModelRange ind_range(ind_from < ind_to ? ind_from : ind_to, ind_from < ind_to ? ind_to : ind_from);
742  if (it_rng->IntersectingWith(ind_range)) {
743  skip = true;
744  break;
745  }
746  }
747  if (skip) {
748  off_x += apart;
749  continue;
750  }
751  }
752 
753  gl.ColorC(curr_color);
754  gl.Begin(GL_TRIANGLE_STRIP);
755  gl.Vertex2d(off_x + 0.0, off_y + size_y2);
756  gl.Vertex2d(off_x + size_x2 , off_y + size_y1);
757  gl.Vertex2d(off_x + size_x1, off_y + size_y1);
758  gl.Vertex2d(off_x, off_y);
759  gl.End();
760  off_x += apart;
761  }
762 }
763 
764 
766  bool direct, TModelUnit size_h,
767  TModelUnit size_v) const
768 {
769  TModelUnit two_pixel_w = ScreenToSeq(2.0);
770  size_h = ScreenToSeq(size_h);
771  TModelUnit tri_w = (size_h - two_pixel_w) * 0.5;
772  TModelUnit tri_h = (size_v - 2.0) * 0.5;
773  const char* label = "5'";
775  size_v -= 1.0;
776 
777  TModelRect rect;
778  TModelUnit label_x, label_y;
779  if (direct) {
780  rect.SetLeft(x);
781  rect.SetRight(x + size_h);
782  rect.SetTop(y - size_v);
783  rect.SetBottom(y);
784  label_x = x + two_pixel_w;
785  label_y = y - 2.0;
786  } else {
787  rect.SetLeft(x - size_h);
788  rect.SetRight(x);
789  rect.SetTop(y + size_v);
790  rect.SetBottom(y);
791  label_x = x - size_h + tri_w - two_pixel_w * 0.5;
792  label_y = y + size_v - 1.0;
793  }
794 
795  DrawRect(rect);
796  if (direct) {
797  TModelUnit corner_x = x + size_h;
798  DrawTriangle(corner_x, y, corner_x, y - tri_h, corner_x - tri_w, y);
799  TModelUnit corner_y = y - size_v;
800  DrawTriangle(corner_x, corner_y, corner_x - tri_w, corner_y, corner_x, corner_y + tri_h);
801  } else {
802  TModelUnit corner_x = x - size_h;
803  DrawTriangle(corner_x, y, corner_x, y + tri_h, corner_x + tri_w, y);
804  TModelUnit corner_y = y + size_v;
805  DrawTriangle(corner_x, corner_y, corner_x + tri_w, corner_y, corner_x, corner_y - tri_h);
806  }
807  TextOut(&font, label, label_x, label_y, false);
808 
809 }
810 
811 
813  const TModelRect& rc_coord) const
814 {
815  IRender& gl = GetGl();
816 
817  CGlAttrGuard AttrGuard(GL_LINE_BIT);
818  GLint prev_shader;
819  glGetIntegerv(GL_CURRENT_PROGRAM, &prev_shader);
820  gl.UseProgram(0);
821 
822  gl.Disable(GL_LINE_SMOOTH);
823  gl.Begin(GL_TRIANGLE_STRIP);
824  gl.TexCoord2d(rc_coord.Left(), rc_coord.Bottom());
825  gl.Vertex2d(rc.Left() - m_Offset, rc.Bottom());
826  gl.TexCoord2d(rc_coord.Right(), rc_coord.Bottom());
827  gl.Vertex2d(rc.Right() - m_Offset, rc.Bottom());
828  gl.TexCoord2d(rc_coord.Left(), rc_coord.Top());
829  gl.Vertex2d(rc.Left() - m_Offset, rc.Top());
830  gl.TexCoord2d(rc_coord.Right(), rc_coord.Top());
831  gl.Vertex2d(rc.Right() - m_Offset, rc.Top());
832  gl.End();
833  gl.Enable(GL_LINE_SMOOTH);
834 
835  gl.UseProgram(prev_shader);
836 }
837 
838 
839 void CRenderingContext::DrawHairLine(int opt, size_t total,
840  const multiset <TSeqPos>& all_pos,
841  TSeqPos pos, TModelUnit line_y,
842  const CRgbaColor& c_light,
843  const CRgbaColor& c_dark) const
844 {
845  IRender& gl = GetGl();
846 
847  bool need_line = true;
849  switch (opt) {
850  case 1: // 1. Show all hairlines with selections
851  color = all_pos.count(pos) > 1 ? c_dark : c_light;
852  break;
853  case 2: // 2. Show only hairlines that are not shared (i.e., places that are different)
854  color = c_light;
855  need_line = all_pos.count(pos) == 1;
856  break;
857  case 3: // 3. Show only hairlines that are shared by any two of the selections
858  color = c_dark;
859  need_line = all_pos.count(pos) >= 2;
860  break;
861  case 4: // 4. Show hairlines shared by *all* of the selections.
862  color = c_dark;
863  need_line = all_pos.count(pos) == total;
864  break;
865  }
866 
868  // render "From"
869  if (need_line) {
870  CGlAttrGuard AttrGuard(GL_LINE_BIT);
871  gl.ColorC(color);
872  gl.Disable(GL_LINE_SMOOTH);
873  DrawLine(pos, line_y, pos, m_bHorz ? rcV.Top() : rcV.Right());
874  gl.Enable(GL_LINE_SMOOTH);
875  }
876 
877 
878 }
879 
880 
882  TModelUnit y1, TModelUnit y2,
883  bool is_polya, const CRgbaColor& color) const
884 {
885  IRender& gl = GetGl();
886  auto c = color;
887  c.Lighten(0.5);
888  gl.ColorC(c);
889  double barh = ::fabs(m_Pane->GetScaleY() * ::fabs(y2-y1));
890  // simplified rendering (just thin line)
891  // when bar height is less that 2 pix
892  bool compressed_mode = barh < kMinBarHeight;
893 
894 
895  {
896  CGlAttrGuard AttrGuard(GL_LINE_BIT);
897  gl.Disable(GL_LINE_SMOOTH);
898  gl.Begin(GL_LINE_LOOP);
899  if (compressed_mode) {
900  gl.Vertex2d(x1 - m_Offset, y1);
901  gl.Vertex2d(x2 - m_Offset, y1);
902  } else {
903  gl.Vertex2d(x1 - m_Offset, y1);
904  gl.Vertex2d(x1 - m_Offset, y2);
905  gl.Vertex2d(x2 - m_Offset, y2);
906  gl.Vertex2d(x2 - m_Offset, y1);
907  }
908  gl.End();
909  }
910 
911  if (!compressed_mode) {
912  gl.ColorC(color);
913  if (is_polya) {
915  TextOut(&font, "pA", (x1 + x2) * 0.5, y2 - 2, true);
916  } else {
917  //TModelUnit off_v = (y2 - y1) * 0.2;
918  TModelUnit off_h = (x2 - x1) / 6;
919  //x1 += off_h;
920  //y1 += off_v;
921  //y2 -= off_v;
922  gl.Begin(GL_LINE_STRIP);
923  gl.Vertex2d(x1 - m_Offset, y2);
924  x1 += 2 * off_h;
925  gl.Vertex2d(x1 - m_Offset, y1);
926  x1 += 0.5 * off_h;
927  gl.Vertex2d(x1 - m_Offset, y2);
928  x1 += off_h;
929  gl.Vertex2d(x1 - m_Offset, y1);
930  x1 += 0.5 * off_h;
931  gl.Vertex2d(x1 - m_Offset, y2);
932  x1 += 2 * off_h;
933  gl.Vertex2d(x1 - m_Offset, y1);
934  gl.End();
935  }
936  }
937 
938 }
939 
940 
941 // slant dashed line
943  TModelUnit x2, TModelUnit y2,
944  const CRgbaColor& light_color,
945  const CRgbaColor& dark_color) const
946 {
947  IRender& gl = GetGl();
948 
949  TModelUnit xoff = 0.0;
951  bool shaded = true;
952 
953  if (fabs(x2-x1) <= GetScale()) {
954  gl.ColorC(light_color);
955  CGlAttrGuard AttrGuard(GL_LINE_BIT);
956  gl.Disable(GL_LINE_SMOOTH);
957  // HACK, mesa somehow projects y differently for drawling a line
958  // and drawing a quad. We add an slight y offset to make this work.
959  TModelUnit y_off = 0.0001;
960  DrawLine(x1, y1 + y_off, x1, y2 + y_off);
961  return;
962  }
963 
964  // Draw a triangle strip alternating colors for each pair of triangles
965  gl.ShadeModel(GL_FLAT);
967  gl.Enable(GL_BLEND);
968  gl.Begin(GL_TRIANGLE_STRIP);
969  gl.ColorC(light_color);
970  gl.Vertex3d(x1 - m_Offset, y1, 0.0);
971  gl.Vertex3d(x1 - m_Offset, y2, 0.0);
972 
973  while (xoff+delta <= x2-x1) {
974  xoff += delta;
975 
976  gl.Vertex3d(x1 + xoff - m_Offset, y1, 0.0);
977  if (shaded)
978  gl.ColorC(dark_color);
979  else
980  gl.ColorC(light_color);
981  gl.Vertex3d(x1 + xoff - m_Offset, y2, 0.0);
982 
983  shaded = !shaded;
984  }
985 
986  // Draw end (should pretty much always be a little more
987  // to draw...)
988  if (x1 + xoff < x2) {
989  gl.Vertex3d(x2 - m_Offset, y1, 0.0);
990  if (shaded)
991  gl.ColorC(dark_color);
992  else
993  gl.ColorC(light_color);
994  gl.Vertex3d(x2 - m_Offset, y2, 0.0);
995  }
996 
997  gl.End();
998 }
999 
1000 // Draw 2 <'s with some anti-aliasing. The previous texture approach
1001 // worked just as well (or better), but doesn't work with PDF output
1003  TModelUnit y2, bool loc, TModelUnit dir) const
1004 {
1005  IRender& gl = GetGl();
1006 
1007  TModelUnit mid = (y1 + y2)/2.0;
1008  TModelUnit w1 = dir*ScreenToSeq(1.0);
1009  TModelUnit w2 = dir*ScreenToSeq(5.0);
1010 
1011  if (loc) {
1012  gl.Color4f(0.3f, 0.1f, 0.1f, 0.7f);
1013  } else {
1014  gl.Color4f(1.0f, 1.0f, 1.0f, 0.7f);
1015  }
1016 
1017  // darker single-width arrow
1018  gl.Begin(GL_TRIANGLES);
1019  gl.Vertex3d(x1 + w1 - m_Offset, mid, 0.0);
1020  gl.Vertex3d(x1 + w2 - m_Offset, y2, 0.0);
1021  gl.Vertex3d(x1 + w2-w1 - m_Offset, y2, 0.0);
1022 
1023  gl.Vertex3d(x1 + w1 - m_Offset, mid, 0.0);
1024  gl.Vertex3d(x1 + w2-w1 - m_Offset, y2, 0.0);
1025  gl.Vertex3d(x1 - m_Offset, mid, 0.0);
1026 
1027  gl.Vertex3d(x1 + w1 - m_Offset, mid, 0.0);
1028  gl.Vertex3d(x1 + w2 - m_Offset, y1, 0.0);
1029  gl.Vertex3d(x1 + w2-w1 - m_Offset, y1, 0.0);
1030 
1031  gl.Vertex3d(x1 + w1 - m_Offset, mid, 0.0);
1032  gl.Vertex3d(x1 + w2-w1 - m_Offset, y1, 0.0);
1033  gl.Vertex3d(x1 - m_Offset, mid, 0.0);
1034 
1035  gl.End();
1036 
1037  if (loc) {
1038  gl.Color4f(0.3f, 0.1f, 0.1f, 0.3f);
1039  } else {
1040  gl.Color4f(1.0f, 1.0f, 1.0f, 0.3f);
1041  }
1042 
1043  // Overlay lighter arrow for antialiasing
1044  w1 = dir*ScreenToSeq(3.0);
1045  w2 = dir*ScreenToSeq(7.0);
1046  x1 -= dir*ScreenToSeq(1.0);
1047 
1048  gl.Begin(GL_TRIANGLES);
1049  gl.Vertex3d(x1 + w1 - m_Offset, mid, 0.0);
1050  gl.Vertex3d(x1 + w2 - m_Offset, y2, 0.0);
1051  gl.Vertex3d(x1 + w2-w1 - m_Offset, y2, 0.0);
1052 
1053  gl.Vertex3d(x1 + w1 - m_Offset, mid, 0.0);
1054  gl.Vertex3d(x1 + w2-w1 - m_Offset, y2, 0.0);
1055  gl.Vertex3d(x1 - m_Offset, mid, 0.0);
1056 
1057  gl.Vertex3d(x1 + w1 - m_Offset, mid, 0.0);
1058  gl.Vertex3d(x1 + w2 - m_Offset, y1, 0.0);
1059  gl.Vertex3d(x1 + w2-w1 - m_Offset, y1, 0.0);
1060 
1061  gl.Vertex3d(x1 + w1 - m_Offset, mid, 0.0);
1062  gl.Vertex3d(x1 + w2-w1 - m_Offset, y1, 0.0);
1063  gl.Vertex3d(x1 - m_Offset, mid, 0.0);
1064 
1065  gl.End();
1066 }
1067 
1068 // symbol '>>'
1070  TModelUnit x2, TModelUnit y2,
1071  bool p_start, bool p_stop,
1072  bool loc) const
1073 {
1074  IRender& gl = GetGl();
1075 
1076  TModelUnit tex_len = ScreenToSeq(8);
1077  if (x2 - x1 < tex_len) return;
1078 
1079  if (p_start) {
1080  DrawPartialBarMark(x1+ScreenToSeq(1.0), y1, y2, loc);
1081  DrawPartialBarMark(x1 + ScreenToSeq(5.0), y1, y2, loc);
1082  }
1083  if (p_stop && (!p_start || (x2 - x1) > 2.0 * tex_len)) {
1084  gl.Disable(GL_CULL_FACE);
1085  DrawPartialBarMark(x2-ScreenToSeq(1.0), y1, y2, loc, -1);
1086  DrawPartialBarMark(x2-ScreenToSeq(5.0), y1, y2, loc, -1);
1087  }
1088 
1089 }
1090 
1091 
1093 {
1094  IRender& gl = GetGl();
1095 
1096  TModelUnit band_w = 4.0;
1097  TModelUnit band_w_x = ScreenToSeq(band_w);
1098  TModelUnit left = rect.Left() - m_Offset;
1099  TModelUnit right = rect.Right() - m_Offset;
1100  TModelUnit frame_gap = ScreenToSeq(1.0);
1101  left -= frame_gap;
1102  right += frame_gap;
1103 
1104  TModelUnit top = rect.Top() - 1.0;
1105  TModelUnit bottom = rect.Bottom();
1106 
1107  //CRgbaColor color1(0.23f, 0.63f, 0.73f, 1.0f);
1108  //CRgbaColor color2(0.23f, 0.63f, 0.73f, 0.1f);
1109 
1110  CRgbaColor color1(color ? *color : m_HighlightsColor);
1111  CRgbaColor color2(0.5f, 0.5f, 0.5f, 0.1f);
1112 
1113  gl.ShadeModel(GL_FLAT);
1114 
1115  gl.ShadeModel(GL_SMOOTH);
1116  gl.Begin(GL_QUADS);
1117  gl.ColorC(color1);
1118  gl.Vertex3d(left, top, 0.0);
1119  gl.Vertex3d(right, top, 0.0);
1120  gl.ColorC(color2);
1121  gl.Vertex3d(right, top - band_w, 0.0);
1122  gl.Vertex3d(left, top - band_w, 0.0);
1123  gl.ColorC(color1);
1124  gl.Vertex3d(right, bottom, 0.0);
1125  gl.Vertex3d(left, bottom, 0.0);
1126  gl.ColorC(color2);
1127  gl.Vertex3d(left, bottom + band_w, 0.0);
1128  gl.Vertex3d(right, bottom + band_w, 0.0);
1129 
1130  gl.ColorC(color1);
1131  gl.Vertex3d(left, bottom, 0.0);
1132  gl.Vertex3d(left, top, 0.0);
1133  gl.ColorC(color2);
1134  gl.Vertex3d(left - band_w_x, top, 0.0);
1135  gl.Vertex3d(left - band_w_x, bottom, 0.0);
1136  gl.ColorC(color1);
1137  gl.Vertex3d(right, bottom, 0.0);
1138  gl.Vertex3d(right, top, 0.0);
1139  gl.ColorC(color2);
1140  gl.Vertex3d(right + band_w_x, top, 0.0);
1141  gl.Vertex3d(right + band_w_x, bottom, 0.0);
1142 
1143  gl.ColorC(color1);
1144  gl.Vertex3d(left, top, 0.0);
1145  gl.ColorC(color2);
1146  gl.Vertex3d(left, top - band_w, 0.0);
1147  gl.Vertex3d(left - band_w_x, top - band_w, 0.0);
1148  gl.Vertex3d(left - band_w_x, top, 0.0);
1149  gl.ColorC(color1);
1150  gl.Vertex3d(right, top, 0.0);
1151  gl.ColorC(color2);
1152  gl.Vertex3d(right + band_w_x, top, 0.0);
1153  gl.Vertex3d(right + band_w_x, top - band_w, 0.0);
1154  gl.Vertex3d(right, top - band_w, 0.0);
1155 
1156  gl.ColorC(color1);
1157  gl.Vertex3d(left, bottom, 0.0);
1158  gl.ColorC(color2);
1159  gl.Vertex3d(left, bottom + band_w, 0.0);
1160  gl.Vertex3d(left - band_w_x, bottom + band_w, 0.0);
1161  gl.Vertex3d(left - band_w_x, bottom, 0.0);
1162  gl.ColorC(color1);
1163  gl.Vertex3d(right, bottom, 0.0);
1164  gl.ColorC(color2);
1165  gl.Vertex3d(right + band_w_x, bottom, 0.0);
1166  gl.Vertex3d(right + band_w_x, bottom + band_w, 0.0);
1167  gl.Vertex3d(right, bottom + band_w, 0.0);
1168 
1169  gl.End();
1170 
1171  gl.ShadeModel(GL_FLAT);
1172 
1173 }
1174 
1176  const char* text,
1177  TModelUnit x, TModelUnit y,
1178  bool center, bool adjust_flip) const
1179 {
1180  IRender& gl = GetGl();
1181 
1182  x -= m_Offset;
1183  TModelUnit width = ScreenToSeq(gl.TextWidth(font, text));
1184  if (center) {
1185  x += m_bHorz ? -width * 0.5 : width * 0.5;
1186  //x = max(x, TModelUnit(0.0));
1187  }
1188  if (m_bFlipped && adjust_flip) {
1189  x += m_bHorz ? width : -width;
1190  }
1191 
1192  gl.BeginText(font);
1193  gl.WriteText(x, y, text);
1194  gl.EndText();
1195 }
1196 
1198  const char* text,
1199  TModelUnit x, TModelUnit y,
1200  bool center, bool adjust_flip) const
1201 {
1202  x -= m_Offset;
1203  TModelUnit width = ScreenToSeq(font->TextWidth(text));
1204  if (center) {
1205  x += m_bHorz ? -width * 0.5 : width * 0.5;
1206  //x = max(x, TModelUnit(0.0));
1207  }
1208  if (m_bFlipped && adjust_flip) {
1209  x += m_bHorz ? width : -width;
1210  }
1211 
1212  font->TextOut(x, y, text);
1213 
1214 }
1215 
1217  TModelUnit x2, TModelUnit y2) const
1218 {
1219  IRender& gl = GetGl();
1220 
1221  gl.Begin(GL_LINES);
1222  gl.Vertex2d(x1 - m_Offset, y1);
1223  gl.Vertex2d(x2 - m_Offset, y2);
1224  gl.End();
1225 }
1226 
1227 
1228 void CRenderingContext::SetIsDrawn(const string& sPName, bool isDrawn)
1229 {
1230  if(isDrawn) {
1231  m_DrawnSet.insert(sPName);
1232  } else {
1233  m_DrawnSet.erase(sPName);
1234  }
1235 }
1236 
1237 
1238 
1239 bool CRenderingContext::GetIsDrawn(const string& sPName) const
1240 {
1241  return m_DrawnSet.count(sPName) > 0;
1242 }
1243 
1244 
1245 
CGlAttrGuard - guard class for restoring OpenGL attributes.
Definition: glutils.hpp:130
class CGlPane
Definition: glpane.hpp:62
bool GetIsDrawn(const string &sPName) const
TModelRange m_LimitRange
Model limits.
virtual ~CRenderingContext()
void DrawDisk(const TModelPoint &p, TModelUnit radius, GLint from=0, GLint to=360) const
void PrepareContext(CGlPane &pane, bool horz, bool flipped)
void TextOut(const CGlTextureFont *font, const char *text, TModelUnit x, TModelUnit y, bool center, bool adjust_flip=true) const
CRgbaColor m_HighlightsColor
static const int kLabelSpacePx
extra space for side labeling, in screen pixels
bool m_bHorz
orientation.
TModelUnit m_MinLabelSizePos
minimum label size, in sequence coordinates
void DrawTriangle(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2, TModelUnit x3, TModelUnit y3, bool border=false) const
void Draw3DFletch(TModelUnit pos_x, TModelUnit line_y1, TModelUnit line_y2, TModelUnit tail_height, const CRgbaColor &color, bool neg_strand) const
void DrawPseudoBar(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2, const CRgbaColor &light_color, const CRgbaColor &dark_color) const
void DrawHighlight(const TModelRect &rect, const CRgbaColor *color=0) const
CGlPane * m_Pane
What we drawing on.
void DrawShadedQuad(const TModelRect &rcm, const CRgbaColor &c1, const CRgbaColor &c2, bool shade_vert=true) const
void DrawArrowBoundary(TModelUnit x1, TModelUnit x2, TModelUnit x3, TModelUnit line_center, TModelUnit bar_h, TModelUnit head_h) const
TModelRange IntersectVisible_Y(const TModelRange &r) const
inttersect with the vertical visible screen space.
void Draw3DQuad_HorzLines(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2, const CRgbaColor &color, bool border=false) const
TModelRange m_VisRange
Model visible limits.
void DrawArrow(TModelUnit x1, TModelUnit x2, TModelUnit x3, TModelUnit line_center, TModelUnit bar_h, TModelUnit head_h) const
void DrawHairLine(int opt, size_t total, const multiset< TSeqPos > &all_pos, TSeqPos pos, TModelUnit line_y, const CRgbaColor &c_light, const CRgbaColor &c_dark) const
void DrawUnalignedTail(TModelUnit x1, TModelUnit x2, TModelUnit y1, TModelUnit y2, bool is_polya, const CRgbaColor &color) const
void DrawLine(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2) const
void DrawRect(const TModelRect &rc) const
void DrawQuad(const TModelRect &rc, bool border=false) const
const TModelUnit & GetScale() const
TSeqRange m_VisSeqRange
Visilble sequence range.
void DrawSelection(const TModelRect &rc) const
CIRef< IVboGeom > m_GlyphGeom
void DrawPartialBar(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2, bool p_start, bool p_stop, bool loc) const
TModelUnit ScreenToSeq(const TModelUnit &size) const
convert from screen pixels to sequence positions
CGlBitmapFont m_Font_Helv10
fonts.
void DrawDisk2(const TModelPoint &p, TModelUnit size, CRgbaColor color)
void DrawSquare(const TModelPoint &p, TModelUnit size, const CRgbaColor &color, bool neg_strand) const
void Draw3DArrow(const TModelPoint &p, TModelUnit size, bool neg_strand) const
void Draw3DQuad(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2, const CRgbaColor &color, bool border=false) const
void DrawTexture(const TModelRect &rc, const TModelRect &rc_coord) const
void SetIsDrawn(const string &sPName, bool isDrawn)
void Draw3DTriangle(const TModelPoint &p, TModelUnit size, const CRgbaColor &color, bool neg_strand, bool need_neck) const
void DrawPartialBarMark(TModelUnit x1, TModelUnit y1, TModelUnit y2, bool loc, TModelUnit dir=1.0) const
Draw partial feature indicator.
void DrawBackground(const TModelRect &rcm, TModelUnit border) const
void DrawStrandIndicators(const TModelPoint &start, TModelUnit length, TModelUnit apart, TModelUnit size, const CRgbaColor &color, bool neg_strand, bool avoid_center=false, bool single_indicator_center=false, const vector< TModelRange > *labels_ranges=nullptr) const
void Draw5Prime(TModelUnit x, TModelUnit y, bool direct, TModelUnit size_h, TModelUnit size_v) const
void DrawGreaterLessSign(TModelUnit x1, TModelUnit x2, TModelUnit bar_h, bool negative) const
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
void erase(iterator pos)
Definition: set.hpp:151
Include a standard set of the NCBI C++ Toolkit most basic headers.
static Uint4 border[]
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
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
#define NULL
Definition: ncbistd.hpp:225
T & Z()
Definition: vect4.hpp:115
void Transpose()
Definition: matrix4.hpp:347
void Identity()
Definition: matrix4.hpp:373
T & X()
Definition: vect4.hpp:111
const T * GetData() const
Definition: matrix4.hpp:103
T & Y()
Definition: vect4.hpp:113
T & W()
Definition: vect4.hpp:117
virtual bool IsSimplified() const =0
GLdouble TModelUnit
Definition: gltypes.hpp:48
void SetRight(T right)
Definition: glrect.hpp:114
void Color4fv(const GLfloat *v)
Definition: irender.hpp:98
static CGlResMgr & Instance()
Definition: glresmgr.cpp:59
T X() const
Definition: glpoint.hpp:59
virtual void Enable(GLenum glstate)=0
virtual void TextOut(const char *text) const
virtual void UseProgram(GLuint program)=0
For shaders. Only works with OpenGL 2.0+.
virtual void Begin(GLenum mode)=0
Start rendering.
void SetBottom(T bottom)
Definition: glrect.hpp:113
T Top() const
Definition: glrect.hpp:84
virtual void BlendFunc(GLenum sfactor, GLenum dfactor)=0
Options to be used when GL_BLEND is enabled.
T Bottom() const
Definition: glrect.hpp:82
virtual CMatrix4< float > GetModelViewMatrix() const =0
virtual void LineJoinStyle(IGlState::ELineJoinStyle s)=0
PDF-specific rendering state.
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
virtual void BeginText(const CGlTextureFont *font, const CRgbaColor &color)=0
Text is drawn is pixel coordinates.
virtual void PdfShadeStyle(IGlState::EPdfShadeStyle s)=0
Set (override defualt) shading style for polygons.
virtual TModelUnit TextWidth(const CGlTextureFont *font, const char *text) const =0
TModelUnit GetOffsetY() const
Definition: glpane.hpp:415
bool IsEnabled(GLenum glstate) const
Return true if option is in m_Enabled list for this state.
Definition: glstate.cpp:371
virtual void EndText()=0
Pops matrices and attributes after writing text.
virtual TModelUnit TextWidth(const char *text) const
compute the length of a null-terminated string
TModelRect & GetModelLimitsRect(void)
Definition: glpane.hpp:347
virtual void ShadeModel(GLenum mode)=0
Set shade model for default lighting: glShadeModel(GL_FLAT or GL_SMOOTH)
T Left() const
Definition: glrect.hpp:81
T Y() const
Definition: glpoint.hpp:60
virtual void End()=0
Finish rendering (create buffer and send to renderer)
void Inflate(T d_x, T d_y)
Definition: glrect.hpp:178
virtual void PolygonMode(GLenum face, GLenum mode)=0
Set the polygon rasterization mode.
void TexCoord2d(GLdouble s, GLdouble t)
Definition: irender.hpp:213
void Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
Definition: irender.hpp:97
virtual void WriteText(TModelUnit x, TModelUnit y, const char *text, TModelUnit rotate_degrees=0.0)=0
Write text at specified model coords.
void SetLeft(T left)
Definition: glrect.hpp:112
TModelRect & GetVisibleRect(void)
Definition: glpane.hpp:357
void Vertex3d(GLdouble x, GLdouble y, GLdouble z)
Definition: irender.hpp:187
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 GetScaleY(void) const
Definition: glpane.cpp:123
TModelUnit GetOffsetX() const
Definition: glpane.hpp:410
virtual CRef< CGlState > GetState()=0
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
void SetTop(T top)
Definition: glrect.hpp:115
void Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
Definition: irender.hpp:193
@ eMiteredJoin
Definition: glstate.hpp:77
@ eRoundedJoin
Definition: glstate.hpp:77
void Darken(float scale)
Definition: rgba_color.cpp:472
float GetBlue(void) const
Definition: rgba_color.hpp:333
float GetGreen(void) const
Definition: rgba_color.hpp:327
void SetAlpha(float r)
Definition: rgba_color.cpp:287
float GetAlpha(void) const
Definition: rgba_color.hpp:339
void Lighten(float scale)
Definition: rgba_color.cpp:463
float GetRed(void) const
Get specific channels in floating point values.
Definition: rgba_color.hpp:321
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:735
TThisType IntersectionWith(const TThisType &r) const
Definition: range.hpp:312
TThisType & Set(position_type from, position_type to)
Definition: range.hpp:188
#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 const char label[]
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
n background color
int i
static void text(MDB_val *v)
Definition: mdb_dump.c:62
const struct ncbi::grid::netcache::search::fields::SIZE size
#define fabs(v)
Definition: ncbi_dispd.c:46
EIPRangeType t
Definition: ncbi_localip.c:101
T negative(T x_)
Int4 delta(size_t dimension_, const Int4 *score_)
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 const float kMinBarHeight
Modified on Tue Apr 16 20:15:00 2024 by modify_doxy.py rev. 669887