]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuShowNPoints.cxx
#3155 creaMaracasVisu Feature New Normal - ViewerPlane ComplexBox
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuShowNPoints.cxx
index ccd3092010052435c663fe7927bd6435bdb9a0cb..796b3c1091916502dd6eb9080968c478a2f21eb5 100644 (file)
+/*# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Sant�)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------ */
+
 #include "bbmaracasvisuShowNPoints.h"
 #include "bbcreaMaracasVisuPackage.h"
 
-#include "vtkProperty.h"
-#include "vtkSphereSource.h"
-#include "vtkPolyDataMapper.h"
-#include "vtkRenderWindow.h"
 
 namespace bbcreaMaracasVisu
 {
 
 
-//----------------------------------------------------------------------
-       WidgetShowNPoints::WidgetShowNPoints(wxWindow *parent, vtkRenderer *renderer, ShowNPoints *box)
-    : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
-  {
-    mbbShowNPoints                             = box;
-    this->renderer                             = renderer;
-       wxPanel *panel                          = this;
-    wxSizer *sizer                             = NULL;
-       
-
-       // 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"));
-
-
-       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(btnDeleteAllPoints->GetId()        , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnDeleteAllPoints);
-
-    sizer1->Add(btnAddPoint);
-    sizer1->Add(btnEraseLstPoint);
-    sizer1->Add(btnDeleteAllPoints);
-
-       sizer = sizer1;
-       panel   ->      SetSizer(sizer);
-    panel      ->      SetAutoLayout(true);
-    panel      ->      Layout();  
-       
-}
-
-
 //------------------------------------------------------------------------
-WidgetShowNPoints::~WidgetShowNPoints()
-{
-}
-
-void WidgetShowNPoints::SetRadio(double radio)
-{
-       mradio=radio;
-}
-
 //------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsX()
-{
-       return lstPointsX;
-}
-
 //------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsY()
+//------------------------------------------------------------------------
+WidgetShowNPointsBox::WidgetShowNPointsBox(wxWindow *parent,  bbcreaMaracasVisu::ShowNPoints *box, int type)
+    : WidgetShowNPoints( parent, type)
 {
-       return lstPointsY;
+       mbbShowNPoints=box;
 }
 
 //------------------------------------------------------------------------
-std::vector<int> WidgetShowNPoints::GetLstPointsZ()
+WidgetShowNPointsBox::~WidgetShowNPointsBox()
 {
-       return lstPointsZ;
 }
 
 
-
-
 //------------------------------------------------------------------------
-void WidgetShowNPoints::SetPoint(std::vector<int> ppoint)
+void WidgetShowNPointsBox::UpdatePoints(wxCommandEvent &event)
 {
-       mpoint = ppoint;
+       WidgetShowNPoints::UpdatePoints(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
+       mbbShowNPoints->bbSetInputOpacity( GetOpacity() );
+       mbbShowNPoints->bbSetInputRadio( GetRadio() );
+       // EED 
+//     RefreshPoints();
 }
 
-//------------------------------------------------------------------------
-void WidgetShowNPoints::SetColour(std::vector<double> colour)
-{
-       this->mcolour = colour;
-}
 
 //------------------------------------------------------------------------
-void WidgetShowNPoints::SetOpacity(double opacity)
+void WidgetShowNPointsBox::SetOutputBox()
 {
-       this->mopacity=opacity;
-}
+       WidgetShowNPoints::SetOutputBox();
 
-//------------------------------------------------------------------------
-void WidgetShowNPoints::SetImage(vtkImageData *image)
-{
-       this->mimage=image;
+//     wxString strTmp;
+//     strTmp.Printf(_T("Nbr of points: %d"), GetModelShowNPoints()->GetLstPointsSize() );
+//     txtNrPoints->SetLabel(  strTmp );
+
+       //--BBTK
+       mbbShowNPoints->bbSetOutputlstPointsX( GetModelShowNPoints()->GetLstPointsX() );
+       mbbShowNPoints->bbSetOutputlstPointsY( GetModelShowNPoints()->GetLstPointsY() );
+       mbbShowNPoints->bbSetOutputlstPointsZ( GetModelShowNPoints()->GetLstPointsZ() );
+       mbbShowNPoints->bbSetOutputlstLabels( GetModelShowNPoints()->GetLstLabels() );
+       mbbShowNPoints->bbSignalOutputModification();
 }
 
 
 
 //------------------------------------------------------------------------
-void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
-{
-//     printf("EED %p WidgetShowNPoints::OnAddPoint %d,%d,%d \n", this,mpoint[0],mpoint[1],mpoint[2] );
-
-       if (mpoint.size()==3){
-               lstPointsX.push_back( mpoint[0] );
-               lstPointsY.push_back( mpoint[1] );
-               lstPointsZ.push_back( mpoint[2] );
-
-               // Sphere
-               vtkSphereSource *vtksphere              = vtkSphereSource::New();
-               vtksphere->SetThetaResolution (20);
-               vtksphere->SetPhiResolution (20);
-               vtksphere->SetRadius( mradio  ); 
-               vtkPolyDataMapper *sphereMapper = vtkPolyDataMapper::New();
-               sphereMapper->SetInput( vtksphere->GetOutput() );
-               vtkActor *sphereActor   = vtkActor::New();
-               sphereActor->SetMapper(sphereMapper);
-               sphereActor->SetOrigin(0, 0, 0);
-               double spc[3];
-               mimage->GetSpacing(spc);
-               sphereActor->SetPosition( spc[0]*mpoint[0] , spc[1]*mpoint[1] , spc[2]*mpoint[2] );
-               sphereActor->GetProperty()->SetColor( mcolour[0] , mcolour[1] , mcolour[2] );
-               sphereActor->GetProperty()->SetOpacity( mopacity );
-
-               lstActors.push_back(sphereActor);
-               renderer->AddActor( sphereActor );
-
-               renderer->GetRenderWindow()->Render();
-
-               //--BBTK
-               mbbShowNPoints->bbSignalOutputModification(std::string("Point"));    
-
-       }
-}
-
 //------------------------------------------------------------------------
-void WidgetShowNPoints::OnErasePoint(wxCommandEvent& event)
-{
-       int id = lstActors.size()-1;
-       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
-               mbbShowNPoints->bbSignalOutputModification(std::string("Point"));    
-       }
-
-}
-
 //------------------------------------------------------------------------
-void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
-{
-       int i,size=lstActors.size();
-       for (i=0;i<size;i++)
-       {
-               renderer->RemoveActor( lstActors[i] );
-       }
-       lstActors.clear();
-       lstPointsX.clear();
-       lstPointsY.clear();
-       lstPointsZ.clear();
-       renderer->GetRenderWindow()->Render();
-       //--BBTK
-       mbbShowNPoints->bbSignalOutputModification(std::string("Point"));    
-}
-
+//------------------------------------------------------------------------
 
 
 
@@ -180,59 +94,70 @@ void WidgetShowNPoints::OnDeleteAllPoints(wxCommandEvent& event)
 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints)
 BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox);
 
+//-----------------------------------------------------------------
 void ShowNPoints::Process()
 {
-       if (mwxwidget!=NULL){
-               mwxwidget->SetPoint( bbGetInputIn() );   
-               mwxwidget->SetImage( bbGetInputImage() );   
-               mwxwidget->SetColour( bbGetInputColour() );   
-               mwxwidget->SetOpacity( bbGetInputOpacity() );   
-               mwxwidget->SetRadio( bbGetInputRadio() );   
-
-               bbSetOutputlstPointsX( mwxwidget->GetLstPointsX() );
-               bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
-               bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() );
+printf("EED ShowNPoints::Process Start\n");
+       if (mwxwidget!=NULL)
+       {
+               mwxwidget->SetRenderer( bbGetInputRenderer() );
+               mwxwidget->SetReferencePoint( bbGetInputIn() );
+               mwxwidget->SetImage( bbGetInputImage() );
+               mwxwidget->SetColour( bbGetInputColour() );
+               mwxwidget->SetOpacity( bbGetInputOpacity() );
+               mwxwidget->SetRadio( bbGetInputRadio() );
+
+               if ( mwxwidget->GetModelShowNPoints()->GetFirstTime()==true )
+               {
+printf("EED ShowNPoints::Process   firsttime\n");
+                       mwxwidget->GetModelShowNPoints()->SetFirstTime(false);
+                       mwxwidget->SetInitLstPoints( bbGetInputInitLstPointsX() , bbGetInputInitLstPointsY() , bbGetInputInitLstPointsZ() , bbGetInputInitLstLabels() );
+               }
+
+               bbSetOutputlstPointsX( mwxwidget->GetModelShowNPoints()->GetLstPointsX() );
+               bbSetOutputlstPointsY( mwxwidget->GetModelShowNPoints()->GetLstPointsY() );
+               bbSetOutputlstPointsZ( mwxwidget->GetModelShowNPoints()->GetLstPointsZ() );
+               bbSetOutputlstLabels( mwxwidget->GetModelShowNPoints()->GetLstLabels() );
+               bbSetOutputWidgetShowNPoints( (WidgetShowNPoints*)mwxwidget );
        } // mwxwidget
+printf("EED ShowNPoints::Process End\n");
 }
 
-
+//-----------------------------------------------------------------
 void ShowNPoints::CreateWidget(wxWindow* parent)
 {
-       mwxwidget = new WidgetShowNPoints( parent , bbGetInputRenderer(), this);
-       mwxwidget->SetPoint( bbGetInputIn() );
-
-       if (bbGetInputImage()==NULL)
-       {
-               printf("Missing Image  (ShowNPoints) \n");
-       }
-
-   bbSetOutputWidget( mwxwidget ); 
-   Process();  
+       mwxwidget = new WidgetShowNPointsBox( parent, this, bbGetInputType() );
+    bbSetOutputWidget( mwxwidget );
 }
 
-void ShowNPoints::bbUserConstructor()
+//-----------------------------------------------------------------
+void ShowNPoints::bbUserSetDefaultValues()
 {
        mwxwidget = NULL;
+       bbSetInputRadio(10);
+       bbSetInputOpacity(1);
        std::vector<double> colour;
        colour.push_back(1.0);
        colour.push_back(0.0);
        colour.push_back(0.0);
        bbSetInputColour(colour);
-       bbSetInputOpacity(1);
        bbSetInputImage(NULL);
-       bbSetInputRadio(0.5);
+       bbSetInputType(0);
+       bbSetInputRenderer(NULL);
+       bbSetOutputWidgetShowNPoints(NULL);
 }
 
+//-----------------------------------------------------------------
+       void ShowNPoints::bbUserInitializeProcessing()
+       {
+       }
 
-void ShowNPoints::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
-{
-}
+//-----------------------------------------------------------------
+       void ShowNPoints::bbUserFinalizeProcessing()
+       {
+       }
 
-void ShowNPoints::bbUserDestructor()
-{
-}
+//-----------------------------------------------------------------
 
 }
 // EO namespace bbcreaMaracasVisu
-
-