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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_SCHEME__HPP
2 #define GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_SCHEME__HPP
3 /* $Id: phylo_tree_scheme.hpp 39666 2017-10-25 16:01:13Z katargir $
4  * ===========================================================================
5  *
6  * PUBLIC DOMAIN NOTICE
7  * National Center for Biotechnology Information
8  *
9  * This software/database is a "United States Government Work" under the
10  * terms of the United States Copyright Act. It was written as part of
11  * the author's official duties as a United States Government employee and
12  * thus cannot be copyrighted. This software/database is freely available
13  * to the public for use. The National Library of Medicine and the U.S.
14  * Government have not placed any restriction on its use or reproduction.
15  *
16  * Although all reasonable efforts have been taken to ensure the accuracy
17  * and reliability of the software and data, the NLM and the U.S.
18  * Government do not and cannot warrant the performance or results that
19  * may be obtained by using this software or data. The NLM and the U.S.
20  * Government disclaim all warranties, express or implied, including
21  * warranties of performance, merchantability or fitness for any particular
22  * purpose.
23  *
24  * Please cite the author in any work or product based on this material.
25  *
26  * ===========================================================================
27  *
28  * Authors: Vladimir Tereshkov
29  *
30  * File Description:
31  *
32  */
33 
34 #include <gui/utils/rgba_color.hpp>
37 
38 class wxArrayString;
39 
41 
43 
44 
45 //"GBPlugins.PhyloTreeView"
46 static const string kPhyloBaseKey("GBPlugins.PhyloTreeView");
47 
49 {
50 public:
51  typedef enum {
54  eMonochrome
55  } TColoration;
56 
57  typedef enum {
61  eLabel
62  } TPhyloTreeObject;
63 
64  typedef enum {
70  eTipSelColor
71  } TPhyloTreeColors;
72 
73  typedef enum {
84  eMinNumChildren
85  } TPhyloTreeSizes;
86 
87  typedef enum {
90  eLabelsHidden
91  } TLabelsVisibility;
92 
93  // Determines if labels going past the edge are truncated or not
94  typedef enum {
96  eLabelsFull
97  } TLabelTruncation;
98 
99  typedef enum {
101  eFancyLabels
102  } TLabelStyle;
103 
104  typedef enum {
107  eAlPaml
108  } TAutoLabels;
109 
110  typedef enum {
112  eHighlightSelection
113  } TSelectionVisibility;
114 
115  typedef enum {eZoomXY, eZoomX, eZoomY} TZoomBehavior;
116 
117 public:
119  virtual ~CPhyloTreeScheme(void) {}
120 
121  // interface functions
122  void SetMargins(const GLdouble & left, const GLdouble & top,
123  const GLdouble & right, const GLdouble & bottom)
124  {
125  m_TopMargin = top;
126  m_BottomMargin = bottom;
127  m_LeftMargin = left;
128  m_RightMargin = right;
129  }
130 
131  void GetMargins(GLdouble & left, GLdouble & top,
132  GLdouble & right, GLdouble & bottom) const
133  {
134  top = m_TopMargin;
135  bottom = m_BottomMargin;
136  left = m_LeftMargin;
137  right = m_RightMargin;
138  }
139 
140  string & SetLabelFormat(void) { return m_LabelFormat; }
141  string & SetTooltipFormat(void) { return m_TooltipFormat; }
142 
143  void SetMaxLabelLength(int len) { m_MaxLabelLength = len; }
144  int GetMaxLabelLength() const { return m_MaxLabelLength; }
145 
146  const TLabelsVisibility & GetLabelVisibility(void) const {
147  return m_LabelVisibility;
148  }
150  m_LabelVisibility = lv;
151  }
152 
154  return m_SelectionVisibility;
155  }
157  m_SelectionVisibility = sv;
158  }
159 
160  // If true (the default) all selected nodes are shown as selected
161  bool GetShowAllSelected() const { return m_ShowAllSelected; }
162  void SetShowAllSelected(bool show_all) { m_ShowAllSelected = show_all; }
163 
164  float GetNonSelectedAlpha() const { return m_NonSelectedAlpha; }
165  void SetNonSelectedAlpha(float a) { m_NonSelectedAlpha = a; }
166 
167  TLabelTruncation& GetLabelTruncation() { return m_LabelTruncation; }
168  void SetLabelTruncation(TLabelTruncation lt) { m_LabelTruncation = lt; }
169 
170  const TLabelStyle & GetLabelStyle(void) const { return m_LabelStyle; }
171  void SetLabelStyle(const TLabelStyle & ls) { m_LabelStyle = ls; }
172 
173  const TColoration & GetColoration(void) const { return m_Coloration; }
174  void SetColoration(const TColoration & col) { m_Coloration = col; }
175 
176  const TAutoLabels & GetAutoLabels(void) const { return m_AutoLabels; }
177  void SetAutoLabels(const TAutoLabels & al) { m_AutoLabels = al; }
178 
179  const CGlTextureFont & GetFont(void) const { return m_Font; }
180  void SetFont(const CGlTextureFont & font) { m_Font = font; }
181 
182  bool GetBoaNodes() const { return m_bBoaNodes; }
183  void SetBoaNodes(bool x_bnodes) { m_bBoaNodes = x_bnodes; }
184 
185  bool GetSolidColorLeaves() const { return m_SolidColorLeaves; }
186  void SetSolidColorLeaves(bool b) { m_SolidColorLeaves = b; }
187 
188  // zoom behavior
189  void SetZoomBehavior(const string& renderer, TZoomBehavior zb);
190  TZoomBehavior GetZoomBehavior(const string& renderer);
191 
192  CRgbaColor & SetColor(TPhyloTreeObject obj, TPhyloTreeColors col);
193  short GetColorIdx(TPhyloTreeObject obj, TPhyloTreeColors col);
194 
195  GLdouble& SetSize(TPhyloTreeSizes obj);
196  GLdouble SetSize(TPhyloTreeSizes obj) const;
197  GLdouble GetLineWidth() const { return m_LineWidth; }
198  GLdouble GetNodeSize() const { return m_NodeSize; }
199  GLdouble GetLeafNodeSize() const { return m_LeafNodeSize; }
200 
201  /// size range for variable-sized collapsed nodes (so min node size here may
202  /// be greater than node size)
203  GLdouble GetMaxNodeSize() const { return m_MaxNodeSize; }
204  GLdouble GetMinNodeSize() const { return m_MinNodeSize; }
205 
206  /// collapsed node sizes are scaled from min to max values based on number of children
207  /// so we need to have that range to do our computation
208  GLdouble GetMinNumChildren() const { return m_MinNumChildren; }
209  GLdouble GetMaxNumChildren() const { return m_MaxNumChildren; }
210  void SetMinNumChildren(GLdouble min_num_children) { m_MinNumChildren = min_num_children; }
211  void SetMaxNumChildren(GLdouble max_num_children) { m_MaxNumChildren = max_num_children; }
212 
213  /// And we scale the length of the collapsed node marker based on the
214  /// max. distance of any child of a collapsed node from the collapsed node
215  /// itself so we need that distance too
216  GLdouble GetMaxBranchDist() const { return m_MaxBranchDist; }
217  void SetMaxBranchDist(GLdouble bd) { m_MaxBranchDist = bd; }
218 
219  void SetLayoutIdx(int lidx) { m_LastLayout = lidx; }
220  int GetLayoutIdx() const { return m_LastLayout; }
221 
222  /// Make sure all current colors used by the scheme are in
223  /// 'color_table' and add the ones that are not.
224  void UpdateColorTable(CRgbaGradColorTable* color_table);
225 
226  virtual bool LoadCurrentSettings();
227  virtual bool SaveCurrentSettings() const;
228 
229  void GetDefaultBroadcastProperties(wxArrayString& wxprops);
230 
231 protected:
232  /// themes
233  string m_CurrTheme;
234  string m_ThemeKey;
239 
240  /// margins
241  GLdouble m_TopMargin;
242  GLdouble m_BottomMargin;
243  GLdouble m_LeftMargin;
244  GLdouble m_RightMargin;
245 
246  /// sizes
247  GLdouble m_LineWidth;
248  GLdouble m_NodeSize;
249  GLdouble m_LeafNodeSize;
250  GLdouble m_MaxNodeSize;
251  GLdouble m_MinNodeSize;
254 
255  // Max distance of any node from root (in current tree). Min is 0.
256  GLdouble m_MaxBranchDist;
257 
258  /// colors
273 
274  /// monochrome colors
289 
290  /// Color indices in color table
305 
320 
321  /// label format
323 
324  /// max label display length (characters). -1=>No max len
326 
327  /// tooltip format
329 
330  /// label visibility
332 
333  /// visibility of selected nodes vs. non selected nodes
335 
336  /// If true (the default) all selected nodes are shown as selected.
337  /// Otherwise only the current node (m_TreeModel->SetCurrentNode()) will
338  /// show as selected (and only if the current node is selected- it
339  /// doesn't have to be).
341 
342  /// alpha value of non-selected glyphs when visibility is eHighlightSelection
344 
345  /// Label truncation (how are labels clipped at edges)
347 
348  /// labels style
350 
351  /// auto-labeling
353 
354  /// zoom behavior by renderer (string is GetDescription() from renderer)
355  std::map<string,TZoomBehavior> m_ZoomBehavior;
356 
358 
360 
361  /// boa - node size behavior
363 
364  /// Solid color leaf nodes (if true)
366 
367  // Last layout selected by user
369 
370  void x_DefaultScheme(void);
371  CRgbaColor & x_SetColorMono(TPhyloTreeObject obj, TPhyloTreeColors col);
372  short x_GetColorMonoIdx(TPhyloTreeObject obj, TPhyloTreeColors col);
373 
374  /// Return a read view of the registry given a base and 2 subkeys
375  CRegistryReadView x_GetReadView(CGuiRegistry& gui_reg,
376  const string& base_key,
377  const string& curr_key,
378  const string& def_key1="") const;
379  /// Return a read-write view of the registry given a base and 2 subkeys
380  CRegistryWriteView x_GetWriteView(CGuiRegistry& gui_reg,
381  const string& base_key,
382  const string& curr_key,
383  const string& def_key1="") const;
384  /// Load a color from the registry
385  bool x_UserFieldToColor(const CRegistryReadView& view,
386  const string& key,
387  CRgbaColor& c);
388  void x_ColorToUserField(CRegistryWriteView& view,
389  const string& key,
390  const CRgbaColor& c) const;
391 
392  /// Check if current color index corresponds to the correct color
393  /// in the color table and, if not, add it.
394  void x_UpdateColorIndex(CRgbaGradColorTable* color_table,
395  const CRgbaColor& current_color,
396  short& current_index);
397 };
398 
399 
401 
402 #endif // GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_SCHEME__HPP
CObject –.
Definition: ncbiobj.hpp:180
GLdouble GetMaxNumChildren() const
TLabelStyle m_LabelStyle
labels style
bool m_SolidColorLeaves
Solid color leaf nodes (if true)
void SetMaxBranchDist(GLdouble bd)
string m_TooltipFormat
tooltip format
CRgbaColor m_NodeTipSelColorMono
CRgbaColor m_LabelSharedColorMono
string & SetTooltipFormat(void)
void SetShowAllSelected(bool show_all)
GLdouble GetMaxNodeSize() const
size range for variable-sized collapsed nodes (so min node size here may be greater than node size)
const TLabelsVisibility & GetLabelVisibility(void) const
GLdouble GetMaxBranchDist() const
And we scale the length of the collapsed node marker based on the max.
void SetBoaNodes(bool x_bnodes)
GLdouble GetLeafNodeSize() const
CRgbaColor m_LineSharedColor
short m_BgColorIdx
Color indices in color table.
void SetFont(const CGlTextureFont &font)
TLabelTruncation & GetLabelTruncation()
void SetLabelStyle(const TLabelStyle &ls)
GLdouble GetLineWidth() const
bool GetSolidColorLeaves() const
void SetColoration(const TColoration &col)
CRgbaColor m_LabelTraceColor
string & SetLabelFormat(void)
void GetMargins(GLdouble &left, GLdouble &top, GLdouble &right, GLdouble &bottom) const
TSelectionVisibility GetSelectionVisibility() const
float GetNonSelectedAlpha() const
CRgbaColor m_BgColorMono
monochrome colors
bool GetShowAllSelected() const
void SetAutoLabels(const TAutoLabels &al)
void SetMaxLabelLength(int len)
void SetSolidColorLeaves(bool b)
const TLabelStyle & GetLabelStyle(void) const
void SetMaxNumChildren(GLdouble max_num_children)
GLdouble GetMinNumChildren() const
collapsed node sizes are scaled from min to max values based on number of children so we need to have...
CRgbaColor m_NodeSharedColor
virtual ~CPhyloTreeScheme(void)
bool m_ShowAllSelected
If true (the default) all selected nodes are shown as selected.
CRgbaColor m_BgColor
colors
void SetLabelVisibility(const TLabelsVisibility &lv)
TSelectionVisibility m_SelectionVisibility
visibility of selected nodes vs. non selected nodes
void SetMargins(const GLdouble &left, const GLdouble &top, const GLdouble &right, const GLdouble &bottom)
CRgbaColor m_LabelSharedColor
int GetMaxLabelLength() const
TLabelTruncation m_LabelTruncation
Label truncation (how are labels clipped at edges)
const TColoration & GetColoration(void) const
CRgbaColor m_NodeTipSelColor
GLdouble m_TopMargin
margins
TAutoLabels m_AutoLabels
auto-labeling
CRgbaColor m_LineSelColorMono
float m_NonSelectedAlpha
alpha value of non-selected glyphs when visibility is eHighlightSelection
CRgbaColor m_LineTraceColorMono
void SetMinNumChildren(GLdouble min_num_children)
CGlTextureFont m_Font
const CGlTextureFont & GetFont(void) const
bool GetBoaNodes() const
CRgbaColor m_NodeSelColorMono
CRgbaColor m_NodeSharedColorMono
GLdouble m_LineWidth
sizes
CRgbaColor m_LineSharedColorMono
void SetLayoutIdx(int lidx)
int m_MaxLabelLength
max label display length (characters). -1=>No max len
const TAutoLabels & GetAutoLabels(void) const
std::map< string, TZoomBehavior > m_ZoomBehavior
zoom behavior by renderer (string is GetDescription() from renderer)
GLdouble GetMinNodeSize() const
CRgbaColor m_LabelSelColorMono
GLdouble GetNodeSize() const
CRgbaColor m_LabelTraceColorMono
void SetSelectionVisibility(const TSelectionVisibility sv)
bool m_bBoaNodes
boa - node size behavior
string m_LabelFormat
label format
TLabelsVisibility m_LabelVisibility
label visibility
string m_CurrTheme
themes
void SetNonSelectedAlpha(float a)
void SetLabelTruncation(TLabelTruncation lt)
CRgbaColor m_NodeTraceColorMono
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CRgbaGradColorTable Provides a storage for colors (to eliminate color creation overhead) and Function...
#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_PHYLO_TREE_EXPORT
Definition: gui_export.h:535
int len
const struct ncbi::grid::netcache::search::fields::KEY key
unsigned int a
Definition: ncbi_localip.c:102
static const string kPhyloBaseKey("GBPlugins.PhyloTreeView")
Modified on Wed Apr 17 13:10:03 2024 by modify_doxy.py rev. 669887