NIREP
|
00001 00002 // Name: Interface.cpp 00003 // Purpose: 00004 // Author: James Harris II 00005 // Modified by: 00006 // Created: 25/01/2008 15:56:32 00007 // RCS-ID: 00008 // Copyright: All rights reserved 00009 // Licence: 00011 00012 // For compilers that support precompilation, includes "wx/wx.h". 00013 #include "wx/wxprec.h" 00014 00015 #ifdef __BORLANDC__ 00016 #pragma hdrstop 00017 #endif 00018 00019 #ifndef WX_PRECOMP 00020 #include "wx/wx.h" 00021 #endif 00022 #include "Interface.h" 00023 00024 00025 #include "new_small.xpm" 00026 #include "open_small.xpm" 00027 #include "save_small.xpm" 00028 #include "undo_small.xpm" 00029 #include "redo_small.xpm" 00030 #include "cut_small.xpm" 00031 #include "copy_small.xpm" 00032 #include "paste_small.xpm" 00033 #include "new.xpm" 00034 #include "open.xpm" 00035 #include "save.xpm" 00036 #include "undo.xpm" 00037 #include "redo.xpm" 00038 #include "copy.xpm" 00039 #include "cut.xpm" 00040 #include "paste.xpm" 00041 #include "fullscreen.xpm" 00042 #include "project_explorer.xpm" 00043 #include "project_explorer_sidebar.xpm" 00044 #include "property_window_sidebar.xpm" 00045 #include "property_window.xpm" 00046 00047 #include "project_explorer_tree.xpm" 00048 #include "datebase_tree.xpm" 00049 #include "display_tree.xpm" 00050 #include "algorithm_tree.xpm" 00051 #include "item.xpm" 00052 #include "NIREPGenericXMLParser.h" 00053 00054 #include "WindowDeleteSpatialData.h" 00055 #include "DeleteSpatialDataAction.h" 00056 00061 #include <vtksys/SystemTools.hxx> 00062 #include <vtksys/CommandLineArguments.hxx> 00063 00064 #include "wx/string.h" 00065 #include "wx/imaglist.h" 00066 #include "wx/menu.h" 00067 #include "wx/filedlg.h" 00068 #include "wx/msgdlg.h" 00069 00070 #include <string> 00071 #include <map> 00072 #include <vector> 00073 00074 #include "EditRDL.h" // GEC Added for debugging 00075 00076 #include "GenerateRDL.h" // JAH Added for debugging 00077 00078 //#include "CreateDisplay.h" //JAH added 00079 #include "ViewDisplayDescription.h"//JAH added 00080 #include "QuickView.h" //JAH added 00081 #include "QuickView2.h" //JAH added 00082 00084 00085 00086 using namespace std; 00092 #include <wx/textfile.h> 00093 00094 #include "NIREPDisplay.h" 00095 00100 IMPLEMENT_CLASS( Interface, wxFrame ) 00101 00102 00106 BEGIN_EVENT_TABLE( Interface, wxFrame ) 00107 00108 EVT_MENU( ID_LOAD_DISPLAY, Interface::OnLoadDisplayClick ) 00109 00110 EVT_MENU( ID_LOAD_RESOURCE_DESCRIPTION_LIST, Interface::OnLoadResourceNewFormatClick) // Added GEC 6/18/2010 debugging 00111 EVT_MENU( ID_SAVE_RESOURCE_DESCRIPTION_LIST, Interface::OnSaveResourceNewFormatClick) // Added GEC 6/18/2010 debugging 00112 EVT_MENU( ID_GENERATE_RESOURCE_DESCRIPTION_LIST, Interface::OnEditResourceNewFormat) // Added GEC 00113 00114 EVT_MENU( ID_CREATE_DISPLAY, Interface::OnViewDisplayDescription) // Added JAH 00115 EVT_MENU( ID_QUICK_VIEW, Interface::OnViewEvaluatorCommands) // Added JAH 00116 00117 EVT_MENU( wxID_SAVE, Interface::OnSaveClick ) 00118 00119 EVT_MENU( ID_SAVE_AS, Interface::OnSaveAsClick ) 00120 00121 EVT_MENU( ID_HELP, Interface::OnHelpClick ) 00122 00123 EVT_TIMER(TIMER_ID, Interface::OnTimer) 00124 00125 00126 EVT_GRID_CMD_CELL_CHANGE(ID_GRID, Interface::OnGridChange) 00127 EVT_GRID_CMD_EDITOR_SHOWN(ID_GRID, Interface::EditorShown) 00128 00129 EVT_MENU(wxID_CLOSE, Interface::OnQuit) 00130 00131 END_EVENT_TABLE() 00132 00137 Interface::Interface() 00138 { 00139 Init(); 00140 } 00141 00142 Interface::Interface( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) : m_timer(this, TIMER_ID) 00143 { 00144 m_timer.Start(100); 00145 Init(); 00146 Create( parent, id, caption, pos, size, style ); 00147 } 00148 00149 void Interface::OnTimer(wxTimerEvent& event) 00150 { 00151 m_timer.Stop(); 00152 m_timer.Start(100); 00153 } 00154 00159 bool Interface::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) 00160 { 00161 wxFrame::Create( parent, id, caption, pos, size, style ); 00162 00163 CreateControls(); 00164 Centre(); 00165 return true; 00166 } 00167 00172 Interface::~Interface() 00173 { 00174 delete dataManager; 00175 dataManager = NULL; 00176 delete evaluator; 00177 evaluator = NULL; 00178 00179 // Added GEC: temporary 00180 if (m_rdl){ 00181 delete m_rdl; 00182 m_rdl = NULL; 00183 } 00184 } 00185 00190 void Interface::Init() 00191 { 00192 dataManager = new NIREPDataManager(); 00193 dataManager->SetInterface(this); 00194 evaluator = new NIREPEvaluator(dataManager); 00195 00196 m_rdl = new ResourceDescriptionList(); // Added GEC: temporary 00197 00198 } 00199 00203 void Interface::CreateControls() 00204 { 00205 Interface* itemFrame1 = this; 00206 00207 //------------------------------Start of file menu--------------------------------------------------------- 00208 wxMenuBar* menuBar = new wxMenuBar; 00209 wxMenu* itemMenu3 = new wxMenu; 00210 { 00211 // Added GEC 00212 wxMenuItem* menuItem = new wxMenuItem(itemMenu3, ID_LOAD_RESOURCE_DESCRIPTION_LIST, _("Load Resource Description List"), _T(""), wxITEM_NORMAL); 00213 wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("open_small.xpm"))); 00214 menuItem->SetBitmap(bitmap); 00215 itemMenu3->Append(menuItem); 00216 } 00217 { 00218 // Added GEC 00219 wxMenuItem* menuItem = new wxMenuItem(itemMenu3, ID_SAVE_RESOURCE_DESCRIPTION_LIST, _("Save Resource Description List"), _T(""), wxITEM_NORMAL); 00220 wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("save_small.xpm"))); 00221 menuItem->SetBitmap(bitmap); 00222 itemMenu3->Append(menuItem); 00223 } 00224 { 00225 // Added GEC 00226 wxMenuItem* menuItem = new wxMenuItem(itemMenu3, ID_GENERATE_RESOURCE_DESCRIPTION_LIST, _("Edit Resource Description List"), _T(""), wxITEM_NORMAL); 00227 wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("new_small.xpm"))); 00228 menuItem->SetBitmap(bitmap); 00229 itemMenu3->Append(menuItem); 00230 } 00231 { 00232 // Added JAH 00233 wxMenuItem* menuItem = new wxMenuItem(itemMenu3, ID_CREATE_DISPLAY, _("Edit Display"), _T(""), wxITEM_NORMAL); 00234 itemMenu3->Append(menuItem); 00235 } 00236 { 00237 // Added JAH 00238 wxMenuItem* menuItem = new wxMenuItem(itemMenu3, ID_QUICK_VIEW, _("Quick View"), _T(""), wxITEM_NORMAL); 00239 itemMenu3->Append(menuItem); 00240 } 00241 { 00242 wxMenuItem* menuItem = new wxMenuItem(itemMenu3, ID_LOAD_DISPLAY, _("Load Display\tCtrl+O"), _T(""), wxITEM_NORMAL); 00243 wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("open_small.xpm"))); 00244 menuItem->SetBitmap(bitmap); 00245 itemMenu3->Append(menuItem); 00246 } 00247 00248 itemMenu3->AppendSeparator(); 00249 //wxMenu* itemMenu7 = new wxMenu; 00250 //itemMenu3->Append(wxID_ADD, _("Add"), itemMenu7); 00251 //{ 00252 // wxMenuItem* menuItem = new wxMenuItem(itemMenu3, wxID_SAVE, _("Save Project\tCtrl+S"), _T(""), wxITEM_NORMAL); 00253 // wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("save_small.xpm"))); 00254 // menuItem->SetBitmap(bitmap); 00255 // itemMenu3->Append(menuItem); 00256 //} 00257 //itemMenu3->Append(ID_SAVE_AS, _("Save Projects As..."), _T(""), wxITEM_NORMAL); 00258 //wxMenu* itemMenu13 = new wxMenu; 00259 //itemMenu3->Append(ID_RECENT_PROJECTS, _("Recent Projects"), itemMenu13); 00260 //itemMenu3->Enable(ID_RECENT_PROJECTS, false); 00261 //itemMenu3->AppendSeparator(); 00262 itemMenu3->Append(wxID_CLOSE, _("Exit\tCtrl+E"), _T(""), wxITEM_NORMAL); 00263 menuBar->Append(itemMenu3, _("File")); 00264 00265 //------------------------------End of file menu--------------------------------------------------------- 00266 00267 //------------------------------Start of Edit menu--------------------------------------------------------- 00268 //wxMenu* itemMenu16 = new wxMenu; 00269 //{ 00270 // wxMenuItem* menuItem = new wxMenuItem(itemMenu16, wxID_UNDO, _("Undo\tCtrl+Z"), _T(""), wxITEM_NORMAL); 00271 // wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("undo_small.xpm"))); 00272 // menuItem->SetBitmap(bitmap); 00273 // itemMenu16->Append(menuItem); 00274 //} 00275 //itemMenu16->Enable(wxID_UNDO, false); 00276 //{ 00277 // wxMenuItem* menuItem = new wxMenuItem(itemMenu16, wxID_REDO, _("Redo\tCtrl+Y"), _("dd"), wxITEM_NORMAL); 00278 // wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("redo_small.xpm"))); 00279 // menuItem->SetBitmap(bitmap); 00280 // itemMenu16->Append(menuItem); 00281 //} 00282 //itemMenu16->AppendSeparator(); 00283 //{ 00284 // wxMenuItem* menuItem = new wxMenuItem(itemMenu16, wxID_CUT, _("Cut\tCtrl+X"), _T(""), wxITEM_NORMAL); 00285 // wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("cut_small.xpm"))); 00286 // menuItem->SetBitmap(bitmap); 00287 // itemMenu16->Append(menuItem); 00288 //} 00289 //{ 00290 // wxMenuItem* menuItem = new wxMenuItem(itemMenu16, wxID_COPY, _("Copy\tCtrl+C"), _T(""), wxITEM_NORMAL); 00291 // wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("copy_small.xpm"))); 00292 // menuItem->SetBitmap(bitmap); 00293 // itemMenu16->Append(menuItem); 00294 //} 00295 //{ 00296 // wxMenuItem* menuItem = new wxMenuItem(itemMenu16, wxID_PASTE, _("Paste\tCtrl+V"), _T(""), wxITEM_NORMAL); 00297 // wxBitmap bitmap(itemFrame1->GetBitmapResource(wxT("paste_small.xpm"))); 00298 // menuItem->SetBitmap(bitmap); 00299 // itemMenu16->Append(menuItem); 00300 //} 00301 //itemMenu16->AppendSeparator(); 00302 //itemMenu16->Append(wxID_SELECTALL, _("Select All\tCtrl+A"), _T(""), wxITEM_NORMAL); 00303 //menuBar->Append(itemMenu16, _("Edit")); 00304 00305 //------------------------------End of edit menu--------------------------------------------------------- 00306 00307 //------------------------------Start of view menu--------------------------------------------------------- 00308 //wxMenu* itemMenu25 = new wxMenu; 00309 //itemMenu25->Append(ID_DATABASE_QUERY, _("Database Query\tAlt+Left"), _T(""), wxITEM_NORMAL); 00310 //itemMenu25->Append(ID_PAIRWISE_COMPARISON, _("Pairwise Comparison\tAlt+Right"), _T(""), wxITEM_NORMAL); 00311 //itemMenu25->Append(ID_GROUP_WISE, _("Group Wise\tAtl+Down"), _T(""), wxITEM_NORMAL); 00312 //menuBar->Append(itemMenu25, _("Preset Views")); 00313 //------------------------------End of view menu--------------------------------------------------------- 00314 00315 //------------------------------Start of help menu--------------------------------------------------------- 00316 wxMenu* itemMenu34 = new wxMenu; 00317 { 00318 wxMenuItem* menuItem = new wxMenuItem(itemMenu3, ID_HELP, _("Help"), _T(""), wxITEM_NORMAL); 00319 itemMenu34->Append(menuItem); 00320 } 00321 menuBar->Append(itemMenu34, _("Help")); 00322 //------------------------------End of help menu--------------------------------------------------------- 00323 00324 //Add the menu bar 00325 itemFrame1->SetMenuBar(menuBar); 00326 00327 //wxToolBar* itemToolBar35 = CreateToolBar( wxTB_FLAT|wxTB_HORIZONTAL, ID_TOOLBAR1 ); 00328 //itemToolBar35->SetToolBitmapSize(wxSize(32, 32)); 00329 //wxBitmap itemtool36Bitmap(itemFrame1->GetBitmapResource(wxT("new.xpm"))); 00330 //wxBitmap itemtool36BitmapDisabled; 00331 //itemToolBar35->AddTool(wxID_NEW, _T(""), itemtool36Bitmap, itemtool36BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00332 //wxBitmap itemtool37Bitmap(itemFrame1->GetBitmapResource(wxT("open.xpm"))); 00333 //wxBitmap itemtool37BitmapDisabled; 00334 //itemToolBar35->AddTool(ID_LOAD_DISPLAY, _T(""), itemtool37Bitmap, itemtool37BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00335 //wxBitmap itemtool38Bitmap(itemFrame1->GetBitmapResource(wxT("save.xpm"))); 00336 //wxBitmap itemtool38BitmapDisabled; 00337 //itemToolBar35->AddTool(wxID_SAVE, _T(""), itemtool38Bitmap, itemtool38BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00338 //itemToolBar35->AddSeparator(); 00339 //wxBitmap itemtool40Bitmap(itemFrame1->GetBitmapResource(wxT("undo.xpm"))); 00340 //wxBitmap itemtool40BitmapDisabled; 00341 //itemToolBar35->AddTool(wxID_UNDO, _T(""), itemtool40Bitmap, itemtool40BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00342 //wxBitmap itemtool41Bitmap(itemFrame1->GetBitmapResource(wxT("redo.xpm"))); 00343 //wxBitmap itemtool41BitmapDisabled; 00344 //itemToolBar35->AddTool(wxID_REDO, _T(""), itemtool41Bitmap, itemtool41BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00345 //itemToolBar35->AddSeparator(); 00346 //wxBitmap itemtool43Bitmap(itemFrame1->GetBitmapResource(wxT("copy.xpm"))); 00347 //wxBitmap itemtool43BitmapDisabled; 00348 //itemToolBar35->AddTool(wxID_COPY, _T(""), itemtool43Bitmap, itemtool43BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00349 //wxBitmap itemtool44Bitmap(itemFrame1->GetBitmapResource(wxT("cut.xpm"))); 00350 //wxBitmap itemtool44BitmapDisabled; 00351 //itemToolBar35->AddTool(wxID_CUT, _T(""), itemtool44Bitmap, itemtool44BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00352 //wxBitmap itemtool45Bitmap(itemFrame1->GetBitmapResource(wxT("paste.xpm"))); 00353 //wxBitmap itemtool45BitmapDisabled; 00354 //itemToolBar35->AddTool(wxID_PASTE, _T(""), itemtool45Bitmap, itemtool45BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00355 //itemToolBar35->AddSeparator(); 00356 //wxBitmap itemtool47Bitmap(itemFrame1->GetBitmapResource(wxT("fullscreen.xpm"))); 00357 //wxBitmap itemtool47BitmapDisabled; 00358 //itemToolBar35->AddTool(ID_ELEMENT, _T(""), itemtool47Bitmap, itemtool47BitmapDisabled, wxITEM_NORMAL, _T(""), wxEmptyString); 00359 //itemToolBar35->Realize(); 00360 //itemFrame1->SetToolBar(itemToolBar35); 00361 00362 wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(2, 2, 0, 0); 00363 itemFlexGridSizer3->AddGrowableRow(0); 00364 itemFlexGridSizer3->AddGrowableCol(0); 00365 itemFrame1->SetSizer(itemFlexGridSizer3); 00366 00367 grid = new wxGrid( itemFrame1, ID_GRID, wxDefaultPosition, wxSize(200, 150), wxSUNKEN_BORDER|wxHSCROLL|wxVSCROLL ); 00368 //wxListCtrl* itemListCtrl2 = new wxListCtrl( itemFrame1, wxID_ANY, wxDefaultPosition, wxSize(100, 100), wxLC_REPORT ); 00369 grid->CreateGrid(1, 3, wxGrid::wxGridSelectCells); 00370 grid->SetColLabelValue(0,_("Data in Memory")); 00371 grid->SetColLabelValue(1,_("Memory Size")); 00372 grid->SetColLabelValue(2,_("Delete?")); 00373 grid->SetReadOnly(0,0,true); 00374 grid->SetReadOnly(0,1,true); 00375 grid->SetReadOnly(0,2,true); 00376 //grid->SetEditable(false); 00377 itemFlexGridSizer3->Add(grid, 0, wxGROW|wxGROW|wxALL, 5); 00378 //wxListItem lI; 00379 //itemListCtrl2->setc 00380 grid->UpdateDimensions(); 00381 grid->AutoSize(); 00382 grid->SetCellValue(0,0,_("Total Memory:")); 00383 grid->UpdateDimensions(); 00384 wxString temp; 00385 unsigned long tempTwo = dataManager->GetMemoryUsage(); 00386 stringstream ss;//create a stringstream 00387 ss << tempTwo;//add number to the stream 00388 temp = wxString(ss.str().c_str(), wxConvUTF8); 00389 grid->SetCellValue(0,1,temp); 00390 00391 } 00392 00397 bool Interface::ShowToolTips() 00398 { 00399 return true; 00400 } 00401 00406 wxBitmap Interface::GetBitmapResource( const wxString& name ) 00407 { 00408 // Bitmap retrieval 00409 if (name == _T("project_explorer_tree_xpm")) 00410 { 00411 wxBitmap bitmap(project_explorer_tree_xpm); 00412 return bitmap; 00413 } 00414 if (name == _T("datebase_tree_xpm")) 00415 { 00416 wxBitmap bitmap(datebase_tree_xpm); 00417 return bitmap; 00418 } 00419 if (name == _T("display_tree_xpm")) 00420 { 00421 wxBitmap bitmap(display_tree_xpm); 00422 return bitmap; 00423 } 00424 if (name == _T("algorithm_tree_xpm")) 00425 { 00426 wxBitmap bitmap(algorithm_tree_xpm); 00427 return bitmap; 00428 } 00429 if (name == _T("item_xpm")) 00430 { 00431 wxBitmap bitmap(item_xpm); 00432 return bitmap; 00433 } 00434 00435 00437 wxUnusedVar(name); 00438 if (name == _T("new_small.xpm")) 00439 { 00440 wxBitmap bitmap(new_small_xpm); 00441 return bitmap; 00442 } 00443 else if (name == _T("open_small.xpm")) 00444 { 00445 wxBitmap bitmap(open_small_xpm); 00446 return bitmap; 00447 } 00448 else if (name == _T("save_small.xpm")) 00449 { 00450 wxBitmap bitmap(save_small_xpm); 00451 return bitmap; 00452 } 00453 else if (name == _T("undo_small.xpm")) 00454 { 00455 wxBitmap bitmap(undo_small_xpm); 00456 return bitmap; 00457 } 00458 else if (name == _T("redo_small.xpm")) 00459 { 00460 wxBitmap bitmap(redo_small_xpm); 00461 return bitmap; 00462 } 00463 else if (name == _T("cut_small.xpm")) 00464 { 00465 wxBitmap bitmap(cut_small_xpm); 00466 return bitmap; 00467 } 00468 else if (name == _T("copy_small.xpm")) 00469 { 00470 wxBitmap bitmap(copy_small_xpm); 00471 return bitmap; 00472 } 00473 else if (name == _T("paste_small.xpm")) 00474 { 00475 wxBitmap bitmap(paste_small_xpm); 00476 return bitmap; 00477 } 00478 else if (name == _T("new.xpm")) 00479 { 00480 wxBitmap bitmap(new_xpm); 00481 return bitmap; 00482 } 00483 else if (name == _T("open.xpm")) 00484 { 00485 wxBitmap bitmap(open_xpm); 00486 return bitmap; 00487 } 00488 else if (name == _T("save.xpm")) 00489 { 00490 wxBitmap bitmap(save_xpm); 00491 return bitmap; 00492 } 00493 else if (name == _T("undo.xpm")) 00494 { 00495 wxBitmap bitmap(undo_xpm); 00496 return bitmap; 00497 } 00498 else if (name == _T("redo.xpm")) 00499 { 00500 wxBitmap bitmap(redo_xpm); 00501 return bitmap; 00502 } 00503 else if (name == _T("copy.xpm")) 00504 { 00505 wxBitmap bitmap(copy_xpm); 00506 return bitmap; 00507 } 00508 else if (name == _T("cut.xpm")) 00509 { 00510 wxBitmap bitmap(cut_xpm); 00511 return bitmap; 00512 } 00513 else if (name == _T("paste.xpm")) 00514 { 00515 wxBitmap bitmap(paste_xpm); 00516 return bitmap; 00517 } 00518 else if (name == _T("fullscreen.xpm")) 00519 { 00520 wxBitmap bitmap(fullscreen_xpm); 00521 return bitmap; 00522 } 00523 return wxNullBitmap; 00525 } 00526 00531 wxIcon Interface::GetIconResource( const wxString& name ) 00532 { 00533 // Icon retrieval 00535 wxUnusedVar(name); 00536 return wxNullIcon; 00538 } 00539 00540 00545 void Interface::OnSize( wxSizeEvent& event ) 00546 { 00547 this->Refresh(false); 00549 // Before editing this code, remove the block markers. 00550 event.Skip(); 00552 } 00553 00554 00559 void Interface::OnMaximize( wxMaximizeEvent& event ) 00560 { 00561 this->Refresh(false); 00563 // Before editing this code, remove the block markers. 00564 event.Skip(); 00566 } 00567 00568 00573 void Interface::OnLoadDisplayClick( wxCommandEvent& event ) 00574 { 00575 //LoadDisplay *temp = new LoadDisplay(NULL,wxID_ANY); 00576 //temp->SetInterface(this); 00577 //temp->Show(true); 00578 00579 wxFileDialog * filedialog = new wxFileDialog(this, wxT("Choose a display description file"), wxT(""), wxT("*.*"), wxT("*.*")); 00580 00581 if( filedialog->ShowModal() == wxID_CANCEL ){ delete filedialog; return;} 00582 00583 wxString path = filedialog->GetPath(); 00584 00585 std::string filename = std::string(path.mb_str()); 00586 this->CreateNIREPDisplay(filename); 00587 00588 delete filedialog; 00589 00590 } 00591 00592 00593 // Added GEC 6/18/2010 debugging 00594 void Interface::OnLoadResourceNewFormatClick( wxCommandEvent& event ) { 00595 wxFileDialog * filedialog = new wxFileDialog(this, wxT("Choose a Resource Description List"), wxT(""), wxT("*.*"), wxT("*.*")); 00596 if( filedialog->ShowModal() == wxID_CANCEL ){ delete filedialog; return;} 00597 00598 wxString path = filedialog->GetPath(); 00599 if (!m_rdl->Load(std::string(path.ToAscii()))){ 00600 /*wxMessageDialog * msgdialog = new wxMessageDialog(NULL, 00601 wxT("Error: Resource Description List has a syntax error, i.e., could not parse XML."), 00602 wxT("Error"), wxICON_EXCLAMATION|wxOK); 00603 msgdialog->ShowModal();*/ 00604 00605 if (filedialog){ 00606 delete filedialog; 00607 } 00608 /*if (msgdialog){ 00609 delete msgdialog; 00610 }*/ 00611 return; 00612 }; 00613 00614 const BasicDescription * bdescrip = m_rdl->GetNameSpaceDescrip(std::string("na0")); 00615 const BasicDescription * csdescrip = m_rdl->GetCSDescrip(std::string("na0|004")); 00616 const BasicDescription * algdescrip = m_rdl->GetAlgorithmDescrip(std::string("SICLE1")); 00617 ResourceDescription * ddescrip = m_rdl->GetDataDescrip(std::string("SpatialData(na0|002,OBJMAP)")); 00618 if (ddescrip){ 00619 const std::string filename0 = ddescrip->GetFilename("0"); 00620 } 00621 ResourceDescription * tdescrip = m_rdl->GetTransformDescrip(std::string("Transformation(na0|008,na0|014,SICLE1)")); 00622 if (tdescrip){ 00623 std::string format = tdescrip->GetFormat(); 00624 std::string transformUnits = tdescrip->GetTransformUnits(); 00625 std::string dispfilename0 = tdescrip->GetFilename("0"); 00626 std::string dispfilename1 = tdescrip->GetFilename("1"); 00627 std::string dispfilename2 = tdescrip->GetFilename("2"); 00628 } 00629 00630 // Do not delete bdescrip, csdescrip, algdescrip, ddescrip, or tdescrip. Deleting these pointers will 00631 // remove their entries in the RDL. 00632 00633 // The following functions return vectors that are owned by this method. Therefore we need to delete them. 00634 std::vector<std::string> * RDL_filename_list = m_rdl->CreateRDLFilenameList(); 00635 std::vector<std::string> * namespace_list = m_rdl->CreateNameSpaceList(); 00636 std::vector<std::string> * cs_list = m_rdl->CreateCSList(); 00637 std::vector<std::string> * alg_list = m_rdl->CreateAlgorithmList(); 00638 std::vector<std::string> * label_list = m_rdl->CreateLabelList(); 00639 00640 00641 if (RDL_filename_list) { delete RDL_filename_list;}; 00642 if (namespace_list) { delete namespace_list;}; 00643 if (cs_list) { delete cs_list;}; 00644 if (alg_list) { delete alg_list;}; 00645 if (label_list) { delete label_list;}; 00646 00647 if (filedialog) { delete filedialog; }; 00648 } 00649 00650 // Added GEC 6/18/2010 debugging 00651 void Interface::OnSaveResourceNewFormatClick( wxCommandEvent& event ) { 00652 wxFileDialog * filedialog = new wxFileDialog(this, wxT("Choose a file to save Resource Description List"), wxT(""), wxT("untitled.xml"), wxT("(*.xml)|*.xml"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT, wxDefaultPosition, wxDefaultSize, wxT("Save")); 00653 if( filedialog->ShowModal() == wxID_CANCEL ){ delete filedialog; return;} 00654 00655 00656 saved_path = filedialog->GetPath(); 00657 m_rdl->Save(std::string(saved_path.ToAscii())); 00658 00659 delete filedialog; 00660 00661 } 00662 00663 // Added GEC 7/6/2010 00664 void Interface::OnEditResourceNewFormat( wxCommandEvent& event ) { 00665 00666 //EditRDL *frame = new EditRDL; 00667 GenerateRDL *frame = new GenerateRDL(this); 00668 frame->Show(true); 00669 00670 } 00671 00672 00677 void Interface::OnSaveClick( wxCommandEvent& event ) 00678 { 00679 00680 if(this->saved_path.empty()) 00681 { 00682 OnSaveAsClick( event ); 00683 return; 00684 } 00685 00686 vector<string> list; 00687 00688 //DisplayManager.GetActiveDisplays(list); 00689 00690 ofstream file; 00691 00692 file.open (saved_path.mb_str()); 00693 00694 file << "version 1.0" << endl; 00695 00696 file << "[Database]" << endl; 00697 00698 map<string,string>::const_iterator iter; 00699 00700 for(iter=DatabaseItemList.begin(); iter != DatabaseItemList.end(); ++iter) 00701 { 00702 file << iter->second << endl; 00703 } 00704 00705 file << "[Display]" << endl; 00706 00707 for(iter=DisplayItemList.begin(); iter != DisplayItemList.end(); ++iter) 00708 { 00709 file << iter->second << endl; 00710 } 00711 00712 file << "[Active]" << endl; 00713 00714 for(int i = 0; i < list.size(); i++) 00715 { 00716 file << list[i] << endl; 00717 } 00718 00719 file.close(); 00720 00721 } 00722 00723 00728 void Interface::OnSaveAsClick( wxCommandEvent& event ) 00729 { 00730 wxFileDialog * filedialog = new wxFileDialog(this, wxT("Choose a file"), wxT(""), wxT("untitled.nirep"), wxT("(*.nirep)|*.nirep"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT, wxDefaultPosition, wxDefaultSize, wxT("Save")); 00731 00732 if( filedialog->ShowModal() == wxID_CANCEL ){ delete filedialog; return;} 00733 00734 saved_path = filedialog->GetPath(); 00735 00736 OnSaveClick( event ); 00737 } 00738 00739 00740 void Interface::CreateNIREPDisplay(std::string& fileName) 00741 { 00742 NIREPDisplay *display = new NIREPDisplay( this, evaluator, fileName ); 00743 display->Show(true); 00744 this->Refresh(); 00745 this->Update(); 00746 } 00747 00748 00749 void Interface::addDatabaseItem(std::string s, unsigned long memory, unsigned long totalMemory) 00750 { 00751 this->SetTotalMemoryUsage(totalMemory); 00752 wxString tempThree; 00753 unsigned long tempFour = memory; 00754 stringstream ssTwo;//create a stringstream 00755 ssTwo << tempFour;//add number to the stream 00756 tempThree = wxString(ssTwo.str().c_str(), wxConvUTF8); 00757 int row = grid->GetRows(); 00758 grid->AppendRows(); 00759 grid->SetCellValue(row,0,wxString(s.c_str(), wxConvUTF8)); 00760 grid->SetCellValue(row,1,tempThree); 00761 grid->SetReadOnly(row,0,true); 00762 grid->SetReadOnly(row,1,true); 00763 //wxGridCellBoolRenderer *boolRenderer = new wxGridCellBoolRenderer; 00764 //wxGridCellBoolEditor *boolEditor = new wxGridCellBoolEditor; 00765 00766 //boolEditor->Create(grid,wxID_ANY,this); 00767 grid->SetCellRenderer(row, 2, new wxGridCellBoolRenderer); 00768 grid->SetCellEditor(row, 2, new wxGridCellBoolEditor); 00769 00770 //int stop = 0; 00771 } 00772 00773 void Interface::SetTotalMemoryUsage(unsigned long totalMemory) 00774 { 00775 wxString temp; 00776 unsigned long tempTwo = totalMemory; 00777 stringstream ss;//create a stringstream 00778 ss << tempTwo;//add number to the stream 00779 temp = wxString(ss.str().c_str(), wxConvUTF8); 00780 grid->SetCellValue(0,1,temp); 00781 } 00782 00783 void Interface::OnGridChange(wxGridEvent & event) 00784 { 00785 //int col = event.GetCol(); 00786 //int row = event.GetRow(); 00787 //bool select = event.Selecting(); 00788 //int stop=0; 00789 } 00790 00791 void Interface::OnHelpClick(wxCommandEvent & event) 00792 { 00793 00794 help.UseConfig(wxConfig::Get()); 00795 bool ret; 00796 help.SetTempDir(wxT(".")); 00797 help.Display(wxT("Help")); 00798 ret = help.AddBook(wxFileName(wxT("NIREPHelp/NIREPHelp.hhp"), wxPATH_UNIX)); 00799 if (! ret) 00800 wxMessageBox(wxT("Failed adding book NIREPHelp/NIREPHelp.hhp")); 00801 //ret = help.AddBook(wxFileName(wxT("helpfiles/another.hhp"), wxPATH_UNIX)); 00802 //if (! ret) 00803 // wxMessageBox(_("Failed adding book helpfiles/another.hhp")); 00804 } 00805 00806 void Interface::EditorShown(wxGridEvent & event) 00807 { 00808 int col = event.GetCol(); 00809 int row = event.GetRow(); 00810 wxString value = grid->GetTable()->GetValue(row,col); 00811 //int returnValue = value.compare(_("0")); 00812 //int returnValueTwo = value.compare("0"); 00813 //int returnValueThree = value.Cmp(_("0")); 00814 //int returnValueFour = value.Cmp("0"); 00815 //if(value.compare(_("0")) ==0) { 00816 // int debugStop=0; 00817 //} 00818 if(value.compare(_("0")) ==-1) { 00819 //this is when the item was not checked and now is being checked 00820 //This is when we display a box asking the user if they really want 00821 //to delete the image out of memory. 00822 WindowDeleteSpatialData *wdsd = new WindowDeleteSpatialData(this, wxID_ANY); 00823 //DeleteSpatialDataAction *dsda = new DeleteSpatialDataAction(); 00824 //dsda->SetInterface(this); 00825 //dsda->SetRowCol(row,col); 00826 //wdsd->SetDeleteSpatialDataAction(dsda); 00827 wdsd->SetRowCol(row,col); 00828 wdsd->Show(true); 00829 00830 } 00831 //int stop=0; 00832 } 00833 00834 void Interface::DeleteSpatialData(int row, int col) 00835 { 00836 wxString temp = grid->GetCellValue(row,0); 00837 dataManager->ReleaseLoadedSpatialDataListEntry(std::string(temp.mb_str())); 00838 grid->DeleteRows(row); 00839 00840 } 00841 00842 void Interface::OnQuit(wxCommandEvent & event) 00843 { 00844 this->Close(true); 00845 } 00846 00847 void Interface::OnViewDisplayDescription( wxCommandEvent& event ) 00848 { 00849 ViewDisplayDescription *temp = new ViewDisplayDescription(this); 00850 temp->Show(); 00851 } 00852 00853 void Interface::OnViewEvaluatorCommands( wxCommandEvent& event ) 00854 { 00855 QuickView2 *temp = new QuickView2(this); 00856 temp->Show(); 00857 } 00858