--- /dev/null
+
+
+#include "ViewShowNPoints.h"
+
+
+//----------------------------------------------------------------------
+ViewShowNPoints::ViewShowNPoints(ModelShowNPoints* modelShowNPoints)
+{
+ renderer = NULL;
+ mmodelShowNPoints=modelShowNPoints;
+}
+//----------------------------------------------------------------------
+
+ViewShowNPoints::~ViewShowNPoints()
+{
+}
+
+
+//------------------------------------------------------------------------
+
+void ViewShowNPoints::RefreshPoint(int id)
+{
+ double spc[3];
+ int x,y,z;
+ GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
+ GetModelShowNPoints()->GetImage()->GetSpacing(spc);
+ std::string label = GetModelShowNPoints()->GetIdLabel(id);
+ double radio = GetModelShowNPoints()->GetRadio();
+ lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
+ lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
+ lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
+ lstSourceSphere[id]->SetRadius( radio );
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ // ..
+#else
+ lstSourceSphere[id]->Update();
+#endif
+ lstActorsText[id]->SetInput( label.c_str() );
+ lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::RefreshPoints()
+{
+ int id,size=lstActorsSphere.size();
+ for (id=0;id<size;id++)
+ {
+ RefreshPoint(id);
+ } // for
+ renderer->GetRenderWindow()->Render();
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::AddVtkPoint()
+{
+ // Sphere
+ vtkSphereSource *vtksphere = vtkSphereSource::New();
+ vtksphere->SetThetaResolution (20);
+ vtksphere->SetPhiResolution (20);
+ vtksphere->SetRadius( 1 );
+ //NTU: For updating points
+ lstSourceSphere.push_back(vtksphere);
+ vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
+
+//EED 2017-01-01 Migration VTK7
+#if VTK_MAJOR_VERSION <= 5
+ sphereMapper->SetInput( vtksphere->GetOutput() );
+#else
+ vtksphere->Update();
+ sphereMapper->SetInputData( vtksphere->GetOutput() );
+#endif
+
+ vtkActor *sphereActor = vtkActor::New();
+ sphereActor->SetMapper(sphereMapper);
+ sphereActor->SetOrigin(0, 0, 0);
+
+ lstActorsSphere.push_back(sphereActor);
+
+ if(renderer==NULL){
+ // EED 2022-05-19
+ // wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
+ // dialog.ShowModal();
+ printf("EED ShowNPoints Warning: Renderer Not Set\n");
+ return;
+ }
+
+ renderer->AddActor( sphereActor );
+ // Actor
+ vtkTextActor3D *textActor = vtkTextActor3D::New();
+// textActor->SetInput( strLabel.c_str() );
+ renderer->AddActor( textActor );
+ lstActorsText.push_back(textActor);
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::AddPoint()
+{
+ AddVtkPoint();
+ RefreshPoint(lstActorsSphere.size()-1);
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::Render()
+{
+ renderer->GetRenderWindow()->Render();
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::ErasePoint(int id)
+{
+ if (this->renderer!=NULL)
+ {
+ if (id>=0)
+ {
+ renderer->RemoveActor( lstActorsSphere[id] );
+ renderer->RemoveActor( lstActorsText[id] );
+ lstActorsSphere[id]->Delete();
+ lstActorsText[id]->Delete();
+ lstSourceSphere[id]->Delete();
+ lstActorsSphere.erase( lstActorsSphere.begin()+id );
+ lstActorsText.erase( lstActorsText.begin()+id );
+ lstSourceSphere.erase( lstSourceSphere.begin()+id );
+ } // if id
+ } // if renderer
+}
+
+//------------------------------------------------------------------------
+ModelShowNPoints* ViewShowNPoints::GetModelShowNPoints()
+{
+ return mmodelShowNPoints;
+}
+
+//------------------------------------------------------------------------
+void ViewShowNPoints::SetModelShowNPoints( ModelShowNPoints* modelShowNPoints)
+{
+ mmodelShowNPoints=modelShowNPoints;
+}
-#include "vtkActor.h"
#include "vtkSphereSource.h"
#include "vtkRenderer.h"
#include "vtkTextActor3D.h"
-#include "vtkProperty.h"
-#include "vtkPolyDataMapper.h"
-#include "vtkRenderWindow.h"
-#include <vtkTextProperty.h>
#include <wx/button.h>
#include <wx/sizer.h>
WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, int type)
: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
{
- mmodelShowNPoints = new ModelShowNPoints();
+ // EED 2022-05-19
+ // mmodelShowNPoints = new ModelShowNPoints();
+ mActualLstPoints=0;
+ ModelShowNPoints* modelShowNPoints = new ModelShowNPoints();
+ lstModelShowNPoints.push_back( modelShowNPoints );
+ lstViewShowNPoints.push_back( new ViewShowNPoints( modelShowNPoints ) );
+
+
mtype = type;
SetType(mtype);
- this->renderer = NULL;
wxPanel *panel = this;
wxSizer *sizer = NULL;
sizer1->Add(btnDeleteAllPoints);
sizer1->Add(spacer);
sizer1->Add(textCtrl);
- sdrOpacity = new wxSlider();
- sdrRadio = new wxSlider();
+ sdrOpacity = new wxSlider();
+ sdrRadio = new wxSlider();
txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));
sizer = sizer1;
} // bbGetInputType 2
//------------------------------------------------------------------------
ModelShowNPoints* WidgetShowNPoints::GetModelShowNPoints()
{
- return mmodelShowNPoints;
+ // EED 2022-05-19
+ // return mmodelShowNPoints;
+ return lstModelShowNPoints[ mActualLstPoints ];
+}
+
+// EED 2022-05-19
+//------------------------------------------------------------------------
+ViewShowNPoints* WidgetShowNPoints::GetViewShowNPoints()
+{
+ return lstViewShowNPoints[ mActualLstPoints ];
}
//------------------------------------------------------------------------
void WidgetShowNPoints::SetRadio(double radio)
{
- GetModelShowNPoints()->SetRadio(radio);
+ // EED 2022-05-19
+ // GetModelShowNPoints()->SetRadio(radio);
+ int i,size = lstModelShowNPoints.size();
+ for (i=0;i<size;i++)
+ {
+ lstModelShowNPoints[i]->SetRadio( radio );
+ } // for i
//NTU: For Slider
sdrRadio->SetValue(radio);
}
//------------------------------------------------------------------------
void WidgetShowNPoints::SetColour(std::vector<double> colour)
{
- this->mcolour = colour;
+ // EED 2022-05-19
+ //this->mcolour = colour;
+ int i,size = lstViewShowNPoints.size();
+ for (i=0 ; i<size ; i++)
+ {
+ lstViewShowNPoints[i]->mcolour = colour;
+ } // for i
}
//------------------------------------------------------------------------
void WidgetShowNPoints::SetImage(vtkImageData* image)
{
- GetModelShowNPoints()->SetImage(image);
+ // EED 2022-05-19
+ //GetModelShowNPoints()->SetImage(image);
+ int i,size = lstModelShowNPoints.size();
+ for (i=0 ; i<size ; i++)
+ {
+ lstModelShowNPoints[i]->SetImage(image);
+ } // for i
}
//------------------------------------------------------------------------
void WidgetShowNPoints::SetOpacity(double opacity)
{
- this->mopacity=opacity;
+ // EED 2022-05-19
+ //this->mopacity=opacity;
+ int i,size = lstViewShowNPoints.size();
+ for (i=0 ; i<size ; i++)
+ {
+ lstViewShowNPoints[i]->mopacity = opacity;
+ } // for i
//NTU: For Slider
- sdrOpacity->SetValue(this->mopacity*100.0);
+ sdrOpacity->SetValue( opacity*100.0 );
}
//------------------------------------------------------------------------
void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer)
{
- this->renderer = renderer;
+ // EED 2022-05-19
+ //this->renderer = renderer;
+ int i,size = lstViewShowNPoints.size();
+ for (i=0 ; i<size ; i++)
+ {
+ lstViewShowNPoints[i]->renderer = renderer;
+ } // for i
}
-
+
+/* EED 2022-05-19
//------------------------------------------------------------------------
void WidgetShowNPoints::RefreshPoint(int id)
{
double spc[3];
-
-//EED 2016/06/17
-// mimage->GetSpacing(spc);
-// int x = lstPointsX[id];
-// int y = lstPointsY[id];
-// int z = lstPointsZ[id];
int x,y,z;
GetModelShowNPoints()->GetIdPoint(id,&x,&y,&z);
GetModelShowNPoints()->GetImage()->GetSpacing(spc);
std::string label = GetModelShowNPoints()->GetIdLabel(id);
double radio = GetModelShowNPoints()->GetRadio();
-
- lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
- lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
- lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
- lstSourceSphere[id]->SetRadius( radio );
-
+ lstActorsSphere[id]->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
+ lstActorsSphere[id]->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
+ lstActorsSphere[id]->GetProperty()->SetOpacity( mopacity );
+ lstSourceSphere[id]->SetRadius( radio );
//EED 2017-01-01 Migration VTK7
#if VTK_MAJOR_VERSION <= 5
// ..
#else
- lstSourceSphere[id]->Update();
+ lstSourceSphere[id]->Update();
#endif
-
- lstActorsText[id]->SetInput( label.c_str() );
- lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
+ lstActorsText[id]->SetInput( label.c_str() );
+ lstActorsText[id]->SetPosition( radio+spc[0]*x , spc[1]*y , spc[2]*z );
}
//------------------------------------------------------------------------
renderer->AddActor( textActor );
lstActorsText.push_back(textActor);
}
+ */
//------------------------------------------------------------------------
void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
{
GetModelShowNPoints()->AddPoint(x,y,z, label );
- AddVtkPoint();
- RefreshPoint(lstActorsSphere.size()-1);
+ // EED 2022-05-19
+ //AddVtkPoint();
+ //RefreshPoint(lstActorsSphere.size()-1);
+ GetViewShowNPoints()->AddPoint();
}
-
-
//------------------------------------------------------------------------
void WidgetShowNPoints::InsertPoint(int x, int y, int z, std::string label)//CFT
{
+ // EED 2022-05-19
+ //if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
+ //{
+ // AddVtkPoint();
+ //} else {
+ // AddPoint(x,y,z,label);
+ //}
+ //RefreshPoints();
+ if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
+ {
+ GetViewShowNPoints()->AddVtkPoint();
+ } else {
+ AddPoint(x,y,z,label);
+ }
+ GetViewShowNPoints()->RefreshPoints();
-//--
- if ( GetModelShowNPoints()->InsertPoint(x,y,z,label) != -1 )
- {
- AddVtkPoint();
- } else {
- AddPoint(x,y,z,label);
- }
- RefreshPoints();
- //end if
}
-
//------------------------------------------------------------------------
void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
{
- if (this->renderer==NULL)
- {
+ // EED 2022-05-19
+ //if (this->renderer==NULL)
+ if (GetViewShowNPoints()->renderer==NULL)
+ {
return;
}
{
AddPoint(point[0],point[1],point[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
SetOutputBox();
- renderer->GetRenderWindow()->Render();
+ // EED 2022-05-19
+ //renderer->GetRenderWindow()->Render();
+ GetViewShowNPoints()->Render();
} else {//mpoint.size
printf("creaMaracasVisu::ShowNPoints (not match point) \n");
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnInsertPoint (wxCommandEvent& event)//CFT
{
- if (this->renderer==NULL)
- {
+ // EED 2022-05-19
+ //if (this->renderer==NULL)
+ if (GetViewShowNPoints()->renderer==NULL)
+ {
return;
}
//EED renderer->GetRenderWindow()->Render();
wxString strTmp;
strTmp.Printf(_T("Nbr of points: %d"), GetModelShowNPoints()->GetLstPointsSize() );
- txtNrPoints->SetLabel( strTmp );
+ txtNrPoints->SetLabel( strTmp );
//--BBTK
//EED 2017-06-03
wxDefaultPosition);
#endif
-
-
int result_FD = FD->ShowModal();
-
// This line is need it by windows //EED
FD->SetReturnCode( result_FD );
-
if (FD->GetReturnCode()==wxID_OK)
{
std::string filename= (const char*) ( FD->GetPath().mb_str() );
int numberPointsRead = GetModelShowNPoints()->ReadPoints( filename );
for (i=0;i<numberPointsRead;i++)
{
- AddVtkPoint();
+ // EED 2022-05-19
+ //AddVtkPoint();
+ GetViewShowNPoints()->AddVtkPoint();
}// for
SetOutputBox();
- RefreshPoints();
+ // EED 2022-05-19
+ //RefreshPoints();
+ GetViewShowNPoints()->RefreshPoints();
} // dialog box
-
}
//------------------------------------------------------------------------
if (id>=0)
{
GetModelShowNPoints()->SetPointId_mReferencePoint(id);
- RefreshPoint(id);
- renderer->GetRenderWindow()->Render();
+ // EED 2022-05-19
+ //RefreshPoint(id);
+ //renderer->GetRenderWindow()->Render();
+ GetViewShowNPoints()->RefreshPoint(id);
+ GetViewShowNPoints()->Render();
} // if id
SetOutputBox();
}
int id = GetModelShowNPoints()->RenamePoint( (const char*) ( textCtrl->GetValue().mb_str() ) );
if (id>=0)
{
- lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
- SetOutputBox();
- renderer->GetRenderWindow()->Render();
+ // EED 2022-05-19
+ //lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
+ //renderer->GetRenderWindow()->Render();
+ GetViewShowNPoints()->lstActorsText[id]->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
+ GetViewShowNPoints()->Render();
+ SetOutputBox();
}
}
//------------------------------------------------------------------------
void WidgetShowNPoints::ErasePoint(int id)
{
- if (this->renderer!=NULL)
+ // EED 2022-05-19
+ //if (this->renderer!=NULL)
+ if (GetViewShowNPoints()->renderer!=NULL)
{
if (id>=0)
{
- renderer->RemoveActor( lstActorsSphere[id] );
- renderer->RemoveActor( lstActorsText[id] );
- lstActorsSphere[id]->Delete();
- lstActorsText[id]->Delete();
- lstSourceSphere[id]->Delete();
- lstActorsSphere.erase( lstActorsSphere.begin()+id );
- lstActorsText.erase( lstActorsText.begin()+id );
- lstSourceSphere.erase( lstSourceSphere.begin()+id );
+ // EED 2022-05-19
+ //renderer->RemoveActor( lstActorsSphere[id] );
+ //renderer->RemoveActor( lstActorsText[id] );
+ //lstActorsSphere[id]->Delete();
+ //lstActorsText[id]->Delete();
+ //lstSourceSphere[id]->Delete();
+ //lstActorsSphere.erase( lstActorsSphere.begin()+id );
+ //lstActorsText.erase( lstActorsText.begin()+id );
+ //lstSourceSphere.erase( lstSourceSphere.begin()+id );
+ GetViewShowNPoints()->ErasePoint(id);
GetModelShowNPoints()->ErasePoint(id);
} // if id
} // if renderer
{
ErasePoint( GetModelShowNPoints()->IdInsidePoint() );
SetOutputBox();
- renderer->GetRenderWindow()->Render();
+ // EED 2022-05-19
+ //renderer->GetRenderWindow()->Render();
+ GetViewShowNPoints()->Render();
}
//------------------------------------------------------------------------
void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
{
- ErasePoint(lstActorsSphere.size()-1);
- SetOutputBox();
- renderer->GetRenderWindow()->Render();
+ // EED 2022-05-19
+ //ErasePoint( lstActorsSphere.size()-1 );
+ //renderer->GetRenderWindow()->Render();
+ int id = GetViewShowNPoints()->lstActorsSphere.size()-1;
+ ErasePoint( id );
+ GetViewShowNPoints()->Render();
+ SetOutputBox();
}
//------------------------------------------------------------------------
void WidgetShowNPoints::DeleteAllPoints()
{
- int id,size=lstActorsSphere.size();
+ // EED 2022-05-19
+ //int id,size=lstActorsSphere.size();
+ int id,size=GetViewShowNPoints()->lstActorsSphere.size();
for (id=size-1;id>=0;id--)
{
ErasePoint(id);
}
SetOutputBox();
- renderer->GetRenderWindow()->Render();
+ // EED 2022-05-19
+ //renderer->GetRenderWindow()->Render();
+ GetViewShowNPoints()->Render();
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
{
- //Difference in Radio for text placement
-// double radio=GetModelShowNPoints()->GetRadio();
- this->mopacity = sdrOpacity->GetValue()/100.0;
- GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
-// radio = sdrRadio->GetValue();
- //NTU refresh the inputs
-
-//EED 2017-06-03
-// mbbShowNPoints->bbSetInputOpacity(this->mopacity);
-// mbbShowNPoints->bbSetInputRadio( radio );
- // EED
- RefreshPoints();
+ // EED 2022-05-19
+ //this->mopacity = sdrOpacity->GetValue()/100.0;
+ //GetModelShowNPoints()->SetRadio( sdrRadio->GetValue() ) ;
+ //RefreshPoints();
+
+ double opacity = sdrOpacity->GetValue()/100.0;
+ double radio = sdrRadio->GetValue();
+ int i,size = lstViewShowNPoints.size();
+ for (i=0 ; i<size ; i++)
+ {
+ lstViewShowNPoints[i]->mopacity = opacity;
+ lstModelShowNPoints[i]->SetRadio( radio ) ;
+ } // for i
+ GetViewShowNPoints()->RefreshPoints();
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
void WidgetShowNPoints::SetInitLstPoints( std::vector<int> initLstPointsX, std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels )
{
- if (this->renderer==NULL)
- {
+ // EED 2022-05-19
+ //if (this->renderer==NULL)
+ if (GetViewShowNPoints()->renderer==NULL)
+ {
return;
}
-
int i,sizeX,sizeY,sizeZ,sizeLabels;
sizeX=(int)initLstPointsX.size();
sizeY=(int)initLstPointsY.size();
sizeZ=(int)initLstPointsZ.size();
sizeLabels=(int)initLstLabels.size();
-
int x,y,z;
std::string label;
-
if ( (sizeX==sizeY) && (sizeX==sizeZ) )
{
-
for (i=0;i<sizeX;i++)
{
x = initLstPointsX[i];
} // for i
// SetOutputBox();
// renderer->GetRenderWindow()->Render();
-
} // if size
}
+
//------------------------------------------------------------------------
void WidgetShowNPoints::SetType(int type)
{
{
return sdrRadio->GetValue();
}
-
//------------------------------------------------------------------------
double WidgetShowNPoints::GetOpacity()
{
- return mopacity;
+ return sdrOpacity->GetValue()/100;
}
-
-