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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___LAYERED_LAYOUT_POLICY__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___LAYERED_LAYOUT_POLICY__HPP
3 
4 /* $Id: layered_layout_policy.hpp 45853 2020-12-17 19:51:53Z 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: Liangshou Wu
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 #include <gui/gui_export.h>
38 
40 
41 ///////////////////////////////////////////////////////////////////////////////
42 /// CLayeredLayout is a standard 2D layout policy.
43 /// This class can perform layout of a number of objects into a single panel of
44 /// multiple rows. All the layout objects are spreaded out vertically with one
45 /// connecting to the other without overlapping.
46 
48  public CObject,
49  public ILayoutPolicy
50 {
51 public:
53  : m_MinDist(0)
54  , m_VertSpace(3)
55  , m_TopMargin(2)
56  , m_MaxRow(-1)
57  , m_Sorted(false)
58  , m_LimitRowPerGroup(true)
59  , m_FillEmptySpaces(true)
60  {}
61 
62  /// access the minimum distance between two objects.
63  /// The distance is in bases.
64  TSeqPos GetMinDist(void) const;
65  int GetVertSpace() const;
66  int GetTopMargin() const;
67  int GetMaxRow();
68 
69  void SetMinDist(TSeqPos dist);
70  void SetVertSpace(int d);
71  void SetTopMargin(int m);
72  void SetMaxRow(int max);
73  void SetMaxHeight(int height);
74  void SetSorted(bool flag);
75  void SetLimitRowPerGroup(bool f);
76 
77  void SetFillEmptySpaces(bool f = true);
78 
79  /// @name ILayoutPolicy interface implementation.
80  /// @{
81  virtual void BuildLayout(CLayoutGroup& group, SBoundingBox& bound) const;
82  /// @}
83 
84 private:
85  /// build the layered layout in favor of object size.
86  /// the larger objects will be arranged first, hence appear
87  /// on the top. This algorithm tends to be more stable in
88  /// terms of object position during zooming in/out, but it
89  /// is more expensive when the object size is large.
90  void x_LayerBySize(CLayoutGroup& group, SBoundingBox& bound) const;
91 
92  /// build the layered layout in favor of object seq position.
93  /// The objects will be sorted by their sequence start position.
94  /// Then arrange accordingly. This algorithm much cheaper compared
95  /// to the previous. It will be used for cases that the object
96  /// number is large.
97  void x_LayerByPos(CLayoutGroup& group, SBoundingBox& bound) const;
98 
99 protected:
100  /// Set the objects' position (Y), and update the bounding
101  /// box of the group (of all objects).
102  virtual void x_SetObjectPos(TLayout& layout, SBoundingBox& bound) const;
103 
104 private:
105  /// The minimum distance we permit two items to be within, horizontally.
109 
110  /// Maximal number of rows allowed.
111  /// Any value <=0 means no limit.
112  int m_MaxRow;
113  bool m_Sorted; ///< layout object already in sorted order.
115 
116  bool m_FillEmptySpaces = true; ///<< default: true, if possible insert new features in between otherwise only add them to the end of the row
117 };
118 
119 ///////////////////////////////////////////////////////////////////////////////
120 /// CLayeredLayout inline methods.
121 ///
122 inline
124 {
125  return m_MinDist;
126 }
127 
128 inline
130 {
131  return m_VertSpace;
132 }
133 
134 inline
136 {
137  return m_TopMargin;
138 }
139 
140 inline
142 {
143  return m_MaxRow;
144 }
145 
146 inline
148 {
149  m_MinDist = dist;
150 }
151 
152 inline
154 {
155  m_VertSpace = d;
156 }
157 
158 inline
160 {
161  m_TopMargin = d;
162 }
163 
164 inline
166 {
167  m_MaxRow = l;
168 }
169 
170 inline
172 {
173  m_Sorted = flag;
174 }
175 
176 inline
178 {
180 }
181 
182 inline
184 {
186 }
187 
189 
190 #endif // GUI_WIDGETS_SEQ_GRAPHIC___LAYERED_LAYOUT_POLICY__HPP
191 
192 
CLayeredLayout is a standard 2D layout policy.
void SetFillEmptySpaces(bool f=true)
void SetMaxHeight(int height)
bool m_Sorted
layout object already in sorted order.
int m_MaxRow
Maximal number of rows allowed.
TSeqPos GetMinDist(void) const
access the minimum distance between two objects.
bool m_FillEmptySpaces
< default: true, if possible insert new features in between otherwise only add them to the end of the...
TSeqPos m_MinDist
The minimum distance we permit two items to be within, horizontally.
void SetMinDist(TSeqPos dist)
void SetLimitRowPerGroup(bool f)
void SetSorted(bool flag)
CLayoutGroup is a container of CSeqGlyphs (layout objects).
CObject –.
Definition: ncbiobj.hpp:180
class ILayoutPolicy defines the abstract interface required for generating layout based on a set of g...
virtual void x_SetObjectPos(TLayout &layout, SBoundingBox &bound) const
Set the objects' position (Y), and update the bounding box of the group (of all objects).
vector< TLayoutRow > TLayout
virtual void BuildLayout(CLayoutGroup &group, SBoundingBox &bound) const =0
Build layout for a list of layout objects.
#define true
Definition: bool.h:35
#define false
Definition: bool.h:36
static FILE * f
Definition: readconf.c:23
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#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
Defines to provide correct exporting from DLLs in Windows.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
T max(T x_, T y_)
T bound(T x_, T xlo_, T xhi_)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Modified on Fri Sep 20 14:57:45 2024 by modify_doxy.py rev. 669887