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

Go to the SVN repository for this file.

1 #ifndef GUI_UTILS___VISIBLE_RANGE__HPP
2 #define GUI_UTILS___VISIBLE_RANGE__HPP
3 
4 /* $Id: visible_range.hpp 40878 2018-04-25 19:54:29Z katargir $
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: Yury Voronov, Vladimir Tereshkov, Andrey Yazhuk, Mike Dicuccio
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 #include <gui/gui_export.h>
37 
39 #include <objmgr/scope.hpp>
40 
42 
44 {
45 public:
46  enum EBasicPolicy {
52  eBasic_Ignore
53  };
54 
55  typedef list< CConstRef<objects::CSeq_loc> > TLocations;
56 
57  CVisibleRange( objects::CScope& scope );
58  ~CVisibleRange();
59 
60  void SetVisibleRangePolicy(EBasicPolicy policy) { m_Policy = policy; }
61 
62  void AddLocation( const objects::CSeq_loc& loc );
63  const TLocations& GetLocations() const;
64 
65  /// See if we can match the supplied range
66  bool Match( const objects::CSeq_id& id ) const;
67 
68  /// Alter the supplied range according to the rules provided in the
69  /// policy and the supplied new location
70  bool Clamp( const objects::CBioseq_Handle& handle, TSeqRange& range ) const;
71 
72  /// Alter the supplied location according to the rules provided in the
73  /// policy and the supplied new location
74  bool Clamp( objects::CSeq_loc& loc ) const;
75 
76 public:
77  static bool IsAutoBroadcast() { return sm_AutoBroadcast; }
78  static void SetAutoBroadcast( bool flag ){ sm_AutoBroadcast = flag; }
79 
80  static EBasicPolicy GetDefaultVisibleRangePolicy() { return sm_DefaultPolicy; }
81  static void SetDefaultVisibleRangePolicy(EBasicPolicy policy) { sm_DefaultPolicy = policy; }
82 
83 private:
84  /// enum controlling policy for response to a change in visible range
85  enum EPolicy {
86  eDefault = 0,
87 
88  /// position tracking options
89  ePositionMask = 0xff,
90  ePosition_Ignore = 1,
91  ePosition_Track = 2,
92  ePosition_TrackCenter = 3,
93  ePosition_Slave = 4,
94 
95  /// location scale tracking options
96  eScaleMask = 0xff << 8,
97  eScale_Ignore = 1 << 8,
98  eScale_Expand = 2 << 8,
99  eScale_Contract = 3 << 8,
100  eScale_TrackRatio = 4 << 8,
101  eScale_TrackScale = 5 << 8,
102  eScale_Slave = 6 << 8,
103 
104  /// combination options
105  eVisible_Ignore = ePosition_Ignore | eScale_Ignore,
106  eVisible_Slave = ePosition_Slave | eScale_Slave,
107  eVisible_Track = ePosition_Track,
108  eVisible_TrackCenter = ePosition_TrackCenter,
109  eVisible_TrackExpand = ePosition_Track | eScale_Expand,
110  eVisible_TrackContract = ePosition_Track | eScale_Contract
111  };
112 
113  /// internal clamping function to clamp a total range based on a location
114  bool x_Clamp(const objects::CSeq_loc& loc,
115  const objects::CBioseq_Handle& handle,
116  TSeqRange& range) const;
117 
118  bool x_Clamp(objects::CSeq_loc& loc,
119  const TSeqRange& range) const;
120 
121  int x_GetPolicy() const;
122 
126 
127 private:
128  static bool sm_AutoBroadcast;
130 };
131 
133 
134 #endif // GUI_UTILS___VISIBLE_RANGE__HPP
135 
static void SetDefaultVisibleRangePolicy(EBasicPolicy policy)
bool x_Clamp(objects::CSeq_loc &loc, const TSeqRange &range) const
EBasicPolicy m_Policy
static bool IsAutoBroadcast()
EPolicy
enum controlling policy for response to a change in visible range
void SetVisibleRangePolicy(EBasicPolicy policy)
static EBasicPolicy GetDefaultVisibleRangePolicy()
static EBasicPolicy sm_DefaultPolicy
static void SetAutoBroadcast(bool flag)
static bool sm_AutoBroadcast
CRef< objects::CScope > m_Scope
TLocations m_Locs
list< CConstRef< objects::CSeq_loc > > TLocations
bool Clamp(const objects::CBioseq_Handle &handle, TSeqRange &range) const
Alter the supplied range according to the rules provided in the policy and the supplied new location.
#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_GUIOBJUTILS_EXPORT
Definition: gui_export.h:512
Defines to provide correct exporting from DLLs in Windows.
range(_Ty, _Ty) -> range< _Ty >
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Sun Mar 03 03:14:57 2024 by modify_doxy.py rev. 669887