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

Go to the SVN repository for this file.

1 /* $Id: desktop_ds.cpp 44457 2019-12-19 19:25:12Z asztalos $
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: Andrea Asztalos
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
35 #include <objmgr/scope.hpp>
36 #include <objmgr/feat_ci.hpp>
37 #include <objmgr/align_ci.hpp>
38 #include <objmgr/graph_ci.hpp>
39 
43 
44 #include <wx/settings.h>
45 #include <wx/dcclient.h>
46 
49 
50 CDesktopDataBuilder::CDesktopDataBuilder(const CSerialObject& so, objects::CScope& scope)
51 {
52  m_Scope = Ref(&scope);
53  const CSeq_id* seq_id = dynamic_cast<const CSeq_id*>(&so);
54  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(&so);
55  const CSeq_entry* seq_entry = dynamic_cast<const CSeq_entry*>(&so);
56  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(&so);
57  const CBioseq_set* bioseq_set = dynamic_cast<const CBioseq_set*>(&so);
58  const CSeq_submit* seq_submit = dynamic_cast<const CSeq_submit*>(&so);
59  const CSeq_annot* annot = dynamic_cast<const CSeq_annot*>(&so);
60 
61  if (seq_entry) {
62  m_Seh = scope.GetSeq_entryHandle(*seq_entry);
63  }
64  else if (bioseq) {
65  CBioseq_Handle bsh = scope.GetBioseqHandle(*bioseq);
66  if (bsh)
67  m_Seh = bsh.GetTopLevelEntry();
68  }
69  else if (bioseq_set) {
70  CBioseq_set_Handle bssh = scope.GetBioseq_setHandle(*bioseq_set);
71  if (bssh)
72  m_Seh = bssh.GetTopLevelEntry();
73  }
74  else if (seq_id) {
75  CBioseq_Handle bsh = scope.GetBioseqHandle(*seq_id);
76  if (bsh)
77  m_Seh = bsh.GetTopLevelEntry();
78  }
79  else if (seq_loc) {
80  CBioseq_Handle bsh = scope.GetBioseqHandle(*seq_loc);
81  if (bsh)
82  m_Seh = bsh.GetTopLevelEntry();
83  }
84  else if (seq_submit) {
85  m_SeqSubmit = ConstRef(seq_submit);
86  if (m_SeqSubmit->IsSetData()) {
87  const CSeq_submit::TData& data = m_SeqSubmit->GetData();
88  if (data.IsEntrys()) {
90  if (!entries.empty()) {
91  m_Seh = scope.GetSeq_entryHandle(**entries.begin());
92  }
93  }
94  }
95  } else if (annot) {
96  m_AnnotHandle = scope.GetSeq_annotHandle(*annot);
97  } else {
98  ReportIDError("", true, "Sequin Desktop View");
99  return;
100  }
101 
103 }
104 
106 {
107  if (m_Seh) {
108 
109  if (m_SeqSubmit) {
111  }
112  else {
113  CConstRef<CSeq_entry> entry = m_Seh.GetCompleteSeq_entry();
114  if (m_Seh.IsSeq()) {
116  m_RootItem = Ref(new CRootDesktopItem(item));
117  x_CreateSeq(m_Seh.GetSeq(), m_RootItem);
118  }
119  else {
121  m_RootItem = Ref(new CRootDesktopItem(item));
122  x_CreateSet(m_Seh.GetSet(), m_RootItem);
123  }
124 
125  }
126  } else if (m_AnnotHandle) {
128  m_RootItem = Ref(new CRootDesktopItem(item));
130  }
131  else {
132  _ASSERT(false);
133  }
134 }
135 
137 {
139  m_RootItem = Ref(new CRootDesktopItem(item));
140 
141  if (m_SeqSubmit->IsSetSub()) {
142  const CSubmit_block& block = m_SeqSubmit->GetSub();
143  if (block.IsSetContact()) {
145  IDesktopItem* contact_item = new CSimpleDesktopItem(item);
146  m_RootItem->Add(*contact_item);
147  }
148  if (block.IsSetCit()) {
150  IDesktopItem* cit_item = new CSimpleDesktopItem(item);
151  m_RootItem->Add(*cit_item);
152  }
153  }
154 
155  if (m_SeqSubmit->IsEntrys()) {
156  if (m_Seh.IsSeq()) {
157  x_CreateSeq(m_Seh.GetSeq(), m_RootItem);
158  }
159  else {
160  x_CreateSet(m_Seh.GetSet(), m_RootItem);
161  }
162  }
163  else if (m_SeqSubmit->IsAnnots()) {
165  x_CreateAnnot(m_Scope->GetSeq_annotHandle(**annot_it), m_RootItem);
166  }
167  }
168 }
169 
171 {
173  IDesktopItem* bseq_item = new CCompositeDesktopItem(item);
174  parent->Add(*bseq_item);
175 
176  const CBioseq& bseq = bsh.GetCompleteBioseq().GetObject();
177  FOR_EACH_SEQDESC_ON_BIOSEQ(desc_it, bseq) {
179  IDesktopItem* desc_item = new CSimpleDesktopItem(item);
180  bseq_item->Add(*desc_item);
181  }
182 
183  FOR_EACH_SEQANNOT_ON_BIOSEQ(annot_it, bseq) {
184  x_CreateAnnot(m_Scope->GetSeq_annotHandle(**annot_it), CIRef<IDesktopItem>(bseq_item));
185  }
186 }
187 
188 
190 {
192  IDesktopItem* annot_item = new CCompositeDesktopItem(item);
193  const wxBrush& bkgd_brush = parent->GetBkgdBrush();
194  annot_item->SetBkgdBrush(bkgd_brush);
195  parent->Add(*annot_item);
196 
197 
198  if (ah.IsFtable()) {
199  for (CFeat_CI feat_it(ah); feat_it; ++feat_it) {
200  CConstRef<IDesktopDataItem> item(new CDesktopFeatItem(feat_it->GetSeq_feat_Handle()));
201  IDesktopItem* feat_item = new CSimpleDesktopItem(item);
202  feat_item->SetBkgdBrush(bkgd_brush);
203  feat_item->SetFrameColor(bkgd_brush.GetColour());
204  annot_item->Add(*feat_item);
205  }
206  }
207  else if (ah.IsAlign()) {
208  for (CAlign_CI align_it(ah); align_it; ++align_it) {
209  CConstRef<IDesktopDataItem> item(new CDesktopAlignItem(align_it.GetSeq_align_Handle()));
210  IDesktopItem* align_item = new CSimpleDesktopItem(item);
211  align_item->SetBkgdBrush(bkgd_brush);
212  align_item->SetFrameColor(bkgd_brush.GetColour());
213  annot_item->Add(*align_item);
214  }
215  }
216  else if (ah.IsGraph()) {
217  for (CGraph_CI graph_it(ah); graph_it; ++graph_it) {
218  CConstRef<IDesktopDataItem> item(new CDesktopGraphItem(graph_it->GetSeq_graph_Handle()));
219  IDesktopItem* graph_item = new CSimpleDesktopItem(item);
220  graph_item->SetBkgdBrush(bkgd_brush);
221  graph_item->SetFrameColor(bkgd_brush.GetColour());
222  annot_item->Add(*graph_item);
223  }
224  }
225 }
226 
228 {
230  IDesktopItem* bset_item = new CCompositeDesktopItem(item);
231  parent->Add(*bset_item);
232 
233  const CBioseq_set& bset = bssh.GetCompleteBioseq_set().GetObject();
234  const wxBrush& bkgd_brush = bset_item->GetBkgdBrush();
235  FOR_EACH_SEQDESC_ON_SEQSET(desc_it, bset) {
237  IDesktopItem* desc_item = new CSimpleDesktopItem(item);
238  desc_item->SetBkgdBrush(bkgd_brush);
239  desc_item->SetFrameColor(bkgd_brush.GetColour());
240  bset_item->Add(*desc_item);
241  }
242 
243  FOR_EACH_SEQANNOT_ON_SEQSET(annot_it, bset) {
244  x_CreateAnnot(m_Scope->GetSeq_annotHandle(**annot_it), CIRef<IDesktopItem>(bset_item));
245  }
246 
247  FOR_EACH_SEQENTRY_ON_SEQSET(entry_it, bset) {
248  const CSeq_entry& subentry = **entry_it;
249  if (subentry.IsSet()) {
250  CBioseq_set_Handle sub_bssh = m_Scope->GetBioseq_setHandle(subentry.GetSet());
251  x_CreateSet(sub_bssh, CIRef<IDesktopItem>(bset_item));
252  }
253  else {
254  CBioseq_Handle sub_bsh = m_Scope->GetBioseqHandle(subentry.GetSeq());
255  x_CreateSeq(sub_bsh, CIRef<IDesktopItem>(bset_item));
256  }
257  }
258 }
259 
CAlign_CI –.
Definition: align_ci.hpp:63
CBioseq_Handle –.
CBioseq_set_Handle –.
A desktop item with children.
CRef< objects::CScope > m_Scope
Definition: desktop_ds.hpp:68
CDesktopDataBuilder(const CSerialObject &so, objects::CScope &scope)
Definition: desktop_ds.cpp:50
void x_CreateAnnot(const objects::CSeq_annot_Handle &ah, CIRef< IDesktopItem > parent)
Definition: desktop_ds.cpp:189
CIRef< IDesktopItem > m_RootItem
Definition: desktop_ds.hpp:65
objects::CSeq_entry_Handle m_Seh
Definition: desktop_ds.hpp:66
objects::CSeq_annot_Handle m_AnnotHandle
Definition: desktop_ds.hpp:69
void x_CreateDesktopItems()
Creates IDesktopItems depending on the type of input.
Definition: desktop_ds.cpp:105
void x_CreateSet(const objects::CBioseq_set_Handle &bssh, CIRef< IDesktopItem > parent)
Definition: desktop_ds.cpp:227
void x_CreateSeq(const objects::CBioseq_Handle &bsh, CIRef< IDesktopItem > parent)
Definition: desktop_ds.cpp:170
CConstRef< objects::CSeq_submit > m_SeqSubmit
Definition: desktop_ds.hpp:67
CFeat_CI –.
Definition: feat_ci.hpp:64
CGraph_CI –.
Definition: graph_ci.hpp:234
A special composite desktop item (one that has children).
CSeq_annot_Handle –.
Definition: Seq_entry.hpp:56
Base class for all serializable objects.
Definition: serialbase.hpp:150
A desktop item that has no children.
CSubmit_block –.
virtual void SetBkgdBrush(const wxBrush &bkgd_brush)=0
virtual const wxBrush & GetBkgdBrush() const =0
virtual void Add(IDesktopItem &)=0
virtual void SetFrameColor(const wxColour &color)=0
USING_SCOPE(objects)
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
bool IsFtable(void) const
bool IsGraph(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CConstRef< CBioseq_set > GetCompleteBioseq_set(void) const
Return the complete bioseq-set object.
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
bool IsAlign(void) const
CSeq_entry_Handle GetTopLevelEntry(void) const
Return a handle for the top-level seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
Definition: ncbiobj.hpp:2024
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
TObjectType & GetNCObject(void) const
Get object.
Definition: ncbiobj.hpp:1187
TObjectType & GetObject(void) const
Get object.
Definition: ncbiobj.hpp:1697
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const TSeq & GetSeq(void) const
Get the variant data.
Definition: Seq_entry_.cpp:102
const TSet & GetSet(void) const
Get the variant data.
Definition: Seq_entry_.cpp:124
bool IsSet(void) const
Check if variant Set is selected.
Definition: Seq_entry_.hpp:263
const TCit & GetCit(void) const
Get the Cit member data.
list< CRef< CSeq_entry > > TEntrys
const TEntrys & GetEntrys(void) const
Get the variant data.
bool IsEntrys(void) const
Check if variant Entrys is selected.
const TContact & GetContact(void) const
Get the Contact member data.
bool IsSetCit(void) const
citation for this submission Check if a value has been assigned to Cit data member.
bool IsSetContact(void) const
who to contact Check if a value has been assigned to Contact data member.
#define FOR_EACH_SEQDESC_ON_BIOSEQ(Itr, Var)
FOR_EACH_SEQDESC_ON_BIOSEQ EDIT_EACH_SEQDESC_ON_BIOSEQ.
Definition: seq_macros.hpp:218
#define FOR_EACH_SEQANNOT_ON_BIOSEQ(Itr, Var)
FOR_EACH_SEQANNOT_ON_BIOSEQ EDIT_EACH_SEQANNOT_ON_BIOSEQ.
Definition: seq_macros.hpp:263
#define FOR_EACH_SEQANNOT_ON_SEQSET(Itr, Var)
FOR_EACH_SEQANNOT_ON_SEQSET EDIT_EACH_SEQANNOT_ON_SEQSET.
#define FOR_EACH_SEQENTRY_ON_SEQSET(Itr, Var)
FOR_EACH_SEQENTRY_ON_SEQSET EDIT_EACH_SEQENTRY_ON_SEQSET.
#define FOR_EACH_SEQDESC_ON_SEQSET(Itr, Var)
FOR_EACH_SEQDESC_ON_SEQSET EDIT_EACH_SEQDESC_ON_SEQSET.
#define FOR_EACH_SEQANNOT_ON_SEQSUBMIT(Itr, Var)
FOR_EACH_SEQANNOT_ON_SEQSUBMIT EDIT_EACH_SEQANNOT_ON_SEQSUBMIT.
#define _ASSERT
static wxAcceleratorEntry entries[3]
void ReportIDError(const string &id_label, bool is_local, const string &title="Error message")
Definition: wx_utils.cpp:99
Modified on Sun Mar 03 03:12:59 2024 by modify_doxy.py rev. 669887