LineView.cxx

Go to the documentation of this file.
00001 
00002 
00003 #include "LineView.h"
00004 
00005 
00006 
00007 
00008 // ----------------------------------------------------------------------------
00009 // ----------------------------------------------------------------------------
00010 // ----------------------------------------------------------------------------
00011 LineView::LineView()
00012 {
00013         _wxvtkbaseview = NULL;
00014 }
00015 
00016 // ----------------------------------------------------------------------------
00017 LineView::~LineView()
00018 {
00019         DeleteLines();
00020 }
00021 
00022 // ----------------------------------------------------------------------------
00023 void LineView::DeleteLines() 
00024 {
00025         DeleteVtkObjects();
00026         contour_mapped.clear();
00027         contour_actor.clear();
00028 }
00029 
00030 // ----------------------------------------------------------------------------
00031 void LineView::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
00032 {
00033         _wxvtkbaseview = wxvtkbaseview;
00034 }
00035 
00036 // ----------------------------------------------------------------------------
00037 void LineView::Refresh()
00038 {
00039         _wxvtkbaseview->GetRenWin()->Render();
00040 }
00041 
00042 // ----------------------------------------------------------------------------
00043 void LineView::CreateNewLine(double x1, double y1, double z1, double x2, double y2, double z2)
00044 {
00045 
00046         vtkPoints*  pointsLine = vtkPoints::New();
00047         vtkPolyLine* aLine = vtkPolyLine::New();
00048         vtkUnstructuredGrid* aLineGrid = vtkUnstructuredGrid::New();
00049         contour_mapped.push_back(vtkDataSetMapper::New());
00050         contour_actor.push_back(vtkActor::New());
00051 
00052     pointsLine->SetNumberOfPoints(2);
00053         pointsLine->InsertPoint(0,x1,y1,z1);
00054         pointsLine->InsertPoint(1,x2,y2,z2);
00055 
00056         (aLine->GetPointIds())->SetNumberOfIds(2);
00057         (aLine->GetPointIds())->SetId(0,0);
00058         (aLine->GetPointIds())->SetId(1,1);
00059 
00060         aLineGrid->Allocate(1,1);
00061         aLineGrid->InsertNextCell(aLine->GetCellType(),aLine->GetPointIds());
00062         aLineGrid->SetPoints(pointsLine);
00063 
00064         
00065         contour_mapped.back()->SetInput(aLineGrid);
00066         contour_mapped.back()->ImmediateModeRenderingOn();
00067 
00068         contour_actor.back()->SetMapper(contour_mapped.back());
00069         contour_actor.back()->GetProperty()->BackfaceCullingOn();
00070         contour_actor.back()->GetProperty()->SetDiffuseColor(0, 0, 1);
00071         contour_actor.back()->ApplyProperties();
00072 
00073         _wxvtkbaseview->GetRenderer()->AddActor(contour_actor.back());
00074         _wxvtkbaseview->GetRenWin()->Render();
00075 
00076 }
00077 
00078 // ----------------------------------------------------------------------------
00079 void LineView::DeleteVtkObjects()
00080 {
00081         int i,size=contour_mapped.size();
00082         for (i=0;i<size; i++){
00083                 if ( contour_mapped[i]  != NULL )       { 
00084                         contour_mapped[i]  -> Delete(); 
00085                 }
00086                 if ( contour_actor[i]   != NULL )       { 
00087                         _wxvtkbaseview->GetRenderer()->RemoveActor(contour_actor[i]);
00088                         contour_actor[i]  -> Delete(); 
00089                 }
00090                 contour_actor[i] = NULL;
00091                 contour_mapped[i] = NULL;
00092         }
00093 }
00094 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1