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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___SEGMENT_SMEAR_GLYPH__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___SEGMENT_SMEAR_GLYPH__HPP
3 
4 /* $Id: segment_smear_glyph.hpp 46008 2021-01-21 12:55:41Z grichenk $
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: Liangshou Wu
30  *
31  * File Description:
32  * CSegmentSmearGlyph -- a smear bar to represent a segments map
33  */
34 
35 
36 #include <corelib/ncbiobj.hpp>
39 
41 
42 class IReader;
43 class IWriter;
44 
46 {
47 public:
48  typedef unsigned int TValueType;
49  typedef vector<CRgbaColor> TColorCode;
50 
51  class CSegMap :
52  public CDensityMap<TValueType>
53  {
54  public:
55  CSegMap(TSeqPos start = 0, TSeqPos stop = 0, double window = 1, accum_functor* func = NULL, TValueType def = 0) :
56  CDensityMap(start, stop, window, func, def),
57  m_ReservedCount(1000)
58  {}
59  CSegMap(const objects::CBioseq_Handle& handle, double window = 1, accum_functor* func = NULL, TValueType def = 0) :
60  CDensityMap(handle, window, func, def),
61  m_ReservedCount(1000)
62  {}
63 
64  void AddRange(TSeqRange range, TValueType score = 1, bool expand = false);
65  void AddRanges(CRangeCollection<TSeqPos> ranges, TValueType score = 1, bool expand = false);
66 
67  void Serialize(IWriter& writer) const;
68  void Deserialize(IReader& reader);
69  void SetRange(const TSeqRange& range);
70  void GetGaps(const TModelRange& range, vector<TSeqRange>& gaps);
71  private:
72  struct SRangeItem
73  {
77  };
79  std::vector<SRangeItem> m_RangesCache;
80  };
81 
83 
84  /// @name CSeqGlyph virtual methods.
85  /// @{
86  virtual bool NeedTooltip(const TModelPoint& p, ITooltipFormatter& tt, string& t_title) const;
87  virtual void GetTooltip(const TModelPoint& p, ITooltipFormatter& tt, string& t_title) const;
88  virtual bool IsClickable() const;
89  /// @}
90 
91  void SetColorCode(const TColorCode& colors);
92 
93 protected:
94  virtual void x_Draw() const;
95  virtual void x_UpdateBoundingBox();
96 
97  void x_DrawGaps() const;
98 
99 private:
100  unique_ptr<CSegMap> m_SegMap;
101 
102  /// color code for segment map.
104 };
105 
106 
107 ///////////////////////////////////////////////////////////////////////////////
108 /// CSegmentSmearGlyph inline methods
109 ///
110 inline
112 {
113  m_Colors = colors;
114 }
115 
116 
118 
119 
120 #endif // GUI_WIDGETS_SEQ_GRAPHIC___SEGMENT_SMEAR_GLYPH__HPP
class CDensityMap generates a low-resolution view of a set of features.
CSegMap(TSeqPos start=0, TSeqPos stop=0, double window=1, accum_functor *func=NULL, TValueType def=0)
std::vector< SRangeItem > m_RangesCache
CSegMap(const objects::CBioseq_Handle &handle, double window=1, accum_functor *func=NULL, TValueType def=0)
vector< CRgbaColor > TColorCode
unique_ptr< CSegMap > m_SegMap
void SetColorCode(const TColorCode &colors)
CSegmentSmearGlyph inline methods.
TColorCode m_Colors
color code for segment map.
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 void x_UpdateBoundingBox()=0
Update the bounding box assuming children's sizes are fixed if any.
A very basic data-read interface.
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
A very basic data-write interface.
Definition: map.hpp:338
static const Colors colors
Definition: cn3d_colors.cpp:50
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define NULL
Definition: ncbistd.hpp:225
#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
range(_Ty, _Ty) -> range< _Ty >
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
TEMPLATE binary functor base struct.
Definition: density_map.hpp:59
void Serialize(CNcbiOstream &, const CRawScoreVector< Key, Score > &)
Generics These throw an exception; we must implement serialization for each type.
void Deserialize(CNcbiIstream &istr, CRawScoreVector< Key, Score > &)
Modified on Fri May 03 15:51:42 2024 by modify_doxy.py rev. 669887