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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_POLICY__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_POLICY__HPP
3 
4 /* $Id: 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  * Author: Liangshou Wu
30  *
31  */
32 
33  /**
34  * File Description:
35  */
36 
37 #include <corelib/ncbiobj.hpp>
38 #include <gui/opengl/gltypes.hpp>
39 #include <gui/gui_export.h>
40 #include <list>
41 
43 
44 class CSeqGlyph;
45 class CLayoutGroup;
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 /// class ILayoutPolicy defines the abstract interface required for
49 /// generating layout based on a set of given CSeqGlyphs (layout objects).
50 ///
51 
53 {
54 public:
55  typedef list< CRef<CSeqGlyph> > TObjectList;
56  typedef vector< CRef<CSeqGlyph> > TLayoutRow;
57  typedef vector<TLayoutRow> TLayout;
58  typedef std::function<bool(const CRef<CSeqGlyph>&, const CRef<CSeqGlyph>&)> TSorter;
59 
60  struct SBoundingBox {
65  };
66 
67  virtual ~ILayoutPolicy() {}
68 
69  /// Build layout for a list of layout objects.
70  /// @param bound the bounding box for all objects
71  virtual void BuildLayout(CLayoutGroup& group, SBoundingBox& bound) const = 0;
72 
73  void SetSorter(TSorter& sorter) {
74  m_Sorter.swap(sorter);
75  }
76 
77 protected:
78  /// Separate objects into multiple sub-groups.
79  /// This is for rendering performance consideration. By creating
80  /// multiple groups, the visibility detection can be done more
81  /// efficiently based on group boundary such that the whole group
82  /// of objects can be skipped from rendering if it is not visible
83  /// to users.
84  void x_SeparateObjects(CLayoutGroup& group, TLayout& layout,
85  SBoundingBox& bound, size_t group_size, int vert_space) const;
86 
87  /// Set the objects' position (Y), and update the bounding
88  /// box of the group (of all objects).
89  virtual void x_SetObjectPos(TLayout& layout, SBoundingBox& bound) const {};
90 
91  TSorter m_Sorter = nullptr;
92 
93 };
94 
95 
97 
98 #endif //GUI_WIDGETS_SEQ_GRAPHIC___LAYOUT_POLICY__HPP
#define bool
Definition: bool.h:34
CLayoutGroup is a container of CSeqGlyphs (layout objects).
class CSeqGlyph defines an interface that wraps a rectilinear abstract object.
Definition: seq_glyph.hpp:82
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.
void SetSorter(TSorter &sorter)
virtual ~ILayoutPolicy()
list< CRef< CSeqGlyph > > TObjectList
vector< CRef< CSeqGlyph > > TLayoutRow
std::function< bool(const CRef< CSeqGlyph > &, const CRef< CSeqGlyph > &)> TSorter
GLdouble TModelUnit
Definition: gltypes.hpp:48
#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 bound(T x_, T xlo_, T xhi_)
Modified on Sun Mar 03 03:13:00 2024 by modify_doxy.py rev. 669887