NCBI C++ ToolKit
trace_glyph.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___TRACE_GLYPH__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___TRACE_GLYPH__HPP
3 
4 /*
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Andrei Shkeda
30  *
31  * File Description:
32  * CTraceGlyph -- utility class for Trace Chromatograms.
33  *
34  */
35 
36 
37 #include <corelib/ncbiobj.hpp>
39 #include <gui/utils/rgba_color.hpp>
44 #include <math.h>
45 #include <array>
46 
48 
49 class CTraceGraphConfig : public CObject
50 {
51 public:
52  /// chromatogram rendering mode
54  {
57  };
58 
60  {
63  eExpanded
64  };
65  enum EColors
66  {
67  eA_trace = 0,
68  eC_trace = 1,
69  eG_trace = 2,
70  eT_trace = 3
71  };
72 public:
74  {
75  m_colors[eA_trace] = CRgbaColor("255 0 0"); // A channel
76  m_colors[eC_trace] = CRgbaColor("0 255 0"); // C channel
77  m_colors[eG_trace] = CRgbaColor("0 0 255"); // G channel
78  m_colors[eT_trace] = CRgbaColor("128 0 128"); // T channel
79  }
81 
84  bool m_bReverseColors = false; // reverse colors for signals measured on back strand
85  // so that they correspond to assembly sequence rather than to trace sequence
86  int m_Height = 70;
90 };
91 
92 
93 
95 {
96 public:
97  /// @name ctors
98  /// @{
100 
101  ~CTraceGlyph();
102  /// @}
103 
104  /// @name CSeqGlyph virtual methods.
105  /// @{
106  virtual bool OnLeftDblClick(const TModelPoint& /*p*/);
107  virtual bool NeedTooltip(const TModelPoint& p, ITooltipFormatter& tt, string& t_title) const;
108  virtual void GetTooltip(const TModelPoint& /*p*/, ITooltipFormatter& tt, string& t_title) const;
109  virtual void GetHTMLActiveAreas(TAreaVector* p_areas) const;
110  virtual bool IsClickable() const;
111  ///@}
112 
113  // access the position of this object.
114  //virtual TSeqRange GetRange(void) const;
115 
116  const string& GetTitle() const;
117  void SetDesc(const string& desc);
118  const string& GetDesc() const;
119 
120  void SetShowTitle(bool f);
121  void SetDialogHost(IGlyphDialogHost* host);
122 
123 protected:
124  virtual void x_Draw() const;
125  virtual void x_UpdateBoundingBox();
126 protected:
127  int x_GetConfGraphH() const;
128  int x_GetSignalGraphH() const;
129 
130 protected:
134 
135  /// Key for accessing histogram settings.
136  /// It is used only when m_Subtype is eSubtype_any.
137  string m_Desc;
139 
140  mutable vector<CRgbaColor> m_vSignalColors;
141  void x_InitColors() const;
142 
143  void x_RenderContour(CGlPane& pane, int y, int top_h, int total_h) const;
144 
145  // renders confidence graph
146  void x_RenderConfGraph(CGlPane& pane, int y, int h) const;
147 
148  void x_RenderSignalGraph(CGlPane& pane, int y, int h) const;
149 
150  void x_RenderCurveSegment(CGlPane& pane,
151  const CSGTraceData::TPositions& positions,
152  const CSGTraceData::TValues& values,
153  int bottom_y, int /*h*/, int amp) const;
154 
155  void x_RenderIntensityGraphs(CGlPane& pane, int y, int h) const;
156 
157  const CRgbaColor& GetColorByValue(double value, int signal) const;
158 
159  int x_FindSampleToLeft(double pos) const;
160  int x_FindSampleToRight(double pos) const;
161 
162 };
163 
164 ///////////////////////////////////////////////////////////////////////////////
165 /// CTraceGlyph inline method implementation.
166 static const string kTitle = "Traces";
167 inline
168 const string& CTraceGlyph::GetTitle() const
169 { return kTitle; }
170 
171 
172 inline
173 void CTraceGlyph::SetDesc(const string& desc)
174 { m_Desc = desc; }
175 
176 inline
177 const string& CTraceGlyph::GetDesc() const
178 { return m_Desc; }
179 
180 
181 inline
183 { m_DlgHost = host; }
184 
185 
187 
188 /* @} */
189 
190 #endif // GUI_WIDGETS_SEQ_GRAPHIC___TRACE_GLYPH__HPP
class CGlPane
Definition: glpane.hpp:62
CObject –.
Definition: ncbiobj.hpp:180
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
vector< TSignalValue > TValues
vector< TFloatSeqPos > TPositions
class CSeqGlyph defines an interface that wraps a rectilinear abstract object.
Definition: seq_glyph.hpp:82
virtual bool IsClickable() const
Query if this glyph is clickable.
Definition: seq_glyph.hpp:195
virtual void x_Draw() const =0
The default renderer for this layout object.
virtual void GetTooltip(const TModelPoint &, ITooltipFormatter &tt, string &t_title) const
Get the tooltip if available.
Definition: seq_glyph.cpp:136
virtual bool NeedTooltip(const TModelPoint &, ITooltipFormatter &, string &) const
Check if need to show tooltip.
Definition: seq_glyph.cpp:130
virtual bool OnLeftDblClick(const TModelPoint &)
Definition: seq_glyph.cpp:76
virtual void GetHTMLActiveAreas(TAreaVector *) const
Get html active areas.
Definition: seq_glyph.hpp:148
virtual void x_UpdateBoundingBox()=0
Update the bounding box assuming children's sizes are fixed if any.
vector< CHTMLActiveArea > TAreaVector
Definition: seq_glyph.hpp:84
void SetShowTitle(bool f)
vector< CRgbaColor > m_vSignalColors
const string & GetTitle() const
CRef< CTraceGraphConfig > m_Config
const string & GetDesc() const
CRef< CSGTraceData > m_Data
void SetDialogHost(IGlyphDialogHost *host)
IGlyphDialogHost * m_DlgHost
string m_Desc
Key for accessing histogram settings.
void SetDesc(const string &desc)
ESingnalStyle m_SignalStyle
Definition: trace_glyph.hpp:80
CRgbaColor m_colorConfMax
Definition: trace_glyph.hpp:89
ESingnalStyle
chromatogram rendering mode
Definition: trace_glyph.hpp:54
EGraphState m_ConfGraphState
Definition: trace_glyph.hpp:82
EGraphState m_SignalGraphState
Definition: trace_glyph.hpp:83
array< CRgbaColor, 4 > m_colors
Definition: trace_glyph.hpp:87
CRgbaColor m_colorConfMin
Definition: trace_glyph.hpp:88
IGlyphDialogHost An interface used for handling issues related to any dialog pops up that requires so...
Definition: seq_glyph.hpp:399
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
char data[12]
Definition: iconv.c:80
NCBI_XOBJUTIL_EXPORT string GetTitle(const CBioseq_Handle &hnd, TGetTitleFlags flags=0)
Definition: seqtitle.cpp:106
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_SEQGRAPHIC_EXPORT
Definition: gui_export.h:536
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static const string kTitle
CTraceGlyph inline method implementation.
Modified on Tue Apr 30 06:42:41 2024 by modify_doxy.py rev. 669887