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