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

Go to the SVN repository for this file.

1 /////////////////////////////////////////////////////////////////////////////
2 // Name: seqgraphic_demo_dlg.cpp
3 // Purpose:
4 // Author: Vlad Lebedev
5 // Modified by:
6 // Created: Fri 15 Feb 14:23:52 2008
7 // RCS-ID:
8 // Copyright:
9 // Licence:
10 /////////////////////////////////////////////////////////////////////////////
11 
12 
13 ////@begin includes
14 ////@end includes
15 
16 #include <ncbi_pch.hpp>
17 #include <corelib/ncbistd.hpp>
18 #include <corelib/ncbitime.hpp>
19 
20 #include "seqgraphic_demo_dlg.hpp"
21 
23 
25 
27 
28 #include <serial/objistr.hpp>
29 #include <serial/serial.hpp>
30 
32 
33 // Register commands
37 
38 #include <wx/msgdlg.h>
39 #include <wx/statline.h>
40 #include <wx/sizer.h>
41 #include <wx/textctrl.h>
42 #include <wx/button.h>
43 #include <wx/bitmap.h>
44 #include <wx/icon.h>
45 
46 ////@begin XPM images
47 ////@end XPM images
48 
49 
52 
53 IMPLEMENT_DYNAMIC_CLASS( CSeqGraphicDemoDlg, wxDialog )
54 BEGIN_EVENT_TABLE( CSeqGraphicDemoDlg, wxDialog )
55 
56 ////@begin CSeqGraphicDemoDlg event table entries
58 
60 
62 
64 
65  EVT_BUTTON( wxID_CLOSE, CSeqGraphicDemoDlg::OnCloseClick )
66 
67 ////@end CSeqGraphicDemoDlg event table entries
68 
70 
71 
73 {
74  Init();
75 }
76 
77 
78 CSeqGraphicDemoDlg::CSeqGraphicDemoDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
79 {
80  Init();
81  Create(parent, id, caption, pos, size, style);
82 }
83 
84 
85 bool CSeqGraphicDemoDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
86 {
87 ////@begin CSeqGraphicDemoDlg creation
88  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
89  wxDialog::Create( parent, id, caption, pos, size, style );
90 
92  Centre();
93 ////@end CSeqGraphicDemoDlg creation
94  return true;
95 }
96 
97 
99 {
100 ////@begin CSeqGraphicDemoDlg destruction
101 ////@end CSeqGraphicDemoDlg destruction
102 }
103 
104 
106 {
107 ////@begin CSeqGraphicDemoDlg member initialisation
108  m_SeqWidget = NULL;
109  m_AccInput = NULL;
110  m_FileInput = NULL;
111  m_FlipStrand = NULL;
112 ////@end CSeqGraphicDemoDlg member initialisation
113 
114  if ( !m_ObjMgr ) {
117 
118  m_Scope.Reset(new CScope(*m_ObjMgr));
119  m_Scope->AddDefaults();
120  }
121 
124  WidgetsWx_RegisterCommands(cmd_reg, *provider);
125  CSeqGraphicWidget::RegisterCommands(cmd_reg, *provider);
126 }
127 
128 
130 {
131 ////@begin CSeqGraphicDemoDlg content construction
132  CSeqGraphicDemoDlg* itemDialog1 = this;
133 
134  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
135  itemDialog1->SetSizer(itemBoxSizer2);
136 
137  m_SeqWidget = new CSeqGraphicWidget( itemDialog1, ID_WIDGET, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
138  itemBoxSizer2->Add(m_SeqWidget, 1, wxGROW|wxALL, 5);
139 
140  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
141  itemBoxSizer2->Add(itemBoxSizer4, 0, wxGROW|wxALL, 5);
142 
143  wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(0, 2, 0, 0);
144  itemBoxSizer4->Add(itemFlexGridSizer5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 0);
145 
146  m_AccInput = new wxTextCtrl( itemDialog1, ID_ACC_TEXT, _("s"), wxDefaultPosition, wxDefaultSize, 0 );
147  m_AccInput->SetMaxLength(20);
148  m_AccInput->SetHelpText(_("Enter Accession"));
150  m_AccInput->SetToolTip(_("Enter Accession"));
151  itemFlexGridSizer5->Add(m_AccInput, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
152 
153  wxButton* itemButton7 = new wxButton( itemDialog1, ID_ACC, _("Load Accession"), wxDefaultPosition, wxDefaultSize, 0 );
154  itemFlexGridSizer5->Add(itemButton7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
155 
156  m_FileInput = new wxTextCtrl( itemDialog1, ID_FILE_TEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
157  m_FileInput->SetMaxLength(256);
158  m_FileInput->SetHelpText(_("Enter asn file name"));
160  m_FileInput->SetToolTip(_("Enter asn file name"));
161  itemFlexGridSizer5->Add(m_FileInput, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
162 
163  wxButton* itemButton9 = new wxButton( itemDialog1, ID_FILE, _("Load File"), wxDefaultPosition, wxDefaultSize, 0 );
164  itemFlexGridSizer5->Add(itemButton9, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
165 
166  itemFlexGridSizer5->AddGrowableCol(0);
167 
168  wxStaticLine* itemStaticLine10 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
169  itemBoxSizer4->Add(itemStaticLine10, 0, wxGROW|wxALL, 5);
170 
171  m_FlipStrand = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Flip Strand"), wxDefaultPosition, wxDefaultSize, 0 );
172  m_FlipStrand->SetValue(false);
173  itemBoxSizer4->Add(m_FlipStrand, 0, wxALIGN_TOP|wxALL, 5);
174 
175  wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CLOSE, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
177  itemButton12->SetToolTip(_("Close"));
178  itemBoxSizer4->Add(itemButton12, 0, wxALIGN_BOTTOM|wxALL, 5);
179 
180 ////@end CSeqGraphicDemoDlg content construction
181  m_SeqWidget->Create();
182  m_AccInput->SetValue(wxT("nt_011515"));
183 }
184 
185 
186 void CSeqGraphicDemoDlg::OnCloseWindow( wxCloseEvent& event )
187 {
188  Destroy();
189 }
190 
191 
192 void CSeqGraphicDemoDlg::OnAccClick( wxCommandEvent& event )
193 {
194  m_SeqId.Reset(new CSeq_id());
195 
196  string acc = ToStdString(m_AccInput->GetValue());
197  try {
198  m_SeqId->Set(acc);
199  }
200  catch (CSeqIdException&) {
201  string msg("Accession '");
202  msg += acc + " not recognized as a valid accession";
203  wxMessageBox(ToWxString(msg), _("Cannot load accesion"),
204  wxOK | wxICON_ERROR);
205  return;
206  }
207 
209  //string file_path = "etc/plugin_config.asn";
210  wxString file_path = CSysPath::ResolvePath(wxT("<std>/etc/plugin_config.asn"));
211  //m_ThemeFile->value(file_path.c_str());
212  /// set the global repository
213  {{
214  CNcbiIfstream istr(file_path.fn_str());
215  if (istr) {
216  reg.SetLocal(istr);
217  }
218  }}
219 
220  try {
222  LOG_POST(Info <<
223  "CViewGraphical::InitView() - finish with loading configuration!");
224  } catch (CException&) {
225  wxMessageBox(_("Something is wrong with configuration!"),
226  _("Failed to load configuration for Graphical view"),
227  wxOK | wxICON_EXCLAMATION);
228  return;
229  }
230 
231  try {
232  // retrieve our sequence
233 
236  string id_desc;
237  } catch (CException&) {
238  string msg("Can't find sequence for accession '");
239  msg += acc + "'";
240  wxMessageBox(ToWxString(msg), _("Cannot load accesion"),
241  wxOK | wxICON_ERROR);
242  return;
243  }
244 }
245 
246 
247 void CSeqGraphicDemoDlg::OnFileClick( wxCommandEvent& event )
248 {
249 ////@begin wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FILE in CSeqGraphicDemoDlg.
250  // Before editing this code, remove the block markers.
251  event.Skip();
252 ////@end wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_FILE in CSeqGraphicDemoDlg.
253 }
254 
255 
256 void CSeqGraphicDemoDlg::OnFlipStrand( wxCommandEvent& event )
257 {
258  m_SeqWidget->SetHorizontal(true, m_FlipStrand->IsChecked());
259 }
260 
261 
262 void CSeqGraphicDemoDlg::OnCloseClick( wxCommandEvent& event )
263 {
264  Close();
265 }
266 
267 
269 {
270  return true;
271 }
272 
273 
274 wxBitmap CSeqGraphicDemoDlg::GetBitmapResource( const wxString& name )
275 {
276  // Bitmap retrieval
277 ////@begin CSeqGraphicDemoDlg bitmap retrieval
278  wxUnusedVar(name);
279  return wxNullBitmap;
280 ////@end CSeqGraphicDemoDlg bitmap retrieval
281 }
282 
283 
284 wxIcon CSeqGraphicDemoDlg::GetIconResource( const wxString& name )
285 {
286  // Icon retrieval
287 ////@begin CSeqGraphicDemoDlg icon retrieval
288  wxUnusedVar(name);
289  return wxNullIcon;
290 ////@end CSeqGraphicDemoDlg icon retrieval
291 }
292 
EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX, CAdjustFeaturesForGaps::OnKnownUnknownSelected) EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX1
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, CReader *reader=0, CObjectManager::EIsDefault is_default=CObjectManager::eDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
Definition: gbloader.cpp:366
virtual void Create()
creates controls and performs basic initialization
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
void SetLocal(CNcbiIstream &istr)
establish our "local" repository.
Definition: registry.cpp:55
CScope –.
Definition: scope.hpp:92
CRef< objects::CSeq_id > m_SeqId
void OnCloseClick(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=10000, const wxString &caption=_("CSeqGraphicDemoDlg"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(800, 600), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxMAXIMIZE_BOX|wxMINIMIZE_BOX)
void OnAccClick(wxCommandEvent &event)
wxIcon GetIconResource(const wxString &name)
wxBitmap GetBitmapResource(const wxString &name)
void OnFileClick(wxCommandEvent &event)
CRef< CObjectManager > m_ObjMgr
void OnFlipStrand(wxCommandEvent &event)
void OnCloseWindow(wxCloseEvent &event)
CSeqGraphicWidget * m_SeqWidget
void UpdateConfig()
The config object has changed. Do what is necessary.
void SetHorizontal(bool b_horz, bool b_flip)
void SetInputObject(SConstScopedObject &obj)
access the data source
static void RegisterCommands(CUICommandRegistry &cmd_reg, wxFileArtProvider &provider)
CSeqIdException –.
Definition: Seq_id.hpp:1001
static wxString ResolvePath(const wxString &path, const wxString &rel_name)
Utility function to hide the platform specifics of locating our standard directories and files.
Definition: sys_path.cpp:106
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
static CUICommandRegistry & GetInstance()
the main instance associated with the application
Definition: ui_command.cpp:176
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define ID_WIDGET
#define ID_ACC_TEXT
#define ID_ACC
#define ID_FILE_TEXT
#define ID_FILE
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
Definition: scope.cpp:504
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
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
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
Definition: ncbistre.hpp:439
END_EVENT_TABLE()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines: CTimeFormat - storage class for time format.
USING_SCOPE(objects)
void WidgetsWx_RegisterCommands(CUICommandRegistry &cmd_reg, wxFileArtProvider &provider)
Register standard commands defined in this file and wxWidgets headers.
Definition: commands.cpp:46
#define ID_CHECKBOX1
wxFileArtProvider * GetDefaultFileArtProvider()
Definition: wx_utils.cpp:334
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Wed Apr 17 13:09:03 2024 by modify_doxy.py rev. 669887