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

Go to the SVN repository for this file.

1 /* $Id: agp_export_page.cpp 39318 2017-09-12 16:00:18Z evgeniev $
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 
32 #include <wx/sizer.h>
33 #include <wx/checkbox.h>
34 #include <wx/choice.h>
35 #include <wx/bmpbuttn.h>
36 #include <wx/textctrl.h>
37 #include <wx/stattext.h>
38 #include <wx/valgen.h>
39 #include <wx/valtext.h>
40 #include <wx/msgdlg.h>
41 #include <wx/filedlg.h>
42 #include <wx/bitmap.h>
43 #include <wx/icon.h>
44 #include <wx/artprov.h>
45 
48 
50 #include <serial/typeinfo.hpp>
51 
52 ////@begin includes
53 ////@end includes
54 
55 #include "agp_export_page.hpp"
56 
57 ////@begin XPM images
58 ////@end XPM images
59 
60 
62 
63 /*!
64  * CAgpExportPage type definition
65  */
66 
67 IMPLEMENT_DYNAMIC_CLASS( CAgpExportPage, wxPanel )
68 
69 
70 /*!
71  * CAgpExportPage event table definition
72  */
73 
74 BEGIN_EVENT_TABLE( CAgpExportPage, wxPanel )
75 
76 ////@begin CAgpExportPage event table entries
77  EVT_BUTTON( ID_BITMAPBUTTON5, CAgpExportPage::OnSelectFileClick )
78 
79 ////@end CAgpExportPage event table entries
80 
82 
83 
84 /*!
85  * CAgpExportPage constructors
86  */
87 
89 {
90  Init();
91 }
92 
93 CAgpExportPage::CAgpExportPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, long style )
94 {
95  Init();
96  Create(parent, id, pos, style);
97 }
98 
99 
100 /*!
101  * CAgpPExportPage creator
102  */
103 
104 bool CAgpExportPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, long style )
105 {
106  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
107  wxPanel::Create( parent, id, pos, wxSize(0,0), style );
108  Hide();
109 
110  CreateControls();
111  if (GetSizer())
112  {
113  GetSizer()->SetSizeHints(this);
114  }
115  Centre();
116 
117  return true;
118 }
119 
120 
121 /*!
122  * CAgpExportPage destructor
123  */
124 
126 {
127 ////@begin CAgpExportPage destruction
128 ////@end CAgpExportPage destruction
129 }
130 
131 
132 /*!
133  * Member initialisation
134  */
135 
137 {
138 ////@begin CAgpExportPage member initialisation
140 ////@end CAgpExportPage member initialisation
141 }
142 
143 
144 /*!
145  * Control creation for CAgpPExportPage
146  */
147 
149 {
150 ////@begin CAgpExportPage content construction
151  CAgpExportPage* itemPanel1 = this;
152 
153  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
154  itemPanel1->SetSizer(itemBoxSizer2);
155 
156  m_LocationSel = new CObjectListWidgetSel( itemPanel1, ID_PANEL2, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL|wxLC_SINGLE_SEL );
157  itemBoxSizer2->Add(m_LocationSel, 1, wxGROW|wxALL, 0);
158 
159  wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0);
160  itemBoxSizer2->Add(itemFlexGridSizer4, 0, wxALIGN_LEFT|wxALL, 0);
161 
162  wxStaticText* itemStaticText5 = new wxStaticText( itemPanel1, wxID_STATIC, _("Gap type (col. 7)"), wxDefaultPosition, wxDefaultSize, 0 );
163  itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
164 
165  wxArrayString itemChoice6Strings;
166  itemChoice6Strings.Add(_("fragment"));
167  itemChoice6Strings.Add(_("clone"));
168  itemChoice6Strings.Add(_("contig"));
169  itemChoice6Strings.Add(_("split_finished"));
170  itemChoice6Strings.Add(_("centromere"));
171  itemChoice6Strings.Add(_("short_arm"));
172  itemChoice6Strings.Add(_("heterochromatin"));
173  itemChoice6Strings.Add(_("telomere"));
174  wxChoice* itemChoice6 = new wxChoice( itemPanel1, ID_CHOICE2, wxDefaultPosition, wxDefaultSize, itemChoice6Strings, 0 );
175  itemFlexGridSizer4->Add(itemChoice6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
176 
177  wxStaticText* itemStaticText7 = new wxStaticText( itemPanel1, wxID_STATIC, _("Alternate object id (column 1)"), wxDefaultPosition, wxDefaultSize, 0 );
178  itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
179 
180  wxTextCtrl* itemTextCtrl8 = new wxTextCtrl( itemPanel1, ID_TEXTCTRL4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
181  itemFlexGridSizer4->Add(itemTextCtrl8, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
182 
183  wxCheckBox* itemCheckBox9 = new wxCheckBox( itemPanel1, ID_CHECKBOX15, _("Assert evidence for linkage between components (\"yes\" in col. 8 of gap lines)"), wxDefaultPosition, wxDefaultSize, 0 );
184  itemCheckBox9->SetValue(false);
185  itemBoxSizer2->Add(itemCheckBox9, 0, wxALIGN_LEFT|wxALL, 5);
186 
187  wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
188  itemBoxSizer2->Add(itemBoxSizer10, 0, wxGROW|wxALL, 0);
189 
190  wxStaticText* itemStaticText11 = new wxStaticText( itemPanel1, wxID_STATIC, _("File name"), wxDefaultPosition, wxDefaultSize, 0 );
191  itemBoxSizer10->Add(itemStaticText11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
192 
193  wxTextCtrl* itemTextCtrl12 = new wxTextCtrl( itemPanel1, ID_TEXTCTRL5, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
194  itemBoxSizer10->Add(itemTextCtrl12, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
195 
196  wxBitmapButton* itemBitmapButton13 = new wxBitmapButton( itemPanel1, ID_BITMAPBUTTON5, itemPanel1->GetBitmapResource(wxT("menu::open")), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW );
197  itemBitmapButton13->SetHelpText(_("Select AGP File"));
199  itemBitmapButton13->SetToolTip(_("Select AGP File"));
200  itemBoxSizer10->Add(itemBitmapButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
201 
202  // Set validators
203  itemTextCtrl8->SetValidator( wxTextValidator(wxFILTER_NONE, & GetData().m_AltObjId) );
204  itemCheckBox9->SetValidator( wxGenericValidator(& GetData().m_AssertEvidence) );
205  itemTextCtrl12->SetValidator( wxTextValidator(wxFILTER_NONE, & GetData().m_FileName) );
206 ////@end CAgpExportPage content construction
207 
208  m_LocationSel->SetTitle(wxT("Select Location"));
209  m_SaveFile.reset(new CSaveFileHelper(this, *itemTextCtrl12));
210 }
211 
213 {
215 
217 }
218 
219 /*!
220  * Should we show tooltips?
221  */
222 
224 {
225  return true;
226 }
227 
228 /*!
229  * Get bitmap resources
230  */
231 
232 wxBitmap CAgpExportPage::GetBitmapResource( const wxString& name )
233 {
234  return wxArtProvider::GetBitmap(name);
235 }
236 
237 /*!
238  * Get icon resources
239  */
240 
241 wxIcon CAgpExportPage::GetIconResource( const wxString& name )
242 {
243  // Icon retrieval
244 ////@begin CAgpExportPage icon retrieval
245  wxUnusedVar(name);
246  return wxNullIcon;
247 ////@end CAgpExportPage icon retrieval
248 }
249 
250 /*!
251  * Transfer data to the window
252  */
253 
255 {
256  wxChoice* choice = (wxChoice*)FindWindow(ID_CHOICE2);
257  choice->SetStringSelection(ToWxString(GetData().m_GapType));
258 
259  return wxPanel::TransferDataToWindow();
260 }
261 
262 /*!
263  * Transfer data from the window
264  */
265 
267 {
268  if (!wxPanel::TransferDataFromWindow())
269  return false;
270 
271  wxChoice* choice = (wxChoice*)FindWindow(ID_CHOICE2);
272  GetData().m_GapType = ToStdString(choice->GetStringSelection());
273 
274  TConstScopedObjects selection;
275  selection = m_LocationSel->GetSelection();
276  m_data.m_SeqLoc = selection[0];
277 
278  wxString path = GetData().GetFileName();
280  return m_SaveFile->Validate(path);
281 }
282 
283 static const char* kLocationList = ".LocationList";
284 
285 void CAgpExportPage::SetRegistryPath(const string& path)
286 {
287  m_RegPath = path;
289 }
290 
292 {
294 }
295 
297 {
299 }
300 
301 void CAgpExportPage::OnSelectFileClick( wxCommandEvent& WXUNUSED(event) )
302 {
304  m_SaveFile->ShowSaveDialog(CFileExtensions::kAGP);
305 }
306 
static const char * kLocationList
virtual void SetRegistryPath(const string &path)
IRegSettings.
static bool ShowToolTips()
Should we show tooltips?
CAgpExportParams m_data
The data edited by this window.
void Init()
Initialises member variables.
std::unique_ptr< CSaveFileHelper > m_SaveFile
virtual bool TransferDataFromWindow()
Transfer data from the window.
void CreateControls()
Creates the controls and sizers.
bool Create(wxWindow *parent, wxWindowID id=ID_CAGPPEXPORTPAGE, const wxPoint &pos=wxDefaultPosition, long style=wxTAB_TRAVERSAL)
Creation.
CAgpExportParams & GetData()
Data access.
CObjectListWidgetSel * m_LocationSel
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
virtual void SaveSettings() const
virtual void LoadSettings()
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
virtual bool TransferDataToWindow()
Transfer data to the window.
void SetObjects(TRelatedObjectsMap *objects)
CAgpExportPage()
Constructors.
~CAgpExportPage()
Destructor.
void OnSelectFileClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BITMAPBUTTON5
SConstScopedObject m_SeqLoc
wxString GetFileName() const
virtual void SetRegistryPath(const string &path)
IRegSettings.
TConstScopedObjects GetSelection() const
void SetObjects(const TObjectListMap &value)
void SetTitle(const wxString &value)
virtual void SaveSettings() const
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
#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()
#define wxT(x)
Definition: muParser.cpp:41
#define _ASSERT
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Tue Jul 16 13:23:21 2024 by modify_doxy.py rev. 669887