]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuShowNPoints.h
#2982 creaMaracasVisu Feature New Normal - ShowNPoints_model
[creaMaracasVisu.git] / bbtk / src / bbmaracasvisuShowNPoints.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #ifdef _USE_WXWIDGETS_
27 #ifndef __bbcreaMaracasVisuShowNPoints_h_INCLUDED__
28 #define __bbcreaMaracasVisuShowNPoints_h_INCLUDED__
29 #include "bbtkWxBlackBox.h"
30 #include <cmath>
31
32 #include "vtkActor.h"
33 #include "vtkSphereSource.h"
34 #include "vtkImageData.h"
35 #include "vtkRenderer.h"
36 #include "vtkTextActor3D.h"
37
38 namespace bbcreaMaracasVisu
39 {
40
41   class ModelShowNPoints
42   {
43         public:
44           ModelShowNPoints();
45           ~ModelShowNPoints(); 
46           std::vector<int>                      GetLstPointsX();
47           std::vector<int>                      GetLstPointsY();
48           std::vector<int>                      GetLstPointsZ();
49           void                                          GetIdPoint(int id, int *x, int *y, int *z);
50           std::string                           GetIdLabel(int id);
51           std::vector<std::string>      GetLstLabels();
52           void                                          AddPoint(int x, int y, int z, std::string label);
53           double                                        Distance(double dX0, double dY0, double dZ0, double dX1, double dY1, double dZ1);
54           int                                           InsertPoint(int x, int y, int z, std::string label);
55           void                                          SavePoints(std::string filename);
56           int                                           ReadPoints(std::string filename);
57           int                                           GetNearestPoint();
58
59           int                                           GetLstPointsSize();
60           void                                          SetPointId_mReferencePoint(int id);
61           int                                           IdInsidePoint();
62
63           void                                          SetReferencePoint(std::vector<int> ppoint);
64           std::vector<int>                      GetReferencePoint();
65           void                                          SetImage(vtkImageData *image);
66           std::string                           CleanSpaces(std::string ss);
67           vtkImageData*                         GetImage();
68           void                                          SetRadio(double radio);
69           double                                        GetRadio();
70           int                                           RenamePoint(std::string label);
71           void                                          ErasePoint(int id);
72
73         private:
74           std::vector<int>              lstPointsX;
75           std::vector<int>              lstPointsY;
76           std::vector<int>              lstPointsZ;
77           std::vector<std::string>      lstLabels;
78           std::vector<int>                      mReferencePoint;
79           double                                mradio;
80           vtkImageData                          *mimage;
81
82   };
83
84
85   class ShowNPoints;
86
87   //--------------------------------------------------------------------------
88   class WidgetShowNPoints : public wxPanel
89   {
90   public:
91           WidgetShowNPoints( wxWindow *parent,  ShowNPoints *box);
92           ~WidgetShowNPoints(); 
93           void OnAddPoint(wxCommandEvent &event);   
94           void OnInsertPoint (wxCommandEvent& event);//CFT
95           void OnSetPoint(wxCommandEvent& event);
96           void OnRenamePoint(wxCommandEvent& event);
97           void OnErasePoint(wxCommandEvent& event);
98           void OnEraseLastPoint(wxCommandEvent &event);   
99           void OnDeleteAllPoints(wxCommandEvent &event);   
100           void OnSavePoints(wxCommandEvent &event);   
101           void OnLoadPoints(wxCommandEvent &event);
102           void UpdatePoints(wxCommandEvent &event);
103           
104           void RefreshPoint(int id);
105           
106           void SetColour(std::vector<double> colour);
107           void SetOpacity(double opacity);
108           void SetRadio(double radio);
109           void SetImage(vtkImageData *image);
110           void SetRenderer(vtkRenderer *renderer);
111           void SetReferencePoint(std::vector<int> point);
112
113           void AddPoint(int x, int y, int z, std::string label);
114           void InsertPoint(int x, int y, int z, std::string label);//CFT
115
116           ModelShowNPoints* GetModelShowNPoints();
117           void RefreshPoints();
118           void AddVtkPoint();
119           void SetInitLstPoints( std::vector<int> initLstPointsX,  std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels );
120
121
122   private:
123           void                                  ErasePoint(int id);
124           void                                  SetOutputBox();
125
126           ShowNPoints                   *mbbShowNPoints;
127           vtkRenderer                   *renderer;
128
129           std::vector<vtkActor*>        lstActorsSphere;//NTU changed from prop3D to Actor
130           std::vector<vtkTextActor3D*>  lstActorsText;
131
132           //NTU: For updating points
133
134           std::vector<vtkSphereSource*> lstSourceSphere;
135
136           std::vector<double>                   mcolour;
137           double                                mopacity;
138           wxStaticText                          *askPointLabel;
139           wxTextCtrl                            *textCtrl;
140           wxStaticText                          *txtNrPoints;
141           wxSlider                              *sdrOpacity;
142           wxSlider                              *sdrRadio;
143
144           ModelShowNPoints                              *mmodelShowNPoints;
145                 
146   };
147
148 class /*BBTK_EXPORT*/ ShowNPoints
149  : 
150    public bbtk::WxBlackBox
151 {
152   BBTK_BLACK_BOX_INTERFACE(ShowNPoints,bbtk::WxBlackBox);
153   BBTK_DECLARE_INPUT(In, std::vector<int> );
154   BBTK_DECLARE_INPUT(Renderer, vtkRenderer* );
155   BBTK_DECLARE_INPUT(Image, vtkImageData* );
156   BBTK_DECLARE_INPUT(Colour, std::vector<double> );
157   BBTK_DECLARE_INPUT(Opacity, double );
158   BBTK_DECLARE_INPUT(Radio, double );
159   BBTK_DECLARE_INPUT(InitLstPointsX, std::vector<int> );
160   BBTK_DECLARE_INPUT(InitLstPointsY, std::vector<int> );
161   BBTK_DECLARE_INPUT(InitLstPointsZ, std::vector<int> );
162   BBTK_DECLARE_INPUT(InitLstLabels, std::vector<std::string> );
163   BBTK_DECLARE_INPUT(Type, int );
164
165   BBTK_DECLARE_OUTPUT( lstPointsX, std::vector<int> );
166   BBTK_DECLARE_OUTPUT( lstPointsY, std::vector<int> );
167   BBTK_DECLARE_OUTPUT( lstPointsZ, std::vector<int> );
168   BBTK_DECLARE_OUTPUT( lstLabels,  std::vector<std::string> );
169   BBTK_PROCESS(Process);
170   void Process();
171   BBTK_CREATE_WIDGET(CreateWidget);
172   void CreateWidget(wxWindow*);
173
174 private:
175         WidgetShowNPoints *mwxwidget; 
176         bool firsttime;
177 };
178
179 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox);
180   BBTK_NAME("ShowNPoints");
181   BBTK_AUTHOR("Eduardo DAVILA");
182   BBTK_DESCRIPTION("widget that shows N moints in 3D (vtkActors)");
183   BBTK_CATEGORY("widgetVtk");
184
185   BBTK_INPUT(ShowNPoints,In,"One Point",std::vector<int>,"");
186   BBTK_INPUT(ShowNPoints,Renderer,"Renderer",vtkRenderer*,"");
187   BBTK_INPUT(ShowNPoints,Image,"vktkImageData",vtkImageData*,"");
188   BBTK_INPUT(ShowNPoints,Colour,"Colour of the actor",std::vector<double>,"colour");
189   BBTK_INPUT(ShowNPoints,Opacity,"Opacity of the actor 0..1 (default 1)",double,"");
190   BBTK_INPUT(ShowNPoints,Radio,"Radio of the spheres 1..50 (default 10)",double,"");
191   BBTK_INPUT(ShowNPoints,InitLstPointsX,"Initial lst of points X",std::vector<int>,"");
192   BBTK_INPUT(ShowNPoints,InitLstPointsY,"Initial lst of points Y",std::vector<int>,"");
193   BBTK_INPUT(ShowNPoints,InitLstPointsZ,"Initial lst of points Z",std::vector<int>,"");
194   BBTK_INPUT(ShowNPoints,InitLstLabels,"Initial lst of labels",std::vector<std::string>,"");
195   BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point",int,"");
196
197   BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector<int> ,"");
198   BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<int> ,"");
199   BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector<int> ,"");
200   BBTK_OUTPUT(ShowNPoints , lstLabels , " list of labels ", std::vector<std::string> ,"");
201
202 BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints);
203 }
204 // EO namespace bbcreaMaracasVisu
205
206 #endif // __bbcreaMaracasVisuShowNPoints_h_INCLUDED__
207 #endif // _USE_WXWIDGETS_