ContourView.cxx

Go to the documentation of this file.
00001 
00002 
00003 #include "ContourView.h"
00004 
00005 
00006 // ----------------------------------------------------------------------------
00007 // ----------------------------------------------------------------------------
00008 // ----------------------------------------------------------------------------
00009 
00010 ContourView::ContourView()
00011 {
00012         _wxvtkbaseview = NULL;
00013 }
00014 
00015 // ----------------------------------------------------------------------------
00016 ContourView::~ContourView()
00017 {
00018         DeleteContours();
00019 }
00020 
00021 // ----------------------------------------------------------------------------
00022 void ContourView::DeleteContours()
00023 {
00024         DeleteVtkObjects();
00025         contour_mapped.clear();
00026         contour_actor.clear();
00027 }
00028 
00029 // ----------------------------------------------------------------------------
00030 void ContourView::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
00031 {
00032         _wxvtkbaseview = wxvtkbaseview;
00033 }
00034 
00035 // ----------------------------------------------------------------------------
00036 void ContourView::Refresh()
00037 {
00038         _wxvtkbaseview->GetRenWin()->Render();
00039 }
00040 
00041 // ----------------------------------------------------------------------------
00042 void ContourView::CreateNewContour(vtkPolyData *contour, int type)
00043 {
00044         contour_mapped.push_back(vtkPolyDataMapper::New());
00045         contour_mapped.back()->ImmediateModeRenderingOn();
00046         contour_mapped.back()->ScalarVisibilityOff( );
00047         contour_mapped.back()->SetInput(contour);
00048 
00049         contour_actor.push_back(vtkActor::New());
00050         contour_actor.back()->SetMapper(contour_mapped.back());
00051         contour_actor.back()->GetProperty()->BackfaceCullingOff();
00052         
00053         switch (type)
00054         {
00055         case ContourView::BLUE :        contour_actor.back()->GetProperty()->SetDiffuseColor(0, 0, 1);
00056                                                                 break;
00057         case ContourView::MAGENTA : contour_actor.back()->GetProperty()->SetDiffuseColor(1, 0, 1);
00058                                                                 break;
00059         case ContourView::GREEN :       contour_actor.back()->GetProperty()->SetDiffuseColor(0, 1, 0);
00060                                                                 break;
00061         case ContourView::YELLOW :      contour_actor.back()->GetProperty()->SetDiffuseColor(0, 1, 1);
00062                                                                 break;
00063         default:                                        contour_actor.back()->GetProperty()->SetDiffuseColor(0, 0, 1);
00064 
00065         }
00066         contour_actor.back()->GetProperty()->SetLineWidth(2);
00067         contour_actor.back()->ApplyProperties();
00068 
00069         _wxvtkbaseview->GetRenderer()->AddActor(contour_actor.back());
00070         _wxvtkbaseview->GetRenWin()->Render();
00071 }
00072 
00073 // ----------------------------------------------------------------------------
00074 void ContourView::DeleteVtkObjects()
00075 {
00076         int i,size=contour_mapped.size();
00077         for (i=0;i<size; i++){
00078                 if ( contour_mapped[i]  != NULL )       { 
00079                         contour_mapped[i]  -> Delete(); 
00080                 }
00081                 if ( contour_actor[i]   != NULL )       { 
00082                         _wxvtkbaseview->GetRenderer()->RemoveActor(contour_actor[i]);
00083                         contour_actor[i]  -> Delete(); 
00084                 }
00085                 contour_actor[i] = NULL;
00086                 contour_mapped[i] = NULL;
00087         }
00088 }

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1