NCBI C++ ToolKit
gui_object_info_other_feats.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: gui_object_info_other_feats.cpp 41372 2018-07-18 20:45:38Z rudnev $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Liangshou Wu
27 *
28 * File Description:
29 * Gui Object Info classes.
30 *
31 */
32 
34 #include <gui/objutils/tooltip.hpp>
35 
38 
39 
40 /// Import feature
42 {
43 public:
44  virtual void GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p = (TSeqPos)-1, bool* isGeneratedBySvc = NULL) const;
45 };
46 
47 void CGuiObjectInfoImpFeature::GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p, bool* isGeneratedBySvc) const
48 {
50  string type_name;
52  tooltip.AddRow(GetSubtype() + ':', type_name);
53 
54  if (m_Feat->GetData().GetImp().IsSetDescr()) {
55  tooltip.AddRow("Title:", m_Feat->GetData().GetImp().GetDescr());
56  }
57 
58  if (m_Feat->IsSetComment() && m_Feat->GetComment() != t_title) {
59  tooltip.AddRow("Comment:", m_Feat->GetComment());
60  }
61 
62  x_AddLocationRows(tooltip);
63  x_AddPositionRows(tooltip, at_p);
64  if(isGeneratedBySvc) {
65  *isGeneratedBySvc = false;
66  }
67 }
68 
69 
70 /// region feature
72 {
73 public:
74  virtual void GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p = (TSeqPos)-1, bool* isGeneratedBySvc = NULL) const;
75 };
76 
77 void CGuiObjectInfoRegionFeature::GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p, bool* isGeneratedBySvc) const
78 {
80  string type_name;
82  tooltip.AddRow(GetSubtype() + ':', type_name);
83 
84  if (m_Feat->IsSetComment() && m_Feat->GetComment() != t_title) {
85  tooltip.AddRow("Comment:", m_Feat->GetComment());
86  }
87 
88  if (m_Feat->IsSetQual()) {
89  ITERATE(CSeq_feat::TQual, it, m_Feat->GetQual()) {
90  tooltip.AddRow((*it)->GetQual() + ':', (*it)->GetVal());
91  }
92  }
93 
94  x_AddLocationRows(tooltip);
95  x_AddPositionRows(tooltip, at_p);
96  if(isGeneratedBySvc) {
97  *isGeneratedBySvc = false;
98  }
99 }
100 
101 
102 /// seq feature
104 {
105 public:
106  virtual void GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p = (TSeqPos)-1, bool* isGeneratedBySvc = NULL) const;
107 };
108 
109 void CGuiObjectInfoSeqFeature::GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p, bool* isGeneratedBySvc) const
110 {
111  if(isGeneratedBySvc) {
112  *isGeneratedBySvc = false;
113  }
115 
116  tooltip.AddRow(GetSubtype() + ':', t_title);
117 
118  if (m_Feat->IsSetComment() && m_Feat->GetComment() != t_title) {
119  tooltip.AddRow("Comment:", m_Feat->GetComment());
120  }
121 
122  if (m_Feat->IsSetQual()) {
123  ITERATE(CSeq_feat::TQual, it, m_Feat->GetQual()) {
124  tooltip.AddRow((*it)->GetQual() + ':', (*it)->GetVal());
125  }
126  }
127 
128  x_AddLocationRows(tooltip);
129 
130  if (m_Location) {
131  size_t intervals = 0;
132  switch (m_Location->Which())
133  {
134  case CSeq_loc::e_Int:
135  intervals = 1;
136  break;
137 
139  intervals = m_Location->GetPacked_int().Get().size();
140  break;
141 
143  intervals = m_Location->GetPacked_pnt().GetPoints().size();
144  break;
145 
146  case CSeq_loc::e_Mix:
147  /// FIXME: this may not always be correct -
148  /// a mix may be a mix of complex intervals
149  intervals = m_Location->GetMix().Get().size();
150  break;
151  default:
152  break;
153  }
154  if (intervals > 0) {
155  tooltip.AddRow("Intervals:", NStr::SizetToString(intervals));
156  }
157  }
158 
159  x_AddPositionRows(tooltip, at_p);
160 }
161 
162 
163 /// site feature
165 {
166 public:
167  virtual void GetToolTip(ITooltipFormatter& tooltip, string& t_title, TSeqPos at_p = (TSeqPos)-1, bool* isGeneratedBySvc = NULL) const;
168 };
169 
170 
171 void CGuiObjectInfoSiteFeature::GetToolTip(ITooltipFormatter& tooltip, string& t_title,TSeqPos at_p, bool* isGeneratedBySvc) const
172 {
173  if(isGeneratedBySvc) {
174  *isGeneratedBySvc = false;
175  }
177  string type_name;
179  tooltip.AddRow(GetSubtype() + ':', type_name);
180 
181  if (m_Feat->IsSetComment()) {
182  tooltip.AddRow("Title:", m_Feat->GetComment());
183  }
184 
185  x_AddLocationRows(tooltip);
186  x_AddPositionRows(tooltip, at_p);
187 }
188 
189 
191 
virtual void GetToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1, bool *isGeneratedBySvc=NULL) const
Get tooltip.
virtual void GetToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1, bool *isGeneratedBySvc=NULL) const
Get tooltip.
virtual void GetToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1, bool *isGeneratedBySvc=NULL) const
Get tooltip.
virtual void GetToolTip(ITooltipFormatter &tooltip, string &t_title, TSeqPos at_p=(TSeqPos) -1, bool *isGeneratedBySvc=NULL) const
Get tooltip.
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
void x_AddPositionRows(ITooltipFormatter &tooltip, TSeqPos at_p) const
Add position-specific (current cursor position) information.
void x_AddLocationRows(ITooltipFormatter &tooltip) const
Add feature location-related information.
CRef< objects::CScope > m_Scope
CConstRef< objects::CSeq_feat > m_Feat
virtual string GetSubtype() const
CConstRef< objects::CSeq_loc > m_Location
Mapped location in top sequence coordinate (can be set externally).
@ eContent
Definition: label.hpp:62
string GetLabel(const CSeq_id &id)
@ fFGL_Content
Include its content if there is any.
Definition: feature.hpp:73
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2751
vector< CRef< CGb_qual > > TQual
Definition: Seq_feat_.hpp:117
@ e_Int
from to
Definition: Seq_loc_.hpp:101
USING_SCOPE(objects)
Modified on Thu Feb 29 12:22:21 2024 by modify_doxy.py rev. 669887