2 #include "PlaneDirectionManager.h"
4 /********************************************************************************************
5 ** Start of data viewmanagerData
6 *********************************************************************************************/
8 PlaneDirectionManager::PlaneDirectionManager(int radio, double colour[3] , int opacity){
15 PlaneDirectionManager::~PlaneDirectionManager(){
16 RemoveAllActorsFromIndex();
19 void PlaneDirectionManager::SetRenderer(vtkRenderer* render){
22 void PlaneDirectionManager::SetVectors( std::vector<double> lstPointsx, std::vector<double> lstPointsy, std::vector<double> lstPointsz){
24 _lstPointsx = lstPointsx;
25 _lstPointsy = lstPointsy;
26 _lstPointsz = lstPointsz;
29 void PlaneDirectionManager::UpdateDirections() throw (std::exception){
35 void PlaneDirectionManager::AddActors(){
36 for(int i = 0; i < _vectdata.size();i++){
37 _render->AddViewProp (_vectdata[i]->GetActor());
40 void PlaneDirectionManager::RemoveAllActorsFromIndex(int n)throw (std::exception){
41 /*due to incompleate set of points to create the plane
44 throw std::exception();
46 for(int i = _vectdata.size()-1; i >= n;i--){
47 _render->RemoveViewProp(_vectdata[i]->GetActor());
52 void PlaneDirectionManager::UpdateVectors()throw (std::exception){
53 PlaneDirectionManagerData* temp;
54 bool deletelast = false;
56 for(int i = 0; i < _lstPointsx.size();i++){
58 if(_vectdata.size()>currentdata){
59 temp = _vectdata[currentdata];
61 temp = new PlaneDirectionManagerData(_radio, _colour, _opacity);
62 _vectdata.push_back(temp);
64 temp->setPoint0(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
67 temp->setPoint1(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
69 temp->setPoint2(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
74 RemoveAllActorsFromIndex(currentdata);
77 void PlaneDirectionManager::UpdateActors(){
78 for(int i = 0; i < _vectdata.size();i++){
79 _vectdata[i]->UpdateActor();
83 void PlaneDirectionManager::addRemoveActor(int index, bool addremove){
85 if(index < _vectdata.size()){
87 _render->AddViewProp (_vectdata[index]->GetActor());
89 _render->RemoveViewProp (_vectdata[index]->GetActor());
94 void PlaneDirectionManager::changeColor(int index,double r,double g,double b)
96 GetPlaneDirectionManagerData(index)->ChangeColour(r,g,b);
99 PlaneDirectionManagerData* PlaneDirectionManager::GetPlaneDirectionManagerData(int id)
101 return _vectdata[id];
104 void PlaneDirectionManager::WriteInformation(std::string filename, double* spc){
106 ff = fopen( filename.c_str() , "w+" );
115 for(int i = 0; i < _vectdata.size();i++){
117 double* p0 = _vectdata[i]->getPoint0();
118 double* p1 = _vectdata[i]->getPoint1();
119 double* p2 = _vectdata[i]->getPoint2();
120 double* dir = _vectdata[i]->GetDirection();
122 double p0x = p0[0]/spc[0];
123 double p0y = p0[1]/spc[1];
124 double p0z = p0[2]/spc[2];
126 double p1x = p1[0]/spc[0];
127 double p1y = p1[1]/spc[1];
128 double p1z = p1[2]/spc[2];
130 double p2x = p2[0]/spc[0];
131 double p2y = p2[1]/spc[1];
132 double p2z = p2[2]/spc[2];
134 double dirx = dir[0]/spc[0];
135 double diry = dir[1]/spc[1];
136 double dirz = dir[2]/spc[2];
138 fprintf(ff,"Dir%d\n",i);
139 fprintf(ff,"\tP0[%f, %f, %f]\tP1[%f, %f, %f]\tP2[%f, %f, %f]\tDir[%f, %f, %f] \n",
140 p0x,p0y,p0z, p1x,p1y,p1z, p2x,p2y,p2z, dirx,diry,dirz);
144 printf("PlaneDirectionManager::WriteInformation ...Error... creating file");
148 void PlaneDirectionManager::SetArrowSize(int arrowsize){