1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #ifdef _USE_WXWIDGETS_
27 #ifndef __bbcreaMaracasVisuShowNPoints_h_INCLUDED__
28 #define __bbcreaMaracasVisuShowNPoints_h_INCLUDED__
29 #include "bbtkWxBlackBox.h"
33 #include "vtkSphereSource.h"
34 #include "vtkImageData.h"
35 #include "vtkRenderer.h"
36 #include "vtkTextActor3D.h"
38 namespace bbcreaMaracasVisu
41 class 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();
59 int GetLstPointsSize();
60 void SetPointId_mReferencePoint(int id);
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);
70 int RenamePoint(std::string label);
71 void ErasePoint(int id);
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;
87 //--------------------------------------------------------------------------
88 class WidgetShowNPoints : public wxPanel
91 WidgetShowNPoints( wxWindow *parent, ShowNPoints *box);
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);
104 void RefreshPoint(int id);
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);
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
116 ModelShowNPoints* GetModelShowNPoints();
117 void RefreshPoints();
119 void SetInitLstPoints( std::vector<int> initLstPointsX, std::vector<int> initLstPointsY, std::vector<int> initLstPointsZ, std::vector<std::string> initLstLabels );
123 void ErasePoint(int id);
126 ShowNPoints *mbbShowNPoints;
127 vtkRenderer *renderer;
129 std::vector<vtkActor*> lstActorsSphere;//NTU changed from prop3D to Actor
130 std::vector<vtkTextActor3D*> lstActorsText;
132 //NTU: For updating points
134 std::vector<vtkSphereSource*> lstSourceSphere;
136 std::vector<double> mcolour;
138 wxStaticText *askPointLabel;
139 wxTextCtrl *textCtrl;
140 wxStaticText *txtNrPoints;
141 wxSlider *sdrOpacity;
144 ModelShowNPoints *mmodelShowNPoints;
148 class /*BBTK_EXPORT*/ ShowNPoints
150 public bbtk::WxBlackBox
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 );
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);
171 BBTK_CREATE_WIDGET(CreateWidget);
172 void CreateWidget(wxWindow*);
175 WidgetShowNPoints *mwxwidget;
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");
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,"");
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> ,"");
202 BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints);
204 // EO namespace bbcreaMaracasVisu
206 #endif // __bbcreaMaracasVisuShowNPoints_h_INCLUDED__
207 #endif // _USE_WXWIDGETS_