]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbmaracasvisuShowNPoints.h
Comments
[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
75   private:
76
77           std::string           CleanSpaces(std::string ss);
78           int                   GetNearestPoint();
79           int                                   IdInsidePoint();
80           void                  ErasePoint(int id);
81           void                  SetOutputBox();
82
83           ShowNPoints                   *mbbShowNPoints;
84           vtkRenderer                   *renderer;
85           std::vector<int>              lstPointsX;
86           std::vector<int>              lstPointsY;
87           std::vector<int>              lstPointsZ;
88           std::vector<std::string>      lstLabels;
89           std::vector<vtkActor*>        lstActorsSphere;//NTU changed from prop3D to Actor
90           std::vector<vtkTextActor3D*>  lstActorsText;
91
92           //NTU: For updating points
93
94           std::vector<vtkSphereSource*> lstSourceSphere;
95
96           std::vector<int>      mpoint;
97           vtkImageData          *mimage;
98           std::vector<double>   mcolour;
99           double                mopacity;
100           double                mradio;
101           wxStaticText          *askPointLabel;
102           wxTextCtrl            *textCtrl;
103           wxStaticText          *txtNrPoints;
104           wxSlider              *sdrOpacity;
105           wxSlider              *sdrRadio;
106
107   };
108
109 class /*BBTK_EXPORT*/ ShowNPoints
110  : 
111    public bbtk::WxBlackBox
112 {
113   BBTK_BLACK_BOX_INTERFACE(ShowNPoints,bbtk::WxBlackBox);
114   BBTK_DECLARE_INPUT(In, std::vector<int> );
115   BBTK_DECLARE_INPUT(Renderer, vtkRenderer* );
116   BBTK_DECLARE_INPUT(Image, vtkImageData* );
117   BBTK_DECLARE_INPUT(Colour, std::vector<double> );
118   BBTK_DECLARE_INPUT(Opacity, double );
119   BBTK_DECLARE_INPUT(Radio, double );
120   BBTK_DECLARE_INPUT(Type, int );
121   BBTK_DECLARE_OUTPUT( lstPointsX, std::vector<int> );
122   BBTK_DECLARE_OUTPUT( lstPointsY, std::vector<int> );
123   BBTK_DECLARE_OUTPUT( lstPointsZ, std::vector<int> );
124   BBTK_DECLARE_OUTPUT( lstLabels,  std::vector<std::string> );
125   BBTK_PROCESS(Process);
126   void Process();
127   BBTK_CREATE_WIDGET(CreateWidget);
128   void CreateWidget(wxWindow*);
129
130 private:
131         WidgetShowNPoints *mwxwidget; 
132 };
133
134 BBTK_BEGIN_DESCRIBE_BLACK_BOX(ShowNPoints,bbtk::WxBlackBox);
135   BBTK_NAME("ShowNPoints");
136   BBTK_AUTHOR("Eduardo DAVILA");
137   BBTK_DESCRIPTION("widget that shows N moints in 3D (vtkActors)");
138   BBTK_CATEGORY("widgetVtk");
139   BBTK_INPUT(ShowNPoints,In,"One Point",std::vector<int>,"");
140   BBTK_INPUT(ShowNPoints,Renderer,"Renderer",vtkRenderer*,"");
141   BBTK_INPUT(ShowNPoints,Image,"vktkImageData",vtkImageData*,"");
142   BBTK_INPUT(ShowNPoints,Colour,"Colour of the actor",std::vector<double>,"colour");
143   BBTK_INPUT(ShowNPoints,Opacity,"Opacity of the actor 0..1 (default 1)",double,"");
144   BBTK_INPUT(ShowNPoints,Radio,"Radio of the spheres 1..50 (default 10)",double,"");
145   BBTK_INPUT(ShowNPoints,Type,"Type of the widget. 0(default): N-points, 1:Just one point",int,"");
146   BBTK_OUTPUT(ShowNPoints , lstPointsX , " list of points X ", std::vector<int> ,"");
147   BBTK_OUTPUT(ShowNPoints , lstPointsY , " list of points Y ", std::vector<int> ,"");
148   BBTK_OUTPUT(ShowNPoints , lstPointsZ , " list of points Z ", std::vector<int> ,"");
149   BBTK_OUTPUT(ShowNPoints , lstLabels , " list of labels ", std::vector<std::string> ,"");
150 BBTK_END_DESCRIBE_BLACK_BOX(ShowNPoints);
151 }
152 // EO namespace bbcreaMaracasVisu
153
154 #endif // __bbcreaMaracasVisuShowNPoints_h_INCLUDED__
155 #endif // _USE_WXWIDGETS_