]> Creatis software - creaMaracasVisu.git/commitdiff
NTU: Added functional Radio and Opacity sliders for showNpoints
authortrillos <trillos>
Tue, 8 Dec 2009 16:02:22 +0000 (16:02 +0000)
committertrillos <trillos>
Tue, 8 Dec 2009 16:02:22 +0000 (16:02 +0000)
bbtk/src/bbmaracasvisuShowNPoints.cxx
bbtk/src/bbmaracasvisuShowNPoints.h

index 6b35fe33e6a5265d2bb30aa64c334adeb5255b1b..bd4ec4272aff02d3718599324a21cd8f685c3dd3 100644 (file)
@@ -32,6 +32,14 @@ namespace bbcreaMaracasVisu
        wxButton *btnLoadPoints                 = new wxButton( panel, -1, _T("Load points"));
        txtNrPoints                                             = new wxStaticText(panel,-1, _T(" "));
 
+       //NTU: Sliders for opacity and radio change
+
+       wxStaticText* txOpacity = new wxStaticText(this, -1, wxString(_T("  Points Opacity  ")));
+       sdrOpacity = new wxSlider(this, -1, 0, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+
+       wxStaticText* txRadio = new wxStaticText(this, -1, wxString(_T("  Points Radio  ")));
+       sdrRadio = new wxSlider(this, -1, 0, 1, 50, wxDefaultPosition, wxDefaultSize, wxSL_LABELS);
+
        wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
 //    sizer1->Add(new wxStaticText(panel,-1,_T("  ")));
 
@@ -43,6 +51,10 @@ namespace bbcreaMaracasVisu
          Connect(btnSavePoints->GetId()                , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSavePoints);
          Connect(btnLoadPoints->GetId()                , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnLoadPoints);
 
+         //NTU: Slider events
+         Connect(sdrOpacity->GetId()                   , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+         Connect(sdrRadio->GetId()                             , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
+
          sizer1->Add(textCtrl);
          sizer1->Add(btnAddPoint);
          sizer1->Add(btnRenamePoint);
@@ -50,6 +62,10 @@ namespace bbcreaMaracasVisu
          sizer1->Add(btnEraseLastPoint);
          sizer1->Add(btnDeleteAllPoints);
          sizer1->Add(txtNrPoints);
+         sizer1->Add(txOpacity);
+         sizer1->Add(sdrOpacity);
+         sizer1->Add(txRadio);
+         sizer1->Add(sdrRadio);
          sizer1->Add(btnSavePoints);
          sizer1->Add(btnLoadPoints);
 
@@ -68,7 +84,9 @@ WidgetShowNPoints::~WidgetShowNPoints()
 
 void WidgetShowNPoints::SetRadio(double radio)
 {
-       mradio=radio;
+       this->mradio=radio;
+       //NTU: For Slider
+       sdrRadio->SetValue(this->mradio);
 }
 
 //------------------------------------------------------------------------
@@ -114,6 +132,8 @@ void WidgetShowNPoints::SetColour(std::vector<double> colour)
 void WidgetShowNPoints::SetOpacity(double opacity)
 {
        this->mopacity=opacity;
+       //NTU: For Slider
+       sdrOpacity->SetValue(this->mopacity*100.0);
 }
 
 //------------------------------------------------------------------------
@@ -155,6 +175,11 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        vtksphere->SetThetaResolution (20);
        vtksphere->SetPhiResolution (20);
        vtksphere->SetRadius( mradio  );
+
+       //NTU: For updating points
+
+       lstSourceSphere.push_back(vtksphere);
+
        vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
        sphereMapper->SetInput( vtksphere->GetOutput() );
        vtkActor *sphereActor   = vtkActor::New();
@@ -364,8 +389,10 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                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 );
 
                                lstPointsX.erase( lstPointsX.begin()+id );
                                lstPointsY.erase( lstPointsY.begin()+id );
@@ -402,6 +429,34 @@ void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
 
 }
 
+//NTU: Method for updating points opacity and Radio
+
+//------------------------------------------------------------------------
+void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
+{
+       //Difference in Radio for text placement
+       int difradio = sdrRadio->GetValue() - this->mradio;
+       
+       this->mopacity = sdrOpacity->GetValue()/100.0;
+       this->mradio = sdrRadio->GetValue();
+       
+       //NTU refresh the inputs
+       mbbShowNPoints->bbSetInputOpacity(this->mopacity);
+       mbbShowNPoints->bbSetInputRadio(this->mradio);
+
+       int size = (int) this->lstActorsSphere.size();
+       int i;
+       for(i = 0; i < size; i ++)
+       {
+               this->lstSourceSphere[i]->SetRadius(mradio);
+               this->lstActorsSphere[i]->GetProperty()->SetOpacity(mopacity);
+               this->lstActorsText[i]->SetPosition(this->lstActorsText[i]->GetPosition()[0]+difradio,this->lstActorsText[i]->GetPosition()[1], this->lstActorsText[i]->GetPosition()[2]);
+       }
+
+       //NTU: For updating
+       SetOutputBox();
+}
+
 
 
 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints)
index d95977ea09ce092390e129f2afbe7ec97dc9a094..231e0905acb912179dfaef2810ba76548c8e4c04 100644 (file)
@@ -5,6 +5,7 @@
 
 
 #include "vtkActor.h"
+#include "vtkSphereSource.h"
 #include "vtkImageData.h"
 #include "vtkRenderer.h"
 #include "vtkTextActor3D.h"
@@ -26,7 +27,9 @@ namespace bbcreaMaracasVisu
          void OnEraseLastPoint(wxCommandEvent &event);   
          void OnDeleteAllPoints(wxCommandEvent &event);   
          void OnSavePoints(wxCommandEvent &event);   
-         void OnLoadPoints(wxCommandEvent &event);   
+         void OnLoadPoints(wxCommandEvent &event);
+
+         void UpdatePoints(wxCommandEvent &event);
          
          void SetPoint(std::vector<int> ppoint);
          void SetColour(std::vector<double> colour);
@@ -53,9 +56,13 @@ namespace bbcreaMaracasVisu
          std::vector<int>                              lstPointsY;
          std::vector<int>                              lstPointsZ;
          std::vector<std::string>              lstLabels;
-         std::vector<vtkProp3D*>               lstActorsSphere;
+         std::vector<vtkActor*>                lstActorsSphere;//NTU changed from prop3D to Actor
          std::vector<vtkTextActor3D*>  lstActorsText;
 
+         //NTU: For updating points
+
+         std::vector<vtkSphereSource*> lstSourceSphere;
+
          std::vector<int>                              mpoint;
          vtkImageData                                  *mimage;
          std::vector<double>                   mcolour;
@@ -63,6 +70,8 @@ namespace bbcreaMaracasVisu
          double                                                mradio;
          wxTextCtrl                                    *textCtrl;
          wxStaticText                                  *txtNrPoints;
+         wxSlider                                              *sdrOpacity;
+         wxSlider                                              *sdrRadio;
   };