53 #define M_NCBI_E 2.71828182845904523536
98 for (
int ch = 0; ch < 4; ++ch) {
155 tt.
AddRow(
"DNA Sequencing Chromatograms");
182 CGlAttrGuard AttrGuard(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_HINT_BIT
183 | GL_LINE_SMOOTH | GL_POLYGON_MODE | GL_LINE_BIT);
190 int top_y = m_ModelRect.
Top();
200 gl.
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
201 gl.
Enable(GL_LINE_SMOOTH);
202 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
260 gl.
Rectd(x1, y1, x2, y2);
261 gl.
Rectd(x1, y3, x2, y4);
292 bool b_average = (scale_x > 0.5);
312 double v = 0, v_min = 0, v_max = 0;
316 if (vis_from > vis_to) {
318 swap(vis_from, vis_to);
335 for (
int pix = range_pix_start; pix <= range_pix_end;) {
337 if (pos < gr_from || pos > gr_to)
342 pos_pix_left = range_pix_start + (left - pos) / scale_x;
344 pos_pix_left = range_pix_start + (pos - left) / scale_x;
346 pos_pix_right = pos_pix_left + 1 / scale_x;
352 while (pos_pix_left < pix + 1) {
353 if (pos < from || pos > to)
361 v_min =
min(v_min, v);
362 v_max =
max(v_max, v);
365 if (pos_pix_right >= pix + 1)
369 pos_pix_left = range_pix_start + (left - pos) / scale_x;
371 pos_pix_left = range_pix_start + (pos - left) / scale_x;
373 pos_pix_right = pos_pix_left + 1 / scale_x;
386 v = v_min = v_max = 0;
404 from = max<TSignedSeqPos>(gr_from, from);
405 to = min<TSignedSeqPos>(gr_to, to);
411 double x = aln_pos - offset_x;
412 gl.
Rectd(x, base_y, x + 1.0, base_y + v);
428 for (
int i_ch = 0; i_ch < 4; i_ch++) {
456 int bottom_y,
int ,
int amp)
const
468 double vis_from = rc_vis.
Left();
469 double vis_to = rc_vis.
Right();
470 if (vis_to < vis_from) {
472 swap(vis_from, vis_to);
475 from =
max(from, vis_from);
476 to =
min(to, vis_to);
481 sm_start =
max(0, sm_start);
484 if (sm_start <= sm_end) {
485 gl.
Begin(GL_TRIANGLE_STRIP);
490 if (sm_start_seqpos < from) {
491 if (sm_start + 1 < sm_end) {
492 double v1 = values[sm_start];
493 double v2 = values[sm_start + 1];
494 double x1 = sm_start_seqpos;
495 double x2 = positions[sm_start + 1];
496 double v = v1 + ((from - x1) * (
v2 - v1) / (x2 - x1));
499 double aln_from = from + (b_neg ? -1 : 0);
500 gl.
Vertex2d(aln_from - offset_x, bottom_y - v);
506 for (
int i_sm = sm_start; i_sm < sm_end; i_sm++) {
508 double v = values[i_sm];
511 double aln_pos = seqpos + (b_neg ? -1 : 0);
512 gl.
Vertex2d(aln_pos - offset_x, bottom_y - v);
516 if (sm_end - 1 > sm_start) {
517 double v1 = values[sm_end - 1];
518 double v2 = values[sm_end];
519 double x1 = positions[sm_end - 1];
520 double x2 = positions[sm_end];
521 double v = v1 + ((to + 1 - x1) * (
v2 - v1) / (x2 - x1));
524 double aln_to = to + (b_neg ? 0 : 1);
525 gl.
Vertex2d(aln_to - offset_x, bottom_y - v);
529 double v = values[sm_end];
532 double aln_pos = seqpos;
533 gl.
Vertex2d(aln_pos - offset_x, bottom_y - v);
556 int band_h = av_h / 4;
557 int off = (av_h - 4 * band_h) / 2;
570 double vis_from = rc_vis.
Left();
571 double vis_to = rc_vis.
Right();
572 if (vis_to < vis_from) {
574 swap(vis_from, vis_to);
584 sm_start =
max(sm_start, 0);
588 double aln_from = from;
593 TVPUnit pix_start = range_pix_start + (aln_from - floor(vis_from)) / scale_x;;
594 TVPUnit pix_end = range_pix_start + (
TVPUnit)ceil((aln_to - floor(vis_from)) / scale_x);
596 pix_start =
max(pix_start, range_pix_start);
597 pix_end =
min(pix_end, range_pix_end);
602 for (
int i_ch = 0; i_ch < 4; i_ch++) {
610 double x1 = 0.0, x2 = 0.0, pix_x1 = 0.0, pix_x2 = 0.0;
611 double v1,
v2, s, dx, sum, sum_pix_x;
616 for (
TVPUnit pix = pix_start; pix <= pix_end; pix++) {
622 x1 = positions[sample];
623 pix_x1 = range_pix_start;
626 pix_x1 += dist / scale_x;
628 v1 =
v2 = values[sample];
630 if (pix_x1 < pix + 1) {
634 x2 = positions[sample + sm_inc];
635 pix_x2 = range_pix_start;
638 pix_x2 += dist / scale_x;
640 v2 = values[sample + sm_inc];
644 v1 += (
v2 - v1) * (pix - pix_x1) / (pix_x2 - pix_x1);
649 while (b_next_point && pix_x2 <= pix + 1)
651 dx = pix_x2 - pix_x1;
652 s = 0.5 * (v1 +
v2) * dx;
665 x2 = positions[sample + sm_inc];
666 pix_x2 = range_pix_start;
669 pix_x2 += dist / scale_x;
670 v2 = values[sample + sm_inc];
674 if (b_next_point && pix_x2 > pix + 1) {
675 dx = pix + 1 - pix_x1;
678 double v = v1 + (
v2 - v1) * dx / (pix_x2 - pix_x1);
679 s = 0.5 * (v1 + v) * dx;
686 double av_v = (sum_pix_x) > 0 ? sum / sum_pix_x : 0;
689 double norm = (MaxSignal == 0) ? 0 : (av_v / MaxSignal);
693 gl.
Vertex2d(pix, band_y + band_h - 1);
707 _ASSERT(signal >= 0 && signal <= 3);
724 if (pos < m_Data->GetSeqFrom() || n_samples == 0) {
734 i =
min(
i, n_samples - 1);
737 if (positions[
i] > pos) {
738 for (;
i > 0 && positions[
i] > pos;
i--) {
741 for (; ++
i < n_samples && positions[
i] < pos;) {
756 if (pos < m_Data->GetSeqFrom() || n_samples == 0) {
766 i =
min(
i, n_samples - 1);
769 if (positions[
i] > pos) {
770 for (;
i > 0 && positions[
i] > pos;
i--) {
774 for (; ++
i < n_samples && positions[
i] < pos;) {
CGlAttrGuard - guard class for restoring OpenGL attributes.
CGlPane * GetGlPane()
inline method implementations
const TModelRange & GetVisibleRange() const
bool IsFlippedStrand() const
class CRgbaColor provides a simple abstraction for managing colors.
TValues & GetValues(EChannel signal)
int GetSamplesCount() const
vector< TSignalValue > TValues
vector< TFloatSeqPos > TPositions
TConfidence GetMaxConfidence() const
TSignedSeqPos GetSeqTo() const
TSignedSeqPos GetSeqFrom() const
Sequence related information.
TPositions & GetPositions()
TSignalValue GetMax(EChannel signal) const
TConfidence GetConfidence(TSignedSeqPos pos) const
TSignedSeqPos GetSeqLength() const
CRenderingContext * m_Context
the rendering context
virtual void SetHeight(TModelUnit h)
virtual void SetWidth(TModelUnit w)
virtual void SetLeft(TModelUnit l)
virtual TModelUnit GetHeight() const
TModelRect GetModelRect() const
get the bounding box.
vector< CHTMLActiveArea > TAreaVector
int x_GetConfGraphH() const
virtual bool OnLeftDblClick(const TModelPoint &)
vector< CRgbaColor > m_vSignalColors
void x_RenderConfGraph(CGlPane &pane, int y, int h) const
void x_RenderSignalGraph(CGlPane &pane, int y, int h) const
int x_FindSampleToLeft(double pos) const
returns index of rightmost sample having m_SeqPos less then "pos".
CTraceGlyph(const CRef< CSGTraceData > &data, const CRef< CTraceGraphConfig > &config)
virtual bool IsClickable() const
Query if this glyph is clickable.
CRef< CTraceGraphConfig > m_Config
void x_InitColors() const
virtual void GetTooltip(const TModelPoint &, ITooltipFormatter &tt, string &t_title) const
Get the tooltip if available.
virtual void GetHTMLActiveAreas(TAreaVector *p_areas) const
Get html active areas.
CRef< CSGTraceData > m_Data
void x_RenderCurveSegment(CGlPane &pane, const CSGTraceData::TPositions &positions, const CSGTraceData::TValues &values, int bottom_y, int, int amp) const
const CRgbaColor & GetColorByValue(double value, int signal) const
void x_RenderIntensityGraphs(CGlPane &pane, int y, int h) const
Render signals for all channels as gradient-color bands with color intensity proprotional to signal s...
int x_FindSampleToRight(double pos) const
returns index of the leftmost sample having m_SeqPos greater than "pos" if "pos" is to the left of th...
void x_RenderContour(CGlPane &pane, int y, int top_h, int total_h) const
virtual void x_Draw() const
The default renderer for this layout object.
virtual bool NeedTooltip(const TModelPoint &p, ITooltipFormatter &tt, string &t_title) const
Check if need to show tooltip.
int x_GetSignalGraphH() const
virtual void x_UpdateBoundingBox()
Update the bounding box assuming children's sizes are fixed if any.
ESingnalStyle m_SignalStyle
CRgbaColor m_colorConfMax
EGraphState m_ConfGraphState
EGraphState m_SignalGraphState
array< CRgbaColor, 4 > m_colors
CRgbaColor m_colorConfMin
int TSignedSeqPos
Type for signed sequence position.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
void SetViewport(const TVPRect &R)
virtual void Enable(GLenum glstate)=0
virtual void Begin(GLenum mode)=0
Start rendering.
virtual void BlendFunc(GLenum sfactor, GLenum dfactor)=0
Options to be used when GL_BLEND is enabled.
void Color3d(GLdouble r, GLdouble g, GLdouble b)
IRender & GetGl()
convenience function for getting current render manager
void Vertex2d(GLdouble x, GLdouble y)
TVPRect & GetViewport(void)
virtual void End()=0
Finish rendering (create buffer and send to renderer)
virtual void PolygonMode(GLenum face, GLenum mode)=0
Set the polygon rasterization mode.
EProjectionMode GetProjMode(void) const
TModelRect & GetVisibleRect(void)
virtual void Disable(GLenum glstate)=0
glDisable()
virtual void LineWidth(GLfloat w)=0
Set line width for drawing: glLineWidth()
TModelUnit GetScaleX(void) const
TModelUnit GetOffsetX() const
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)
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
static void RgbToHsv(const CRgbaColor &rgb, float &h, float &s, float &v)
convert RGB to HSV.
static CRgbaColor HsvToRgb(float h, float s, float v)
position_type GetLength(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
TFrom GetFrom(void) const
Get the From member data.
unsigned int
A callback function used to compare two keys in a database.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static const double kSignalGraphPrefHR
CRgbaColor s_GradientToWhite(const CRgbaColor &rgb, float degree)
static const int kGradColors
static const double kConfGraphPrefHR
static const int kGraphOffsetY
static const int kCollapsedGraphH