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(" ")));
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);
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);
void WidgetShowNPoints::SetRadio(double radio)
{
- mradio=radio;
+ this->mradio=radio;
+ //NTU: For Slider
+ sdrRadio->SetValue(this->mradio);
}
//------------------------------------------------------------------------
void WidgetShowNPoints::SetOpacity(double opacity)
{
this->mopacity=opacity;
+ //NTU: For Slider
+ sdrOpacity->SetValue(this->mopacity*100.0);
}
//------------------------------------------------------------------------
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();
sphereActor->SetMapper(sphereMapper);
sphereActor->SetOrigin(0, 0, 0);
double spc[3];
+ if(mimage==NULL){
+ wxMessageDialog dialog(this, _T("Image Not Set"),_T("Image Not Set"),wxICON_ERROR);
+ dialog.ShowModal();
+ return;
+ }
mimage->GetSpacing(spc);
sphereActor->SetPosition( spc[0]*x , spc[1]*y , spc[2]*z );
sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
sphereActor->GetProperty()->SetOpacity( mopacity );
lstActorsSphere.push_back(sphereActor);
+ if(renderer==NULL){
+ wxMessageDialog dialog(this, _T("Renderer Not Set"),_T("Renderer Not Set"),wxICON_ERROR);
+ dialog.ShowModal();
+ return;
+ }
renderer->AddActor( sphereActor );
// Actor
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)
+ if(mimage ==NULL){
+ wxMessageDialog* diag = new wxMessageDialog(this, _T("Image not set"), _T("Image Not Set"), wxICON_ERROR);
+ diag->ShowModal();
+ return -1;
+ }else{
+
+ mimage->GetSpacing(spc);
+
+ for ( i=0 ; i<size; i++ )
{
- id=i;
- } // if
- } // for
+ 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
- return id;
+ return 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 );
lstPointsX.erase( lstPointsX.begin()+id );
lstPointsY.erase( lstPointsY.begin()+id );
}
+//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)
{
mwxwidget = NULL;
- bbSetInputRadio(0.5);
+ bbSetInputRadio(1);
bbSetInputOpacity(1);
std::vector<double> colour;