NIREP

Panel.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 #include "Panel.h"
00005 #include "wx/menu.h"
00006 #include "NIREPvtkInteractorStyleImage2D.h"
00007 #include "NIREPvtkViewImage2DCommand.h"
00008 #include "PanelForm.h"
00009 #include "NIREPDisplay.h"
00010 #include "wxVtkImageFlip.h"
00011 #include "NIREPvtkViewImage.h"
00012 #include <vtkLookupTableManager.h>
00013 #include "vtkIntArray.h"
00014 #include "vtkCharArray.h"
00015 #include "lut/HotMetal.h"
00016 #include <vtkImageFlip.h>
00017 #include "RelativeOverlap.h"
00018 #include "vtkRendererCollection.h"
00019 #include "NIREPRelativeOverlap.h"
00020 #include "NIREPInverseConsistencyError.h"
00021 #include "NIREPTransitivityError.h"
00022 #include "NIREPIntensityVariance.h"
00023 #include "VectorField.h"
00024 //#include "gecMath.h"
00025 
00026 // OBJMAP includes
00027 #include "vtkLookupTable.h"
00028 #include "ObjectmapForm.h"
00029 
00030 
00031 
00032 
00037 IMPLEMENT_DYNAMIC_CLASS( Panel, wxPanel )
00038 
00039 
00040 
00044 BEGIN_EVENT_TABLE( Panel, wxPanel )
00045 
00046     EVT_MENU(ID_POPUP,Panel::PanelFrame)
00047     EVT_MENU(ID_POPUPTHREE,Panel::Mouse)
00048     EVT_MENU(ID_POPUPFOUR,Panel::Mouse)
00049     EVT_MENU(ID_POPUPFIVE,Panel::Mouse)
00050     EVT_MENU(ID_POPUPSIX,Panel::Flip)
00051     EVT_MENU(ID_POPUPSEVEN,Panel::ObjectMapForm)
00052 
00053 END_EVENT_TABLE()
00054 
00055 
00056 /*
00057   function:  Panel
00058   purpose:   constructor
00059   overloads: Panel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
00060 */
00061 Panel::Panel()
00062 {
00063     Init();
00064 }
00065 
00066 /*
00067   function:  Panel
00068   purpose:   constructor
00069   overloads: Panel(void)
00070 */
00071 Panel::Panel(wxWindow* parent,DisplayDescription *dd, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
00072 {
00073   //Initialize some of the class variables
00074     Init();
00075 
00076     m_displayDescription = dd;
00077 
00078     //create the initial items for the panel.  However, to have a true 
00079     //view be displayed, you will need to call either the function
00080     //use(int widget) or one of the use*() functions
00081     bool temp = Create(parent, id, pos, size, style);
00082 }
00083 
00084 
00085 /*
00086   function: Create
00087   purpose:  
00088   input:
00089   output:   bool
00090 */
00091 bool Panel::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
00092 {
00093     wxPanel::Create(parent, id, pos, size, style);
00094     CreateControls();
00095     return true;
00096 }
00097 
00098 
00099 /*
00100   function: ~Panel
00101   purpose: class destructor, destroying references to pointers 
00102   input:
00103   output:
00104 */
00105 Panel::~Panel()
00106 {
00107   if(!ObjectEntryTable.empty()) {
00108     ObjectEntryTable.clear();
00109   }
00110   if(wxView) {
00111     wxView->Delete();
00112     wxView = NULL;
00113   }
00114   if(m_widget) {
00115     m_widget->Delete();
00116     m_widget = NULL;
00117   }
00118   if(TreePopupMenu) {
00119     delete TreePopupMenu;
00120     TreePopupMenu = NULL;
00121   }
00122   if(PanelLookupTable) {
00123     //PanelLookupTable->Delete();
00124     PanelLookupTable = NULL;
00125   }
00126   if(parent) {
00127     parent = NULL;
00128   }
00129   if(evaluator) {
00130     evaluator = NULL;
00131   }
00132   if(m_flexGridSizer) {
00133     m_flexGridSizer = NULL;
00134   }
00135   if(m_richTextController) {
00136     m_richTextController = NULL;
00137   }
00138   if(m_displayDescription) {
00139     m_displayDescription = NULL;
00140   }
00141 }
00142 
00143 
00144 /*
00145   function: Init
00146   purpose:  
00147   input:
00148   output:
00149 */
00150 void Panel::Init()
00151 {
00152   wxView = NULL;
00153   m_widget = NULL;
00154   m_richTextController = NULL;
00155   TreePopupMenu = NULL;
00156   mouse = 0;
00157 
00158   PanelLookupTable = vtkLookupTable::New();
00159   PanelLookupTable->SetTableRange (0, 1);
00160   PanelLookupTable->SetSaturationRange (0, 0);
00161   PanelLookupTable->SetHueRange (0, 0);
00162   PanelLookupTable->SetValueRange (0, 1);
00163   PanelLookupTable->SetAlphaRange (0, 1);
00164   PanelLookupTable->Build();
00165   m_lookupTableSelection = 0;
00166   this->m_orientation = NIREPvtkViewImage::AXIAL_ID;
00167 }
00168 
00169 /*
00170   function: SetLookUpTable
00171   purpose:  
00172   input: vtkLookupTable *
00173          int
00174   output:
00175 */
00176 void Panel::SetLookUpTable(vtkLookupTable *vlt, int selection)
00177 {
00178   m_lookupTableSelection = selection;
00179   if(PanelLookupTable)
00180       PanelLookupTable->Delete();
00181 
00182 
00183   PanelLookupTable = vlt;
00184   // TODO: m_widgetType is a std::string, cannot compare to integer 
00185   //if(m_widget && !m_widgetType.compare("4") && !m_widgetType.compare("5"))
00186     //m_widget->SetLookupTable(vlt);
00187 }
00188 
00189 
00190 
00191 /*
00192   function: CreateControls
00193   purpose:  
00194   input:
00195   output:
00196 */
00197 //Create the initial items for this panel.  However, to have a true 
00198 //view be displayed, you will need to call either the function
00199 //use(int widget) or one of the use*() functions
00200 void Panel::CreateControls()
00201 {    
00202     Panel* itemPanel1 = this;
00203     //Add a flex grid for the view
00204     m_flexGridSizer = new wxFlexGridSizer(2, 1, 0, 0);
00205 
00206     //Set the sizer up so that when the panel is resized that the view also
00207     //resizes.
00208     m_flexGridSizer->AddGrowableCol(0);
00209     m_flexGridSizer->AddGrowableRow(0);
00210 
00211     //Set the sizer to this panel
00212     itemPanel1->SetSizer(m_flexGridSizer);
00213 
00214     //Create the vtkRenderWindow and partial interactor.  This is still not
00215     //the view, this is just the RenderWindow which will need to be used
00216     //to display the different views.
00217     wxView = new NIREPwxVTKRenderWindowInteractor(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE, wxT("")); 
00218 
00219     //Add the RenderWindow to the panel
00220     m_flexGridSizer->Add(wxView, 1, wxALL|wxEXPAND|wxGROW, 0);
00221 }
00222 
00223 
00224 /*
00225   function: ShowToolTips
00226   purpose:  
00227   input:
00228   output: bool
00229 */
00230 bool Panel::ShowToolTips()
00231 {
00232     return true;
00233 }
00234 
00235 /*
00236   function: GetBitmapResource
00237   purpose:  
00238   input: const wxString&
00239   output: wxBitmap
00240 */
00241 wxBitmap Panel::GetBitmapResource( const wxString& name )
00242 {
00243     wxUnusedVar(name);
00244     return wxNullBitmap;
00245 }
00246 
00247 /*
00248   function: GetIconResource
00249   purpose:  
00250   input: const wxString&
00251   output: wxIcon
00252 */
00253 wxIcon Panel::GetIconResource( const wxString& name )
00254 {
00255     wxUnusedVar(name);
00256     return wxNullIcon;
00257 }
00258 
00259 
00260 //-------------------------------Beginning of Use-------------------------
00261 //The following Use*() are functions to make the programmers life easier.
00262 //This way the programmer does not have to know which integer goes with
00263 //which widget.
00264 void Panel::UseImage()
00265 {
00266   //this->UseWidget(IMAGE_WIDGET);
00267   this->UseWidget(WidgetCmd["view"]);
00268 }
00269 
00270 void Panel::UseCheckerboard()
00271 {
00272   //this->UseWidget(CHECKERBOARD_WIDGET);
00273   this->UseWidget(WidgetCmd["checkerboard"]);
00274 }
00275 
00276 void Panel::UseWipe()
00277 {
00278   //this->UseWidget(WIPE_WIDGET);
00279   this->UseWidget(WidgetCmd["wipe"]);
00280 }
00281 
00282 void Panel::UseObjectMap()
00283 {
00284   //this->UseWidget(OBJECTMAP_WIDGET);
00285   this->UseWidget(WidgetCmd["objectmap"]);
00286 }
00287 
00288 void Panel::UseOverlayObjectMap()
00289 {
00290   //this->UseWidget(OVERLAY_OBJECTMAP_WIDGET);
00291   this->UseWidget(WidgetCmd["overlayObjectMap"]);
00292 }
00293 
00294 void Panel::UseOverlayImage()
00295 {
00296   //this->UseWidget(OVERLAY_IMAGE_WIDGET);
00297   this->UseWidget(WidgetCmd["overlayImage"]);
00298 }
00299 
00300 void Panel::UseRelativeOverlap()
00301 {
00302   //this->UseWidget(RELATIVE_OVERLAP);
00303   this->UseWidget(WidgetCmd["relativeOverlap"]);
00304 }
00305 
00306 void Panel::UseRelativeOverlapTextStatistic()
00307 {
00308   //this->UseWidget(RELATIVE_OVERLAP_TEXT);
00309   this->UseWidget(WidgetCmd["relativeOverlapTextWidget"]);
00310 }
00311 
00312 void Panel::UseIntensityVarianceTextStatistic()
00313 {
00314   //this->UseWidget(INTENSITY_VARIANCE_TEXT);
00315   this->UseWidget(WidgetCmd["intensityVarianceTextWidget"]);
00316 }
00317 
00318 void Panel::UseInverseConsistencyTextStatistic()
00319 {
00320   //this->UseWidget(INVERSE_CONSISTENCY_TEXT);
00321   this->UseWidget(WidgetCmd["inverseConsistencyTextWidget"]);
00322 }
00323 
00324 void Panel::UseTransitivityErrorTextStatistic()
00325 {
00326   //this->UseWidget(TRANSITIVITY_ERROR_TEXT);
00327   this->UseWidget(WidgetCmd["transitivityErrorTextWidget"]);
00328 }
00329 
00330 void Panel::UseVarianceTransformTextStatistic()
00331 {
00332   //this->UseWidget(VARIANCE_TRANSFORM_TEXT);
00333   this->UseWidget(WidgetCmd["varianceTransformText"]);
00334 }
00335 
00336 void Panel::UseVarianceImageTextStatistic()
00337 {
00338   //this->UseWidget(VARIANCE_IMAGE_TEXT);
00339   this->UseWidget(WidgetCmd["varianceImageText"]);
00340 }
00341 
00342 void Panel::UseBlank()
00343 {
00344   //this->UseWidget(BLANK_WIDGET);
00345   this->UseWidget(WidgetCmd["blankWidget"]);
00346 }
00347 
00348 void Panel::UseVectorField()
00349 {
00350   //this->UseWidget(BLANK_WIDGET);
00351   this->UseWidget(WidgetCmd["vectorField"]);
00352 }
00353 
00354 
00355 /*
00356   function: UseWidget
00357   purpose:  
00358   input: int
00359   output:
00360 */
00361 //This is the main use function, all the previous use function will call
00362 //this function with the correct integer value.  However, if you know which
00363 //integer goes with which widget then you can call this right away.
00364 void Panel::UseWidget(const std::string& widget)
00365 {
00366   
00367   //Set the class variable m_widgetType to the widget that is being used
00368   m_widgetType = widget;
00369 
00370   //Clear the ObjectEntryTable just in case the user changed the widget,
00371   //to a widget that does not use the object entries.
00372   ObjectEntryTable.clear();
00373 
00374   //Grab the children and parent of the old widget so that we 
00375   //can add them to the new widget.
00376   vtkSynchronizedView *tempParent = NULL;
00377   std::vector < vtkSynchronizedView* > tempChildren;
00378   if(m_widget) {
00379     
00380     //Get the Parent and place it into the tempParent
00381     tempParent=this->m_widget->GetParent();
00382     tempChildren=this->m_widget->GetChildren();
00383     
00384     //m_widget->clClear();
00385     m_widget->Detach();
00386     m_widget->Delete();
00387     m_widget = NULL;
00388     //wxView->Delete();
00389     wxView = NULL;
00390   }
00391 
00392   //if(  widget == INVERSE_CONSISTENCY_TEXT ||
00393   //     widget == RELATIVE_OVERLAP_TEXT ||
00394   //     widget == INTENSITY_VARIANCE_TEXT ||
00395   //     widget == TRANSITIVITY_ERROR_TEXT ||
00396   //     widget == VARIANCE_TRANSFORM_TEXT ||
00397   //     widget == VARIANCE_IMAGE_TEXT)
00398   if(  widget.compare(WidgetCmd["relativeOverlapTextWidget"])    == 0 ||
00399        widget.compare(WidgetCmd["intensityVarianceTextWidget"])  == 0 ||
00400        widget.compare(WidgetCmd["inverseConsistencyTextWidget"]) == 0 ||
00401        widget.compare(WidgetCmd["transitivityErrorTextWidget"])  == 0 ||
00402        widget.compare(WidgetCmd["varianceTransformText"])        == 0 ||
00403        widget.compare(WidgetCmd["varianceImageText"])            == 0)
00404   {
00405     //wxSizer* m_flexGridSizer = this->GetSizer();
00406     if(wxView!=NULL) {
00407       m_flexGridSizer->Detach(wxView);
00408       //m_flexGridSizer->Remove(wxView);
00409       
00410       wxView->Delete();
00411       wxView = NULL;
00412     }
00413     if(m_richTextController != NULL)
00414       delete m_richTextController;
00415     m_richTextController = new wxRichTextCtrl( this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL );
00416     m_flexGridSizer->Add(m_richTextController,1, wxALL|wxEXPAND|wxGROW, 0);
00417     m_flexGridSizer->Layout();
00418     
00419     
00420     NIREPStatistics* stats = NULL;
00421     TextTable textTable;  // this is what will be returned
00422     //if(widget == INVERSE_CONSISTENCY_TEXT) {
00423     if(widget.compare(WidgetCmd["inverseConsistencyTextWidget"]) == 0) {
00424       if(this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription) == NULL ) {
00425         return;
00426       }
00427       ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription)->GetObjectEntryTable());
00428       stats = new NIREPInverseConsistencyError(evaluator);
00429       textTable = stats->ComputeStatistic(this->ids, m_displayDescription);
00430     }
00431     //else if(widget == RELATIVE_OVERLAP_TEXT) {
00432     else if(widget.compare(WidgetCmd["relativeOverlapTextWidget"]) == 0) {
00433       if(this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription) == NULL ) {
00434         return;
00435       }
00436       ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription)->GetObjectEntryTable());
00437       stats = new NIREPRelativeOverlap(evaluator);
00438       textTable = stats->ComputeStatistic(this->ids, m_displayDescription);
00439     }
00440     //else if(widget == INTENSITY_VARIANCE_TEXT) {
00441     else if(widget.compare(WidgetCmd["intensityVarianceTextWidget"]) == 0) {
00442       if(this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription) == NULL ) {
00443         return;
00444       }
00445       ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription)->GetObjectEntryTable());
00446       //textStatTable = stats.ComputeIV(this->ids);
00447     }
00448     //else if(widget == TRANSITIVITY_ERROR_TEXT) {
00449     else if(widget.compare(WidgetCmd["transitivityErrorTextWidget"]) == 0) {
00450       if(this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription) == NULL ) {
00451         return;
00452       }
00453       ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription)->GetObjectEntryTable());
00454       stats = new NIREPTransitivityError(evaluator);
00455       textTable = stats->ComputeStatistic(this->ids, m_displayDescription);
00456     }
00457     //else if(widget == VARIANCE_TRANSFORM_TEXT) {
00458     else if(widget.compare(WidgetCmd["varianceTransformText"]) == 0) {
00459       stats = new NIREPIntensityVariance(evaluator);
00460       this->ids.insert(this->ids.begin(),"RegisteredImageVariance");
00461       textTable = stats->ComputeStatistic(this->ids, m_displayDescription);
00462     }
00463     //else if(widget == VARIANCE_IMAGE_TEXT) {
00464     else if(widget.compare(WidgetCmd["varianceImageText"]) == 0) {
00465       stats = new NIREPIntensityVariance(evaluator);
00466       this->ids.insert(this->ids.begin(),"ImageVariance");
00467       textTable = stats->ComputeStatistic(this->ids, m_displayDescription);
00468     }
00469 
00470     if(stats != NULL) {
00471       delete stats;  // Not needed anymore beyond this point
00472       stats = NULL;
00473     }
00474 
00475     wxArrayInt tabs;
00476     tabs.Add(200);
00477     tabs.Add(600);
00478     for(int i=1; i<textTable.ColumnHeading.size();i++) {
00479        tabs.Add(600+200*i);
00480     }
00481     wxTextAttrEx attr;
00482     attr.SetFlags(wxTEXT_ATTR_TABS);
00483     attr.SetTabs(tabs);
00484     m_richTextController->SetDefaultStyle(attr);
00485 
00486 
00487     m_richTextController->WriteText( wxString(textTable.Title.c_str(), wxConvUTF8) );
00488     m_richTextController->Newline();
00489     for(int i=0; i< textTable.ColumnHeading.size(); i++) {
00490       m_richTextController->WriteText(wxT("\t") + wxString(textTable.ColumnHeading.at(i).c_str(), wxConvUTF8));
00491     }
00492     m_richTextController->Newline();
00493 
00494     if(!ObjectEntryTable.empty()) {
00495       for(int i=0;i<ObjectEntryTable.size();i++) {
00496         m_richTextController->WriteText(wxString::Format(wxT("%d"), i));
00497         m_richTextController->WriteText(wxT("\t")); 
00498         m_richTextController->WriteText(wxString( ObjectEntryTable.at(i)->GetName().c_str(), wxConvUTF8 ));
00499         m_richTextController->WriteText(wxT("\t")); 
00500         for(int j=0;j<textTable.ColumnHeading.size()-1;j++) {
00501           * m_richTextController << textTable.Value[j][i];
00502           m_richTextController->WriteText(wxT("\t")); 
00503         }
00504         m_richTextController->Newline();
00505       }
00506     }
00507     else if(!textTable.Value.empty()) {
00508       for(int i=0; i<textTable.Value[0].size();i++) {
00509         for(int j=0;j<textTable.ColumnHeading.size();j++) {
00510           * m_richTextController << textTable.Value[j][i];
00511           m_richTextController->WriteText(wxT("\t")); 
00512         }
00513         m_richTextController->Newline();
00514       }
00515     }
00516     return;
00517   }
00518   else if(wxView == NULL)
00519   {
00520     if(m_richTextController != NULL)
00521     {
00522       m_flexGridSizer->Remove(0);
00523       delete m_richTextController;
00524       m_richTextController = NULL;
00525     }
00526     //Create the vtkRenderWindow and partial interactor.  This is still not
00527     //the view, this is just the RenderWindow which will need to be used
00528     //to display the different views.
00529     wxView = new NIREPwxVTKRenderWindowInteractor(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxNO_FULL_REPAINT_ON_RESIZE, wxT("")); 
00530 
00531     //Add the RenderWindow to the panel
00532     m_flexGridSizer->Add(wxView, 1, wxALL|wxEXPAND|wxGROW, 0);
00533     m_flexGridSizer->Layout();
00534   }
00535 
00536   //Ok the following code is thrown together.  I need to through and clean it up.
00537   //So the gist of what is happening:
00538 
00539   //Create the NIREPvtkInteractorStyleImage2D, which is going to be called the interactorStyle.
00540   //We pass the panel to the interactorStyle so that the interactorStyle can call the panel
00541   //if the user right clicks.  The right click will pop up a menu for the user to make 
00542   //some changes or bring up more windows to make more changes.
00543 
00544   NIREPvtkInteractorStyleImage2D *interactorStyle = NIREPvtkInteractorStyleImage2D::New();
00545   interactorStyle->SetPanel(this);
00546     
00547   //Create a NIREPvtkViewImage2DCommand.  This will be used to funnel
00548   //off the different actions that happen.
00549   NIREPvtkViewImage2DCommand *cbk = NIREPvtkViewImage2DCommand::New();  
00550   
00551   //Add a bunch of observers to the interactorStyle.
00552   //The first part will take care of normal vtk commands.
00553   interactorStyle->AddObserver(vtkCommand::KeyPressEvent, cbk);
00554   interactorStyle->AddObserver(vtkCommand::WindowLevelEvent, cbk);
00555   interactorStyle->AddObserver(vtkCommand::StartWindowLevelEvent, cbk);
00556   interactorStyle->AddObserver(vtkCommand::ResetWindowLevelEvent, cbk);
00557   interactorStyle->AddObserver(vtkCommand::EndWindowLevelEvent, cbk);
00558   interactorStyle->AddObserver(vtkCommand::PickEvent, cbk);
00559   interactorStyle->AddObserver(vtkCommand::StartPickEvent, cbk);
00560   interactorStyle->AddObserver(vtkCommand::EndPickEvent, cbk);
00561 
00562   //This second part will take care of the other commands that
00563   //deal with the vtkInria3D items.  
00564   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::ResetZoomEvent, cbk);
00565   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::ResetPositionEvent, cbk);
00566   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::StartZSliceMoveEvent, cbk);
00567   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::ZSliceMoveEvent, cbk);
00568   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::EndZSliceMoveEvent, cbk);
00569   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::StartMeasureEvent, cbk);
00570   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::MeasureEvent, cbk);
00571   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::EndMeasureEvent, cbk);
00572   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::FullPageEvent, cbk);
00573   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::ZoomEvent, cbk);
00574   interactorStyle->AddObserver(NIREPvtkViewImage2DCommand::DefaultMoveEvent, cbk);
00575     
00576   //Create a renderer.
00577   vtkRenderer* rend = vtkRenderer::New();
00578 
00579   //Figure out which widget should be used.
00580   //if(widget == BLANK_WIDGET) {
00581   if(widget.compare(WidgetCmd["blankWidget"]) == 0) {
00582     m_widget = NIREPvtkViewImage2D::New();
00583     m_widget->SetConventionsToNeurological();
00584     m_widget->SetOrientation(this->m_orientation);
00585     m_widget->SetLookupTable(PanelLookupTable);
00586     cbk->SetView(m_widget);
00587     interactorStyle->SetView(m_widget);
00588     m_widget->SetRenderWindow (wxView->GetRenderWindow());
00589     
00590     m_widget->ScalarBarVisibilityOn();
00591     m_widget->SetLinkZoom (true);
00592     m_widget->SetLinkCameraFocalAndPosition(true);
00593     m_widget->SetBackgroundColor (0.0,0.0,0.0);
00594     m_widget->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00595     return;
00596   }
00597   //else if(widget == IMAGE_WIDGET) {
00598   else if(widget.compare(WidgetCmd["view"]) == 0) {
00599     m_widget = NIREPvtkViewImage2D::New();
00600     //m_widget->SetConventionsToNeurological();
00601     m_widget->SetConventionsToRadiological();
00602     m_widget->SetOrientation(this->m_orientation);
00603     if(m_lookupTableSelection != OTHER )
00604     {
00605       vtkLookupTableManager *tempTwo = vtkLookupTableManager::New();
00606       vtkLookupTable *temp = tempTwo->GetLookupTable(m_lookupTableSelection);
00607       // = vtkLookupTableManager::GetLookupTable(colorMapChoice);
00608       //panel->SetLookUpTable(temp,colorMapChoice);
00609       m_widget->SetLookupTable(temp);
00610       temp->Delete();
00611       tempTwo->Delete();
00612     }
00613 
00614     cbk->SetView(m_widget);
00615     interactorStyle->SetView(m_widget);
00616     m_widget->SetRenderWindow (wxView->GetRenderWindow());
00617     m_widget->SetRenderer (rend);
00618     m_widget->ScalarBarVisibilityOn();
00619     m_widget->SetLinkZoom (true);
00620     m_widget->SetLinkCameraFocalAndPosition(true);
00621     m_widget->SetBackgroundColor (0.0,0.0,0.0);
00622     m_widget->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00623     
00624     
00625     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00626       return;
00627     }
00628     m_widget->SetImage(this->evaluator->GetImage(this,this->ids[0], m_displayDescription) );
00629     m_widget->GetScalarBar()->SetInteractor(m_widget->GetRenderWindowInteractor());
00630 
00631     m_widget->SetShow2DAxis(0);
00632   }
00633   //else if(widget == CHECKERBOARD_WIDGET) {
00634   else if(widget.compare(WidgetCmd["checkerboard"]) == 0) {
00635     Checkerboard *tempThree = Checkerboard::New();
00636 
00637     //tempThree->SetConventionsToRadiological(); GEC Switching to radiological had no effect
00638     tempThree->SetConventionsToNeurological();
00639 
00640     tempThree->SetOrientation(this->m_orientation);
00641     tempThree->SetLookupTable(PanelLookupTable);
00642     cbk->SetView(tempThree);
00643     interactorStyle->SetView(tempThree);
00644     tempThree->SetRenderWindow (wxView->GetRenderWindow());
00645     tempThree->SetRenderer (rend);
00646     tempThree->ScalarBarVisibilityOn();
00647     tempThree->SetLinkZoom (true);
00648     tempThree->SetLinkCameraFocalAndPosition(true);
00649     tempThree->SetBackgroundColor (0.0,0.0,0.0);
00650     tempThree->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00651     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00652       return;
00653     }
00654     tempThree->SetImage(this->evaluator->GetImage(this,this->ids[0], m_displayDescription) );
00655     if( this->evaluator->GetImage(this,this->ids[1], m_displayDescription) == NULL) {
00656       return;
00657     }
00658     tempThree->SetSecondImage( (this->evaluator->GetImage(this,this->ids[1], m_displayDescription)) );
00659     tempThree->GetScalarBar()->SetInteractor(tempThree->GetRenderWindowInteractor());
00660 
00661 
00662     m_widget = tempThree;
00663   }
00664   //else if(widget == WIPE_WIDGET) {
00665   else if(widget.compare(WidgetCmd["wipe"]) == 0) {
00666     Wipe *tempTwo = Wipe::New();
00667     
00668     //tempTwo->SetConventionsToRadiological();  GEC Switching to radiological had no effect
00669     tempTwo->SetConventionsToNeurological();
00670 
00671     tempTwo->SetOrientation(this->m_orientation);
00672     tempTwo->SetLookupTable(PanelLookupTable);
00673     cbk->SetView(tempTwo);
00674     interactorStyle->SetView(tempTwo);
00675     tempTwo->SetRenderWindow (wxView->GetRenderWindow());
00676     tempTwo->SetRenderer (rend);
00677     //wxView->Render();   GEC 7/10/2010 removed to prevent wipe window from appearing in wrong window
00678     //wxView->GetRenderWindow()->Render(); GEC 7/10/2010 removed to prevent wipe window from appearing in wrong window
00679     tempTwo->ScalarBarVisibilityOn();
00680     tempTwo->SetLinkZoom (true);
00681     tempTwo->SetLinkCameraFocalAndPosition(true);
00682     tempTwo->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00683     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00684       return;
00685     }
00686     tempTwo->SetImage(this->evaluator->GetImage(this,this->ids[0], m_displayDescription) );
00687     if( this->evaluator->GetImage(this,this->ids[1], m_displayDescription) == NULL) {
00688       return;
00689     }
00690     tempTwo->SetSecondImage( (this->evaluator->GetImage(this,this->ids[1], m_displayDescription)) );
00691     tempTwo->SetBackgroundColor (0.0,0.0,0.0);
00692     tempTwo->GetScalarBar()->SetInteractor(tempTwo->GetRenderWindowInteractor());
00693     m_widget = tempTwo;
00694   }
00695   //else if(widget == OVERLAY_IMAGE_WIDGET) {
00696   else if(widget.compare(WidgetCmd["overlayImage"]) == 0) {
00697     m_widget = NIREPvtkViewImage2D::New();
00698     m_widget->SetConventionsToNeurological();
00699     m_widget->SetOrientation(this->m_orientation);
00700     m_widget->SetLookupTable(PanelLookupTable);
00701     cbk->SetView(m_widget);
00702     interactorStyle->SetView(m_widget);
00703     m_widget->SetRenderWindow (wxView->GetRenderWindow());
00704     m_widget->SetRenderer (rend);
00705     m_widget->ScalarBarVisibilityOn();
00706     m_widget->SetLinkZoom (true);
00707     m_widget->SetLinkCameraFocalAndPosition(true);
00708     m_widget->SetBackgroundColor (0.0,0.0,0.0);
00709     m_widget->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00710     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00711       return;
00712     }
00713     m_widget->SetImage( (this->evaluator->GetImage(this,this->ids[0], m_displayDescription)) );
00714     if( this->evaluator->GetImage(this,this->ids[1], m_displayDescription) == NULL) {
00715       return;
00716     }
00717     m_widget->SetOverlappingImage( (this->evaluator->GetImage(this,this->ids[1], m_displayDescription)) );
00718     m_widget->GetScalarBar()->SetInteractor(m_widget->GetRenderWindowInteractor());
00719   }
00720   else if(m_widgetType.compare(WidgetCmd["vectorField"]) == 0) {
00721     VectorField *tempTwo = VectorField::New();
00722     tempTwo->SetConventionsToNeurological();
00723     tempTwo->SetOrientation(this->m_orientation);
00724     tempTwo->SetLookupTable(PanelLookupTable);
00725     cbk->SetView(tempTwo);
00726     interactorStyle->SetView(tempTwo);
00727     tempTwo->SetRenderWindow (wxView->GetRenderWindow());
00728     tempTwo->SetRenderer (rend);
00729     tempTwo->ScalarBarVisibilityOn();
00730     tempTwo->SetLinkZoom (true);
00731     tempTwo->SetLinkCameraFocalAndPosition(true);
00732     tempTwo->SetBackgroundColor (0.0,0.0,0.0);
00733     tempTwo->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00734     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00735       return;
00736     }
00737     tempTwo->SetImage( (this->evaluator->GetImage(this,this->ids[0], m_displayDescription)) );
00738     m_widget = tempTwo;
00739   }
00740 
00741   //this begins the object map portion of the widgets
00742   //else if(widget == OVERLAY_OBJECTMAP_WIDGET) {
00743   else if(widget.compare(WidgetCmd["overlayObjectMap"]) == 0) {
00744     m_widget = NIREPvtkViewImage2D::New();
00745     m_widget->SetConventionsToNeurological();
00746     m_widget->SetOrientation(this->m_orientation);
00747     cbk->SetView(m_widget);
00748     interactorStyle->SetView(m_widget);
00749     m_widget->SetRenderWindow (wxView->GetRenderWindow());
00750     m_widget->SetRenderer (rend);
00751     m_widget->ScalarBarVisibilityOn();
00752     m_widget->SetLinkZoom (true);
00753     m_widget->SetLinkCameraFocalAndPosition(true);
00754     m_widget->SetBackgroundColor (0.0,0.0,0.0);
00755     m_widget->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00756     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00757       return;
00758     }
00759     m_widget->SetImage( (this->evaluator->GetImage(this,this->ids[0], m_displayDescription)) );
00760     if( this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription) == NULL) {
00761       return;
00762     }
00763     ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription)->GetObjectEntryTable());
00764     vtkLookupTable* lut = vtkLookupTable::New();
00765     lut->SetNumberOfTableValues(ObjectEntryTable.size());
00766     lut->Build();
00767     for(int i=0;i<ObjectEntryTable.size();i++) {
00768       
00769       if(ObjectEntryTable.at(i)->GetDisplayFlag() != 0)
00770         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), (double)ObjectEntryTable.at(i)->GetOpacity());
00771       else
00772         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), 0);
00773     }
00774 
00775     if(PanelLookupTable)
00776       PanelLookupTable->Delete();
00777 
00778     PanelLookupTable = lut;
00779     m_lookupTableSelection = OTHER;
00780     m_widget->SetMaskImage((this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription))->GetVTKData() ,lut );
00781     m_widget->GetScalarBar()->SetInteractor(m_widget->GetRenderWindowInteractor());
00782   }
00783   //else if(widget == RELATIVE_OVERLAP) {
00784   else if(widget.compare(WidgetCmd["relativeOverlap"]) == 0) {
00785     RelativeOverlap *relativeOverlap = RelativeOverlap::New();
00786     m_widget = NIREPvtkViewImage2D::New();
00787     m_widget->SetConventionsToNeurological();
00788     m_widget->SetOrientation(this->m_orientation);
00789     m_widget->SetLookupTable(PanelLookupTable);
00790     cbk->SetView(m_widget);
00791     interactorStyle->SetView(m_widget);
00792     m_widget->SetRenderWindow (wxView->GetRenderWindow());
00793     m_widget->SetRenderer (rend);
00794     m_widget->ScalarBarVisibilityOn();
00795     m_widget->SetLinkZoom (true);
00796     m_widget->SetLinkCameraFocalAndPosition(true);
00797     m_widget->SetBackgroundColor (0.0,0.0,0.0);
00798     m_widget->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00799     if( this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription) == NULL) {
00800       return;
00801     }
00802     relativeOverlap->SetInput1( (this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription))->GetVTKData() );
00803     if( this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription) == NULL) {
00804       return;
00805     }
00806     ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription)->GetObjectEntryTable());
00807     vtkLookupTable* lut = vtkLookupTable::New();
00808     lut->SetNumberOfTableValues(ObjectEntryTable.size());
00809     lut->Build();
00810     for(int i=0;i<ObjectEntryTable.size();i++) {
00811       
00812       if(ObjectEntryTable.at(i)->GetDisplayFlag() != 0)
00813         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), (double)ObjectEntryTable.at(i)->GetOpacity());
00814       else
00815         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), 0);
00816     }
00817 
00818     if(PanelLookupTable)
00819       PanelLookupTable->Delete();
00820 
00821     PanelLookupTable = lut;
00822     m_lookupTableSelection = OTHER;
00823     m_widget->SetLookupTable(lut);
00824     relativeOverlap->SetInput2((this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription))->GetVTKData() );
00825     relativeOverlap->Update();
00826     m_widget->SetImage(relativeOverlap->GetOutput());
00827     m_widget->GetScalarBar()->SetInteractor(m_widget->GetRenderWindowInteractor());
00828     relativeOverlap->Delete();
00829   }
00830   //else if(widget == OBJECTMAP_WIDGET) {
00831   else if(widget.compare(WidgetCmd["objectmap"]) == 0) {
00832     m_widget = NIREPvtkViewImage2D::New();
00833     m_widget->SetConventionsToNeurological();
00834     m_widget->SetOrientation(this->m_orientation);
00835     cbk->SetView(m_widget);
00836     interactorStyle->SetView(m_widget);
00837     m_widget->SetRenderWindow (wxView->GetRenderWindow());
00838     m_widget->SetRenderer (rend);
00839     m_widget->ScalarBarVisibilityOn();
00840     m_widget->SetLinkZoom (true);
00841     m_widget->SetLinkCameraFocalAndPosition(true);
00842     m_widget->SetBackgroundColor (0.0,0.0,0.0);
00843     m_widget->SetInteractionStyle (NIREPvtkViewImage2D::SELECT_INTERACTION);
00844     if( this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription) == NULL) {
00845       return;
00846     }
00847     ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription)->GetObjectEntryTable());
00848     vtkLookupTable* lut = vtkLookupTable::New();
00849     lut->SetNumberOfTableValues(ObjectEntryTable.size());
00850     lut->Build();
00851     for(int i=0;i<ObjectEntryTable.size();i++) {
00852       
00853       if(ObjectEntryTable.at(i)->GetDisplayFlag() != 0)
00854         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), (double)ObjectEntryTable.at(i)->GetOpacity());
00855       else
00856         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), 0);
00857     }
00858 
00859     if(PanelLookupTable)
00860       PanelLookupTable->Delete();
00861 
00862     PanelLookupTable = lut;
00863     m_lookupTableSelection = OTHER;
00864     m_widget->SetLookupTable(lut);
00865     m_widget->SetImage((this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription))->GetVTKData() );
00866     m_widget->GetScalarBar()->SetInteractor(m_widget->GetRenderWindowInteractor());
00867     
00868   }
00869   rend->Delete();
00870   m_widget->GetRenderWindowInteractor()->SetInteractorStyle(interactorStyle);
00871   cbk->Delete();
00872   interactorStyle->Delete();
00873   m_widget->ResetCurrentPoint();
00874   m_widget->SetResetWindowLevelModeToFullRange();
00875   m_widget->ResetWindowLevel();
00876 
00877   //I think I was trying to set up the widgets to be connected so that they
00878   //update together.
00879   if(tempParent) {
00880     tempParent->AddChild(m_widget);
00881   }
00882   if(!tempChildren.empty()){
00883     this->m_widget->AddChildren(tempChildren);
00884   }
00885 
00886   int* dataDim = m_widget->GetImage()->GetDimensions();
00887   wxSize tempSize;
00888   tempSize.SetHeight(dataDim[0]);
00889   tempSize.SetWidth(dataDim[1]);
00890   this->SetMinSize(tempSize);
00891   m_widget->SetVisibility(1);
00892   //this->Render();
00893 }
00894 
00895 //--------------------------------------------End of Use----------------------
00896 
00897 
00898 /*
00899   function: SetIds
00900   purpose:  
00901   input: std::string d
00902   output:
00903 */
00904 //This function stores the ids of the images that are being
00905 //displayed.  This way we can send these ids to the evaluator
00906 //and get back the correct images.
00907 void Panel::SetIds(const std::string& d)
00908 {
00909   ids.push_back(d);
00910 }
00911 
00912 /*
00913   function: GetIds
00914   purpose:  
00915   input:
00916   output: std::vector<std::string>0
00917 */
00918 std::vector<std::string> Panel::GetIds()
00919 {
00920   return ids;
00921 }
00922 
00923 /*
00924   function: ClearIds
00925   purpose:  
00926   input: std::string id
00927   output:
00928 */
00929 void Panel::ClearIds(const std::string& id)
00930 {
00931   if(!id.compare("")) {
00932     ids.clear();
00933   }
00934   else {
00935     std::vector<std::string>::iterator iteratorTwo = this->ids.begin();;
00936     for(int i =0; i< ids.size();i++) {
00937       if(ids[i].compare(id)) {
00938         this->ids.erase(iteratorTwo); 
00939         return;
00940       }
00941       iteratorTwo++;
00942     }
00943   }
00944 }
00945 
00946 /*
00947   function: UpdatePanel
00948   purpose:  
00949   input:
00950   output:
00951 */
00952 void Panel::UpdatePanel()
00953 {
00954   if(!m_widget) {
00955     return;
00956   }
00957 
00958   //if(m_widgetType == IMAGE_WIDGET) {
00959   if(m_widgetType.compare(WidgetCmd["view"]) == 0) {
00960     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00961       return;
00962     }
00963     ((NIREPvtkViewImage2D*)(this->m_widget))->SetImage(this->evaluator->GetImage(this,this->ids[0], m_displayDescription) );
00964   }
00965   //else if(m_widgetType == CHECKERBOARD_WIDGET) {
00966   else if(m_widgetType.compare(WidgetCmd["checkerboard"]) == 0) {
00967     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00968       return;
00969     }
00970     ((Checkerboard*)(this->m_widget))->SetImage(this->evaluator->GetImage(this,this->ids[0], m_displayDescription) );
00971     if( this->evaluator->GetImage(this,this->ids[1], m_displayDescription) == NULL) {
00972       return;
00973     }
00974     ((Checkerboard*)(this->m_widget))->SetSecondImage( (this->evaluator->GetImage(this,this->ids[1], m_displayDescription)) );    
00975   }
00976   //else if(m_widgetType == WIPE_WIDGET) {
00977   else if(m_widgetType.compare(WidgetCmd["wipe"]) == 0) {
00978     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00979       return;
00980     }
00981     ((Wipe*)(this->m_widget))->SetImage(this->evaluator->GetImage(this,this->ids[0], m_displayDescription) );
00982     if( this->evaluator->GetImage(this,this->ids[1], m_displayDescription) == NULL) {
00983       return;
00984     }
00985     ((Wipe*)(this->m_widget))->SetSecondImage( (this->evaluator->GetImage(this,this->ids[1], m_displayDescription)) );
00986   }
00987   //else if(m_widgetType == OVERLAY_IMAGE_WIDGET) {
00988   else if(m_widgetType.compare(WidgetCmd["checkerboard"]) == 0) {
00989     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
00990       return;
00991     }
00992     ((NIREPvtkViewImage2D*)(this->m_widget))->SetImage( (this->evaluator->GetImage(this,this->ids[0], m_displayDescription)) );
00993     if( this->evaluator->GetImage(this,this->ids[1], m_displayDescription) == NULL) {
00994       return;
00995     }
00996     ((NIREPvtkViewImage2D*)(this->m_widget))->SetOverlappingImage( (this->evaluator->GetImage(this,this->ids[1], m_displayDescription)) );
00997   }
00998 
00999   //this begins the object map portion of the widgets
01000   //else if(m_widgetType == OVERLAY_OBJECTMAP_WIDGET) {
01001   else if(m_widgetType.compare(WidgetCmd["overlayObjectMap"]) == 0) {
01002     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
01003       return;
01004     }
01005     ((NIREPvtkViewImage2D*)(this->m_widget))->SetImage( (this->evaluator->GetImage(this,this->ids[0], m_displayDescription)) );
01006     if( this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription) == NULL) {
01007       return;
01008     }
01009     ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription)->GetObjectEntryTable());
01010     vtkLookupTable* lut = vtkLookupTable::New();
01011     lut->SetNumberOfTableValues(ObjectEntryTable.size());
01012     lut->Build();
01013     for(int i=0;i<ObjectEntryTable.size();i++) {
01014       if(ObjectEntryTable.at(i)->GetDisplayFlag() != 0)
01015         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), (double)ObjectEntryTable.at(i)->GetOpacity());
01016       else
01017         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), 0);
01018     }
01019 
01020     if(PanelLookupTable)
01021       PanelLookupTable->Delete();
01022 
01023     PanelLookupTable = lut;
01024     m_lookupTableSelection = OTHER;
01025     ((NIREPvtkViewImage2D*)(this->m_widget))->SetMaskImage((this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription))->GetVTKData() ,lut );
01026   }
01027   //else if(m_widgetType == RELATIVE_OVERLAP) {
01028   else if(m_widgetType.compare(WidgetCmd["relativeOverlap"]) == 0) {
01029     RelativeOverlap *relativeOverlap = RelativeOverlap::New();
01030     if( this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription) == NULL) {
01031       return;
01032     }
01033     relativeOverlap->SetInput1( (this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription))->GetVTKData() );
01034     if( this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription) == NULL) {
01035       return;
01036     }
01037     ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription)->GetObjectEntryTable());
01038     vtkLookupTable* lut = vtkLookupTable::New();
01039     lut->SetNumberOfTableValues(ObjectEntryTable.size());
01040     lut->Build();
01041     for(int i=0;i<ObjectEntryTable.size();i++) {
01042       if(ObjectEntryTable.at(i)->GetDisplayFlag() != 0)
01043         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), (double)ObjectEntryTable.at(i)->GetOpacity());
01044       else
01045         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), 0);
01046     }
01047 
01048     if(PanelLookupTable)
01049       PanelLookupTable->Delete();
01050     PanelLookupTable = lut;
01051     m_lookupTableSelection = OTHER;
01052     ((NIREPvtkViewImage2D*)(this->m_widget))->SetLookupTable(lut);
01053     relativeOverlap->SetInput2((this->evaluator->GetObjectMap(this,this->ids[1], m_displayDescription))->GetVTKData() );
01054     relativeOverlap->Update();
01055     ((NIREPvtkViewImage2D*)(this->m_widget))->SetImage(relativeOverlap->GetOutput());
01056     relativeOverlap->Delete();
01057   }
01058   //else if(m_widgetType == OBJECTMAP_WIDGET) {
01059   else if(m_widgetType.compare(WidgetCmd["objectmap"]) == 0) {
01060     if( this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription) == NULL) {
01061       return;
01062     }
01063     ObjectEntryTable = *(this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription)->GetObjectEntryTable());
01064     vtkLookupTable* lut = vtkLookupTable::New();
01065     lut->SetNumberOfTableValues(ObjectEntryTable.size());
01066     lut->Build();
01067     for(int i=0;i<ObjectEntryTable.size();i++) {
01068       if(ObjectEntryTable.at(i)->GetDisplayFlag() != 0)
01069         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), (double)ObjectEntryTable.at(i)->GetOpacity());
01070       else
01071         lut->SetTableValue(i, (double)ObjectEntryTable.at(i)->GetEndRed(), (double)ObjectEntryTable.at(i)->GetEndGreen(), (double)ObjectEntryTable.at(i)->GetEndBlue(), 0);
01072     }
01073 
01074     if(PanelLookupTable)
01075       PanelLookupTable->Delete();
01076 
01077     PanelLookupTable = lut;
01078     m_lookupTableSelection = OTHER;
01079     ((NIREPvtkViewImage2D*)(this->m_widget))->SetLookupTable(lut);
01080     ((NIREPvtkViewImage2D*)(this->m_widget))->SetImage((this->evaluator->GetObjectMap(this,this->ids[0], m_displayDescription))->GetVTKData() );
01081   }
01082   else if(m_widgetType.compare(WidgetCmd["vectorField"]) == 0) {
01083     if( this->evaluator->GetImage(this,this->ids[0], m_displayDescription) == NULL) {
01084       return;
01085     }
01086     ((VectorField*)(this->m_widget))->SetImage(this->evaluator->GetImage(this,this->ids[0], m_displayDescription) );
01087   }
01088   this->m_widget->Render();
01089 }
01090 
01091 /*
01092   function: Render
01093   purpose:  
01094   input:
01095   output:
01096 */
01097 void Panel::Render()
01098 {
01099   wxView->Modified();
01100   wxView->Render();
01101   this->Refresh();
01102 }
01103 
01104 /*
01105   function: GetRenderWindow
01106   purpose:  
01107   input:
01108   output: vtkRenderWindow*
01109 */
01110 vtkRenderWindow* Panel::GetRenderWindow()
01111 {
01112   return wxView->GetRenderWindow();
01113 }
01114 
01115 /*
01116   function: GetView
01117   purpose:  
01118   input:
01119   output: NIREPvtkViewImage2D*
01120 */
01121 NIREPvtkViewImage2D* Panel::GetView()
01122 {
01123   return m_widget;
01124 }
01125 
01126 /*
01127   function: PanelFrame
01128   purpose:  
01129   input: wxCommandEvent &
01130   output:
01131 */
01132 //This function creates the window that lets the user
01133 //modify this panel
01134 void Panel::PanelFrame(wxCommandEvent &event)
01135 {
01136   //Now for the fun.  Need to create a form to change this panel.
01137   PanelForm *panelForm = new PanelForm(this,wxID_ANY);
01138   panelForm->Show();
01139   panelForm->Layout();
01140 }
01141 
01142 /*
01143   function: ObjectMapForm
01144   purpose:  
01145   input: wxCommandEvent &
01146   output:
01147 */
01148 void Panel::ObjectMapForm(wxCommandEvent &event)
01149 {
01150   //Now for the fun.  Need to create a form to change the object map.
01151   ObjectmapForm *objectmapForm = new ObjectmapForm(this,wxID_ANY);
01152   objectmapForm->SetPanel(this);
01153   objectmapForm->Show();
01154   objectmapForm->Layout();
01155 }
01156 
01157 /*
01158   function: RightClick
01159   purpose:  
01160   input: int x
01161          int y
01162   output:
01163 */
01164 //Display to the user the different options
01165 //that they can do to the view and panel
01166 void Panel::RightClick(int x, int y)
01167 {
01168   TreePopupMenu = new wxMenu;
01169   wxMenu *wxmenu = new wxMenu;
01170   TreePopupMenu->Append(ID_POPUP, wxT("Edit m_widget"));
01171   wxmenu->Append(ID_POPUPTHREE,wxT("Pointer"));
01172   wxmenu->Append(ID_POPUPFOUR,wxT("Level/Window"));
01173   wxmenu->Append(ID_POPUPFIVE,wxT("Zoom"));
01174   TreePopupMenu->Append(ID_POPUPTWO, wxT("Left Click"),wxmenu);
01175   TreePopupMenu->Append(ID_POPUPSIX,wxT("Flip Image"));
01176   if(!ObjectEntryTable.empty())
01177     TreePopupMenu->Append(ID_POPUPSEVEN,wxT("Object Map"));
01178   this->PopupMenu(TreePopupMenu);
01179   delete TreePopupMenu;
01180   TreePopupMenu = NULL;
01181 }
01182 
01183 /*
01184   function:
01185   purpose:  
01186   input:
01187   output:
01188 */
01189 void Panel::Delete()
01190 {
01191   parent->DeleteWidget(id);
01192 }
01193 
01194 /*
01195   function: Mouse
01196   purpose:  
01197   input: wxCommandEvent&
01198   output:
01199 */
01200 //Figure out what the user picked from the popup
01201 void Panel::Mouse(wxCommandEvent &event)
01202 {
01203   if(event.GetId()==ID_POPUPTHREE) {
01204     mouse = 0;
01205     this->m_widget->SetInteractionStyle(NIREPvtkViewImage2D::SELECT_INTERACTION);
01206   }
01207   else if(event.GetId()==ID_POPUPFOUR) {
01208     mouse = 1;
01209     this->m_widget->SetInteractionStyle(NIREPvtkViewImage2D::WINDOW_LEVEL_INTERACTION);
01210   }
01211   else if(event.GetId()==ID_POPUPFIVE) {
01212     mouse = 2;
01213     this->m_widget->SetInteractionStyle(NIREPvtkViewImage2D::ZOOM_INTERACTION);
01214   }
01215 }
01216 
01217 /*
01218   function: Flip
01219   purpose:  
01220   input: wxCommandEvent&
01221   output:
01222 */
01223 //Todo:
01224 //Make this work, here is the code from the interactor, so it should be easy to modify.
01225 void Panel::Flip(wxCommandEvent& event)
01226 {
01227     //if(m_widgetType == OVERLAY_OBJECTMAP_WIDGET) {
01228     if(m_widgetType.compare(WidgetCmd["overlayObjectMap"])) {
01229 //      vtkErrorMacro("Can not flip overlay object maps right now.");
01230       return;
01231     }
01232     wxVtkImageFlip* myflipper = new wxVtkImageFlip (this, -1,
01233                                                     wxT("Radiologic conventions"),
01234                                                     wxDefaultPosition,
01235                                                     wxSize(400,400));
01236     
01237     myflipper->SetImage (m_widget->GetImage());
01238     int OK = myflipper->ShowModal();
01239     if (OK == wxID_OK ) {
01240       m_widget->SetImage(myflipper->GetOutput());
01241     }
01242     //if(m_widgetType == CHECKERBOARD_WIDGET) {
01243     if(m_widgetType.compare(WidgetCmd["checkerboard"])) {
01244       myflipper->SetImage (((Checkerboard*)m_widget)->GetSecondImage());
01245       ((Checkerboard*)m_widget)->SetSecondImage(myflipper->GetOutput());
01246     }
01247     //else if(m_widgetType == OVERLAY_OBJECTMAP_WIDGET) {
01248     else if(m_widgetType.compare(WidgetCmd["overlayObjectMap"])) {
01249       vtkImageFlip *flip = vtkImageFlip::New();
01250       flip->SetInput((this->evaluator->GetImage(this,this->ids[1], m_displayDescription)) );
01251       flip->SetFilteredAxes(1);
01252       flip->Update();
01253       myflipper->SetImage (flip->GetOutput());
01254       myflipper->Update();
01255       m_widget->SetMaskImage(myflipper->GetOutput(),this->GetLookUpTable());
01256       flip->Delete();
01257     }
01258     myflipper->Destroy();
01259     this->m_widget->Render();
01260 }
01261 
01262 /*
01263   function: BlendImages
01264   purpose:  
01265   input:
01266   output:
01267 */
01268 void Panel::BlendImages()
01269 {
01270   //blender->SetLookupTable(this->GetLookUpTable());
01271   //blender->Modified();
01272  // blender->Update();
01273   //m_widget->SetImage(blender->GetOutput());
01274   m_widget->SetMaskImage(m_widget->GetMaskImage(),this->GetLookUpTable());
01275 }
01276 
01277 /*
01278   function: GetObjectEntries
01279   purpose:  
01280   input:
01281   output: gec::ObjectMap::ObjectEntryTable&
01282 */
01283 itk::AnalyzeObjectEntryArrayType * Panel::GetObjectEntries()
01284 {
01285   return &ObjectEntryTable;
01286 }
01287 
01288 /*
01289   function:  CheckImage
01290   purpose:  
01291   input: gec::Image *
01292   output: bool
01293 */
01294 bool Panel::CheckImage(gec::Image *image)
01295 {
01296   if(image == NULL) {
01297     return false;
01298   }
01299   return true;
01300 }
01301 
01302 void Panel::SetCursorLocation(int x, int y)
01303 {
01304   if(this->m_widget != NULL) {
01305     double  *temp = new double[2]();
01306     temp[0] = x;
01307     temp[1] = y;
01308     this->m_widget->SyncSetCurrentPoint(temp);
01309   }
01310 }
01311 
01312 void Panel::SetSlice(int s)
01313 {
01314   if(this->m_widget != NULL)
01315     this->m_widget->SyncSetSlice(this->GetOrientation(), s);
01316 }
01317 
01318 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines