#include "vtkSphereSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
+#include "vtkTextActor3D.h"
namespace bbcreaMaracasVisu
{
// Widget interface
- wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point"));
- wxButton *btnEraseLstPoint = new wxButton( panel, -1, _T("Erase Last point"));
- wxButton *btnDeleteAllPoints= new wxButton( panel, -1, _T("Delete all points"));
+ textCtrl = new wxTextCtrl(panel, -1);
+ wxButton *btnAddPoint = new wxButton( panel, -1, _T("Add Point"));
+ wxButton *btnEraseLastPoint = new wxButton( panel, -1, _T("Erase Last point"));
+ wxButton *btnErasePoint = new wxButton( panel, -1, _T("Erase point"));
+ wxButton *btnDeleteAllPoints = new wxButton( panel, -1, _T("Delete all points"));
wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
// sizer1->Add(new wxStaticText(panel,-1,_T(" ")));
Connect(btnAddPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnAddPoint);
- Connect(btnEraseLstPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
+ Connect(btnEraseLastPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnEraseLastPoint);
+ Connect(btnErasePoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnErasePoint);
Connect(btnDeleteAllPoints->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
- sizer1->Add(btnAddPoint);
- sizer1->Add(btnEraseLstPoint);
+ sizer1->Add(textCtrl);
+ sizer1->Add(btnAddPoint);
+ sizer1->Add(btnErasePoint);
+ sizer1->Add(btnEraseLastPoint);
sizer1->Add(btnDeleteAllPoints);
sizer = sizer1;
//------------------------------------------------------------------------
void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
{
-printf("EED %p WidgetShowNPoints::OnAddPoint 01\n", this);
if (this->renderer!=NULL){
-printf("EED %p WidgetShowNPoints::OnAddPoint 02\n", this);
if (mpoint.size()==3){
-printf("EED %p WidgetShowNPoints::OnAddPoint 03\n", this);
lstPointsX.push_back( mpoint[0] );
lstPointsY.push_back( mpoint[1] );
lstPointsZ.push_back( mpoint[2] );
sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
sphereActor->GetProperty()->SetOpacity( mopacity );
- lstActors.push_back(sphereActor);
+ lstActorsSphere.push_back(sphereActor);
renderer->AddActor( sphereActor );
-
+
+ // Actor
+ vtkTextActor3D *text = vtkTextActor3D::New();
+ text->SetPosition( mradio+spc[0]*mpoint[0] , spc[1]*mpoint[1] , spc[2]*mpoint[2] );
+ text->SetInput( (const char*) ( textCtrl->GetValue().mb_str() ) );
+ renderer->AddActor( text );
+ lstActorsText.push_back(text);
+
renderer->GetRenderWindow()->Render();
//--BBTK
-//EED??? mbbShowNPoints->bbSignalOutputModification(std::string("Point"));
-
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
+
} else {//mpoint.size
- printf("creaMaracasVisu::ShowNPoints (not match point)");
+ printf("creaMaracasVisu::ShowNPoints (not match point) \n");
}
} // renderer
}
-//------------------------------------------------------------------------
-void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
-{
- int id = lstActors.size()-1;
- if (this->renderer!=NULL){
- if (id>=0){
- renderer->RemoveActor( lstActors[id] );
- lstActors.erase( lstActors.begin()+id );
- lstPointsX.erase( lstPointsX.begin()+id );
- lstPointsY.erase( lstPointsY.begin()+id );
- lstPointsZ.erase( lstPointsZ.begin()+id );
- renderer->GetRenderWindow()->Render();
- //--BBTK
-//EED??? mbbShowNPoints->bbSignalOutputModification(std::string("Point"));
- } // if id
- } // if renderer
-}
-
+
+ //------------------------------------------------------------------------
+ void WidgetShowNPoints::ErasePoint(int id)
+ {
+ if (this->renderer!=NULL){
+ if (id>=0){
+ renderer->RemoveActor( lstActorsSphere[id] );
+ renderer->RemoveActor( lstActorsText[id] );
+ lstActorsSphere[id]->Delete();
+ lstActorsText[id]->Delete();
+ lstActorsSphere.erase( lstActorsSphere.begin()+id );
+ lstActorsText.erase( lstActorsText.begin()+id );
+ lstPointsX.erase( lstPointsX.begin()+id );
+ lstPointsY.erase( lstPointsY.begin()+id );
+ lstPointsZ.erase( lstPointsZ.begin()+id );
+ renderer->GetRenderWindow()->Render();
+ //--BBTK
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
+ } // if id
+ } // if renderer
+ }
+
+ //------------------------------------------------------------------------
+ void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
+ {
+ int id=-1;
+ int i, size=(int)(lstActorsSphere.size());
+ double spc[3];
+ mimage->GetSpacing(spc);
+
+ for ( i=0 ; i<size; i++ )
+ {
+ double rx = spc[0]*(mpoint[0] - lstPointsX [i]);
+ double ry = spc[1]*(mpoint[1] - lstPointsY [i]);
+ double rz = spc[2]*(mpoint[2] - lstPointsZ [i]);
+ if ( rx*rx + ry*ry + rz*rz <= mradio*mradio)
+ {
+ id=i;
+ } // if
+ } // for
+ ErasePoint(id);
+ }
+
+ //------------------------------------------------------------------------
+ void WidgetShowNPoints::OnEraseLastPoint(wxCommandEvent& event)
+ {
+ ErasePoint(lstActorsSphere.size()-1);
+ }
+
+
//------------------------------------------------------------------------
void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
{
- int i,size=lstActors.size();
+ int i,size=lstActorsSphere.size();
if (this->renderer!=NULL){
for (i=0;i<size;i++)
{
- renderer->RemoveActor( lstActors[i] );
+ renderer->RemoveActor( lstActorsSphere[i] );
+ renderer->RemoveActor( lstActorsText[i] );
}
- lstActors.clear();
+ lstActorsSphere.clear();
+ lstActorsText.clear();
lstPointsX.clear();
lstPointsY.clear();
lstPointsZ.clear();
renderer->GetRenderWindow()->Render();
//--BBTK
-//EED??? mbbShowNPoints->bbSignalOutputModification(std::string("Point"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsX"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsY"));
+ mbbShowNPoints->bbSignalOutputModification(std::string("lstPointsZ"));
} // renderer
}
void ShowNPoints::Process()
{
-printf("EED %p ShowNPoints::Process 01\n", this);
if (mwxwidget!=NULL){
-printf("EED %p ShowNPoints::Process 02\n", this);
mwxwidget->SetRenderer( bbGetInputRenderer() );
mwxwidget->SetPoint( bbGetInputIn() );
mwxwidget->SetImage( bbGetInputImage() );