NIREP
|
00001 #include "NIREPDisplay.h" 00002 00003 #include "NIREPvtkViewImage2D.h" 00004 #include "NIREPwxVTKRenderWindowInteractor.h" 00005 #include <vtkImageData.h> 00006 #include <vtkRenderer.h> 00007 #include <vtkLookupTableManager.h> 00008 #include "GetPanelFromUser.h" 00009 #include "EditTextPanels.h" 00010 #include "GaugeNotification.h" 00011 #include "NIREPDefinitions.h" 00012 #include "NIREPEditProjectFile.h" 00013 #include "PairwiseComparison.h" 00014 00015 #include "wx/progdlg.h" 00016 00017 IMPLEMENT_CLASS( NIREPDisplay, wxFrame ) 00018 00019 BEGIN_EVENT_TABLE( NIREPDisplay, wxFrame ) 00020 00021 EVT_MENU( ID_SAVE, NIREPDisplay::OnSaveClick ) 00022 EVT_MENU( ID_OPEN_NIREPDisplay_DESCRIPTION, NIREPDisplay::OnOpenDisplayDescriptionClick ) 00023 EVT_MENU( ID_NEW_WINDOW, NIREPDisplay::OnNewWindowClick ) 00024 EVT_MENU( ID_CLOSE, NIREPDisplay::OnCloseClick ) 00025 EVT_MENU( ID_ADD_ROW, NIREPDisplay::OnAddRowClick ) 00026 EVT_MENU( ID_ADD_COLUMN, NIREPDisplay::OnAddColumnClick ) 00027 EVT_MENU( ID_TURN_OFF_TITLES, NIREPDisplay::OnTurnOffTitlesClick ) 00028 EVT_MENU( ID_TURN_ON_TITLES, NIREPDisplay::OnTurnOnTitlesClick ) 00029 00030 EVT_MENU( ID_TURN_ON_ALL_CURSORS, NIREPDisplay::OnTurnOnAllCursorsClick ) 00031 EVT_MENU( ID_TURN_OFF_ALL_CURSORS, NIREPDisplay::OnTurnOffAllCursorsClick ) 00032 00033 EVT_MENU( ID_LOCK_ALL, NIREPDisplay::OnLockAllClick ) 00034 EVT_MENU( ID_LOCK_ROWS, NIREPDisplay::OnLockRowsClick ) 00035 EVT_MENU( ID_LOCK_COLS, NIREPDisplay::OnLockColsClick ) 00036 00037 EVT_MENU( ID_UNLOCK_ALL, NIREPDisplay::OnUnLockAllClick ) 00038 EVT_MENU( ID_UNLOCK_ROWS, NIREPDisplay::OnUnLockAllClick ) 00039 EVT_MENU( ID_UNLOCK_COLS, NIREPDisplay::OnUnLockAllClick ) 00040 00041 EVT_MENU( ID_GROUP1, NIREPDisplay::OnGroup1Click ) 00042 EVT_MENU( ID_GROUP2, NIREPDisplay::OnGroup2Click ) 00043 EVT_MENU( ID_GROUP3, NIREPDisplay::OnGroup3Click ) 00044 EVT_MENU( ID_NEXT_GROUP, NIREPDisplay::OnNextGroupClick ) 00045 EVT_MENU( ID_PREVIOUS_GROUP, NIREPDisplay::OnPreviousGroupClick ) 00046 EVT_MENU( ID_ADD_OBJECT_MAPS, NIREPDisplay::OnAddObjectMapsClick ) 00047 EVT_MENU( ID_ADD_LANKDMARKS, NIREPDisplay::OnAddLandmarksClick ) 00048 00049 EVT_MENU( ID_GROUP1, NIREPDisplay::OnGroup1Click ) 00050 EVT_MENU( ID_GROUP2, NIREPDisplay::OnGroup2Click ) 00051 EVT_MENU( ID_GROUP3, NIREPDisplay::OnGroup3Click ) 00052 EVT_MENU( ID_NEXT_GROUP, NIREPDisplay::OnNextGroupClick ) 00053 EVT_MENU( ID_PREVIOUS_GROUP, NIREPDisplay::OnPreviousGroupClick ) 00054 EVT_MENU( ID_ADD_OBJECT_MAPS, NIREPDisplay::OnAddObjectMapsClick ) 00055 EVT_MENU( ID_ADD_LANKDMARKS, NIREPDisplay::OnAddLandmarksClick ) 00056 00057 EVT_MENU( ID_EDIT_PANEL, NIREPDisplay::OnEditPanelClick ) 00058 00059 EVT_MENU( ID_EDIT_DISPLAY_VARS, NIREPDisplay::OnEditDisplayFileClick ) 00060 00061 EVT_MENU( ID_SAC, NIREPDisplay::OnSingleAlgorithmComparisonClick ) 00062 00063 END_EVENT_TABLE() 00064 00065 00066 NIREPDisplay::NIREPDisplay (wxWindow* parent,NIREPEvaluator *ev, const std::string& FileName, 00067 int id, 00068 const wxString& title, 00069 const wxPoint& pos, 00070 const wxSize& size, 00071 long style, 00072 const wxString& name 00073 ) 00074 : wxFrame(parent, id,title, pos, size, style, name) 00075 { 00076 00077 if(size == wxDefaultSize) { 00078 this->Maximize(); 00079 } 00080 m_fileName = wxT("Undefined"); 00081 groupNumber = NOGROUP; 00082 presetView = 0; 00083 displayDescription = NULL; 00084 m_Sizer = NULL; 00085 //head = NULL; 00086 wxMenuBar* menuBar = new wxMenuBar; 00087 00088 //----------------------------------File Menu--------------------------------------- 00089 wxMenu* file_menu = new wxMenu; 00090 file_menu->Append(ID_OPEN_NIREPDisplay_DESCRIPTION, _("Open NIREPDisplay description"), _T(""), wxITEM_NORMAL); 00091 file_menu->Append(ID_NEW_WINDOW, _("Open new window"), _T(""), wxITEM_NORMAL); 00092 file_menu->Append(ID_CLOSE, _("Close"), _T(""), wxITEM_NORMAL); 00093 //As soon as we get the writing of the different descriptions we will 00094 //un comment this line and make the function OnSaveClick use the 00095 //writers of the various desriptions 00096 //file_menu->Append(ID_SAVE, _("Save"), _T(""), wxITEM_NORMAL); 00097 menuBar->Append(file_menu, _("File")); 00098 //----------------------------------End of File Menu--------------------------------------- 00099 00100 00101 //----------------------------------Edit Menu--------------------------------------- 00102 wxMenu* edit_menu = new wxMenu; 00103 edit_menu->Append(ID_EDIT_PANEL, _("Edit Panel..."), _T(""), wxITEM_NORMAL); 00104 edit_menu->Append(ID_EDIT_DISPLAY_VARS, _("Edit Display Variables..."), _T("Change values of variables that are defined for current display."), wxITEM_NORMAL); 00105 edit_menu->Append(ID_ADD_ROW, _("Add Row"), _T(""), wxITEM_NORMAL); 00106 edit_menu->Append(ID_ADD_COLUMN, _("Add Column"), _T(""), wxITEM_NORMAL); 00107 edit_menu->Append(ID_TURN_OFF_TITLES, _("Turn Off Titles"), _T(""), wxITEM_NORMAL); 00108 edit_menu->Append(ID_TURN_ON_TITLES, _("Turn On Titles"), _T(""), wxITEM_NORMAL); 00109 menuBar->Append(edit_menu, _("Edit")); 00110 //----------------------------------End of Edit Menu--------------------------------------- 00111 00112 //----------------------------------View Menu--------------------------------------- 00113 wxMenu* view_menu = new wxMenu; 00114 view_menu->Append(ID_TURN_ON_ALL_CURSORS, _("Show Cursors"), _T(""), wxITEM_NORMAL); 00115 view_menu->Append(ID_TURN_OFF_ALL_CURSORS, _("Hide Cursors"), _T(""), wxITEM_NORMAL); 00116 menuBar->Append(view_menu, _("View")); 00117 //----------------------------------End of View Menu--------------------------------------- 00118 00119 //----------------------------------Cursor Lock Menu--------------------------------------- 00120 wxMenu* cursor_lock_menu = new wxMenu; 00121 cursor_lock_menu->Append(ID_LOCK_ALL, _("Lock All"), _T(""), wxITEM_NORMAL); 00122 cursor_lock_menu->Append(ID_LOCK_ROWS, _("Lock Rows"), _T(""), wxITEM_NORMAL); 00123 cursor_lock_menu->Append(ID_LOCK_COLS, _("Lock Columns"), _T(""), wxITEM_NORMAL); 00124 00125 cursor_lock_menu->Append(ID_UNLOCK_ALL, _("UnLock All"), _T(""), wxITEM_NORMAL); 00126 cursor_lock_menu->Append(ID_UNLOCK_ROWS, _("UnLock Rows"), _T(""), wxITEM_NORMAL); 00127 cursor_lock_menu->Append(ID_UNLOCK_COLS, _("UnLock Columns"), _T(""), wxITEM_NORMAL); 00128 menuBar->Append(cursor_lock_menu, _("Cursor Lock")); 00129 //----------------------------------End of Cursor Lock Menu--------------------------------------- 00130 00131 00132 //----------------------------------Database view Menu--------------------------------------- 00133 //wxMenu* itemMenu7 = new wxMenu; 00134 //itemMenu7->Append(ID_GROUP1, _("1-6"), _T(""), wxITEM_NORMAL); 00135 //itemMenu7->Append(ID_GROUP2, _("7-12"), _T(""), wxITEM_NORMAL); 00136 //itemMenu7->Append(ID_GROUP3, _("13-16"), _T(""), wxITEM_NORMAL); 00137 //itemMenu7->Append(ID_NEXT_GROUP, _("Next Group"), _T(""), wxITEM_NORMAL); 00138 //itemMenu7->Append(ID_PREVIOUS_GROUP, _("Previous Group"), _T(""), wxITEM_NORMAL); 00139 //itemMenu7->Append(ID_ADD_OBJECT_MAPS, _("Add Object Maps to all"), _T(""), wxITEM_NORMAL); 00140 //itemMenu7->Append(ID_ADD_LANKDMARKS, _("Add Landmarks to all"), _T(""), wxITEM_NORMAL); 00141 //menuBar->Append(itemMenu7, _("Database")); 00142 //----------------------------------End of Database view Menu--------------------------------------- 00143 00144 //----------------------------------Pairwise Comparison Menu--------------------------------------- 00145 wxMenu* itemMenu8 = new wxMenu; 00146 itemMenu8->Append(ID_SAC, _("Single Algorithm Comparison"), _T(""), wxITEM_NORMAL); 00147 itemMenu8->Append(wxID_ANY, _("Absoulte Difference"), _T(""), wxITEM_NORMAL); 00148 itemMenu8->Append(wxID_ANY, _("Window Wipe"), _T(""), wxITEM_NORMAL); 00149 itemMenu8->Append(wxID_ANY, _("Checkerboard"), _T(""), wxITEM_NORMAL); 00150 itemMenu8->Append(wxID_ANY, _("R, Y, G fusion"), _T(""), wxITEM_NORMAL); 00151 itemMenu8->Append(wxID_ANY, _("Relative Overlap"), _T(""), wxITEM_NORMAL); 00152 menuBar->Append(itemMenu8, _("Pairwise Comparison")); 00153 //----------------------------------End of Pairwise Comparison Menu--------------------------------------- 00154 00155 //----------------------------------Groupwise Comparison Menu--------------------------------------- 00156 wxMenu* itemMenu9 = new wxMenu; 00157 menuBar->Append(itemMenu9, _("Groupwise Comparison")); 00158 //----------------------------------End of Groupwise Comparison Menu--------------------------------------- 00159 00160 00161 this->SetMenuBar(menuBar); 00162 evaluator = ev; 00163 00164 00165 m_SizerTwo = new wxFlexGridSizer(1, 1, 0, 0); 00166 m_SizerTwo->AddGrowableRow(0); 00167 m_SizerTwo->AddGrowableCol(0); 00168 this->SetSizer(m_SizerTwo); 00169 00170 m_scrolledWindow = new wxScrolledWindow( this, ID_SCROLLEDWINDOW, wxDefaultPosition, wxDefaultSize ); 00171 m_SizerTwo->Add(m_scrolledWindow, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5); 00172 m_scrolledWindow->SetScrollbars(1, 1, 0, 0); 00173 00174 //have to have a NIREPDisplay description otherwise 00175 //we will not now what to NIREPDisplay. 00176 if(!FileName.empty()) { 00177 CreateNIREPDisplay(FileName); 00178 } 00179 //else { 00180 // ::wxLogError( "ERROR - NIREP Display Filename is empty!"); 00181 //} 00182 00183 00184 } 00185 00186 NIREPDisplay::~NIREPDisplay() 00187 { 00188 this->RemoveAll(); 00189 int psize = panel.size(); 00190 //Make sure we detach all of the views otherwise we will get errors and 00191 //memory leaks. 00192 for(int j=0;j<psize;j++) { 00193 panel.at(j)->GetWidget()->Detach(); 00194 } 00195 for(int j=0; j<psize;j++) { 00196 delete panel.at(j); 00197 panel.at(j) = NULL; 00198 } 00199 if(displayDescription) { 00200 delete displayDescription; 00201 displayDescription = NULL; 00202 } 00203 if(evaluator) { 00204 evaluator = NULL; 00205 } 00206 if(m_SizerTwo) { 00207 m_SizerTwo = NULL; 00208 } 00209 if(m_scrolledWindow) { 00210 m_scrolledWindow = NULL; 00211 } 00212 if(m_Sizer) { 00213 m_Sizer = NULL; 00214 } 00215 } 00216 00217 //Set some class variables. 00218 void NIREPDisplay::SetProperties() 00219 { 00220 m_InteractionStyle = NIREPvtkViewImage2D::SELECT_INTERACTION; 00221 m_LinkViews = true; 00222 m_ShowCursors = true; 00223 m_OrientationFlag = NIREPvtkViewImage::AXIAL_ID; 00224 } 00225 00226 //Update the sizer and the layout of this window. 00227 void NIREPDisplay::DoLayout() 00228 { 00229 m_Sizer->Layout(); 00230 //set the sizer of this window to the sizer that was created 00231 this->SetSizer (m_SizerTwo); 00232 //tell the window to auto layout that way if something changes 00233 //to the layout, that the layout actually updates 00234 this->SetAutoLayout (true); 00235 this->Layout(); 00236 } 00237 00238 00239 //This function is the main function for this class. This will add in the 00240 //labels and the views based on the NIREPDisplay description. So this function 00241 //will run through an outer loop of the rows and an inner loop twice. The 00242 //first for loop runs through the columns to place the labels and then run 00243 //another for loop to place the views in. 00244 void NIREPDisplay::CreateGrid () 00245 { 00246 int width = 0; 00247 int num_rows = this->displayDescription->GetDisplayAttributes()->GetRowDimension(); 00248 int num_cols = this->displayDescription->GetDisplayAttributes()->GetColDimension(); 00249 int num_panels = num_rows * num_cols; 00250 bool cont = true; 00251 00252 wxProgressDialog * load_status_dialog = new wxProgressDialog(wxT("Creating Display"), wxT("Processing Display Description"), 00253 num_panels, // number of segments in progress bar 00254 this, // parent window 00255 wxPD_CAN_ABORT | wxPD_APP_MODAL | wxPD_AUTO_HIDE | 00256 wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME); 00257 00258 //Run through the rows 00259 for(int i=0;i<num_rows;i++) { 00260 //Run through the columns for the labels 00261 for(int j=0;j<num_cols;j++) { 00262 //Add in the labels that are above the views. Eventually this 00263 //will get moved into the panel so that we just plop a panel 00264 //in and not worry about the label but there are problems with 00265 //the size and resizeing things. 00266 //PanelStorage tempStorage; 00267 //if(head == NULL) 00268 //{ 00269 // head = &tempStorage; 00270 //} 00271 //else 00272 //{ 00273 // tail->next = &tempStorage; 00274 //} 00275 //tail = &tempStorage; 00276 00277 //first get the parameters from the NIREPDisplay description 00278 //std::vector<std::string> temp = this->displayDescription->GetWidgetList()->GetWidgetParameters(i,j); 00279 00280 //create the label 00281 wxStaticText* itemStaticText67 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxString( this->displayDescription->GetWidgetList()->GetTitle(i,j).c_str(), wxConvUTF8 ), wxDefaultPosition, wxSize(-1,55), wxST_NO_AUTORESIZE|wxALIGN_CENTRE ); 00282 00283 //add the text of the label to a map so that if the user wants to change 00284 //the text then it is an easy lookup and change. 00285 panelTitle.insert(std::make_pair(i*this->GetColumns()+j,itemStaticText67)); 00286 00287 //Set the color of the text 00288 itemStaticText67->SetForegroundColour(wxColour(129, 248, 150)); 00289 00290 //Set the color of the background to black 00291 itemStaticText67->SetBackgroundColour(wxColour(0, 0, 0)); 00292 00293 //Set the font but if the user wants they can change it from the panelForm 00294 itemStaticText67->SetFont(wxFont(14, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma"))); 00295 00296 //add the label to this window 00297 m_Sizer->Add(itemStaticText67,1, wxALL|wxEXPAND|wxGROW, 0); 00298 00299 //tempStorage.text = itemStaticText67; 00300 } 00301 00302 //run through the columns for the views 00303 for(int j=0;j<num_cols;j++) { 00304 //gaugeNotification->AddItem(this->displayDescription->GetWidgetList()->GetWidgetType(i,j)); 00305 wxString msg(wxT("Loading: ")); 00306 msg += wxString(this->displayDescription->GetWidgetList()->GetWidgetType(i,j).c_str(), wxConvUTF8); 00307 cont = load_status_dialog->Update(i*num_cols + j,msg); 00308 00309 if (!cont){ 00310 if (wxMessageBox(wxT("Do you really want to cancel?"), 00311 wxT("Process dialog question"), 00312 wxYES_NO | wxICON_QUESTION) == wxYES){ 00313 // Probably need to do some clean up here if abort, but don't have timme 00314 // to do it now. GEC 00315 load_status_dialog->Show(false); 00316 delete load_status_dialog; 00317 return; 00318 } 00319 load_status_dialog->Resume(); 00320 } 00321 00322 //Create a panel 00323 Panel* panelTwo = new Panel (m_scrolledWindow,this->displayDescription, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE); 00324 00325 //set the evaluator that way the panel can get images 00326 panelTwo->SetEvaluator(this->evaluator); 00327 00328 //set the id of the panel, this way if we need to figure out which 00329 //panel this is, we can call getID of the panel and do a quick 00330 //search in a map. 00331 panelTwo->SetID(panel.size()); 00332 00333 //the panel needs to know about the NIREPDisplay so that the panel can do 00334 //some global items, such as linking itself with other panels and deleting 00335 //itself. 00336 panelTwo->SetParent(this); 00337 00338 //add the panel to the sizer 00339 m_Sizer->Add (panelTwo, 1, wxALL|wxEXPAND|wxGROW, 0); 00340 00341 //get the parameters for this specific panel 00342 std::vector<std::string> temp = this->displayDescription->GetWidgetList()->GetWidgetParameters(i,j); 00343 00344 //set the ids from the NIREPDisplay description. The ids are the images that the user 00345 //wants NIREPDisplayed 00346 //do not grab the last parameter because it is the text that will be NIREPDisplayed 00347 //in the label 00348 for(int k=0;k<temp.size()-1;k++) { 00349 panelTwo->SetIds(temp[k]); 00350 } 00351 00352 //Now run through a big if, else if clause to figure out which 00353 //view to use. 00354 std::string widget_type = this->displayDescription->GetWidgetList()->GetWidgetType(i,j); 00355 00356 // Convert widget_type to lower case for comparison 00357 std::transform(widget_type.begin(), widget_type.end(), widget_type.begin(), ::tolower); 00358 00359 // The WidgetCmd list is defined in NIREPDefinitions. If you want to change 00360 // the string for the widget, change the value of WidgetCmd in NIREPDefinitions and 00361 // not the key value. That is the key values below should stay the 00362 // same no matter what the value associated with the key becomes. 00363 // Note that all comparison are lower case because the value of WidgetCmd is lower 00364 // case. It does not matter the case of the key shown below. 00365 if(widget_type.compare(WidgetCmd["view"]) == 0) { 00366 //panelTwo->SetLookUpTable(vtkLookupTableManager::GetLookupTable(3),3); 00367 panelTwo->UseImage(); 00368 } 00369 else if(widget_type.compare(WidgetCmd["checkerboard"]) == 0) { 00370 panelTwo->UseCheckerboard(); 00371 } 00372 else if(widget_type.compare(WidgetCmd["wipe"]) == 0) { 00373 panelTwo->UseWipe(); 00374 } 00375 else if(widget_type.compare(WidgetCmd["objectmap"]) == 0) { 00376 panelTwo->UseObjectMap(); 00377 } 00378 else if(widget_type.compare(WidgetCmd["overlayObjectMap"]) == 0) { 00379 panelTwo->UseOverlayObjectMap(); 00380 } 00381 else if(widget_type.compare(WidgetCmd["overlayImage"]) == 0) { 00382 panelTwo->UseOverlayImage(); 00383 } 00384 else if(widget_type.compare(WidgetCmd["relativeOverlap"]) == 0) { 00385 panelTwo->UseRelativeOverlap(); 00386 } 00387 else if(widget_type.compare(WidgetCmd["relativeOverlapTextWidget"]) == 0) { 00388 panelTwo->UseRelativeOverlapTextStatistic(); 00389 } 00390 else if(widget_type.compare(WidgetCmd["intensityVarianceTextWidget"]) == 0) { 00391 panelTwo->UseIntensityVarianceTextStatistic(); 00392 } 00393 else if(widget_type.compare(WidgetCmd["inverseConsistencyTextWidget"]) == 0) { 00394 panelTwo->UseInverseConsistencyTextStatistic(); 00395 } 00396 else if(widget_type.compare(WidgetCmd["transitivityErrorTextWidget"]) == 0) { 00397 panelTwo->UseTransitivityErrorTextStatistic(); 00398 } 00399 else if(widget_type.compare(WidgetCmd["varianceTransformText"]) == 0) { 00400 panelTwo->UseVarianceTransformTextStatistic(); 00401 } 00402 else if(widget_type.compare(WidgetCmd["varianceImageText"]) == 0) { 00403 panelTwo->UseVarianceImageTextStatistic(); 00404 } 00405 else if(widget_type.compare(WidgetCmd["blankWidget"]) == 0) { 00406 panelTwo->UseBlank(); 00407 } 00408 else if(widget_type.compare(WidgetCmd["vectorField"]) == 0) { 00409 panelTwo->UseVectorField(); 00410 } 00411 else { 00412 wxString temp = wxT("Unrecognized widget command: "); 00413 temp.Append(wxString::Format (wxT("%s."), wxString(widget_type.c_str(), wxConvUTF8))); 00414 wxLogError(temp); 00415 } 00416 00417 //push the panel onto a vector so that we can 00418 //do some global items, such as linking and deleting. 00419 //Also later on, we can go through this vector and 00420 //do some saving of information so that the next 00421 //time the user uses the program they can start 00422 //from where they left off. 00423 panel.push_back (panelTwo); 00424 width += panelTwo->GetMinWidth(); 00425 } 00426 } 00427 00428 cont = load_status_dialog->Update(num_panels,wxT("Done.")); 00429 00430 DistributeAttributes(); 00431 00432 //wxSize tempSize; 00433 //tempSize.SetWidth(width); 00434 //this->SetMinSize(tempSize); 00435 00436 m_scrolledWindow->FitInside(); 00437 //Call the function DoLayout just to be on the safe side because 00438 //we did changes to the layout 00439 this->DoLayout(); 00440 00441 //gaugeNotification->Show(false); 00442 //delete gaugeNotification; 00443 00444 delete load_status_dialog; 00445 } 00446 00447 00448 //Not sure if this actually works. Might have to change it so that 00449 //we have a viewImage2D with an image of one pixel that is black. 00450 //void NIREPDisplay::RemoveView (const int& i) 00451 //{ 00452 // if( i<0 || i>=(int)(panel.size()) ) { 00453 // return; 00454 // } 00455 // std::vector<Panel*> newWxList; 00456 // for( int j=0; j<(int)(panel.size()); j++) { 00457 // if( j==i ) { 00458 // bool isDetached = m_Sizer->Detach ( panel[j] ); 00459 // if( !isDetached ) { 00460 // std::cerr << "Warning: child was not found." << std::endl; 00461 // } 00462 // panel[j]->GetView()->Detach(); 00463 // panel[j]->GetView()->Delete(); 00464 // m_Sizer->Layout(); 00465 // } 00466 // else { 00467 // if(j<i) { 00468 // panel[j]->SetID(j); 00469 // } 00470 // else { 00471 // panel[j]->SetID(j-1); 00472 // } 00473 // newWxList.push_back ( panel[j] ); 00474 // } 00475 // } 00476 // panel = newWxList; 00477 //} 00478 00479 //This function works but needs to be changed. 00480 //This will delete a widget and push all the other 00481 //items behind it in the sizer one space forward. 00482 //So the problem comes in that a widget might go 00483 //into a slot for the label and a label will go 00484 //into a slot for the view. So this kind of 00485 //works but needs to be changed. 00486 void NIREPDisplay::DeleteWidget(const int &Location) 00487 { 00488 if( Location<0 || Location>=(int)(panel.size()) ) { 00489 return; 00490 } 00491 std::vector<Panel*> newWxList; 00492 for( int j=0; j<(int)(panel.size()); j++) { 00493 if( j==Location ) { 00494 bool isDetached = m_Sizer->Detach ( panel[j] ); 00495 int debugStop = j%this->GetColumns(); 00496 int debugStopTwo = j/this->GetColumns(); 00497 m_Sizer->InsertStretchSpacer((debugStopTwo+2)*(this->GetColumns())+debugStop); 00498 if( !isDetached ) { 00499 std::cerr << "Warning: child was not found." << std::endl; 00500 } 00501 delete panel[j]; 00502 m_Sizer->Layout(); 00503 } 00504 else { 00505 if(j<Location) { 00506 panel[j]->SetID(j); 00507 } 00508 else { 00509 panel[j]->SetID(j-1); 00510 } 00511 newWxList.push_back ( panel[j] ); 00512 } 00513 } 00514 panel = newWxList; 00515 } 00516 00517 //Remove all the panels from this window. 00518 void NIREPDisplay::RemoveAll() 00519 { 00520 if(m_Sizer == NULL) 00521 return; 00522 int size = m_Sizer->GetChildren().GetCount(); 00523 for( int i=0; i<size;i++) { 00524 m_Sizer->Detach (0); 00525 } 00526 for(int j=0;j<panel.size();j++) { 00527 if( panel.at(j)->GetView() != NULL) 00528 panel.at(j)->GetWidget()->Detach(); 00529 } 00530 for( unsigned int i=0; i<panel.size(); i++) { 00531 delete panel[i]; 00532 } 00533 for(std::map<int, wxStaticText*>::iterator temp = panelTitle.begin(); temp!= panelTitle.end(); temp++) { 00534 delete temp->second; 00535 } 00536 panel.clear(); 00537 panelTitle.clear(); 00538 if(m_Sizer) { 00539 m_Sizer->Layout(); 00540 } 00541 } 00542 00543 //Run through all the panels and call render 00544 //on them. 00545 void NIREPDisplay::Render() 00546 { 00547 for( unsigned int i=0; i<panel.size(); i++) { 00548 if( !panel[i]->GetRenderWindow()->GetNeverRendered() ) { 00549 panel[i]->Render(); 00550 } 00551 } 00552 } 00553 00554 00555 00556 //Set the size of the columns and run through the 00557 //sizer and add growable columns if the sizer had 00558 //less columns then what was passed in. 00559 void NIREPDisplay::SetColumns(int col) 00560 { 00561 if(m_Sizer->GetCols() <col) { 00562 for(int i=m_Sizer->GetCols();i<col;i++) { 00563 m_Sizer->AddGrowableCol(i); 00564 } 00565 } 00566 m_Sizer->SetCols(col); 00567 } 00568 00569 //This will add a panel with the specfic type of view that is passed in type. 00570 //Also need the parameters so that we know what images to use. This probably 00571 //needs some more work because we have been concentrating in createGrid to 00572 //get things working. 00573 void NIREPDisplay::AddWidget(std::string type, std::vector<std::string> parameters) { 00574 00575 00576 00577 if(type.compare( WidgetCmd["view"])) { 00578 Panel* wxView = new Panel (this,this->displayDescription, wxID_ANY, wxDefaultPosition, wxDefaultSize); 00579 wxView->SetID(panel.size()); 00580 wxView->SetParent(this); 00581 m_Sizer->Add (wxView, 1, wxALL|wxEXPAND|wxGROW, 0); 00582 wxView->UseImage(); 00583 panel.push_back(wxView); 00584 } 00585 else if(type.compare( WidgetCmd["objectmap"])) { 00586 Panel* wxView = new Panel (this,this->displayDescription, wxID_ANY, wxDefaultPosition, wxDefaultSize); 00587 wxView->SetID(panel.size()); 00588 wxView->SetParent(this); 00589 m_Sizer->Add (wxView, 1, wxALL|wxEXPAND|wxGROW, 0); 00590 for(int i=0; i < parameters.size(); i++ ) { 00591 //wxView->SetInput(ConvertImage(evaluator->get(wxView,parameters[i]))); 00592 } 00593 wxView->UseObjectMap(); 00594 panel.push_back(wxView); 00595 } 00596 else if(type.compare(WidgetCmd["checkerboard"])) { 00597 Panel* wxView = new Panel (this,this->displayDescription, wxID_ANY, wxDefaultPosition, wxDefaultSize); 00598 wxView->SetID(panel.size()); 00599 wxView->SetParent(this); 00600 m_Sizer->Add (wxView, 1, wxALL|wxEXPAND|wxGROW, 0); 00601 for(int i=0; i < parameters.size(); i++ ) { 00602 //wxView->SetInput(ConvertImage(evaluator->get(wxView,parameters[i]))); 00603 } 00604 wxView->UseCheckerboard (); 00605 panel.push_back(wxView); 00606 } 00607 } 00608 00609 //Link all the views (true) or unlink all the views (false) 00610 void NIREPDisplay::LinkViews (bool val) 00611 { 00612 m_LinkViews = val; 00613 if (!m_LinkViews) { 00614 for( unsigned int i=0; i<panel.size(); i++) { 00615 panel[i]->GetView()->Detach(); 00616 } 00617 } 00618 else { 00619 NIREPvtkViewImage2D *previousView = NULL; 00620 NIREPvtkViewImage2D *firstView = NULL; 00621 for( unsigned int i=0; i<panel.size(); i++) { 00622 if(panel[i]->GetView() != NULL) { 00623 panel[i]->GetView()->RemoveAllChildren(); 00624 if(previousView != NULL) 00625 previousView->AddChild( panel[i]->GetView() ); 00626 else 00627 firstView = panel[i]->GetView(); 00628 previousView = panel[i]->GetView(); 00629 } 00630 } 00631 if(previousView != NULL) 00632 previousView->AddChild(firstView); 00633 previousView = NULL; 00634 firstView = NULL; 00635 00636 } 00637 } 00638 00639 //Not using this but might be useful in the future. 00640 //void NIREPDisplay::LinkViews (std::vector<std::string> Panels) 00641 //{ 00642 // if(Panels.empty()) 00643 // { 00644 // return; 00645 // } 00646 // std::string line = Panels[0]; 00647 // //Get the column that the widget is supposed to be in 00648 // size_t found = line.find_first_of(","); 00649 // 00650 // std::string id(line, 1,found); 00651 // wxString wxID = id.c_str(); 00652 // wxID.Trim(); 00653 // wxID.Trim(false); 00654 // id = wxID.ToAscii(); 00655 // 00656 // //Get the row that the widget is supposed to be in 00657 // size_t foundTwo = line.find_first_of("="); 00658 // std::string idTwo(line, found+1,foundTwo); 00659 // wxString wxIDTwo = idTwo.c_str(); 00660 // wxIDTwo.Trim(); 00661 // wxIDTwo.Trim(false); 00662 // idTwo = wxIDTwo.ToAscii(); 00663 // 00664 // double col; 00665 // wxIDTwo.ToDouble(&col); 00666 // double row; 00667 // wxID.ToDouble(&row); 00668 // int tempTwo = ((int)row-1)*this->GetColumns()+(int)col-1; 00669 // int beginPanel = tempTwo; 00670 // 00671 // int previousPanel = beginPanel; 00672 // 00673 // for(int i=1;i<Panels.size();i++) 00674 // { 00675 // line = Panels[i]; 00676 // //Get the column that the widget is supposed to be in 00677 // found = line.find_first_of(","); 00678 // 00679 // std::string id(line, 1,found); 00680 // wxID = id.c_str(); 00681 // wxID.Trim(); 00682 // wxID.Trim(false); 00683 // id = wxID.ToAscii(); 00684 // 00685 // //Get the row that the widget is supposed to be in 00686 // foundTwo = line.find_first_of("="); 00687 // std::string idTwo(line, found+1,foundTwo); 00688 // wxIDTwo = idTwo.c_str(); 00689 // wxIDTwo.Trim(); 00690 // wxIDTwo.Trim(false); 00691 // idTwo = wxIDTwo.ToAscii(); 00692 // 00693 // wxIDTwo.ToDouble(&col); 00694 // wxID.ToDouble(&row); 00695 // tempTwo = ((int)row-1)*this->GetColumns()+(int)col-1; 00696 // 00697 // panel[previousPanel]->GetView()->Detach(); 00698 // 00699 // 00700 // previousPanel = tempTwo; 00701 // } 00702 // 00703 // panel[previousPanel]->GetView()->Detach(); 00704 // 00705 // previousPanel = beginPanel; 00706 // 00707 // for(int i=1;i<Panels.size();i++) 00708 // { 00709 // line = Panels[i]; 00710 // //Get the column that the widget is supposed to be in 00711 // found = line.find_first_of(","); 00712 // 00713 // std::string id(line, 1,found); 00714 // wxID = id.c_str(); 00715 // wxID.Trim(); 00716 // wxID.Trim(false); 00717 // id = wxID.ToAscii(); 00718 // 00719 // //Get the row that the widget is supposed to be in 00720 // foundTwo = line.find_first_of("="); 00721 // std::string idTwo(line, found+1,foundTwo); 00722 // wxIDTwo = idTwo.c_str(); 00723 // wxIDTwo.Trim(); 00724 // wxIDTwo.Trim(false); 00725 // idTwo = wxIDTwo.ToAscii(); 00726 // 00727 // wxIDTwo.ToDouble(&col); 00728 // wxID.ToDouble(&row); 00729 // tempTwo = ((int)row-1)*this->GetColumns()+(int)col-1; 00730 // 00731 // panel[previousPanel]->GetView()->AddChild( panel[tempTwo]->GetView() ); 00732 // previousPanel = tempTwo; 00733 // } 00734 // 00735 // 00736 // if(beginPanel != -1) 00737 // { 00738 // NIREPvtkViewImage2D *bob = panel[ previousPanel]->GetView(); 00739 // panel[ previousPanel]->GetView()->AddChild(panel[beginPanel]->GetView()); 00740 // } 00741 // 00742 //} 00743 00744 //Link the panels that are passed in. 00745 void NIREPDisplay::LinkViews (std::vector<int> Panels) 00746 { 00747 if(Panels.empty()) { 00748 return; 00749 } 00750 00751 //First run through the panels and detach from the 00752 //other panels. Also set the vector of widgets 00753 //which the panel is linked to. 00754 for(int i=0;i<Panels.size();i++) { 00755 if( panel[Panels.at(i)]->GetView() !=NULL) 00756 panel[Panels.at(i)]->GetView()->Detach(); 00757 panel[Panels.at(i)]->SetLinkedWidgets(Panels); 00758 } 00759 00760 //Link the widgets by adding children to the panels 00761 for(int i=0;i<(Panels.size()-1);i++) { 00762 panel[Panels.at(i)]->GetView()->AddChild( panel[Panels.at(i+1)]->GetView() ); 00763 } 00764 00765 //Set the child of the last panel to the first panel, thereby creating 00766 //a loop of panels. 00767 if(Panels.size()!=0) 00768 { 00769 if( panel[Panels.at(Panels.size()-1)]->GetView() !=NULL && panel[Panels.at(0)]->GetView() != NULL) 00770 panel[Panels.at(Panels.size()-1)]->GetView()->AddChild(panel[Panels.at(0)]->GetView()); 00771 else if(panel[Panels.at(Panels.size()-1)]->GetView() !=NULL) { 00772 for(int i=1; i<Panels.size(); i++) { 00773 panel[Panels.at(Panels.size()-1)]->GetView()->AddChild(panel[Panels.at(i)]->GetView()); 00774 } 00775 } 00776 else if(panel[Panels.at(0)]->GetView() != NULL) { 00777 for(int i=Panels.size()-2; i>0; i--) { 00778 panel[Panels.at(i)]->GetView()->AddChild(panel[Panels.at(0)]->GetView()); 00779 } 00780 } 00781 } 00782 00783 } 00784 00785 //Run through the unlinked panels. Check the linked vector in each unlinked panel 00786 //and make sure that if there is a panel in the linkedPanels and in the panel that 00787 //is not supposed to be linked that the panel is taken out. 00788 //I.E. if linkedPanels has 1,2 and unlinked panels has 0,3,4 and panel 0 has panel 00789 //1 in the linked panels vector that we take panel 1 out. 00790 void NIREPDisplay::UnLinkViews (std::vector<int> LinkedPanels, std::vector<int> UnLinkedPanels) 00791 { 00792 if(LinkedPanels.empty()) { 00793 return; 00794 } 00795 00796 for(int i=0;i<UnLinkedPanels.size();i++) { 00797 std::vector<int>::iterator tempTwo = LinkedPanels.begin(); 00798 std::vector<int> tempThree = panel[UnLinkedPanels.at(i)]->GetLinkedWidgets(); 00799 for(; tempTwo != LinkedPanels.end();tempTwo++) { 00800 if(panel[UnLinkedPanels.at(i)]->GetLinkedWidgets().size() != 0) { 00801 std::vector<int>::iterator temp = tempThree.begin(); 00802 std::vector<int>::iterator end = tempThree.end(); 00803 for(; temp != tempThree.end(); temp++) { 00804 if( *temp == *tempTwo ) { 00805 temp = tempThree.erase(temp); 00806 if(temp != tempThree.begin()) { 00807 temp--; 00808 } 00809 } 00810 } 00811 } 00812 } 00813 panel[UnLinkedPanels.at(i)]->SetLinkedWidgets(tempThree); 00814 } 00815 00816 } 00817 00818 //Get the label of the panel that is specfied. This is 00819 //mostly used in the panelForm so that the user can 00820 //change the label. 00821 wxStaticText * NIREPDisplay::GetPanelTitle(int panelID) 00822 { 00823 return panelTitle[panelID]; 00824 } 00825 00827 void NIREPDisplay::OnSaveClick( wxCommandEvent& event ) 00828 { 00829 } 00830 00832 void NIREPDisplay::OnOpenDisplayDescriptionClick( wxCommandEvent& event ) 00833 { 00834 wxFileDialog * filedialog = new wxFileDialog(this, wxT("Choose NIREPDisplay file"), wxT(""), wxT("*.*"), wxT("*.*")); 00835 if( filedialog->ShowModal() == wxID_CANCEL ){ delete filedialog; return;} 00836 wxString path = filedialog->GetPath(); 00837 CreateNIREPDisplay(std::string(path.mb_str())); 00838 delete filedialog; 00839 } 00840 00842 void NIREPDisplay::OnNewWindowClick( wxCommandEvent& event ) 00843 { 00844 NIREPDisplay *newNIREPDisplay = new NIREPDisplay(this->GetParent(),evaluator); 00845 newNIREPDisplay->Show(true); 00846 } 00847 00849 void NIREPDisplay::OnCloseClick( wxCommandEvent& event ) 00850 { 00851 this->Close(); 00852 } 00853 00854 void NIREPDisplay::CreateNIREPDisplay(const std::string& FileName) 00855 { 00856 this->RemoveAll(); 00857 00858 if(!FileName.empty() ) { 00859 if(displayDescription != NULL) 00860 delete displayDescription; 00861 displayDescription = new DisplayDescription(FileName); 00862 00863 if(displayDescription->GetWidgetList()->AnyError() || displayDescription->GetEvaluatorList()->AnyError() ) { 00864 m_fileName = wxT("Undefined"); 00865 return; 00866 } 00867 m_fileName = wxString(FileName.c_str(), wxConvUTF8); 00868 } 00869 00870 // set the evaluator list 00871 //evaluator->SetTaskList( displayDescription->GetEvaluatorList() ); 00872 00873 //Set the sizer up for 100 rows and the number of columns in the NIREPDisplay 00874 //description. 00875 m_Sizer = new wxFlexGridSizer(100,displayDescription->GetDisplayAttributes()->GetColDimension(),0,0); 00876 00877 00878 00879 //Add growable columns, that way when the user resizes the window 00880 //the views grow or shrink. 00881 for (unsigned int i=0; i<displayDescription->GetDisplayAttributes()->GetColDimension(); i++) { 00882 m_Sizer->AddGrowableCol (i); 00883 } 00884 00885 // TO DO : try to put a scrollbar instead of fixing rows to 100 00886 // TO DO : Get the labels and views together so that I don't 00887 // have to to every other row as a view. 00888 00889 //Make every other row, which will be the views growable, 00890 //this way when the user resizes the window the views 00891 //resize as well. 00892 for( int i=1; i<displayDescription->GetDisplayAttributes()->GetRowDimension()*2; i=i+2) { 00893 m_Sizer->AddGrowableRow (i); 00894 } 00895 00896 m_scrolledWindow->SetSizer(m_Sizer); 00897 00898 //This is the function that places the labels and views into 00899 //this window. 00900 this->CreateGrid(); 00901 00902 //Set some class variables. 00903 this->SetProperties(); 00904 00905 //Need to call this so that the sizers can update and everything looks 00906 //decent when the windows shows up for the first time. 00907 this->DoLayout(); 00908 } 00909 00911 void NIREPDisplay::OnLockAllClick( wxCommandEvent& event ) 00912 { 00913 if(displayDescription == NULL) { 00914 return; 00915 } 00916 this->LinkViews(true); 00917 } 00918 00920 void NIREPDisplay::OnLockRowsClick( wxCommandEvent& event ) 00921 { 00922 if(displayDescription == NULL) { 00923 return; 00924 } 00925 for( unsigned int j=0;j<this->displayDescription->GetDisplayAttributes()->GetRowDimension(); j++) { 00926 unsigned int i=0; 00927 for( ; i<this->GetColumns()-1; i++) { 00928 panel[j*this->GetColumns() + i]->GetView()->RemoveAllChildren(); 00929 panel[j*this->GetColumns() + i]->GetView()->AddChild( panel[j*this->GetColumns() + i+1]->GetView() ); 00930 } 00931 panel[ j*this->GetColumns() + i]->GetView()->AddChild(panel[j*this->GetColumns()]->GetView()); 00932 } 00933 } 00934 00936 void NIREPDisplay::OnLockColsClick( wxCommandEvent& event ) 00937 { 00938 if(displayDescription == NULL) { 00939 return; 00940 } 00941 for(unsigned int i=0 ; i<this->GetColumns(); i++) { 00942 unsigned int j=0; 00943 for(;j<this->displayDescription->GetDisplayAttributes()->GetRowDimension()-1; j++ ) { 00944 panel[j*this->GetColumns() + i]->GetView()->RemoveAllChildren(); 00945 panel[j*this->GetColumns() + i]->GetView()->AddChild( panel[j*this->GetColumns() + i+this->GetColumns()]->GetView() ); 00946 } 00947 panel[ j*this->GetColumns() + i]->GetView()->AddChild(panel[i]->GetView()); 00948 } 00949 } 00950 00952 void NIREPDisplay::OnUnLockAllClick( wxCommandEvent& event ) 00953 { 00954 if(displayDescription == NULL) { 00955 return; 00956 } 00957 this->LinkViews(false); 00958 } 00959 00960 void NIREPDisplay::SetPresetView(int pv) 00961 { 00962 if(pv == NOPRESET || pv == DATABASE_QUERY || pv == PAIRWISE_COMPARISON || pv == GROUP_WISE) 00963 presetView = pv; 00964 } 00965 00966 int NIREPDisplay::GetPresetView() 00967 { 00968 return presetView; 00969 } 00970 00972 void NIREPDisplay::OnGroup1Click( wxCommandEvent& event ) 00973 { 00974 groupNumber = GROUP1; 00975 this->CreateNIREPDisplay("MenuOptions/Group1.txt"); 00976 } 00977 00979 void NIREPDisplay::OnGroup2Click( wxCommandEvent& event ) 00980 { 00981 groupNumber = GROUP2; 00982 this->CreateNIREPDisplay("MenuOptions/Group2.txt"); 00983 } 00984 00986 void NIREPDisplay::OnGroup3Click( wxCommandEvent& event ) 00987 { 00988 groupNumber = GROUP3; 00989 this->CreateNIREPDisplay("MenuOptions/Group3.txt"); 00990 } 00991 00993 void NIREPDisplay::OnNextGroupClick( wxCommandEvent& event ) 00994 { 00995 if(groupNumber == NOGROUP) { 00996 OnGroup1Click(event); 00997 } 00998 else if(groupNumber == GROUP1) { 00999 OnGroup2Click(event); 01000 } 01001 else if(groupNumber == GROUP2) { 01002 OnGroup3Click(event); 01003 } 01004 else if(groupNumber == GROUP3) { 01005 OnGroup1Click(event); 01006 } 01007 } 01008 01010 void NIREPDisplay::OnPreviousGroupClick( wxCommandEvent& event ) 01011 { 01012 if(groupNumber == NOGROUP) { 01013 OnGroup3Click(event); 01014 } 01015 else if(groupNumber == GROUP1) { 01016 OnGroup3Click(event); 01017 } 01018 else if(groupNumber == GROUP2) { 01019 OnGroup1Click(event); 01020 } 01021 else if(groupNumber == GROUP3) { 01022 OnGroup2Click(event); 01023 } 01024 } 01025 01027 void NIREPDisplay::OnAddObjectMapsClick( wxCommandEvent& event ) 01028 { 01029 if(groupNumber == NOGROUP) { 01030 this->CreateNIREPDisplay("MenuOptions/Group1ObjectMap.txt"); 01031 } 01032 else if(groupNumber == GROUP1) { 01033 this->CreateNIREPDisplay("MenuOptions/Group1ObjectMap.txt"); 01034 } 01035 else if(groupNumber == GROUP2) { 01036 this->CreateNIREPDisplay("MenuOptions/Group2ObjectMap.txt"); 01037 } 01038 else if(groupNumber == GROUP3) { 01039 this->CreateNIREPDisplay("MenuOptions/Group3ObjectMap.txt"); 01040 } 01041 } 01042 01044 void NIREPDisplay::OnAddLandmarksClick( wxCommandEvent& event ) 01045 { 01046 this->CreateNIREPDisplay("MenuOptions/Landmarks.txt"); 01047 } 01048 01049 void NIREPDisplay::OnEditPanelClick( wxCommandEvent& event ) 01050 { 01051 if(displayDescription == NULL) { 01052 return; 01053 } 01054 GetPanelFromUser *temp = new GetPanelFromUser(this, this->displayDescription->GetDisplayAttributes()->GetRowDimension(),this->displayDescription->GetDisplayAttributes()->GetColDimension() ); 01055 temp->Show(); 01056 } 01057 01058 01059 void NIREPDisplay::OnAddRowClick( wxCommandEvent& event ) 01060 { 01061 //Make sure we update the display description with the new row dimension 01062 this->displayDescription->GetDisplayAttributes()->SetRowDimension( this->displayDescription->GetDisplayAttributes()->GetRowDimension() + 1 ); 01063 //Because the Titles take up a row by themselves, we have to double the row dimension 01064 m_Sizer->SetRows(this->displayDescription->GetDisplayAttributes()->GetRowDimension()*2); 01065 01066 //Because the Titles take up a row by themselves, we have to make both the 01067 //titles and the widgets growable 01068 m_Sizer->AddGrowableRow(this->displayDescription->GetDisplayAttributes()->GetRowDimension() - 1); 01069 m_Sizer->AddGrowableRow(this->displayDescription->GetDisplayAttributes()->GetRowDimension() - 2); 01070 01071 //Run through a for loop to add in the Titles 01072 for(unsigned int i=0;i<this->displayDescription->GetDisplayAttributes()->GetColDimension(); i++) { 01073 //create the label 01074 wxStaticText* itemStaticText67 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,55), wxST_NO_AUTORESIZE|wxALIGN_CENTRE ); 01075 01076 //add the text of the label to a map so that if the user wants to change 01077 //the text then it is an easy lookup and change. 01078 panelTitle.insert(std::make_pair((this->displayDescription->GetDisplayAttributes()->GetRowDimension()-1)*this->displayDescription->GetDisplayAttributes()->GetColDimension()+i,itemStaticText67)); 01079 01080 //Set the color of the text 01081 itemStaticText67->SetForegroundColour(wxColour(129, 248, 150)); 01082 01083 //Set the color of the background to black 01084 itemStaticText67->SetBackgroundColour(wxColour(0, 0, 0)); 01085 01086 //Set the font but if the user wants they can change it from the panelForm 01087 itemStaticText67->SetFont(wxFont(20, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma"))); 01088 01089 //add the label to this window 01090 m_Sizer->Add(itemStaticText67,1, wxALL|wxEXPAND|wxGROW, 0); 01091 } 01092 01093 //Run through a for loop to add in the Panels 01094 //The reason I have two seperate for loops is that items in the sizer is in a linear 01095 //fashion and not in a grid layout. So if I were to add a title and then a panel 01096 //the panel would be where a title should be. 01097 for(unsigned int i=0;i<this->displayDescription->GetDisplayAttributes()->GetColDimension(); i++) { 01098 Panel *panelTwo = new Panel(m_scrolledWindow,this->displayDescription, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE); 01099 01100 //set the evaluator that way the panel can get images 01101 panelTwo->SetEvaluator(this->evaluator); 01102 01103 //set the id of the panel, this way if we need to figure out which 01104 //panel this is, we can call getID of the panel and do a quick 01105 //search in a map. 01106 panelTwo->SetID(panel.size()); 01107 01108 //the panel needs to know about the NIREPDisplay so that the panel can do 01109 //some global items, such as linking itself with other panels and deleting 01110 //itself. 01111 panelTwo->SetParent(this); 01112 01113 panelTwo->UseBlank(); 01114 01115 //add the panel to the sizer 01116 m_Sizer->Add (panelTwo, 1, wxALL|wxEXPAND|wxGROW, 0); 01117 01118 //push the panel onto a vector so that we can 01119 //do some global items, such as linking and deleting. 01120 //Also later on, we can go through this vector and 01121 //do some saving of information so that the next 01122 //time the user uses the program they can start 01123 //from where they left off. 01124 panel.push_back (panelTwo); 01125 } 01126 01127 this->DoLayout(); 01128 } 01129 01130 01131 void NIREPDisplay::OnAddColumnClick( wxCommandEvent& event ) 01132 { 01133 //Make sure we update the display description with the new column dimension 01134 this->displayDescription->GetDisplayAttributes()->SetColDimension( this->displayDescription->GetDisplayAttributes()->GetColDimension() + 1 ); 01135 01136 //increase the column size of the sizer 01137 m_Sizer->SetCols(this->displayDescription->GetDisplayAttributes()->GetColDimension()); 01138 01139 //make the new column growable 01140 m_Sizer->AddGrowableCol(this->displayDescription->GetDisplayAttributes()->GetColDimension() - 1); 01141 01142 std::map<int, wxStaticText*> tempPanelTitle; 01143 int add = 0; 01144 int PanelTitleLocation = 0; 01145 this->panel.resize(this->displayDescription->GetDisplayAttributes()->GetRowDimension()*this->displayDescription->GetDisplayAttributes()->GetRowDimension()); 01146 for(int i=0; i < this->displayDescription->GetDisplayAttributes()->GetRowDimension();i++) 01147 { 01148 for(int j=0; j < this->displayDescription->GetDisplayAttributes()->GetColDimension()-1;j++) 01149 { 01150 if(panelTitle.find(PanelTitleLocation) != panelTitle.end() ) { 01151 tempPanelTitle.insert(std::make_pair(PanelTitleLocation + add,panelTitle.find(PanelTitleLocation)->second)); 01152 panel.at(PanelTitleLocation)->SetID(PanelTitleLocation + add); 01153 } 01154 PanelTitleLocation++; 01155 } 01156 add++; 01157 } 01158 panelTitle.clear(); 01159 panelTitle = tempPanelTitle; 01160 //The reason I am using one for loop is that I am inserting a title and panel at the locations that 01161 //they need to be at. If I try to use two for loops to first add in the titles and then the panels 01162 //the location of the titles will be off by one. 01163 for(unsigned int i=0;i<this->displayDescription->GetDisplayAttributes()->GetRowDimension(); i++) { 01164 //create the label 01165 wxStaticText* itemStaticText67 = new wxStaticText( m_scrolledWindow, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,55), wxST_NO_AUTORESIZE|wxALIGN_CENTRE ); 01166 01167 //add the text of the label to a map so that if the user wants to change 01168 //the text then it is an easy lookup and change. 01169 int location = this->displayDescription->GetDisplayAttributes()->GetColDimension()*i + this->displayDescription->GetDisplayAttributes()->GetColDimension()-1; 01170 01171 panelTitle.insert(std::make_pair(this->displayDescription->GetDisplayAttributes()->GetColDimension()*i + this->displayDescription->GetDisplayAttributes()->GetColDimension()-1,itemStaticText67)); 01172 01173 //Set the color of the text 01174 itemStaticText67->SetForegroundColour(wxColour(129, 248, 150)); 01175 01176 //Set the color of the background to black 01177 itemStaticText67->SetBackgroundColour(wxColour(0, 0, 0)); 01178 01179 //Set the font but if the user wants they can change it from the panelForm 01180 itemStaticText67->SetFont(wxFont(20, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma"))); 01181 01182 //add the label to this window 01183 m_Sizer->Insert(this->displayDescription->GetDisplayAttributes()->GetColDimension()*i*2 + this->displayDescription->GetDisplayAttributes()->GetColDimension()-1, itemStaticText67,1, wxALL|wxEXPAND|wxGROW, 0); 01184 01185 Panel *panelTwo = new Panel(m_scrolledWindow,this->displayDescription, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE); 01186 01187 //set the evaluator that way the panel can get images 01188 panelTwo->SetEvaluator(this->evaluator); 01189 01190 //set the id of the panel, this way if we need to figure out which 01191 //panel this is, we can call getID of the panel and do a quick 01192 //search in a map. 01193 panelTwo->SetID(panel.size()); 01194 01195 //the panel needs to know about the NIREPDisplay so that the panel can do 01196 //some global items, such as linking itself with other panels and deleting 01197 //itself. 01198 panelTwo->SetParent(this); 01199 01200 panelTwo->UseBlank(); 01201 01202 01203 //int temp = this->displayDescription->GetDisplayAttributes()->GetColDimension()*(i+1)*2 + -1; 01204 //add the panel to the sizer 01205 m_Sizer->Insert (this->displayDescription->GetDisplayAttributes()->GetColDimension()*(i+1)*2 + -1,panelTwo, 1, wxALL|wxEXPAND|wxGROW, 0); 01206 01207 //push the panel onto a vector so that we can 01208 //do some global items, such as linking and deleting. 01209 //Also later on, we can go through this vector and 01210 //do some saving of information so that the next 01211 //time the user uses the program they can start 01212 //from where they left off. 01213 panel.push_back (panelTwo); 01214 } 01215 this->DoLayout(); 01216 } 01217 01218 01219 void NIREPDisplay::OnSingleAlgorithmComparisonClick( wxCommandEvent& event ) 01220 { 01221 PairwiseComparison *temp = new PairwiseComparison(this, this->displayDescription); 01222 temp->Show(true); 01223 } 01224 01225 void NIREPDisplay::OnEditDisplayFileClick( wxCommandEvent& event ) 01226 { 01227 if(displayDescription == NULL) { 01228 return; 01229 } 01230 NIREPEditProjectFile *temp = new NIREPEditProjectFile(this,displayDescription); 01231 temp->Show(); 01232 } 01233 01234 01235 void NIREPDisplay::OnTurnOffTitlesClick( wxCommandEvent& event ) 01236 { 01237 for(unsigned int i=0;i<this->displayDescription->GetDisplayAttributes()->GetRowDimension(); i++) { 01238 for(unsigned int j=0; j< this->displayDescription->GetDisplayAttributes()->GetColDimension(); j++) { 01239 m_Sizer->Show(j + i * this->displayDescription->GetDisplayAttributes()->GetColDimension() * 2, false); 01240 } 01241 } 01242 this->DoLayout(); 01243 } 01244 01245 void NIREPDisplay::OnTurnOnTitlesClick( wxCommandEvent& event ) 01246 { 01247 for(unsigned int i=0;i<this->displayDescription->GetDisplayAttributes()->GetRowDimension(); i++) { 01248 for(unsigned int j=0; j< this->displayDescription->GetDisplayAttributes()->GetColDimension(); j++) { 01249 m_Sizer->Show(j + i * this->displayDescription->GetDisplayAttributes()->GetColDimension() * 2, true); 01250 } 01251 } 01252 this->DoLayout(); 01253 } 01254 01255 01257 void NIREPDisplay::OnTurnOnAllCursorsClick( wxCommandEvent& event ) 01258 { 01259 ShowCursors(true); 01260 //this->DoLayout(); 01261 } 01262 01264 void NIREPDisplay::OnTurnOffAllCursorsClick( wxCommandEvent& event ) 01265 { 01266 ShowCursors(false); 01267 //this->DoLayout(); 01268 } 01269 01270 //Show cursors in all views (true) or turn cursors off in all views (false) 01271 void NIREPDisplay::ShowCursors(bool value) 01272 { 01273 m_ShowCursors = value; 01274 01275 for( unsigned int i=0; i<panel.size(); i++) { 01276 if (m_ShowCursors) { 01277 panel[i]->GetWidget()->SetShow2DAxis(true); 01278 } else { 01279 panel[i]->GetWidget()->SetShow2DAxis(false); 01280 } 01281 panel[i]->GetWidget()->Render(); 01282 } 01283 } 01284 01285 01286 void NIREPDisplay::EditPanel(int row, int col, bool editViewPanel) 01287 { 01288 if(editViewPanel) { 01289 panel.at(row*this->GetColumns()+col)->PanelFrame(*(wxCommandEvent*)NULL); 01290 return; 01291 } 01292 std::string widgetType = panel.at(row*this->GetColumns()+col)->GetWidgetType(); 01293 //if(widgetType == RELATIVE_OVERLAP_TEXT || 01294 // widgetType == INTENSITY_VARIANCE_TEXT || 01295 // widgetType == INVERSE_CONSISTENCY_TEXT || 01296 // widgetType ==TRANSITIVITY_ERROR_TEXT) 01302 if(widgetType.compare(WidgetCmd["relativeOverlapTextWidget"]) == 0 || 01303 widgetType.compare(WidgetCmd["intensityVarianceTextWidget"]) == 0 || 01304 widgetType.compare(WidgetCmd["inverseConsistencyTextWidget"]) == 0 || 01305 widgetType.compare(WidgetCmd["transitivityErrorTextWidget"]) == 0) 01306 { 01307 EditTextPanels *editTextPanels = new EditTextPanels(this,row,col); 01308 editTextPanels->Show(true); 01309 int debugStop = 0; 01310 } 01311 //else if(widgetType == IMAGE_WIDGET || 01312 // widgetType == CHECKERBOARD_WIDGET || 01313 // widgetType == WIPE_WIDGET || 01314 // widgetType == OBJECTMAP_WIDGET || 01315 // widgetType == OVERLAY_OBJECTMAP_WIDGET || 01316 // widgetType == OVERLAY_IMAGE_WIDGET || 01317 // widgetType == RELATIVE_OVERLAP || 01318 // widgetType == BLANK_WIDGET) 01319 else if(widgetType.compare(WidgetCmd["view"]) == 0 || 01320 widgetType.compare(WidgetCmd["checkerboard"]) == 0 || 01321 widgetType.compare(WidgetCmd["wipe"]) == 0 || 01322 widgetType.compare(WidgetCmd["objectmap"]) == 0 || 01323 widgetType.compare(WidgetCmd["overlayObjectMap"]) == 0 || 01324 widgetType.compare(WidgetCmd["overlayImage"]) == 0 || 01325 widgetType.compare(WidgetCmd["relativeOverlap"]) == 0 || 01326 widgetType.compare(WidgetCmd["blankWidget"]) == 0) 01327 { 01328 panel.at(row*this->GetColumns()+col)->PanelFrame(*(wxCommandEvent*)NULL); 01329 int debugStop=0; 01330 } 01331 } 01332 01333 void NIREPDisplay::UpdatePanels() 01334 { 01335 for(int i=0;i<this->displayDescription->GetDisplayAttributes()->GetRowDimension();i++) { 01336 //Run through the columns for the labels 01337 for(int j=0;j<this->displayDescription->GetDisplayAttributes()->GetColDimension();j++) { 01338 wxStaticText *tempText = (wxStaticText*)(this->m_Sizer->GetItem(i*2*this->GetColumns()+j)->GetWindow()); 01339 std::string whatIsThis = this->displayDescription->GetWidgetList()->GetTitle(i,j); 01340 wxString whatIsThisToo = tempText->GetLabel(); 01341 tempText->SetLabel( wxString( this->displayDescription->GetWidgetList()->GetTitle(i,j).c_str(), wxConvUTF8 ) ); 01342 } 01343 } 01344 for(unsigned int i=0;i< panel.size();i++) { 01345 panel[i]->UpdatePanel(); 01346 } 01347 } 01348 01349 //Since we have DisplayAttributes, need to go through 01350 //the DisplayAttributes and distruibute the items 01351 //that are expressed in the DisplayAttributes 01352 //to the widgets that are identified or 01353 //to other commands for the display of the 01354 //widgets. 01355 void NIREPDisplay::DistributeAttributes() 01356 { 01357 01358 for(DisplayAttributeCmdList::iterator i = DisplayAttributeCmd.begin(); i != DisplayAttributeCmd.begin(); i++) { 01359 std::string displayAttributeCommand = i->second; 01360 std::vector<std::vector<std::string> > tempTwo = displayDescription->GetDisplayAttributes()->GetAttributes()->find(displayAttributeCommand)->second; 01361 for(unsigned int j=0; j<tempTwo.size(); j++) { 01362 std::vector<std::string> tempThree = tempTwo.at(j); 01363 //Lock 01364 if(displayAttributeCommand.compare(DisplayAttributeCmd.find("Lock")->second)==0 ) { 01365 std::vector<int> tempFour; 01366 for(int k=0; k < tempThree.size(); k++) { 01367 tempFour.push_back(this->displayDescription->GetWidgetList()->GetLocation(tempThree.at(k) ) ); 01368 } 01369 this->LinkViews(tempFour); 01370 } 01371 //CursorLocation 01372 else if(displayAttributeCommand.compare(DisplayAttributeCmd.find("Cursorlocation")->second)==0 ) { 01373 this->panel.at(this->displayDescription->GetWidgetList()->GetLocation(tempThree.at(0) ) ) ->SetCursorLocation(atoi(tempThree.at(1).c_str()),atoi(tempThree.at(2).c_str()) ); 01374 } 01375 //Slice 01376 else if(displayAttributeCommand.compare(DisplayAttributeCmd.find("Slice")->second)==0 ) { 01377 this->panel.at(this->displayDescription->GetWidgetList()->GetLocation(tempThree.at(0) ) ) ->SetSlice(atoi(tempThree.at(1).c_str())); 01378 } 01379 else if(displayAttributeCommand.compare(DisplayAttributeCmd.find("Orientation")->second)==0 ) { 01380 unsigned int ori = 0; 01381 if(!tempThree.at(1).compare("SAGITTAL")) { 01382 ori = NIREPvtkViewImage2D::SAGITTAL_ID; 01383 } 01384 else if(!tempThree.at(1).compare("CORONAL")) { 01385 ori = NIREPvtkViewImage2D::CORONAL_ID; 01386 } 01387 else if(!tempThree.at(1).compare("TRANSVERSE")) { 01388 ori = NIREPvtkViewImage2D::AXIAL_ID; 01389 } 01390 01391 this->panel.at(this->displayDescription->GetWidgetList()->GetLocation(tempThree.at(0) ) ) ->SetOrientation(ori); 01392 } 01393 else if(displayAttributeCommand.compare(DisplayAttributeCmd.find("Lockall")->second)==0 ) { 01394 this->LinkViews(true); 01395 } 01396 } 01397 } 01398 } 01399 01400 //void NIREPDisplay::InsertIntoLink(int location, PanelStorage* ps) 01401 //{ 01402 //PanelStorage *temp = GetPanelStorage(location); 01403 //PanelStorage *tempTwo = temp->next; 01404 //temp->next = ps; 01405 //ps->next = tempTwo; 01406 //} 01407 01408 //PanelStorage* NIREPDisplay::GetPanelStorage(int location) 01409 //{ 01410 // PanelStorage *temp; 01411 // for(int i=0; 01412 // return NULL; 01413 //}