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

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___HISTOGRAM_CONF_PARAMS__HPP
2 #define GUI_OBJUTILS___HISTOGRAM_CONF_PARAMS__HPP
3 
4 /* $Id: histogram_conf.hpp 42475 2019-03-05 20:47:36Z shkeda $
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  * Author: Liangshou Wu
30  *
31  */
32 
33  /**
34  * File Description:
35  */
36 
37 
38 #include <gui/gui.hpp>
40 #include <gui/utils/rgba_color.hpp>
41 #include <gui/objects/Choice.hpp>
42 
44 
45 ///////////////////////////////////////////////////////////////////////////////
46 /// CHistParams: the data structure holding feature rendering parameters.
47 ///
48 
50 {
51 public:
53 
54  enum EType {
59  eDefaultType = eHistogram
60  };
61 
62  enum EScale {
66  eLoge
67  };
68 
69 
70 public:
72  : m_Height(10)
73  , m_Type(eHistogram)
74  , m_Scale(eLinear)
75  , m_StoredScale(eLinear)
76  , m_NeedRuler(false)
77  , m_DrawBg(false)
78  , m_ClipOutliers(false)
79  , m_SDeviationThreshold(5)
80  , m_Dirty(false)
81  {}
82 
83  static EType TypeStrToValue(const string& type);
84  static const string& TypeValueToStr(CHistParams::EType type);
85 
86  static EScale ScaleStrToValue(const string& scale);
87  static const string& ScaleValueToStr(CHistParams::EScale scale);
88  static const string& ScaleValueToName(CHistParams::EScale scale);
89 
90  /// converts values returned in TMS "stored_scale" attribute (e.g. "log2 scaled") to
91  /// values understood by ScaleStrToValue() and JS code (e.g. "log2")
92  static string ScaleTMSToStr(const string& sScaleTMS);
93 
94  static CRef<objects::CChoice> CreateScaleOptions(const string& option_name, CHistParams::EScale option_value);
95 
96 
97  void SetDirty(bool f) { m_Dirty = f; }
98  bool GetDirty() const { return m_Dirty; }
99 
100 public:
101  /// @name Colors.
102  /// @{
110  CRgbaColor m_OutlierColor{"red"};
112  /// @}
113 
114  /// @name Sizes.
115  /// @{
116  TModelUnit m_Height = 10;
117  /// @}
118 
119  EType m_Type = eHistogram;
120  /// requested scale
121  EScale m_Scale = eLinear;
122 
123  /// stored scale of the underlying data (e.g. as reported by TMS)
124  EScale m_StoredScale = eLinear;
125  bool m_NeedRuler = false;
126  bool m_NeedRulerLabels = true; // not optional, set to false for alignment coverage graphs
127  bool m_DrawBg = false;
128  bool m_ClipOutliers = false;
129  int m_SDeviationThreshold = 5;
130  int m_NumBins = 0; // HeatMap bin number
131  bool m_RangeAutoscale = true;
132  bool m_SmoothCurve = false;
133  int m_FitStep = 4;
135 
136 private:
137  mutable bool m_Dirty = false;
138 };
139 
140 
141 ///////////////////////////////////////////////////////////////////////////////
142 /// CHistParamsManager: class for manage histogram/graph settings for
143 /// all feature subtype and various graphs.
144 ///
145 
147 {
148 public:
150  typedef int TFeatSubtype;
151 
152  void LoadSettings(const string& curr_color, const string& curr_size);
153 
154  void SaveSettings(const string& curr_color, const string& curr_size) const;
155 
156  CRef<CHistParams> GetDefHistParams() const;
157 
158  /// Get histogram settings using feature subtype.
159  /// If there is no settings for the given feature subtype,
160  /// the default one (Master) will be returned.
161  CRef<CHistParams> GetHistParams(TFeatSubtype subtype) const;
162 
163  /// Get histogram settings using a key name.
164  /// If there is no settings for the given name,
165  /// the default one will be returned.
166  CRef<CHistParams> GetHistParams(const string& name) const;
167 
168  /// Check if there is settings for a given name.
169  bool IsTempSettings(const string& name) const;
170 
171  /// Check if there is settings for a given name.
172  bool HasSettings(const string& name) const;
173 
174  /// Check if there is settings for a given feature subtype.
175  bool HasSettings(TFeatSubtype subtype) const;
176 
177 
178  /// Add a new settings for a given name.
179  /// If there exists settings for the given name, then the existing one
180  /// will get modified.
181  void AddSettings(const string& name, CRef<CHistParams> hist_params);
182 
183  /// Add a temporary settings for a given name.
184  void AddTempSettings(const string& name, CRef<CHistParams> hist_params);
185 
186 private:
187  void x_AddSettings(const string& name, CRef<CHistParams> hist_params,
188  THistParams& settings);
189 
190 private:
191  /// cached histogram rendering parameters.
193 
194  /// temporary histogram settings.
195  /// no need to save.
197 
198 };
199 
200 
201 ///////////////////////////////////////////////////////////////////////////////
202 /// CHistParamsManager inline methods
203 ///
204 
205 inline
206 void CHistParamsManager::AddSettings(const string& name,
207  CRef<CHistParams> hist_params)
208 {
209  hist_params->SetDirty(true);
210  x_AddSettings(name, hist_params, m_HistSettings);
211 }
212 
213 inline
214 void CHistParamsManager::AddTempSettings(const string& name,
215  CRef<CHistParams> hist_params)
216 {
217  x_AddSettings(name, hist_params, m_TempHistSettings);
218 }
219 
220 
221 
223 
224 #endif // GUI_OBJUTILS___HISTOGRAM_CONF_PARAMS__HPP
User-defined methods of the data storage class.
#define false
Definition: bool.h:36
CHistParamsManager: class for manage histogram/graph settings for all feature subtype and various gra...
void AddSettings(const string &name, CRef< CHistParams > hist_params)
Add a new settings for a given name.
void AddTempSettings(const string &name, CRef< CHistParams > hist_params)
Add a temporary settings for a given name.
THistParams m_HistSettings
cached histogram rendering parameters.
THistParams m_TempHistSettings
temporary histogram settings.
map< string, CRef< CHistParams > > THistParams
void x_AddSettings(const string &name, CRef< CHistParams > hist_params, THistParams &settings)
File Description:
CRgbaColor m_fgNegColor
map< string, CRgbaColor > TColorSet
CRgbaColor m_SmearColorMin
void SetDirty(bool f)
CRgbaColor m_LabelColor
CRgbaColor m_RulerColor
bool GetDirty() const
TColorSet m_Colors
CRgbaColor m_bgColor
CRgbaColor m_fgColor
CRange< float > m_ValueRange
CRgbaColor m_SmearColorMax
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
GLdouble TModelUnit
Definition: gltypes.hpp:48
#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
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
Definition: type.c:6
Modified on Fri Jan 05 07:25:54 2024 by modify_doxy.py rev. 669887