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

Go to the SVN repository for this file.

1 #ifndef GUI_UTILS___SIMPLE_LAYOUT_POLICY__HPP
2 #define GUI_UTILS___SIMPLE_LAYOUT_POLICY__HPP
3 
4 /* $Id: simple_layout_policy.hpp 34827 2016-02-17 00:59:08Z rudnev $
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 
35 
36 
38 
39 ///////////////////////////////////////////////////////////////////////////////
40 /// CSimpleLayout is the simpliest layout policy that simply stack
41 /// a set of glyphs one on top of the other vertically.
42 ///
44  public CObject,
45  public ILayoutPolicy
46 {
47 public:
48  enum ESortingType {
50  eSort_BySeqPos, ///< seq start position
51  eSort_BySeqSize ///< sequence length
52  //eSort_ByName
53  };
54 
56 
58  : m_VertSpace(3)
59  , m_TopMargin(2)
60  , m_SortingType(eSort_No) {}
61 
62  virtual void BuildLayout(CLayoutGroup& group, SBoundingBox& bound) const;
63 
64  int GetVertSpace() const;
65  int GetTopMargin() const;
66  TSortingMethod GetSortingType() const;
67 
68  void SetVertSpace(int d);
69  void SetTopMargin(int m);
70  void SetSortingType(TSortingMethod meth);
71 
72 private:
76 };
77 
78 
79 ///////////////////////////////////////////////////////////////////////////////
80 /// CInlineLayout is the anther simple layout policy that put a list of
81 /// glyphs in a single line horizontally sorted by glyph's start position.
82 /// Additionally, if a glyph has sided label, the policy will force to
83 /// hide its label when there is not enough space between glyphs to fit
84 /// the label.
85 ///
87  public CObject,
88  public ILayoutPolicy
89 {
90 public:
92  : m_TopMargin(2)
93  , m_AllowOverlap(true) {}
94 
95  CInlineLayout(bool allow_overlap)
96  : m_TopMargin(2)
97  , m_AllowOverlap(allow_overlap) {}
98 
99  virtual void BuildLayout(CLayoutGroup& group, SBoundingBox& bound) const;
100  void BuildLayout(TObjectList& objs, SBoundingBox& bound) const;
101 
102  int GetTopMargin() const;
103  void SetTopMargin(int d);
104 
105  void SetAllowOverlap(bool flag);
106 
107 private:
108  void x_BuildLayout1Row(TObjectList& objects,
109  SBoundingBox& bound, bool side_labeling) const;
110 
111  void x_BuildLayoutMultiRows(TObjectList& objects,
112  SBoundingBox& bound,bool side_labeling) const;
113 
114 private:
117 };
118 
119 
120 ///////////////////////////////////////////////////////////////////////////////
121 /// COverlayLayout is the layout policy that arranges glyphs over the top of each other
122 ///
124  public CObject,
125  public ILayoutPolicy
126 {
127 public:
128  virtual void BuildLayout(CLayoutGroup& group, SBoundingBox& bound) const;
129 private:
130 };
131 
132 
133 
134 ///////////////////////////////////////////////////////////////////////////////
135 /// CSimpleLayout inline method implementation
136 ///
137 inline
139 {
140  return m_VertSpace;
141 }
142 
143 inline
145 {
146  return m_TopMargin;
147 }
148 
149 inline
151 {
152  return m_SortingType;
153 }
154 
155 inline
157 {
158  m_VertSpace = d;
159 }
160 
161 inline
163 {
164  m_TopMargin = m;
165 }
166 
167 inline
169 {
170  m_SortingType = meth;
171 }
172 
173 ///////////////////////////////////////////////////////////////////////////////
174 /// CInlineLayout inline method implementation
175 ///
176 inline
178 {
179  return m_TopMargin;
180 }
181 
182 inline
184 {
185  m_TopMargin = m;
186 }
187 
188 inline
190 {
191  m_AllowOverlap = flag;
192 }
193 
195 
196 #endif // GUI_UTILS___SIMPLE_LAYOUT_POLICY__HPP
#define true
Definition: bool.h:35
CInlineLayout is the anther simple layout policy that put a list of glyphs in a single line horizonta...
CInlineLayout(bool allow_overlap)
void SetAllowOverlap(bool flag)
int GetTopMargin() const
CInlineLayout inline method implementation.
CLayoutGroup is a container of CSeqGlyphs (layout objects).
CObject –.
Definition: ncbiobj.hpp:180
COverlayLayout is the layout policy that arranges glyphs over the top of each other.
CSimpleLayout is the simpliest layout policy that simply stack a set of glyphs one on top of the othe...
TSortingMethod m_SortingType
ESortingType TSortingMethod
@ eSort_BySeqPos
seq start position
int GetVertSpace() const
CSimpleLayout inline method implementation.
TSortingMethod GetSortingType() const
void SetSortingType(TSortingMethod meth)
class ILayoutPolicy defines the abstract interface required for generating layout based on a set of g...
virtual void BuildLayout(CLayoutGroup &group, SBoundingBox &bound) const =0
Build layout for a list of layout objects.
#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
T bound(T x_, T xlo_, T xhi_)
Modified on Tue Feb 27 05:57:03 2024 by modify_doxy.py rev. 669887