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

Go to the SVN repository for this file.

1 #ifndef GUI_OBJUTILS___VIEW_EVENT__HPP
2 #define GUI_OBJUTILS___VIEW_EVENT__HPP
3 
4 /* $Id: obj_event.hpp 45881 2021-01-05 03:10:02Z 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 CAnyType 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 CAnyType particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Vladimir Tereshkov, Andrey Yazhuk, Mike Dicuccio
30  *
31  * File Description:
32  * Event object for view communications
33  */
34 
35 #include <util/range_coll.hpp>
36 
41 
42 
44 
45 #include <gui/utils/rgba_color.hpp>
46 #include <gui/objutils/objects.hpp>
47 #include <gui/objutils/snp_gui.hpp>
48 
50 
51 ///////////////////////////////////////////////////////////////////////////////
52 ///
54 {
55 public: // TODO
56 
59 };
60 
61 ///////////////////////////////////////////////////////////////////////////////
62 /// CSelectionEvent
63 /// CSelectionEvent is used for broadcasting selection between views.
64 /// It containes separate "packages" for different types of selection.
65 /// If package
66 /// This class is not thread-safe.
68 {
69 public:
72  typedef vector< CConstRef<objects::CSeq_feat> > TFeats;
73  typedef vector< CConstRef<objects::CSeq_align> > TAligns;
74  typedef vector< CConstRef<objects::CSeq_loc> > TSeqLocs;
75  typedef vector< CConstRef<objects::CSeq_id> > TIds;
76  typedef vector< CConstRef<CIdLoc> > TIdLocs;
79  typedef vector< CConstRef<CObject> > TOther;
80  typedef vector< CConstRef<objects::CVcfVariant>> TVcfVariants;
81 
83 
84  CSelectionEvent(objects::CScope& scope);
85 
88  eAtLeastOne
89  };
92  eAccOnly
93  };
94 
95  objects::CScope& GetScope() { return *m_Scope; }
96 
97  /// Range Selection - represents a collection of selected segments
98  bool HasRangeSelection() const;
99  const objects::CHandleRangeMap& GetRangeSelection() const;
100  void AddRangeSelection(const objects::CSeq_id& id, const TRangeColl& segs);
101  void AddRangeSelection(const objects::CSeq_loc& loc);
102  bool GetRangeSelection(const objects::CSeq_id& id, objects::CScope& scope,
103  TRangeColl& segs);
104  void GetRangeSelectionAsLocs(TConstObjects& objs) const;
105 
106  /// Object Selection - represents select Objects
107  /// (such as features, alignments, etc)
108  bool HasObjectSelection();
109  bool AddObjectSelection(const CObject& obj);
110  void AddObjectSelection(const TConstObjects& objs); // temporary
111  void AddObjectSelection(const objects::CSeq_id& id);
112  void AddObjectSelection(const objects::CSeq_feat& feat);
113  void AddObjectSelection(const objects::CSeq_align& align);
114  void AddObjectSelection(const objects::CSeq_loc& loc);
115  void AddObjectSelection(const objects::CSeq_id& id, const CRange<TSeqPos>& range);
116  void AddObjectSelection(const objects::CVcfVariant& vcf_variant);
117  void AddTaxIDSelection(TTaxId tid);
118 
119  const TFeats& GetFeats() const { return m_Feats; }
120  const TAligns& GetAligns() const { return m_Aligns; }
121  const TSeqLocs& GetSeqLocs() const { return m_SeqLocs; }
122  const TIds& GetIds() const { return m_Ids; }
123  const TIdLocs& GetIdLocs() const { return m_IdLocs; }
124  const TTaxIds& GetTaxIDs() const { return m_TaxIds; }
125  const TVcfVariants& GetVcfVariants() const { return m_VcfVariants; }
126 
127  void GetAllObjects(TConstObjects& objs) const;
128  void GetOther(TConstObjects& objs) const;
129 
130  /// @name Private selection broadcasting functions
131  /// Private is used for View-to-View communication, when Views need to send extended
132  /// broadcastin information which only view of the same type can understand.
133  ///
134  /// Selection inspector is not supposed to interpret this.
135  ///
136  /// Functionality is added to implement robust tree comparison GB-3152
137  ///
138  /// @{
139 
140  /// Add private selection broadcasting info
141  ///
142  /// @param area_name is a string used to identify private information
143  /// @param obj - CObject derived class with selection infomation (can be downcasted by the receiver)
144  ///
145  void AddIndexed(const string& area_name, const CObject& obj);
146 
147  /// Get Objects from the private broadcasting area
148  /// (caller has to make sure output objs is empty)
149  ///
150  void GetIndexed(const string& area_name, TConstObjects& objs) const;
151 
152  /// Get access to private index map (all areas)
153  /// (mostly to avoid copy-ctr overhead associated with GetIndexed() )
154  ///
155  const TIndexed& GetIndexMap() const { return m_Indexed; }
156  /// @}
157 
158  /// @name Matching functons
159  /// @{
160  static bool Match(const CObject& obj1, objects::CScope& scope1,
161  const CObject& obj2, objects::CScope& scope2);
162 
163  static bool MatchFeatWithFeat(const objects::CSeq_feat& feat1,
164  objects::CScope& scope1,
165  const objects::CSeq_feat& feat2,
166  objects::CScope& scope2);
167 
168  static bool MatchFeatWithLoc(const objects::CSeq_feat& feat1,
169  objects::CScope& scope1,
170  const objects::CSeq_loc& loc2,
171  objects::CScope& scope2);
172 
173  static bool MatchFeatWithId(const objects::CSeq_feat& feat1,
174  objects::CScope& scope1,
175  const objects::CSeq_id& id2,
176  objects::CScope& scope2);
177 
178  static bool MatchAlignWithAlign(const objects::CSeq_align& align1,
179  objects::CScope& scope1,
180  const objects::CSeq_align& align2,
181  objects::CScope& scope2);
182 
183  static bool MatchLocWithLoc(const objects::CSeq_loc& loc1,
184  objects::CScope& scope1,
185  const objects::CSeq_loc& loc2,
186  objects::CScope& scope2);
187 
188  static bool MatchLocWithId(const objects::CSeq_loc& loc1,
189  objects::CScope& scope1,
190  const objects::CSeq_id& id2,
191  objects::CScope& scope2);
192 
193  static bool MatchIdWithId(const objects::CSeq_id& id1,
194  objects::CScope& scope1,
195  const objects::CSeq_id& id2,
196  objects::CScope& scope2);
197  /// @}
198 protected:
199  /// Matches two ids using current policy; does not consider synonyms
200  static bool x_SimpleMatch(const objects::CSeq_id_Handle& h_sel_id,
201  const objects::CSeq_id_Handle& h_id);
202 private:
203  void x_Init();
204 
205 public:
208  static bool sm_MatchAlnLocs;
209  static bool sm_MatchByProduct;
210  static bool sm_AutoBroadcast;
211  static bool sm_InterDocBroadcast; /// broadcast sel. between documents
212 
213  static vector<string> sm_TreeBroadcastProperties; /// Node properties used to compare trees when broadcasting
214  /// If true, when views of the same tree are opened, selection will be broadcasted based on node ids.
215  /// If false, selection will be defined by broadcast properties
217 
218 protected:
219  enum EObjType {
224  eSeq_vcf_variant
225  };
228 
229  CRef<objects::CScope> m_Scope; // scope corresponding to the source of selection
230 
231  // Range Selection package
233  objects::CHandleRangeMap m_RangeMap; // storage for Range Selection
234 
235  // Object Selection Package
246 };
247 
249 
250 #endif // GUI_UTILS___VIEW_EVENT__HPP
static CRef< CScope > m_Scope
CConstRef< objects::CSeq_id > m_Id
Definition: obj_event.hpp:57
CRange< TSeqPos > m_Range
Definition: obj_event.hpp:58
CObject –.
Definition: ncbiobj.hpp:180
CSelectionEvent CSelectionEvent is used for broadcasting selection between views.
Definition: obj_event.hpp:68
TSeqLocs m_SeqLocs
Definition: obj_event.hpp:239
vector< CConstRef< objects::CSeq_id > > TIds
Definition: obj_event.hpp:75
void AddObjectSelection(const objects::CSeq_id &id)
const TIdLocs & GetIdLocs() const
Definition: obj_event.hpp:123
const TTaxIds & GetTaxIDs() const
Definition: obj_event.hpp:124
map< string, TConstObjects > TIndexed
Definition: obj_event.hpp:82
bool GetRangeSelection(const objects::CSeq_id &id, objects::CScope &scope, TRangeColl &segs)
static bool sm_MatchByProduct
Definition: obj_event.hpp:209
const TIndexed & GetIndexMap() const
Get access to private index map (all areas) (mostly to avoid copy-ctr overhead associated with GetInd...
Definition: obj_event.hpp:155
TTaxIds::TTaxId TTaxId
Definition: obj_event.hpp:78
const TSeqLocs & GetSeqLocs() const
Definition: obj_event.hpp:121
TIdLocs m_IdLocs
Definition: obj_event.hpp:241
static EObjMatchPolicy sm_ObjMatchPolicy
Definition: obj_event.hpp:206
static bool sm_TreeBroadcastOneToOne
Node properties used to compare trees when broadcasting.
Definition: obj_event.hpp:216
bool m_HasObjectSelection
Definition: obj_event.hpp:236
vector< CConstRef< objects::CSeq_loc > > TSeqLocs
Definition: obj_event.hpp:74
static bool sm_InterDocBroadcast
Definition: obj_event.hpp:211
objects::CHandleRangeMap m_RangeMap
Definition: obj_event.hpp:233
vector< CConstRef< objects::CSeq_feat > > TFeats
Definition: obj_event.hpp:72
CRangeCollection< TSeqPos > TRangeColl
Definition: obj_event.hpp:70
static bool sm_MatchAlnLocs
Definition: obj_event.hpp:208
static bool sm_AutoBroadcast
Definition: obj_event.hpp:210
CTaxIdSelSet TTaxIds
Definition: obj_event.hpp:77
void AddRangeSelection(const objects::CSeq_id &id, const TRangeColl &segs)
void AddObjectSelection(const objects::CVcfVariant &vcf_variant)
void AddObjectSelection(const objects::CSeq_align &align)
CRef< objects::CScope > m_Scope
Definition: obj_event.hpp:229
TRangeColl::TRange TRange
Definition: obj_event.hpp:71
void AddObjectSelection(const objects::CSeq_feat &feat)
TVcfVariants m_VcfVariants
Definition: obj_event.hpp:245
vector< CConstRef< objects::CSeq_align > > TAligns
Definition: obj_event.hpp:73
static vector< string > sm_TreeBroadcastProperties
broadcast sel. between documents
Definition: obj_event.hpp:213
TTaxIds m_TaxIds
Definition: obj_event.hpp:242
bool m_HasRangeSelection
Definition: obj_event.hpp:232
const TFeats & GetFeats() const
Definition: obj_event.hpp:119
static EIdMatchPolicy sm_IdMatchPolicy
Definition: obj_event.hpp:207
vector< CConstRef< CIdLoc > > TIdLocs
Definition: obj_event.hpp:76
objects::CScope & GetScope()
Definition: obj_event.hpp:95
vector< CConstRef< objects::CVcfVariant > > TVcfVariants
Definition: obj_event.hpp:80
const TVcfVariants & GetVcfVariants() const
Definition: obj_event.hpp:125
void AddObjectSelection(const objects::CSeq_loc &loc)
const TIds & GetIds() const
Definition: obj_event.hpp:122
const TAligns & GetAligns() const
Definition: obj_event.hpp:120
map< string, EObjType > TRawNameToType
Definition: obj_event.hpp:226
TAligns m_Aligns
Definition: obj_event.hpp:238
TIndexed m_Indexed
Definition: obj_event.hpp:244
static TRawNameToType sm_RawNameToType
Definition: obj_event.hpp:227
vector< CConstRef< CObject > > TOther
Definition: obj_event.hpp:79
Class designed to hold a set of tax-ids represented as (on) bits in a bit vector.
bm::id_t TTaxId
vector< CConstRef< CObject > > TConstObjects
Definition: objects.hpp:64
#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
range(_Ty, _Ty) -> range< _Ty >
Modified on Sun Jul 21 04:21:41 2024 by modify_doxy.py rev. 669887