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

Go to the SVN repository for this file.

1 #ifndef __GUI_WIDGETS_ALNMULTI___ROW_DISPLAY_STYLE__HPP
2 #define __GUI_WIDGETS_ALNMULTI___ROW_DISPLAY_STYLE__HPP
3 
4 /* $Id: row_display_style.hpp 44974 2020-04-30 18:27:28Z 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  * Authors: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 
38 
39 #include <gui/utils/rgba_color.hpp>
40 
42 #include <gui/opengl/irender.hpp>
43 
45 #include <gui/opengl/gltexture.hpp>
48 
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// CWidgetDisplayStyle is a collection of display properties common for all
53 /// rows in the CAlnMultiWidget.
54 
56 {
57 public:
59 
60  enum EColorType {
61  eInvalid = -1,
70  eAlignSegsNoScores /// this color is used when scoring is enabled but
71  /// cannot be displayed because of the scale
72  };
73 
74  struct SColumn {
75  string m_Name;
76  int m_Width;
77  int m_Visible;
78  };
79  typedef vector<SColumn> TColumns;
80 
81  CWidgetDisplayStyle(void);
83  virtual ~CWidgetDisplayStyle(void) {};
84 
85  virtual const CRgbaColor& GetColor(EColorType type) const;
86  virtual void SetColor(EColorType type, const CRgbaColor& color);
87 
88  void LoadSettings(const CRegistryReadView& view);
89  void SaveSettings(CRegistryWriteView view, IAlnExplorer::EAlignType type);
90 
91 protected:
92  void ReadColor(EColorType type, const CRegistryReadView& view, const string& key);
93  void x_GetColor(EColorType type, const CRgbaColor& c);
94 
95 public:
96  CGlTextureFont m_TextFont; /// text font (description, positions etc.)
97  CGlTextureFont m_SeqFont; /// sequence font
98  bool m_ShowIdenticalBases; // If false, don't draw base letters matching master row
99  bool m_ShowConsensus; // Show consensus if available (sparse align has no consensu track)
100 
102 
103  string m_DefDNAMethod; /// default scoring method for DNA alignments
104  string m_DefProteinMethod; /// default scoring method for protein alignments
105 
106  string m_DotImage; ///< png file name - image for identical dot (14x14, 16x16)
107 
108 protected:
110 };
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 /// CRowDisplayStyle is a base class representing a display style for IAlignRow.
114 ///
115 /// CRowDisplayStyle plays a role of Proxy providing functions for accessing
116 /// display properties actually stored in a widget.
117 
119 {
120 public:
122  fShown_Alignment = 8,
123  fShown_Track = 16,
124  fShown_All = 0xFF
125  };
127 
129  virtual ~CRowDisplayStyle(void);
130 
131  virtual void SetWidgetStyle(const CWidgetDisplayStyle* style);
132 
133  /// @name Proxy methods
134  /// provide access to the Widget display style properties
135  /// @{
136  virtual const CGlTextureFont& GetTextFont(void) const;
137  virtual const CGlTextureFont& GetSeqFont(void) const;
138  virtual bool GetShowIdenticalBases(void) const;
139 
140  virtual const CRgbaColor& GetColor(TColorType type) const;
141  /// @}
142 
143  void SetShownElements(int shown_mask);
144  int GetShownElements() const;
145 
146  void SetSeqGraphicConfig(CRef<CSeqGraphicConfig>& config);
147  CRef<CSeqGraphicConfig> GetSeqGraphicConfig() const;
148 
149  void SetTrackSettings(const CTrackConfigManager::TTrackProxies& track_settings);
150  const CTrackConfigManager::TTrackProxies& GetTrackSettings() const;
151 
152  void SetTrackConfigKey(const string& config_key);
153  const string& GetTrackConfigKey() const;
154 
155  void SetDotTexture(CRef<CGlTexture>& dot_texture);
156  CRef<CGlTexture> GetDotTexture() const;
157 
158  // Rendering happens in Browser (not gbench or pdf/svg prinout)
159  bool IsWebRendering() const {
160  return GetSeqGraphicConfig()->GetCgiMode() && !GetGl().IsPrinterFriendly();
161  }
162 
163 protected:
164  const CWidgetDisplayStyle* m_WidgetStyle; /// pointer to Widget's style
165  int m_ShownElements = fShown_All;
167 
169  string m_TrackConfigKey = "GBPlugins.MSAFeatPanel";
170 
172 
173 
174 };
175 
176 ////////////////////////////////////////////////////////////////////////////////
177 /// CRowStyleCatalog is a collection of CRowDisplayStyle-s assigned to rows
178 /// in alignment.
179 /// By default all rows have the same style but can be customized by...
180 
182 {
183 public:
184  typedef int TNumrow;
185 
187  ~CRowStyleCatalog();
188 
189  void SetWidgetStyle(const CWidgetDisplayStyle* style);
190 
191  /// assumes ownership
192  void SetDefaultStyle(CRowDisplayStyle* style);
193 
194  void SetRowStyle(TNumrow row, CRowDisplayStyle* style);
195  void SetRowTypeStyle(int type, CRowDisplayStyle* style);
196 
197  const CRowDisplayStyle* GetStyleForRow(TNumrow row) const;
198  const CRowDisplayStyle* GetStyleForRow(TNumrow row, int type) const;
199 
200  void ClearCustomStyles();
201 
202 protected:
205 
208 
209  TRowToStyle m_RowToStyle; /// overriden styles for rows
210  TTypeToStyle m_TypeToStyle; /// overriden styles for row types
211 };
212 
213 inline
215 {
216  m_ShownElements = shown_mask;
217 }
218 
219 inline
221 {
222  return m_ShownElements;
223 }
224 
225 
226 inline
228 {
229  m_gConfig = config;
230 }
231 
232 inline
234 {
235  m_TrackSettings = track_settings;
236 }
237 
238 inline
240 {
241  return m_TrackSettings;
242 }
243 
244 inline
245 void CRowDisplayStyle::SetTrackConfigKey(const string& config_key)
246 {
247  m_TrackConfigKey = config_key;
248 }
249 
250 inline
252 {
253  return m_TrackConfigKey;
254 }
255 
256 
257 inline
259 {
260  m_DotTexture = dot_texture;
261 }
262 
263 inline
265 {
266  return m_DotTexture;
267 }
268 
269 
270 
271 
273 
274 #endif // __GUI_WIDGETS_ALNMULTI___ROW_DISPLAY_STYLE__HPP
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
CRowDisplayStyle is a base class representing a display style for IAlignRow.
void SetTrackSettings(const CTrackConfigManager::TTrackProxies &track_settings)
CRef< CGlTexture > GetDotTexture() const
void SetDotTexture(CRef< CGlTexture > &dot_texture)
const CWidgetDisplayStyle * m_WidgetStyle
void SetTrackConfigKey(const string &config_key)
int GetShownElements() const
CRef< CSeqGraphicConfig > m_gConfig
int m_ShownElements
pointer to Widget's style
const string & GetTrackConfigKey() const
CWidgetDisplayStyle::EColorType TColorType
void SetShownElements(int shown_mask)
CRef< CGlTexture > m_DotTexture
void SetSeqGraphicConfig(CRef< CSeqGraphicConfig > &config)
const CTrackConfigManager::TTrackProxies & GetTrackSettings() const
bool IsWebRendering() const
CTrackConfigManager::TTrackProxies m_TrackSettings
CRowStyleCatalog is a collection of CRowDisplayStyle-s assigned to rows in alignment.
map< TNumrow, CRowDisplayStyle * > TRowToStyle
TTypeToStyle m_TypeToStyle
overriden styles for rows
map< int, CRowDisplayStyle * > TTypeToStyle
CRowDisplayStyle * m_DefStyle
const CWidgetDisplayStyle * m_WidgetStyle
CTempTrackProxy::TTrackProxies TTrackProxies
CWidgetDisplayStyle is a collection of display properties common for all rows in the CAlnMultiWidget.
bool m_ShowIdenticalBases
sequence font
string m_DefProteinMethod
default scoring method for DNA alignments
CGlTextureFont m_TextFont
map< int, CRgbaColor > TColorMap
vector< SColumn > TColumns
CGlTextureFont m_SeqFont
text font (description, positions etc.)
virtual ~CWidgetDisplayStyle(void)
string m_DotImage
default scoring method for protein alignments
struct config config
CRgbaColor & GetColor(CSeqFeatData::ESubtype subtype)
IRender & GetGl()
convenience function for getting current render manager
virtual bool IsPrinterFriendly() const =0
EFontFace
Set of pre-defined fonts for which we know we have valid font files.
#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_ALNMULTIPLE_EXPORT
Definition: gui_export.h:520
n background color
EColorType
Definition: map_control.hpp:48
const struct ncbi::grid::netcache::search::fields::KEY key
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
#define row(bind, expected)
Definition: string_bind.c:73
Definition: type.c:6
Modified on Sun Jun 23 05:21:01 2024 by modify_doxy.py rev. 669887