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

Go to the SVN repository for this file.

1 /* $Id: cds_product_panel.cpp 25718 2012-04-26 13:31:53Z bollin $
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: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 ////@begin includes
32 ////@end includes
33 
34 #include "cds_product_panel.hpp"
35 
39 
42 #include <serial/serialbase.hpp>
43 #include <serial/typeinfo.hpp>
44 
45 #include <wx/sizer.h>
46 #include <wx/stattext.h>
47 #include <wx/textctrl.h>
48 #include <wx/choice.h>
49 #include <wx/bitmap.h>
50 #include <wx/icon.h>
51 
52 ////@begin XPM images
53 ////@end XPM images
54 
57 
58 /*!
59  * CCDSProductPanel type definition
60  */
61 
62 IMPLEMENT_DYNAMIC_CLASS( CCDSProductPanel, wxPanel )
63 
64 
65 /*!
66  * CCDSProductPanel event table definition
67  */
68 
69 BEGIN_EVENT_TABLE( CCDSProductPanel, wxPanel )
70 
71 ////@begin CCDSProductPanel event table entries
72 ////@end CCDSProductPanel event table entries
73 
75 
76 
77 /*!
78  * CCDSProductPanel constructors
79  */
80 
82 {
83  Init();
84 }
85 
86 CCDSProductPanel::CCDSProductPanel( wxWindow* parent, CSerialObject& object, CScope&,
87  wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
88  : m_Object(0)
89 {
90  m_Object = &object;
91  _ASSERT(m_Object->GetThisTypeInfo()->GetName() == "Cdregion");
92  Init();
93  Create(parent, id, pos, size, style);
94 }
95 
96 /*!
97  * CCDSProductPanel creator
98  */
99 
100 bool CCDSProductPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
101 {
102 ////@begin CCDSProductPanel creation
103  wxPanel::Create( parent, id, pos, size, style );
104 
105  CreateControls();
106  if (GetSizer())
107  {
108  GetSizer()->SetSizeHints(this);
109  }
110  Centre();
111 ////@end CCDSProductPanel creation
112  return true;
113 }
114 
115 
116 /*!
117  * CCDSProductPanel destructor
118  */
119 
121 {
122 ////@begin CCDSProductPanel destruction
123 ////@end CCDSProductPanel destruction
124 }
125 
126 
127 /*!
128  * Member initialisation
129  */
130 
132 {
133 ////@begin CCDSProductPanel member initialisation
134 ////@end CCDSProductPanel member initialisation
135 }
136 
137 
138 /*!
139  * Control creation for CCDSProductPanel
140  */
141 
143 {
144 ////@begin CCDSProductPanel content construction
145  CCDSProductPanel* itemPanel1 = this;
146 
147  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
148  itemPanel1->SetSizer(itemBoxSizer2);
149 
150 ////@end CCDSProductPanel content construction
151 
152  CCdregion& cds = dynamic_cast<CCdregion&>(*m_Object);
153 
154  string codeName;
155  int codeId = 1;
156 
157  if (cds.IsSetCode()) {
158  const CCdregion::TCode& code = cds.GetCode();
159  codeId = code.GetId();
160  codeName = code.GetName();
161  }
162 
164  const CGenetic_code_table::Tdata& codes = code_table.Get();
165 
166  int idIndex = -1, idByName = -1;
167  ITERATE (CGenetic_code_table::Tdata, it, codes) {
168  string str = (*it)->GetName();
169  int id = (*it)->GetId();
170 
171  string::size_type pos = str.find(';');
172  string tmp = (pos != string::npos) ? str.substr(0, pos) + ", etc." : str;
173  int index = m_GeneticCode->Append(ToWxString(tmp), (void*)id);
174 
175  if (codeId == id)
176  idIndex = index;
177 
178  if (codeName == str)
179  idByName = index;
180  }
181 
182  if (idIndex < 0)
183  idIndex = idByName;
184  if (idIndex < 0)
185  idIndex = 0;
186 
187  m_GeneticCode->SetSelection(idIndex);
188 
189  if (cds.IsSetConflict() && cds.GetConflict()) {
190  m_ConflictCtrl->SetValue (true);
191  }
192 }
193 
194 
196 {
197  bool result = wxPanel::TransferDataFromWindow();
198 
199  int index = m_GeneticCode->GetSelection();
200  int id = 1;
201  if (index != wxNOT_FOUND)
202  id = (long)m_GeneticCode->GetClientData(index);
203 
205  ce->SetId(id);
207  code->Set().push_back(ce);
208 
209  CCdregion& cds = dynamic_cast<CCdregion&>(*m_Object);
210  cds.SetCode(*code);
211 
212  if (m_ConflictCtrl->GetValue ()) {
213  cds.SetConflict(true);
214  } else {
215  cds.ResetConflict();
216  }
217 
218  return result;
219 }
220 
221 
223 {
225  CCdregion& cds = dynamic_cast<CCdregion&>(*m_Object);
226  if (cds.IsSetCode()) {
227  CRef<CGenetic_code> new_code(new CGenetic_code());
228  new_code->Assign(cds.GetCode());
229  edit_cds.SetCode(*new_code);
230  } else {
231  edit_cds.ResetCode();
232  }
233  if (cds.IsSetFrame()) {
234  edit_cds.SetFrame(cds.GetFrame());
235  } else {
236  edit_cds.ResetFrame();
237  }
238 
239  if (cds.IsSetConflict() && cds.GetConflict()) {
240  edit_cds.SetConflict(true);
241  } else {
242  edit_cds.ResetConflict();
243  }
244 
245 }
246 
247 
248 /*!
249  * Should we show tooltips?
250  */
251 
253 {
254  return true;
255 }
256 
257 /*!
258  * Get bitmap resources
259  */
260 
261 wxBitmap CCDSProductPanel::GetBitmapResource( const wxString& name )
262 {
263  // Bitmap retrieval
264 ////@begin CCDSProductPanel bitmap retrieval
265  wxUnusedVar(name);
266  return wxNullBitmap;
267 ////@end CCDSProductPanel bitmap retrieval
268 }
269 
270 /*!
271  * Get icon resources
272  */
273 
274 wxIcon CCDSProductPanel::GetIconResource( const wxString& name )
275 {
276  // Icon retrieval
277 ////@begin CCDSProductPanel icon retrieval
278  wxUnusedVar(name);
279  return wxNullIcon;
280 ////@end CCDSProductPanel icon retrieval
281 }
282 
User-defined methods of the data storage class.
USING_SCOPE(objects)
void SetCdregionFields(objects::CCdregion &cds)
CCDSProductPanel()
Constructors.
~CCDSProductPanel()
Destructor.
virtual bool TransferDataFromWindow()
CSerialObject * m_Object
static bool ShowToolTips()
Should we show tooltips?
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void Init()
Initialises member variables.
bool Create(wxWindow *parent, wxWindowID id=ID_CCDSPRODUCTPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void CreateControls()
Creates the controls and sizers.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
CCdregion –.
Definition: Cdregion.hpp:66
static const CGenetic_code_table & GetCodeTable(void)
CRef –.
Definition: ncbiobj.hpp:618
CScope –.
Definition: scope.hpp:92
Base class for all serializable objects.
Definition: serialbase.hpp:150
static void Init(void)
Definition: cursor6.c:76
static const char * str(char *buf, int n)
Definition: stats.c:84
static char tmp[3200]
Definition: utf8.c:42
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
#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 string & GetName(void) const
Get name of this type.
Definition: typeinfo.cpp:249
bool IsSetCode(void) const
genetic code used Check if a value has been assigned to Code data member.
Definition: Cdregion_.hpp:700
void ResetCode(void)
Reset Code data member.
Definition: Cdregion_.cpp:63
void SetCode(TCode &value)
Assign a value to Code data member.
Definition: Cdregion_.cpp:68
list< CRef< CGenetic_code > > Tdata
bool IsSetConflict(void) const
conflict Check if a value has been assigned to Conflict data member.
Definition: Cdregion_.hpp:559
TFrame GetFrame(void) const
Get the Frame member data.
Definition: Cdregion_.hpp:534
const TCode & GetCode(void) const
Get the Code member data.
Definition: Cdregion_.hpp:712
void ResetFrame(void)
Reset Frame data member.
Definition: Cdregion_.hpp:521
void ResetConflict(void)
Reset Conflict data member.
Definition: Cdregion_.hpp:571
const Tdata & Get(void) const
Get the member data.
void SetConflict(TConflict value)
Assign a value to Conflict data member.
Definition: Cdregion_.hpp:587
void SetFrame(TFrame value)
Assign a value to Frame data member.
Definition: Cdregion_.hpp:540
TConflict GetConflict(void) const
Get the Conflict member data.
Definition: Cdregion_.hpp:578
bool IsSetFrame(void) const
Check if a value has been assigned to Frame data member.
Definition: Cdregion_.hpp:509
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
Definition: inftrees.h:24
#define _ASSERT
else result
Definition: token2.c:20
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Sat Jun 29 13:55:08 2024 by modify_doxy.py rev. 669887