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

Go to the SVN repository for this file.

1 /* $Id: reference_panel.cpp 47033 2022-05-23 19:38:42Z 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 
29 
30 #include <ncbi_pch.hpp>
35 
36 #include <objects/seq/Seqdesc.hpp>
37 #include <objects/seq/Pubdesc.hpp>
40 
41 #include <wx/sizer.h>
42 #include <wx/listbook.h>
43 #include <wx/icon.h>
44 
45 
47 
48 /*
49  * CReferencePanel type definition
50  */
51 
52 IMPLEMENT_DYNAMIC_CLASS( CReferencePanel, wxPanel )
53 
54 
55 /*
56  * CReferencePanel event table definition
57  */
58 
59 BEGIN_EVENT_TABLE( CReferencePanel, wxPanel )
60  EVT_LISTBOOK_PAGE_CHANGED(ID_REFERENCELISTBOOK, CReferencePanel::OnPageChanged)
61  EVT_LISTBOOK_PAGE_CHANGING(ID_REFERENCELISTBOOK, CReferencePanel::OnPageChanging)
63 
64 
65 /*
66  * CReferencePanel constructors
67  */
68 
70 {
71  Init();
72 }
73 
74 CReferencePanel::CReferencePanel( wxWindow* parent, ICommandProccessor* cmdproc, objects::CSeq_entry_Handle seh, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
75  : m_CmdProcessor(cmdproc), m_Seh(seh)
76 {
77  Init();
78  Create(parent, id, pos, size, style);
79 }
80 
81 
82 /*
83  * CReferencePanel creator
84  */
85 
86 bool CReferencePanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
87 {
88 ////@begin CReferencePanel creation
89  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
90  wxPanel::Create( parent, id, pos, size, style );
91 
93  if (GetSizer())
94  {
95  GetSizer()->SetSizeHints(this);
96  }
97  Centre();
98 ////@end CReferencePanel creation
99  return true;
100 }
101 
102 
103 /*
104  * CReferencePanel destructor
105  */
106 
108 {
109 ////@begin CReferencePanel destruction
110 ////@end CReferencePanel destruction
111 }
112 
113 
114 /*
115  * Member initialisation
116  */
117 
119 {
120 ////@begin CReferencePanel member initialisation
121  m_Listbook = NULL;
122  //m_AuthorPanel = NULL;
124 ////@end CReferencePanel member initialisation
125 }
126 
127 
128 /*
129  * Control creation for CReferencePanel
130  */
131 
133 {
134 ////@begin CReferencePanel content construction
135  CReferencePanel* itemPanel1 = this;
136 
137  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
138  itemPanel1->SetSizer(itemBoxSizer2);
139 
140  m_Listbook = new wxListbook( itemPanel1, ID_REFERENCELISTBOOK, wxDefaultPosition, wxDefaultSize, wxBK_TOP|wxNO_BORDER );
141  itemBoxSizer2->Add(m_Listbook, 1, wxGROW|wxALL, 5);
142 
143  CRef<objects::CAuth_list> authlist(new objects::CAuth_list());
144  m_AuthorsPanel = new CAuthorNamesPanel(m_Listbook, *authlist, false);
145  m_Listbook->AddPage(m_AuthorsPanel, wxT("Sequence authors"));
146 
148  m_Listbook->AddPage(m_StatusPanel, _("Publication"));
149 
150 }
151 
153 {
154  return x_DoStepForward(m_Listbook);
155 }
156 
158 {
160 }
161 
162 void CReferencePanel::OnPageChanging(wxBookCtrlEvent& event)
163 {
164  ApplyCommand();
165 }
166 
167 void CReferencePanel::OnPageChanged(wxBookCtrlEvent& event)
168 {
169  GetParentWizard(this)->UpdateOnPageChange(this);
170 }
171 
172 /*
173  * Should we show tooltips?
174  */
175 
177 {
178  return true;
179 }
180 
181 /*
182  * Get bitmap resources
183  */
184 
185 wxBitmap CReferencePanel::GetBitmapResource( const wxString& name )
186 {
187  // Bitmap retrieval
188 ////@begin CReferencePanel bitmap retrieval
189  wxUnusedVar(name);
190  return wxNullBitmap;
191 ////@end CReferencePanel bitmap retrieval
192 }
193 
194 /*
195  * Get icon resources
196  */
197 
198 wxIcon CReferencePanel::GetIconResource( const wxString& name )
199 {
200  // Icon retrieval
201 ////@begin CReferencePanel icon retrieval
202  wxUnusedVar(name);
203  return wxNullIcon;
204 ////@end CReferencePanel icon retrieval
205 }
206 
207 
208 void CReferencePanel::ApplySubmitBlock(objects::CSubmit_block& block)
209 {
210  m_SubmitBlock.Reset(&block);
212  m_StatusPanel->ApplyCitSub(block.SetCit());
213 }
214 
215 
216 void CReferencePanel::ApplyDescriptor(objects::CSeqdesc& desc)
217 {
218  m_StatusPanel->ApplyPub(desc.SetPub());
219 }
220 
221 
223 {
224  if (!wxPanel::TransferDataFromWindow()) {
225  return false;
226  }
227  m_AuthorsPanel->PopulateAuthors(m_SubmitBlock->SetCit().SetAuthors());
228  return true;
229 }
230 
231 
232 bool CReferencePanel::MatchesCitSubAuthors(const objects::CAuth_list& auth_list)
233 {
234  m_AuthorsPanel->PopulateAuthors(m_SubmitBlock->SetCit().SetAuthors());
235  if (m_SubmitBlock && m_SubmitBlock->IsSetCit() && m_SubmitBlock->GetCit().IsSetAuthors() && m_SubmitBlock->GetCit().GetAuthors().Equals(auth_list)) {
236  return true;
237  } else {
238  return false;
239  }
240 }
241 
242 
243 bool CReferencePanel::CopyAuthors(objects::CAuth_list& authlist)
244 {
245  m_AuthorsPanel->PopulateAuthors(m_SubmitBlock->SetCit().SetAuthors());
246  if (m_SubmitBlock && m_SubmitBlock->IsSetCit() && m_SubmitBlock->GetCit().IsSetAuthors()) {
247  authlist.Assign(m_SubmitBlock->GetCit().GetAuthors());
248  return true;
249  } else {
250  return false;
251  }
252 }
253 
254 void CReferencePanel::CopyAffil(objects::CAuth_list &auth_list)
255 {
256  if (m_SubmitBlock && m_SubmitBlock->IsSetContact() && m_SubmitBlock->GetContact().IsSetContact() && m_SubmitBlock->GetContact().GetContact().IsSetAffil()) {
257  auth_list.SetAffil().Assign(m_SubmitBlock->GetContact().GetContact().GetAffil());
258  }
259 }
260 
262 {
263  for (size_t i = 0; i < m_Listbook->GetPageCount(); ++i) {
264  m_Listbook->GetPage(i)->TransferDataToWindow();
265  }
266  return wxPanel::TransferDataToWindow();
267 }
268 
270 {
271  auto page = x_GetCurrentPage();
272  if (page) {
274  page->ApplyCommand();
275  }
276 }
277 
279 {
280  ISubmissionPage* page = nullptr;
281  if (m_Listbook) {
282  wxWindow *win = m_Listbook->GetCurrentPage();
283  if (win) {
284  page = dynamic_cast<ISubmissionPage*>(win);
285  }
286  }
287  return page;
288 }
289 
290 void CReferencePanel::SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
291 {
292  m_Seh = seh;
294 }
295 
297 {
298  for (size_t i = 0; i < m_Listbook->GetPageCount(); ++i)
299  {
300  wxWindow* win = m_Listbook->GetPage(i);
301  ISubmissionPage* page = dynamic_cast<ISubmissionPage*>(win);
302  page->ReportMissingFields(text);
303  }
304 }
305 
307 {
308  auto page = x_GetCurrentPage();
309  if (page) {
310  return page->GetAnchor();
311  }
312  return wxEmptyString;
313 }
314 
315 wxString CReferencePanel::GetName() const
316 {
317  auto page = x_GetCurrentPage();
318  if (page) {
319  return page->GetName();
320  }
321  return wxEmptyString;
322 }
323 
User-defined methods of the data storage class.
void PopulateAuthors(objects::CAuth_list &auth_list)
virtual void ApplySubmitBlock(objects::CSubmit_block &block)
void ApplyPub(objects::CPubdesc &pubdesc)
void ApplyCitSub(objects::CCit_sub &sub)
virtual void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
CRef –.
Definition: ncbiobj.hpp:618
CPubStatusPanel * m_StatusPanel
bool MatchesCitSubAuthors(const objects::CAuth_list &authlist)
virtual wxString GetAnchor()
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void CopyAffil(objects::CAuth_list &auth_list)
virtual bool TransferDataToWindow()
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
virtual bool TransferDataFromWindow()
virtual void ReportMissingFields(string &text)
virtual bool StepForward()
ISubmissionPage * x_GetCurrentPage() const
virtual void ApplyCommand()
CAuthorNamesPanel * m_AuthorsPanel
static bool ShowToolTips()
Should we show tooltips?
objects::CSeq_entry_Handle m_Seh
CRef< objects::CSubmit_block > m_SubmitBlock
void CreateControls()
Creates the controls and sizers.
virtual void ApplySubmitBlock(objects::CSubmit_block &block)
virtual void SetSeqEntryHandle(objects::CSeq_entry_Handle seh)
bool Create(wxWindow *parent, wxWindowID id=ID_CREFERENCEPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
virtual void ApplyDescriptor(objects::CSeqdesc &desc)
ICommandProccessor * m_CmdProcessor
bool CopyAuthors(objects::CAuth_list &authlist)
void Init()
Initialises member variables.
void OnPageChanging(wxBookCtrlEvent &event)
virtual wxString GetName() const
~CReferencePanel()
Destructor.
void OnPageChanged(wxBookCtrlEvent &event)
virtual bool StepBackward()
CReferencePanel()
Constructors.
wxListbook * m_Listbook
virtual void UpdateOnPageChange(wxWindow *current_page)=0
Undo/Redo interface for editing operations.
bool x_DoStepForward(wxListbook *book)
virtual void ReportMissingFields(string &text)
bool x_DoStepBackward(wxListbook *book)
CSubmissionPageChangeListener * GetParentWizard(wxWindow *wnd) const
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
END_EVENT_TABLE()
int i
static void text(MDB_val *v)
Definition: mdb_dump.c:62
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
Modified on Sun Mar 03 03:12:25 2024 by modify_doxy.py rev. 669887