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

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___TRANSLATION_GLYPH__HPP
2 #define GUI_OBJUTILS___TRANSLATION_GLYPH__HPP
3 
4 /* $Id: translation_glyph.hpp 42821 2019-04-18 19:32:56Z joukovv $
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  */
33 
34 
35 #include <corelib/ncbiobj.hpp>
36 #include <gui/utils/rgba_color.hpp>
39 
40 
42 
43 class CTranslationConfig;
44 
46 {
47 public:
48  enum EFrame {
49  ePositive_One = 0,
55  eFrame_Max
56  };
57 
58  typedef vector<char> TTransSeq;
59  typedef vector<TSeqRange> TORFs;
60  typedef vector<TSeqPos> TCodons;
61 
62  // consturctor
64 
65  CTranslationGlyph(TSeqPos start, TSeqPos stop, EFrame frame);
66 
67  /// @name CSeqGlyph virtual methods.
68  /// @{
69  virtual bool NeedTooltip(const TModelPoint& p, ITooltipFormatter& tt, string& t_title) const;
70  virtual void GetTooltip(const TModelPoint& p, ITooltipFormatter& tt, string& t_title) const;
71  virtual void GetHTMLActiveAreas(TAreaVector* p_areas) const;
72  virtual bool IsClickable() const;
73  ///@}
74 
75  void SetConfig(CTranslationConfig* config);
76 
77  TTransSeq& GetTranslation();
78  const TTransSeq& GetTranslation() const;
79 
80  TORFs& GetOrfs();
81  const TORFs& GetOrfs() const;
82 
83  TCodons& GetStartCodons();
84  const TCodons& GetStartCodons() const;
85 
86  TCodons& GetStopCodons();
87  const TCodons& GetStopCodons() const;
88 
89  void SetStart(TSeqPos start);
90  void SetStop(TSeqPos stop);
91 
92  EFrame GetFrame() const;
93  bool NegativeStrand() const;
94 
95 protected:
96  /// @name CSeqGlyph virtual methods.
97  /// @{
98  virtual void x_Draw() const;
99  virtual void x_UpdateBoundingBox();
100  /// @}
101 
102 private:
103  void x_DrawSequence(TSeqPos start, TSeqPos stop, TSeqPos vis_from,
104  TSeqPos vis_to, TModelUnit center_y, bool negative) const;
105 
106  bool x_Intersecting(TSeqPos f1, TSeqPos t1, TSeqPos f2, TSeqPos t2) const;
107  string x_GetFrameLabel() const;
108 
109 private:
110  TTransSeq m_TransSeq; ///< translation sequence
111  TORFs m_Orfs; ///< Open reading frame list
114  EFrame m_Frame; ///< which frame
115  CRef<CTranslationConfig> m_Config; ///< configuration for rendering
116 };
117 
118 
120 {
121 public:
123  : m_BarHeight(10)
124  , m_OrfThreshold(20)
126  , m_ShowLabel(true)
127  {}
128 
129  void SetStartCodonColor(const CRgbaColor& color);
131  const CRgbaColor& GetStartCodonColor() const;
132 
133  void SetStopCodonColor(const CRgbaColor& color);
135  const CRgbaColor& GetStopCodonColor() const;
136 
139  const CRgbaColor& GetOrfHighlightColor() const;
140 
141  void SetSeqColor(const CRgbaColor& color);
143  const CRgbaColor& GetSeqColor() const;
144 
145  void SetOrfSeqColor(const CRgbaColor& color);
147  const CRgbaColor& GetOrfSeqColor() const;
148 
149  void SetLabelBgColor(const CRgbaColor& color);
151  const CRgbaColor& GetLabelBgColor() const;
152 
153  void SetCommentColor(const CRgbaColor& color);
155  const CRgbaColor& GetCommentColor() const;
156 
157  void SetSeqFont(CGlTextureFont::EFontFace font, unsigned int font_size);
159  const CGlTextureFont& GetSeqFont() const;
160 
161  void SetStrandFont(CGlTextureFont::EFontFace font, unsigned int font_size);
163  const CGlTextureFont& GetStrandFont() const;
164 
165  void SetBarHeight(int h);
166  int GetBarHeight() const;
167 
168  void SetOrfThreshold(int val);
169  int GetOrfThreshold() const;
170 
171  void SetHighlightCodons(bool f);
172  bool GetHighlightCodons() const;
173 
174  void SetShowLabel(bool f);
175  bool ShowLabel() const;
176 
177 private:
191 };
192 
193 
194 ///////////////////////////////////////////////////////////////////////////////
195 /// CTranslationGlyph inline methods
196 ///
197 inline
199 { m_Config.Reset(config); }
200 
201 inline
203 { return m_Orfs; }
204 
205 inline
207 { return m_Orfs; }
208 
209 inline
211 { return m_StartCodons; }
212 
213 inline
215 { return m_StartCodons; }
216 
217 inline
219 { return m_StopCodons; }
220 
221 inline
223 { return m_StopCodons; }
224 
225 inline
227 { return m_TransSeq; }
228 
229 inline
231 { return m_TransSeq; }
232 
233 inline
235 { SetLeft(start); }
236 
237 inline
239 {
240  if (stop < GetLeft()) {
241  SetWidth(GetLeft() - stop);
242  SetStart(stop);
243  } else {
244  SetWidth(stop - GetLeft());
245  }
246 }
247 
248 inline
250 { return m_Frame; }
251 
252 inline
254 { return m_Frame / 3 == 1; }
255 
256 ///////////////////////////////////////////////////////////////////////////////
257 /// CTranslationConfig inline methods
258 ///
259 inline
262 
263 inline
265 { return m_StartCodonColor; }
266 
267 inline
269 { return m_StartCodonColor; }
270 
271 inline
273 { m_StopCodonColor = color; }
274 
275 inline
277 { return m_StopCodonColor; }
278 
279 inline
281 { return m_StopCodonColor; }
282 
283 inline
286 
287 inline
289 { return m_OrfHighlightColor; }
290 
291 inline
293 { return m_OrfHighlightColor; }
294 
295 inline
297 { m_SeqColor = color; }
298 
299 inline
301 { return m_SeqColor; }
302 
303 inline
305 { return m_SeqColor; }
306 
307 inline
309 { m_OrfSeqColor = color; }
310 
311 inline
313 { return m_OrfSeqColor; }
314 
315 inline
317 { return m_OrfSeqColor; }
318 
319 inline
321 { m_LabelBgColor = color; }
322 
323 inline
325 { return m_LabelBgColor; }
326 
327 inline
329 { return m_LabelBgColor; }
330 
331 inline
333 { m_CommentColor = color; }
334 
335 inline
337 { return m_CommentColor; }
338 
339 inline
341 { return m_CommentColor; }
342 
343 inline
345 { m_SeqFont.SetFontFace(font); m_SeqFont.SetFontSize(font_size); }
346 
347 inline
349 { return m_SeqFont; }
350 
351 inline
353 { return m_SeqFont; }
354 
355 inline
357 { m_StrandFont.SetFontFace(font); m_StrandFont.SetFontSize(font_size); }
358 
359 inline
361 { return m_StrandFont; }
362 
363 inline
365 { return m_StrandFont; }
366 
367 inline
369 { m_BarHeight = h; }
370 
371 inline
373 { return m_BarHeight; }
374 
375 inline
377 { m_OrfThreshold = val; }
378 
379 inline
381 { return m_OrfThreshold; }
382 
383 inline
385 { m_HighlightCodons = f; }
386 
387 inline
389 { return m_HighlightCodons; }
390 
391 inline
393 { m_ShowLabel = f; }
394 
395 inline
397 { return m_ShowLabel; }
398 
400 
401 /* @} */
402 
403 #endif // GUI_OBJUTILS___TRANSLATION_GLYPH__HPP
CObject –.
Definition: ncbiobj.hpp:180
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
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 SetWidth(TModelUnit w)
Definition: seq_glyph.hpp:646
virtual void SetLeft(TModelUnit l)
Definition: seq_glyph.hpp:654
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.
virtual TModelUnit GetLeft() const
Definition: seq_glyph.hpp:595
vector< CHTMLActiveArea > TAreaVector
Definition: seq_glyph.hpp:84
void SetOrfHighlightColor(const CRgbaColor &color)
CRgbaColor & GetStopCodonColor()
void SetSeqColor(const CRgbaColor &color)
void SetLabelBgColor(const CRgbaColor &color)
CGlTextureFont & GetSeqFont()
bool GetHighlightCodons() const
void SetStartCodonColor(const CRgbaColor &color)
CTranslationConfig inline methods.
void SetOrfSeqColor(const CRgbaColor &color)
CRgbaColor & GetLabelBgColor()
CGlTextureFont & GetStrandFont()
void SetStopCodonColor(const CRgbaColor &color)
CRgbaColor & GetCommentColor()
void SetHighlightCodons(bool f)
void SetSeqFont(CGlTextureFont::EFontFace font, unsigned int font_size)
CGlTextureFont m_StrandFont
CRgbaColor & GetOrfSeqColor()
void SetStrandFont(CGlTextureFont::EFontFace font, unsigned int font_size)
void SetCommentColor(const CRgbaColor &color)
CGlTextureFont m_SeqFont
void SetOrfThreshold(int val)
CRgbaColor & GetStartCodonColor()
CRgbaColor & GetOrfHighlightColor()
CRgbaColor & GetSeqColor()
void SetStop(TSeqPos stop)
vector< char > TTransSeq
EFrame GetFrame() const
vector< TSeqRange > TORFs
TORFs m_Orfs
Open reading frame list.
void SetStart(TSeqPos start)
TTransSeq m_TransSeq
translation sequence
EFrame m_Frame
which frame
CRef< CTranslationConfig > m_Config
configuration for rendering
void SetConfig(CTranslationConfig *config)
CTranslationGlyph inline methods.
TTransSeq & GetTranslation()
vector< TSeqPos > TCodons
bool NegativeStrand() const
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
#define true
Definition: bool.h:35
static FILE * f
Definition: readconf.c:23
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
GLdouble TModelUnit
Definition: gltypes.hpp:48
void SetFontFace(EFontFace face, bool use_bitmap_overrides=true)
EFontFace
Set of pre-defined fonts for which we know we have valid font files.
void SetFontSize(unsigned int size)
Set/get font size in points.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#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
n background color
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
T negative(T x_)
Modified on Fri Sep 20 14:57:39 2024 by modify_doxy.py rev. 669887