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

Go to the SVN repository for this file.

1 /* $Id: cdd_splash_dialog.cpp 96808 2022-05-12 15:45:21Z dzhang $
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: Paul Thiessen
27 *
28 * File Description:
29 * dialog for CDD splash screen
30 *
31 * ===========================================================================
32 */
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/ncbistd.hpp>
36 
40 #include <objects/pub/Pub.hpp>
49 
51 
52 #include "cdd_splash_dialog.hpp"
53 #include "structure_window.hpp"
54 #include "structure_set.hpp"
55 #include "cn3d_tools.hpp"
56 #include "chemical_graph.hpp"
57 #include "molecule_identifier.hpp"
58 #include "sequence_set.hpp"
59 
60 
61 ////////////////////////////////////////////////////////////////////////////////////////////////
62 // The following is taken unmodified from wxDesigner's C++ header from cdd_splash_dialog.wdr
63 ////////////////////////////////////////////////////////////////////////////////////////////////
64 
65 #include <wx/image.h>
66 #include <wx/statline.h>
67 #include <wx/spinbutt.h>
68 #include <wx/spinctrl.h>
69 #include <wx/splitter.h>
70 #include <wx/listctrl.h>
71 #include <wx/treectrl.h>
72 #include <wx/notebook.h>
73 #include <wx/grid.h>
74 
75 // Declare window functions
76 
77 #define ID_TEXT 10000
78 #define ID_ST_NAME 10001
79 #define ID_T_DESCR 10002
80 #define ID_B_ANNOT 10003
81 #define ID_B_REF 10004
82 #define ID_B_DONE 10005
83 wxSizer *SetupCDDSplashDialog( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE );
84 
85 ////////////////////////////////////////////////////////////////////////////////////////////////
86 
89 
90 
91 BEGIN_SCOPE(Cn3D)
92 
93 #define DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(var, id, type) \
94  type *var; \
95  var = wxDynamicCast(FindWindow(id), type); \
96  if (!var) { \
97  ERRORMSG("Can't find window with id " << id); \
98  return; \
99  }
100 
101 BEGIN_EVENT_TABLE(CDDSplashDialog, wxDialog)
102  EVT_CLOSE ( CDDSplashDialog::OnCloseWindow)
103  EVT_BUTTON (-1, CDDSplashDialog::OnButton)
105 
107  StructureSet *structureSet, CDDSplashDialog **parentHandle,
108  wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos) :
109  wxDialog(parent, id, title, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE),
110  handle(parentHandle), structureWindow(cn3dFrame)
111 {
112  if (!structureSet) {
113  Destroy();
114  return;
115  }
116 
117  // construct the panel
118  wxSizer *topSizer = SetupCDDSplashDialog(this, false);
119 
120  // fill in info
125 
126  const string& cddName = structureSet->GetCDDName();
127  if (cddName.size() > 0)
128  tName->SetLabel(cddName.c_str());
129 
130  const string& cddDescr = structureSet->GetCDDDescription();
131  if (cddDescr.size() > 0) {
132  unsigned int i, j;
133  for (i=j=0; i<cddDescr.size(); ++i, ++j) {
134  if (j > 60 && cddDescr[i] == ' ') {
135  *tDescr << '\n';
136  j = 0;
137  } else
138  *tDescr << cddDescr[i];
139  }
140  *tDescr << "\n\n";
141  }
142 
143  // summarize annotations
144  const CAlign_annot_set *annots = structureSet->GetCDDAnnotSet();
145  if (annots && annots->Get().size() > 0) {
146  *tDescr << "Annotation summary:\n\n";
147  CAlign_annot_set::Tdata::const_iterator a, ae = annots->Get().end();
148  for (a=annots->Get().begin(); a!=ae; ++a) {
149  *tDescr << ((*a)->IsSetDescription() ? (*a)->GetDescription() : string("")).c_str()
150  << "; evidence:\n";
151  if ((*a)->IsSetEvidence()) {
152  CAlign_annot::TEvidence::const_iterator e, ee = (*a)->GetEvidence().end();
153  for (e=(*a)->GetEvidence().begin(); e!=ee; ++e) {
154  if ((*e)->IsComment())
155  *tDescr << " comment: " << (*e)->GetComment().c_str() << '\n';
156  else if ((*e)->IsReference() && (*e)->GetReference().IsPmid()) {
157  string pmid_str = NStr::NumericToString((*e)->GetReference().GetPmid().Get());
158  *tDescr << " PubMed " << pmid_str << '\n';
159  }
160  else if ((*e)->IsBsannot()) {
161  *tDescr << " structure:";
162  if ((*e)->GetBsannot().GetFeatures().size() > 0 &&
163  (*e)->GetBsannot().GetFeatures().front()->IsSetDescr() &&
164  (*e)->GetBsannot().GetFeatures().front()->IsSetDescr() &&
165  (*e)->GetBsannot().GetFeatures().front()->GetDescr().front()->IsName())
166  *tDescr << ' ' <<
167  (*e)->GetBsannot().GetFeatures().front()->GetDescr().front()->GetName().c_str();
168  if ((*e)->GetBsannot().IsSetId() && (*e)->GetBsannot().GetId().front()->IsMmdb_id()) {
169  int mmdbID = (*e)->GetBsannot().GetId().front()->GetMmdb_id().Get();
170  StructureSet::ObjectList::const_iterator o, oe = structureSet->objects.end();
171  for (o=structureSet->objects.begin(); o!=oe; ++o) {
172  if ((*o)->mmdbID == mmdbID) {
173  *tDescr << " (" << (*o)->GetPDBID().c_str() << ')';
174  break;
175  }
176  }
177  }
178  *tDescr << '\n';
179  }
180  }
181  }
182  *tDescr << '\n';
183  }
184  }
185 
186  // summarize structures
187  if (structureSet->objects.size() > 0) {
188  *tDescr << "Structure summary:\n";
189  StructureSet::ObjectList::const_iterator o, oe = structureSet->objects.end();
190  for (o=structureSet->objects.begin(); o!=oe; ++o) {
191  *tDescr << "\nPDB " << (*o)->GetPDBID().c_str() << " (MMDB " << (*o)->mmdbID << ")\n";
192 
193  // make lists of biopolymer chains and heterogens
194  typedef list < string > ChainList;
195  ChainList chainList;
196  typedef map < string , int > HetList;
197  HetList hetList;
198  ChemicalGraph::MoleculeMap::const_iterator m, me = (*o)->graph->molecules.end();
199  for (m=(*o)->graph->molecules.begin(); m!=me; ++m) {
200  if (m->second->IsProtein() || m->second->IsNucleotide()) {
201  wxString descr;
202  SequenceSet::SequenceList::const_iterator
203  s, se = structureSet->sequenceSet->sequences.end();
204  for (s=structureSet->sequenceSet->sequences.begin(); s!=se; ++s) {
205  if ((*s)->identifier == m->second->identifier) {
206  string gi_str = NStr::NumericToString((*s)->identifier->gi);
207  descr.Printf("%s: gi %s (%s)", m->second->identifier->ToString().c_str(),
208  gi_str.c_str(), (*s)->GetDescription().c_str());
209  break;
210  }
211  }
212 
213  if (s == se) {
214  string gi_str = NStr::NumericToString(m->second->identifier->gi);
215  descr.Printf("%s: gi %s", m->second->identifier->ToString().c_str(), gi_str.c_str());
216  }
217 
218  chainList.push_back(WX_TO_STD(descr));
219  } else if (m->second->IsHeterogen()) {
220  // get name from local graph name of first (should be only) residue
221  const string& name = m->second->residues.find(1)->second->nameGraph;
222  HetList::iterator n = hetList.find(name);
223  if (n == hetList.end())
224  hetList[name] = 1;
225  else
226  ++(n->second);
227  }
228  }
229  chainList.sort();
230 
231  // print chains
232  ChainList::const_iterator c, ce = chainList.end();
233  for (c=chainList.begin(); c!=ce; ++c)
234  *tDescr << " " << c->c_str() << '\n';
235 
236  // print hets
237  if (hetList.size() > 0) {
238  *tDescr << "Heterogens: ";
239  HetList::const_iterator h, he = hetList.end();
240  for (h=hetList.begin(); h!=he; ++h) {
241  if (h != hetList.begin())
242  *tDescr << ", ";
243  wxString descr;
244  if (h->second > 1)
245  descr.Printf("%s (x%i)", h->first.c_str(), h->second);
246  else
247  descr = h->first.c_str();
248  *tDescr << descr;
249  }
250  *tDescr << '\n';
251  }
252  }
253  }
254 
255  const CCdd_descr_set *cddRefs = structureSet->GetCDDDescrSet();
256  CCdd_descr_set::Tdata::const_iterator d, de = cddRefs->Get().end();
257  for (d=cddRefs->Get().begin(); d!=de; ++d) {
258  if ((*d)->IsReference() && (*d)->GetReference().IsPmid())
259  break;
260  }
261  if (d == de) // if no PMID references found
262  bRef->Enable(false);
263 
264  const CAlign_annot_set *cddAnnot = structureSet->GetCDDAnnotSet();
265  if (cddAnnot->Get().size() == 0)
266  bAnnot->Enable(false);
267 
268  // call sizer stuff
269  topSizer->Fit(this);
270  topSizer->SetSizeHints(this);
271 }
272 
274 {
275  if (handle && *handle) *handle = NULL;
276 }
277 
278 // same as hitting done
279 void CDDSplashDialog::OnCloseWindow(wxCloseEvent& event)
280 {
281  Destroy();
282 }
283 
284 void CDDSplashDialog::OnButton(wxCommandEvent& event)
285 {
286  if (event.GetId() == ID_B_ANNOT) {
288  }
289 
290  else if (event.GetId() == ID_B_REF) {
292  }
293 
294  else if (event.GetId() == ID_B_DONE) {
295  Destroy();
296  }
297 }
298 
299 END_SCOPE(Cn3D)
300 
301 //////////////////////////////////////////////////////////////////////////////////////////////////
302 // The following are taken *without* modification from wxDesigner C++ code generated from
303 // cdd_splash_dialog.wdr.
304 //////////////////////////////////////////////////////////////////////////////////////////////////
305 
306 wxSizer *SetupCDDSplashDialog( wxWindow *parent, bool call_fit, bool set_sizer )
307 {
308  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
309 
310  wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
311  item1->AddGrowableCol( 1 );
312 
313  wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, "Name:", wxDefaultPosition, wxDefaultSize, 0 );
314  item1->Add( item2, 0, wxALIGN_CENTRE|wxALL, 5 );
315 
316  wxStaticText *item3 = new wxStaticText( parent, ID_ST_NAME, "", wxDefaultPosition, wxDefaultSize, 0 );
317  item1->Add( item3, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
318 
319  item0->Add(item1, 0, wxGROW | wxALL, 5);
320 
321  wxTextCtrl *item4 = new wxTextCtrl( parent, ID_T_DESCR, "", wxDefaultPosition, wxSize(-1,100), wxTE_MULTILINE|wxTE_READONLY );
322  item0->Add(item4, 0, wxGROW | wxALL, 5);
323 
324  wxBoxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
325 
326  wxButton *item6 = new wxButton( parent, ID_B_ANNOT, "Show Annotations Panel", wxDefaultPosition, wxDefaultSize, 0 );
327  item5->Add( item6, 0, wxGROW | wxALL, 5 );
328 
329  wxButton *item7 = new wxButton( parent, ID_B_REF, "Show References Panel", wxDefaultPosition, wxDefaultSize, 0 );
330  item5->Add(item7, 0, wxGROW | wxALL, 5);
331 
332  item5->Add( 20, 20, 0, wxALIGN_CENTRE| wxALL, 5 );
333 
334  wxButton *item8 = new wxButton( parent, ID_B_DONE, "Dismiss", wxDefaultPosition, wxDefaultSize, 0 );
335  item5->Add( item8, 0, wxGROW | wxALL, 5 );
336 
337  item0->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 );
338 
339  if (set_sizer)
340  {
341  parent->SetAutoLayout( TRUE );
342  parent->SetSizer( item0 );
343  if (call_fit)
344  {
345  item0->Fit( parent );
346  item0->SetSizeHints( parent );
347  }
348  }
349 
350  return item0;
351 }
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
USING_SCOPE(objects)
#define ID_B_ANNOT
#define DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(var, id, type)
#define ID_ST_NAME
#define ID_TEXT
#define ID_B_DONE
USING_NCBI_SCOPE
#define ID_T_DESCR
#define ID_B_REF
wxSizer * SetupCDDSplashDialog(wxWindow *parent, bool call_fit=TRUE, bool set_sizer=TRUE)
CAlign_annot_set –.
CCdd_descr_set –.
CDDSplashDialog ** handle
void OnCloseWindow(wxCloseEvent &event)
void OnButton(wxCommandEvent &event)
StructureWindow * structureWindow
void ShowCDDReferences(void)
void ShowCDDAnnotations(void)
const_iterator end() const
Definition: map.hpp:152
#define WX_TO_STD(wxstring)
Definition: cn3d_tools.hpp:285
Include a standard set of the NCBI C++ Toolkit most basic headers.
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
const Tdata & Get(void) const
Get the member data.
const Tdata & Get(void) const
Get the member data.
END_EVENT_TABLE()
int i
yy_size_t n
unsigned int a
Definition: ncbi_localip.c:102
@ TRUE
Definition: testodbc.c:27
#define const
Definition: zconf.h:230
Modified on Tue Dec 05 02:19:26 2023 by modify_doxy.py rev. 669887