52 : m_SignalStyle(eCurve),
53 m_ConfGraphState(eExpanded),
54 m_SignalGraphState(eExpanded),
55 m_bReverseColors(
true)
75 : m_DataProxy(handle, b_neg_strand),
78 m_TextColor(0.6f, 0.6f, 0.6f)
176 float v = 1.0f - k * j;
234 CGlAttrGuard AttrGuard(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_HINT_BIT
235 | GL_LINE_SMOOTH | GL_POLYGON_MODE | GL_LINE_BIT);
251 unique_ptr<IAlnSegmentIterator> it_1(it.
Clone());
258 gl.
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
260 gl.
Enable(GL_LINE_SMOOTH);
261 glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
264 unique_ptr<IAlnSegmentIterator> it_3(it.
Clone());
274 unique_ptr<IAlnSegmentIterator> it_4(it.
Clone());
286 unique_ptr<IAlnSegmentIterator> it_2(it.
Clone());
405 gl.
Rectd(x1, y1, x2, y2);
406 gl.
Rectd(x1, y3, x2, y4);
413 const static float kEps = 0.000001f;
445 bool b_average = (scale_x > 0.3);
460 bool it_seg_moved =
true;
467 double v = 0, v_min = 0, v_max = 0;
471 for(
int pix = range_pix_start;
472 pix <= range_pix_end && it_seg && pos <= gr_to; ) {
492 if(vis_to < vis_from) {
494 swap(vis_from, vis_to);
496 from =
max(from, vis_from);
497 to =
min(to, vis_to);
508 it_seg_moved =
false;
513 pos_pix_left = range_pix_start + (aln_pos - left) / scale_x;
514 pos_pix_right = pos_pix_left + 1 / scale_x;
520 while(pos >= from && pos <= to && pos_pix_left < pix + 1) {
524 v_min = b_first ? v :
min(v_min, v);
525 v_max = b_first ? v :
max(v_max, v);
528 if(pos_pix_right < pix +1) {
531 pos_pix_left = range_pix_start + (aln_pos - left) / scale_x;
532 pos_pix_right = pos_pix_left + 1 / scale_x;
536 if(ch_pix_end < pix + 1) {
545 gl.
Color3d(0.0f, 0.75f, 0.25f);
551 v = v_min = v_max = 0;
561 for( ; it_seg; ++it_seg ) {
575 double x = aln_pos - offset_x;
576 gl.
Rectd(x , base_y, x + 1.0, base_y + v);
597 for(
int i_ch = 0; i_ch < 4; i_ch++ ) {
611 unique_ptr<IAlnSegmentIterator> p_it_1(it.
Clone());
613 if(it_1->IsAligned()) {
629 int bottom_y,
int ,
int amp)
648 if(vis_to < vis_from) {
650 swap(vis_from, vis_to);
653 from =
max(from, vis_from);
654 to =
min(to, vis_to);
659 sm_start =
max(0, sm_start);
662 if(sm_start <= sm_end) {
663 gl.
Begin(GL_QUAD_STRIP);
668 if(sm_start_seqpos < from) {
669 if(sm_start + 1 < sm_end) {
670 double v1 = values[sm_start];
671 double v2 = values[sm_start + 1];
672 double x1 = sm_start_seqpos;
673 double x2 = positions[sm_start + 1];
674 double v = v1 + ((from - x1) * (
v2 - v1) / (x2 - x1));
678 gl.
Vertex2d(aln_from - offset_x, bottom_y - v);
684 for(
int i_sm = sm_start; i_sm < sm_end; i_sm++ ) {
686 double v = values[i_sm];
690 gl.
Vertex2d(aln_pos - offset_x, bottom_y - v);
694 if( sm_end - 1 > sm_start) {
695 double v1 = values[sm_end -1];
696 double v2 = values[sm_end];
697 double x1 = positions[sm_end - 1];
698 double x2 = positions[sm_end];
699 double v = v1 + ((to + 1 - x1) * (
v2 - v1) / (x2 - x1));
703 gl.
Vertex2d(aln_to - offset_x, bottom_y - v);
707 double v = values[sm_end];
711 gl.
Vertex2d(aln_pos - offset_x, bottom_y - v);
735 int band_h = av_h / 4;
736 int off = (av_h - 4 * band_h) / 2;
750 for(
int pix = range_pix_start; pix <= range_pix_end && it_seg; ++it_seg) {
764 if(vis_to < vis_from) {
766 swap(vis_from, vis_to);
769 from =
max(from, vis_from);
770 to =
min(to, vis_to);
775 sm_start =
max(sm_start, 0);
782 swap(aln_from, aln_to);
786 TVPUnit pix_start = range_pix_start + (
TVPUnit) floor((aln_from - left) / scale_x);
787 TVPUnit pix_end = range_pix_start + (
TVPUnit) ceil((aln_to - left) / scale_x);
788 pix_start =
max(pix_start, range_pix_start);
789 pix_end =
min(pix_end, range_pix_end);
794 for(
int i_ch = 0; i_ch < 4; i_ch++ ) {
802 double x1 = 0.0, x2 = 0.0, pix_x1 = 0.0, pix_x2 = 0.0;
803 double v1,
v2, s, dx, sum, sum_pix_x;
808 for(
TVPUnit pix = pix_start; pix <= pix_end; pix++ ) {
814 x1 = positions[sample];
818 v1 =
v2 = values[sample];
820 if(pix_x1 < pix + 1) {
822 bool b_next_point =
m_Data->
IsNegative() ? (sample > sm_start) : (sample < sm_end);
824 x2 = positions[sample + sm_inc];
828 v2 = values[sample + sm_inc];
832 v1 += (
v2 - v1) * (pix - pix_x1) / (pix_x2 - pix_x1);
837 while(b_next_point && pix_x2 <= pix + 1)
839 dx = pix_x2 - pix_x1;
840 s = 0.5 * (v1 +
v2) * dx;
850 b_next_point =
m_Data->
IsNegative() ? (sample > sm_start) : (sample < sm_end);
852 x2 = positions[sample + sm_inc];
856 v2 = values[sample + sm_inc];
861 if(b_next_point && pix_x2 > pix + 1) {
862 dx = pix + 1 - pix_x1;
865 double v = v1 + (
v2 - v1) * dx / (pix_x2 - pix_x1);
866 s = 0.5 * (v1 + v) * dx;
873 double av_v = (sum_pix_x) > 0 ? sum / sum_pix_x : 0;
876 double norm = (MaxSignal == 0) ? 0 : (av_v / MaxSignal);
880 gl.
Vertex2d(pix, band_y - band_h - 1);
895 _ASSERT(signal >= 0 && signal <= 3);
909 if(pos < m_Data->GetSeqFrom() || n_samples == 0) {
919 i =
min(
i, n_samples - 1);
922 if(positions[
i] > pos) {
923 for( ;
i > 0 && positions[
i] > pos;
i-- ) {
926 for( ; ++
i < n_samples && positions[
i] < pos; ) {
941 if(pos < m_Data->GetSeqFrom() || n_samples == 0) {
951 i =
min(
i, n_samples - 1);
954 if(positions[
i] > pos) {
955 for( ;
i > 0 && positions[
i] > pos;
i-- ) {
959 for( ; ++
i < n_samples && positions[
i] < pos; ) {
CGlAttrGuard - guard class for restoring OpenGL attributes.
class CRgbaColor provides a simple abstraction for managing colors.
TSignedSeqPos GetSeqFrom() const
Sequence related information.
TConfidence GetConfidence(TSignedSeqPos pos) const
TSignalValue GetMax(EChannel signal) const
int GetSamplesCount() const
TValues & GetValues(EChannel signal)
TConfidence GetMaxConfidence() const
TSignedSeqPos GetSeqTo() const
TPositions & GetPositions()
vector< TFloatSeqPos > TPositions
vector< TSignalValue > TValues
TSignedSeqPos GetSeqLength() const
EGraphState m_ConfGraphState
ESingnalStyle m_SignalStyle
EGraphState m_SignalGraphState
CTraceGraphProperties & operator=(const CTraceGraphProperties &orig)
void x_RenderIntensityGraphs(CGlPane &pane, int y, int h, IAlnSegmentIterator &it)
Render signals for all channels as gradient-color bands with color intensity proprotional to signal s...
void x_RenderText(CGlPane &pane)
void x_RenderSignalGraph(CGlPane &pane, int y, int h, IAlnSegmentIterator &it)
vector< CRgbaColor > m_vSignalColors
CTraceGraph(const objects::CBioseq_Handle &handle, bool b_neg_strand)
CTraceDataProxy m_DataProxy
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...
virtual void Render(CGlPane &pane)
void x_RenderContour(CGlPane &pane, int y, int conf_h, int total_h, IAlnSegmentIterator &it)
void SetSignalGraphState(EGraphState state)
void x_RenderCurveSegment(CGlPane &pane, const IAlnSegment &seg, const CTraceData::TPositions &positions, const CTraceData::TValues &values, int bottom_y, int h, int amp)
void SetConfGraphState(EGraphState state)
virtual bool IsCreated() const
Graph is not considered fully functional until it has been "created" by the call to create function.
void x_RenderConfGraph(CGlPane &pane, int y, int h, IAlnSegmentIterator &it)
int x_GetConfGraphH() const
virtual bool NeedTooltip(CGlPane &pane, int vp_x, int vp_y)
const CRgbaColor & GetColorByValue(double value, int signal) const
int x_GetSignalGraphH() const
virtual string GetTooltip()
virtual const IAlnRowGraphProperties * GetProperties() const
virtual void SetProperties(IAlnRowGraphProperties *props)
int x_FindSampleToLeft(double pos) const
returns index of rightmost sample having m_SeqPos less then "pos".
CTraceGraphProperties m_Props
virtual TVPPoint PreferredSize()
Alignment segment iterator interface.
virtual IAlnSegmentIterator * Clone(void) const =0
Create a copy of the iterator.
Alignment segment interface.
virtual const TSignedRange & GetRange(void) const =0
Get the selected row range.
bool IsAligned(void) const
virtual const TSignedRange & GetAlnRange(void) const =0
Get alignment range for the segment.
Include a standard set of the NCBI C++ Toolkit most basic headers.
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)
virtual void Enable(GLenum glstate)=0
virtual void Begin(GLenum mode)=0
Start rendering.
CGlPoint< TVPUnit > TVPPoint
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)
TModelUnit GetOffsetY() const
bool PtInRect(T x, T y) const
virtual void End()=0
Finish rendering (create buffer and send to renderer)
void Inflate(T d_x, T d_y)
virtual void PolygonMode(GLenum face, GLenum mode)=0
Set the polygon rasterization mode.
EProjectionMode GetProjMode(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)
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)
position_type GetLength(void) const
TThisType & IntersectWith(const TThisType &r)
bool NotEmpty(void) const
CRange< TSignedSeqPos > TSignedSeqRange
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
unsigned int
A callback function used to compare two keys in a database.
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
const GenericPointer< typename T::ValueType > T2 value
const TSignedSeqRange * m_AlnRange
double GetSeqPosFromAlnPos(double aln_pos)
double GetAlnPosFromSeqPos(double seq_pos)
const TSignedSeqRange * m_SeqRange
void Init(const TSignedSeqRange &seq_range, const TSignedSeqRange &aln_range, bool negative)
TSignedSeqPos GetAlnPosFromSeqPos(TSignedSeqPos seq_pos)
TSignedSeqPos GetSeqPosFromAlnPos(TSignedSeqPos aln_pos)
static const int kSignalGraphPrefH
static const int kGradColors
CTraceGraph.
static const int kGraphOffsetY
static const int kTextOff
static const int kIntBandSpace
static const int kCollapsedGraphH
static const int kConfGraphPrefH