]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuShowNPoints.h
Support #1768 CREATIS Licence insertion
[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
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 ShowNPoints;
42
43   //--------------------------------------------------------------------------
44   class WidgetShowNPoints : public wxPanel
45   {
46   public:
47           WidgetShowNPoints( wxWindow *parent,  ShowNPoints *box);
48           ~WidgetShowNPoints(); 
49           void OnAddPoint(wxCommandEvent &event);   
50           void OnSetPoint(wxCommandEvent& event);
51           void OnRenamePoint(wxCommandEvent& event);
52           void OnErasePoint(wxCommandEvent& event);
53           void OnEraseLastPoint(wxCommandEvent &event);   
54           void OnDeleteAllPoints(wxCommandEvent &event);   
55           void OnSavePoints(wxCommandEvent &event);   
56           void OnLoadPoints(wxCommandEvent &event);
57           void UpdatePoints(wxCommandEvent &event);
58           
59           void RefreshPoint(int id);
60           
61           void SetPoint(std::vector<int> ppoint);
62           void SetColour(std::vector<double> colour);
63           void SetOpacity(double opacity);
64           void SetRadio(double radio);
65           void SetImage(vtkImageData *image);
66           void SetRenderer(vtkRenderer *renderer);
67           std::vector<int> GetLstPointsX();
68           std::vector<int> GetLstPointsY();
69           std::vector<int> GetLstPointsZ();
70           std::vector<std::string> GetLstLabels();
71
72           void                  AddPoint(int x, int y, int z, std::string label);
73           
74   private:
75
76           std::string           CleanSpaces(std::string ss);
77           int                   GetNearestPoint();
78           int                                   IdInsidePoint();
79           void                  ErasePoint(int id);
80           void                  SetOutputBox();
81
82           ShowNPoints                   *mbbShowNPoints;
83           vtkRenderer                   *renderer;
84           std::vector<int>              lstPointsX;
85           std::vector<int>              lstPointsY;
86           std::vector<int>              lstPointsZ;
87           std::vector<std::string>      lstLabels;
88           std::vector<vtkActor*>        lstActorsSphere;//NTU changed from prop3D to Actor
89           std::vector<vtkTextActor3D*>  lstActorsText;
90
91           //NTU: For updating points
92
93           std::vector<vtkSphereSource*> lstSourceSphere;
94
95           std::vector<int>      mpoint;
96           vtkImageData          *mimage;
97           std::vector<double>   mcolour;
98           double                mopacity;
99           double                mradio;
100           wxStaticText          *askPointLabel;
101           wxTextCtrl            *textCtrl;
102           wxStaticText          *txtNrPoints;
103           wxSlider              *sdrOpacity;
104           wxSlider              *sdrRadio;
105   };
106
107 class /*BBTK_EXPORT*/ ShowNPoints
108  : 
109    public bbtk::WxBlackBox
110 {
111   BBTK_BLACK_BOX_INTERFACE(ShowNPoints,bbtk::WxBlackBox);
112   BBTK_DECLARE_INPUT(In, std::vector<int> );
113   BBTK_DECLARE_INPUT(Renderer, vtkRenderer* );
114   BBTK_DECLARE_INPUT(Image, vtkImageData* );
115   BBTK_DECLARE_INPUT(Colour, std::vector<double> );
116   BBTK_DECLARE_INPUT(Opacity, double );
117   BBTK_DECLARE_INPUT(Radio, double );
118   BBTK_DECLARE_INPUT(Type, int );
119   BBTK_DECLARE_OUTPUT( lstPointsX, std::vector<int> );
120   BBTK_DECLARE_OUTPUT( lstPointsY, std::vector<int> );
121   BBTK_DECLARE_OUTPUT( lstPointsZ, std::vector<int> );
122   BBTK_DECLARE_OUTPUT( lstLabels,  std::vector<std::string> );
123   BBTK_PROCESS(Process);
124   void Process();
125   BBTK_CREATE_WIDGET(CreateWidget);
126   void CreateWidget(wxWindow*);
127
128 private:
129         WidgetShowNPoints *mwxwidget; 
130 };
131
132 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox);
133   BBTK_NAME("ShowNPoints");
134   BBTK_AUTHOR("Eduardo DAVILA");
135   BBTK_DESCRIPTION("widget that shows N moints in 3D (vtkActors)");
136   BBTK_CATEGORY("widgetVtk");
137   BBTK_INPUT(ShowNPoints,In,"One Point",std::vector<int>,"");
138   BBTK_INPUT(ShowNPoints,Renderer,"Renderer",vtkRenderer*,"");
139   BBTK_INPUT(ShowNPoints,Image,"vktkImageData",vtkImageData*,"");
140   BBTK_INPUT(ShowNPoints,Colour,"Colour of the actor",std::vector<double>,"colour");
141   BBTK_INPUT(ShowNPoints,Opacity,"Opacity of the actor",double,"");
142   BBTK_INPUT(ShowNPoints,Radio,"Radio of the spheres",double,"");
143   BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point",int,"");
144   BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector<int> ,"");
145   BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<int> ,"");
146   BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector<int> ,"");
147   BBTK_OUTPUT(ShowNPoints , lstLabels , " list of labels ", std::vector<std::string> ,"");
148 BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints);
149 }
150 // EO namespace bbcreaMaracasVisu
151
152 #endif // __bbcreaMaracasVisuShowNPoints_h_INCLUDED__
153 #endif // _USE_WXWIDGETS_