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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___COMMENT_GLYPH__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___COMMENT_GLYPH__HPP
3 
4 /* $Id: comment_glyph.hpp 35878 2016-07-05 18:06:44Z evgeniev $
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>
39 #include <gui/utils/rgba_color.hpp>
40 
41 
43 
44 class CCommentConfig;
45 
46 ///////////////////////////////////////////////////////////////////////////////
47 /// CCommentGlyph -- utility class for having comments in graphical glyphs.
48 /// For most of cases, a comment glyph may serve as a label for another glyph.
49 /// In those cases, a comment will be linked to a glyph, and the comment will
50 /// behave like a delegate of that linked glyph. Since the linked glyph can
51 /// be a object-based glyph, so is the comment.
52 
54  : public CSeqGlyph
55  //, public IObjectBasedGlyph
56 {
57 public:
58  CCommentGlyph(const string& comment, CRef<CSeqGlyph> glyph);
59  CCommentGlyph(const string& comment, const TModelPoint& pos, bool repeated = false);
60 
61  /// @name CSeqGlyph virtual methods.
62  /// @{
63  virtual bool NeedTooltip(const TModelPoint& p, ITooltipFormatter& tt, string& t_title) const;
64  virtual void GetTooltip(const TModelPoint& p, ITooltipFormatter& tt, string& t_title) const;
65  // do we need this for comment glyh
66  //virtual void GetHTMLActiveAreas(TAreaVector* p_areas) const;
67  /// @}
68 
69  ///// @name IObjectBasedGlyph interface implement
70  ///// @{
71  ///// Access the remapped location.
72  //const objects::CSeq_loc& GetLocation(void) const;
73  ///// Access the data as a CObject.
74  //virtual CConstRef<CObject> GetObject(TSeqPos pos) const;
75  //virtual void GetObjects(vector<CConstRef<CObject> >& objs) const;
76  //virtual bool HasObject(CConstRef<CObject> obj) const;
77  //virtual const TIntervals& GetIntervals(void) const;
78  ///// @}
79  const TModelPoint& GetTargetPos() const;
80  void SetTargetPos(const TModelPoint& pos);
81  void SetConfig(CConstRef<CCommentConfig> config);
82 
83  CRef<CSeqGlyph> GetLinkedGlyph();
84 
85 protected:
86  virtual void x_Draw() const;
87  virtual void x_UpdateBoundingBox();
88 
89 protected:
90  CRef<CSeqGlyph> m_LinkedGlyph; ///< associated glyph
91  string m_Comment; ///< label
92  TModelPoint m_TargetPos; ///< target position (if glyph not set)
93  bool m_Repeated;
94 
96 };
97 
98 ///////////////////////////////////////////////////////////////////////////////
99 /// CCommentConfig -- help config class for holding a set of settings for
100 /// a comment glyph.
101 class CCommentConfig : public CObject
102 {
103 public:
104  enum EPosition {
110  ePos_Any
111  };
112 
115  , m_LabelColor(0.0f, 0.0f, 0.0f)
116  , m_LineColor(0.0f, 0.0f, 1.0f)
117  , m_Font(CGlTextureFont::eFontFace_Helvetica, 10)
120  , m_Centered(true)
121  {}
122 
123  /// relative position between the comment and target.
129 
130  /// display a connection between the comment and target.
132  /// label is centered against the target.
134 };
135 
136 
137 ///////////////////////////////////////////////////////////////////////////////
138 /// CCommentGlyph inline methods
139 ///
140 inline
142 {
143  return m_TargetPos;
144 }
145 
146 inline
148 {
149  m_TargetPos = pos;
150 }
151 
152 inline
154 {
155  m_Config = config;
156 }
157 
158 
159 inline
161 {
162  return m_LinkedGlyph;
163 }
164 
166 
167 /* @} */
168 
169 #endif // GUI_WIDGETS_SEQ_GRAPHIC___COMMENT_GLYPH__HPP
CCommentConfig – help config class for holding a set of settings for a comment glyph.
CRgbaColor m_LineColor
CGlTextureFont m_Font
CRgbaColor m_LabelColor
bool m_Centered
label is centered against the target.
bool m_ShowConnection
display a connection between the comment and target.
EPosition m_RelativePos
relative position between the comment and target.
CCommentGlyph – utility class for having comments in graphical glyphs.
string m_Comment
label
CRef< CSeqGlyph > GetLinkedGlyph()
void SetTargetPos(const TModelPoint &pos)
TModelPoint m_TargetPos
target position (if glyph not set)
CConstRef< CCommentConfig > m_Config
const TModelPoint & GetTargetPos() const
CCommentGlyph inline methods.
CRef< CSeqGlyph > m_LinkedGlyph
associated glyph
void SetConfig(CConstRef< CCommentConfig > config)
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 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.
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
struct config config
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
#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
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Tue Apr 30 06:41:53 2024 by modify_doxy.py rev. 669887