From: Eduardo Davila Date: Fri, 29 May 2009 14:27:18 +0000 (+0000) Subject: . X-Git-Tag: EED.02Oct2009~59 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0639da4f50de993c0234f26f18ac0528e537017a;p=creaMaracasVisu.git . --- diff --git a/bbtk/src/bbmaracasvisuShowNPoints.cxx b/bbtk/src/bbmaracasvisuShowNPoints.cxx index ca5a850..ef31b02 100644 --- a/bbtk/src/bbmaracasvisuShowNPoints.cxx +++ b/bbtk/src/bbmaracasvisuShowNPoints.cxx @@ -5,6 +5,7 @@ #include "vtkSphereSource.h" #include "vtkPolyDataMapper.h" #include "vtkRenderWindow.h" +#include "vtkTextActor3D.h" namespace bbcreaMaracasVisu { @@ -21,20 +22,25 @@ 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; @@ -111,11 +117,8 @@ void WidgetShowNPoints::SetRenderer(vtkRenderer *renderer) //------------------------------------------------------------------------ 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] ); @@ -136,54 +139,101 @@ printf("EED %p WidgetShowNPoints::OnAddPoint 03\n", this); 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 ; irenderer!=NULL){ for (i=0;iRemoveActor( 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 } @@ -196,9 +246,7 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox); 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() ); diff --git a/bbtk/src/bbmaracasvisuViewerMPR.cxx b/bbtk/src/bbmaracasvisuViewerMPR.cxx index f0acd3a..05191c7 100644 --- a/bbtk/src/bbmaracasvisuViewerMPR.cxx +++ b/bbtk/src/bbmaracasvisuViewerMPR.cxx @@ -86,9 +86,10 @@ END_EVENT_TABLE( ); //--------------- void wxWidgetMPR::OnRefreshView(wxCommandEvent &event) { - + printf("EED wxWidgetMPR::OnRefreshView 01\n"); if((wxwidget!=NULL) && (mbbViewerMPR!=NULL)) { + printf("EED wxWidgetMPR::OnRefreshView 02\n"); point.clear(); point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetX()); point.push_back((int)wxwidget->GetVtkMPRBaseData()->GetY()); diff --git a/bbtk/src/bbmaracasvisuViewerNV.cxx b/bbtk/src/bbmaracasvisuViewerNV.cxx index 8ada867..3fd608f 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.cxx +++ b/bbtk/src/bbmaracasvisuViewerNV.cxx @@ -27,18 +27,26 @@ bbwxMaracas_N_ViewersWidget::bbwxMaracas_N_ViewersWidget(ViewerNV* box, bbwxMaracas_N_ViewersWidget::~bbwxMaracas_N_ViewersWidget() { } - + //------------------------------------------------------------- void bbwxMaracas_N_ViewersWidget::OnRefreshView(wxCommandEvent & event) { - wxMaracas_N_ViewersWidget::OnRefreshView(event); + + mbbViewerNV->point.clear(); + + mbbViewerNV->point.push_back( (int)GetX() ); + mbbViewerNV->point.push_back( (int)GetY() ); + mbbViewerNV->point.push_back( (int)GetZ() ); + mbbViewerNV->bbSetOutputPoint( mbbViewerNV->point ); mbbViewerNV->bbSignalOutputModification(std::string("Point")); + wxMaracas_N_ViewersWidget::OnRefreshView(event); } //------------------------------------------------------------- void bbwxMaracas_N_ViewersWidget::OnDClickLeft(wxCommandEvent & event) { +printf("EED bbwxMaracas_N_ViewersWidget::OnDClickLeft \n"); wxMaracas_N_ViewersWidget::OnDClickLeft(event); mbbViewerNV->bbSignalOutputModification(std::string("Point")); } diff --git a/bbtk/src/bbmaracasvisuViewerNV.h b/bbtk/src/bbmaracasvisuViewerNV.h index 4222d32..e92aa73 100644 --- a/bbtk/src/bbmaracasvisuViewerNV.h +++ b/bbtk/src/bbmaracasvisuViewerNV.h @@ -60,9 +60,10 @@ class /*BBTK_EXPORT*/ ViewerNV BBTK_CREATE_WIDGET(CreateWidget); void CreateWidget(wxWindow* parent); + std::vector point; private: bool enter; - std::vector point; + vtkImageData* currentimg; std::vector currenttype; wxMaracas_N_ViewersWidget *mwxwidget;