]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbmaracasvisuShowNPoints.cxx
2115 creaMaracasVisu Bug New Normal DrawAxisTree interaction with LineWidth
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuShowNPoints.cxx
index fd778dca7de22406fda0fdc829ff5681e93ea336..b33daa47a187c337002ca084e8fcf6f5cf680a34 100644 (file)
@@ -1,3 +1,28 @@
+/*# ---------------------------------------------------------------------
+#
+# 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"
 
@@ -6,6 +31,7 @@
 #include "vtkPolyDataMapper.h"
 #include "vtkRenderWindow.h"
 #include "vtkTextActor3D.h"
+#include <vtkTextProperty.h>
 
 namespace bbcreaMaracasVisu
 {
@@ -79,7 +105,7 @@ namespace bbcreaMaracasVisu
                  // Widget interface
                  wxButton *btnSetPositionPoint         = new wxButton( panel, -1, _T("Set nearest point"));
                  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);
@@ -89,7 +115,7 @@ namespace bbcreaMaracasVisu
                  Connect(btnSetPositionPoint->GetId()  , wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &WidgetShowNPoints::OnSetPoint);
                  Connect(sdrOpacity->GetId()   , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
                  Connect(sdrRadio->GetId()     , wxEVT_COMMAND_SLIDER_UPDATED  , (wxObjectEventFunction) &WidgetShowNPoints::UpdatePoints);
-                 
+
                  sizer1->Add(btnSetPositionPoint);
                  sizer1->Add(txtNrPoints);
                  sizer1->Add(txOpacity);
@@ -98,7 +124,33 @@ namespace bbcreaMaracasVisu
                  sizer1->Add(sdrRadio,1,wxGROW );
                  sizer = sizer1;
          }
-                 
+    
+        if (mbbShowNPoints->bbGetInputType() == 2) {
+            askPointLabel = new wxStaticText(panel, -1, _T("\nPOINT CONTROLS:")); // JPR
+            
+            wxButton *btnAddPoint = new wxButton(panel, -1,        _T("      Add  Point      "));
+            wxButton *btnDeleteAllPoints = new wxButton(panel, -1, _T("      Delete All      "));
+            wxStaticText* spacer = new wxStaticText(panel, -1, _T("\n")); // JPR
+            textCtrl = new wxTextCtrl(panel, -1);
+            
+            wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
+
+            Connect(btnAddPoint->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnAddPoint);
+            Connect(btnDeleteAllPoints->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) & WidgetShowNPoints::OnDeleteAllPoints);
+            
+            sizer1->Add(askPointLabel); 
+            sizer1->Add(btnAddPoint);
+            sizer1->Add(btnDeleteAllPoints);
+            sizer1->Add(spacer);
+            sizer1->Add(textCtrl);
+            
+            sdrOpacity = new wxSlider();
+            sdrRadio = new wxSlider();
+            
+            txtNrPoints = new wxStaticText(panel, -1, _T("\n\n\n"));  
+            
+            sizer = sizer1;
+        } 
          if (sizer!=NULL)
          {
                  panel->SetSizer(sizer);
@@ -112,6 +164,7 @@ WidgetShowNPoints::~WidgetShowNPoints()
 {
 }
 
+//------------------------------------------------------------------------
 void WidgetShowNPoints::SetRadio(double radio)
 {
        this->mradio=radio;
@@ -160,7 +213,7 @@ void WidgetShowNPoints::SetOpacity(double opacity)
 {
        this->mopacity=opacity;
        //NTU: For Slider
-       sdrOpacity->SetValue(this->mopacity/100.0);
+       sdrOpacity->SetValue(this->mopacity*100.0);
 }
 
 //------------------------------------------------------------------------
@@ -233,8 +286,7 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        vtkActor *sphereActor   = vtkActor::New();
        sphereActor->SetMapper(sphereMapper);
        sphereActor->SetOrigin(0, 0, 0);
-       
-       
+
 /*EED Borrame
        double spc[3];
        if(mimage==NULL){
@@ -247,7 +299,7 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        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);
@@ -266,7 +318,6 @@ void WidgetShowNPoints::AddPoint(int x, int y, int z, std::string label)
        lstActorsText.push_back(textActor);
 
        RefreshPoint(lstPointsX.size()-1);
-       SetOutputBox();
 }
 
 //------------------------------------------------------------------------
@@ -281,6 +332,7 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
        if (this->renderer!=NULL){
                if (mpoint.size()==3){
                        AddPoint(mpoint[0],mpoint[1],mpoint[2], (const char*) ( textCtrl->GetValue().mb_str() ) );
+                       SetOutputBox();
                } else {//mpoint.size
                        printf("creaMaracasVisu::ShowNPoints (not match point) \n");
                }
@@ -319,7 +371,8 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                //EED
 
                int result_FD = FD->ShowModal();
-
+               std::string tmpLabel;
+               
                // This line is need it by windows //EED
                FD->SetReturnCode( result_FD );
 
@@ -341,7 +394,13 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                        y=lstPointsY[i];
                                        z=lstPointsZ[i];
                                        value= mimage->GetScalarComponentAsDouble(x,y,z,0);
-                                       fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value  , lstLabels[i].c_str());
+                                       if (lstLabels[i]!="") 
+                                       {
+                                               tmpLabel=lstLabels[i];
+                                       } else{
+                                           tmpLabel="<_VOID_>";
+                                       }
+                                       fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value  , tmpLabel.c_str());
                                } // for
                                fclose(ff);
                        } else {   // else ff
@@ -384,8 +443,10 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                                for (i=0; i<size; i++)
                                {
                                        fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp );  // x,y,z,value,label
+                                       if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
                                        AddPoint(x,y,z, chartmp );
                                }
+                               SetOutputBox();
                                fclose(ff);
                        } else {   // else ff
                                printf("WidgetShowNPoints::OnLoadPoints  ...Error... reading file");
@@ -435,6 +496,7 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                {
                        id=0;
                        AddPoint(0,0,0,"");
+                       SetOutputBox();
                }
                
                
@@ -485,7 +547,6 @@ void WidgetShowNPoints::OnAddPoint (wxCommandEvent& event)
                }
        }
 
-       
 //------------------------------------------------------------------------
        void WidgetShowNPoints::OnRenamePoint(wxCommandEvent& event)
        {
@@ -567,16 +628,20 @@ void WidgetShowNPoints::UpdatePoints(wxCommandEvent &event)
        {
                this->lstSourceSphere[i]->SetRadius(mradio);
                this->lstActorsSphere[i]->GetProperty()->SetOpacity(mopacity);
+               this->lstActorsText[i]->GetTextProperty()->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();
+//EED  SetOutputBox();
+        renderer->GetRenderWindow()->Render();
+
 }
 
 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ShowNPoints)
 BBTK_BLACK_BOX_IMPLEMENTATION(ShowNPoints,bbtk::WxBlackBox);
 
+//-----------------------------------------------------------------
 void ShowNPoints::Process()
 {
        if (mwxwidget!=NULL)
@@ -592,20 +657,23 @@ void ShowNPoints::Process()
                bbSetOutputlstPointsY( mwxwidget->GetLstPointsY() );
                bbSetOutputlstPointsZ( mwxwidget->GetLstPointsZ() );
                bbSetOutputlstLabels( mwxwidget->GetLstLabels() );
+
        } // mwxwidget
 }
 
+//-----------------------------------------------------------------
 void ShowNPoints::CreateWidget(wxWindow* parent)
 {
        mwxwidget = new WidgetShowNPoints( parent, this);
-       bbSetOutputWidget( mwxwidget );
+    bbSetOutputWidget( mwxwidget );
 }
 
+//-----------------------------------------------------------------
 void ShowNPoints::bbUserSetDefaultValues()
 {
-       mwxwidget       = NULL;
+       mwxwidget = NULL;
 
-       bbSetInputRadio(1);
+       bbSetInputRadio(10);
        bbSetInputOpacity(1);
 
        std::vector<double> colour;