]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/include/wxReadingPriorityPanel.h
f429be0bb0fa81c4abc9023d88d937f492f900f2
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / include / wxReadingPriorityPanel.h
1
2 #ifndef wx_Reading_Priority_Panel_H
3 #define wx_Reading_Priority_Panel_H
4
5 #include <wx/wx.h>
6 #include <wx/slider.h>
7 #include <wx/panel.h>
8
9
10 //EED 15Avril2008 
11 //  #include "wxImageViewerWidget.h"
12 #include "InterfaceVtkPanelWidgets.h"
13
14 #include "marGdcmDicom.h"
15 #include "pPlotter/mBarRange.h"//SIL//
16
17 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
20
21
22 #define PriorityLoadImage_MAX_P 5
23
24 class PriorityLoop  {
25         public:
26                 PriorityLoop();
27                 virtual ~PriorityLoop();
28                                 void    SetStartEndActualMax(int start,int end, int actual,int deltaImg, int maxImages);
29                                 void    Iteration();
30                                 void    InitLoop();
31
32                                 void    StopLoop();
33                                 bool    IsLoop();
34                                 void    WaitUntil_i_isDone(int i);
35                                 void    WaitUntil_segment_isDone(int start, int end,bool forceEndLoopRegion=true);
36                                 void    ForceEndLoopRegion();
37                 virtual void    Action_i( int i );
38                 virtual void    RefreshForce() {}; 
39
40         private:
41
42
43                 int             _start;
44                 int             _end;
45                 int             _actual;
46                 int             _deltaImg;
47                 int             _maxImages;
48                 int             _tstart;
49                 int             _tend;
50                 int             _tactual;
51                 int             _tdeltaImg;
52                 int             _tmaxImages;
53
54                 int             _counterReading;
55                 int             _max_p;
56                 bool    _loadingSerie;
57                 int     _forceReadRegion;
58                 int             _i_forceReadReagion;
59                 bool    _needToChange;
60
61                 int             _priority;
62                 int             _priorityType;
63                 bool    _dg[PriorityLoadImage_MAX_P];                 // right - left
64                 int             _counterActual[PriorityLoadImage_MAX_P];      // 
65                 bool    *_vecIdImage;
66
67                 int             Get_i_image();
68                 int             Geti(int id,int step,int start,int actualg,int actuald,int end);
69                 bool    _Action_i( int i );
70                 void    Create_Empty_Vector();
71                 void    InitConfiguration();
72                 bool    _ForceEndLoopRegion();
73                 void    NeedToChange();
74 };
75
76 // ----------------------------------------------------------------------------
77 // ----------------------------------------------------------------------------
78 // ----------------------------------------------------------------------------
79
80 class BarLoading :public  wxPanel{
81 public:
82         BarLoading(wxWindow *parent, int w, int h);
83         virtual ~BarLoading();
84         void SetI(int i);
85         void Reset();
86         void Paint();
87         virtual void OnPaint( wxPaintEvent &WXUNUSED(event) );
88         void SetSizeData(int sizeData);
89         void RefreshForce();
90 private:
91         std::vector<int>    lstInt;
92         int                     _w;
93         int                     _h;
94         int                     _sizeData;
95         wxBitmap        *_bitmap;
96         bool            _flag_bitmap;
97         bool            _flag2_bitmap;
98         DECLARE_CLASS(BarLoading)
99     // any class wishing to process wxWindows events must use this macro
100     DECLARE_EVENT_TABLE()
101 };
102
103
104 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
107 /*  EED Borrame
108 class BarRange :public  wxPanel{
109 public:
110         BarRange(wxWindow *parent, int w, int h);
111         ~BarRange();
112         void SetActual(int i);
113         void SetStart(int i);
114         void SetEnd(int i);
115         void SetMax(int i);
116         void OnPaint( wxPaintEvent &WXUNUSED(event) );
117         void RefreshView();
118         void RefreshForce();
119
120 private:
121         int                     _w;
122         int                     _h;
123         int                     _actual;
124         int                     _start;
125         int                     _end;
126         int                     _max;
127         wxBitmap        *_bitmap;
128         DECLARE_CLASS(BarRange)
129     // any class wishing to process wxWindows events must use this macro
130     DECLARE_EVENT_TABLE()
131 };
132 */
133
134
135 // ----------------------------------------------------------------------------
136 // ----------------------------------------------------------------------------
137 // ----------------------------------------------------------------------------
138
139 class PriorityLoadImageBar : public PriorityLoop{
140 public:
141         PriorityLoadImageBar(marFilesBase *marfilesbase, BarLoading *bar);
142         virtual ~PriorityLoadImageBar();
143         void Action_i(int i);
144         virtual void RefreshForce();
145
146 private:
147         marFilesBase    *_marfilesbase;
148         BarLoading              *_bar;
149 };
150
151
152
153
154 // ----------------------------------------------------------------------------
155 // ----------------------------------------------------------------------------
156 // ----------------------------------------------------------------------------
157 /*
158
159 class PriorityBar : public PriorityLoop{
160 public:
161         PriorityBar(BarLoading *bar);
162         ~PriorityBar();
163         void Action_i(int i);
164         virtual void RefreshForce();
165
166 private:
167         BarLoading *_bar;
168 };
169 */
170 // ----------------------------------------------------------------------------
171 // ----------------------------------------------------------------------------
172 // ----------------------------------------------------------------------------
173
174 WX_DEFINE_ARRAY(wxThread *, wxArrayThread);
175
176 class AdminThreadEED{
177 public:
178         AdminThreadEED();
179         ~AdminThreadEED();
180
181         wxCriticalSection m_critsect;
182     // all the threads currently alive - as soon as the thread terminates, it's
183     // removed from the array
184     wxArrayThread m_threads;
185     // the last exiting thread should signal m_condAllDone if this is true
186     // (protected by the same m_critsect)
187     bool m_waitingUntilAllDone;
188     wxCondition m_condAllDone;
189     // the (mutex, condition) pair used to wait for the threads to exit, see
190     // MyFrame::OnQuit()
191     wxMutex m_mutexAllDone;
192
193 private:
194 };
195
196 // ----------------------------------------------------------------------------
197 // ----------------------------------------------------------------------------
198 // ----------------------------------------------------------------------------
199
200 class MyThread : public wxThread{
201 public:
202         MyThread(PriorityLoop *priorityLoop, AdminThreadEED *adminThreadEED);
203     virtual void* Entry();
204         virtual void  OnExit();
205 private:
206         PriorityLoop *_priorityLoop;
207         AdminThreadEED *_adminThreadEED;
208 };
209
210
211 // ----------------------------------------------------------------------------
212 // ----------------------------------------------------------------------------
213 // ----------------------------------------------------------------------------
214
215 class LoadRangeImage : public wxPanel, InterfaceVtkPanelWidgets{
216 public:
217         LoadRangeImage(wxWindow *parent,marFilesBase *marfilesbase/*,wxImageViewerWidget *imageViewerWidget*/);
218         virtual ~LoadRangeImage();
219 // EED Borrame
220 //      void OnSliceStart(wxScrollEvent& event);
221 //      void OnSliceEnd(wxScrollEvent& event);
222         void OnSliceActual(wxScrollEvent& event);
223         void OnBtnStart(wxCommandEvent& event);
224         void OnBtnEnd(wxCommandEvent& event);
225 //      void OnBtnResetRoi(wxCommandEvent& event);
226         void Reset();
227
228         void RefreshSlice();
229         void SetActualSlice(int actual);
230         int  GetActualSlice();
231         void ResetActualSlice();
232
233         virtual void CallBackOnMouseWheel( wxMouseEvent& event );
234         void Start();
235         void ForceToFinisReadActiveImages();
236         void GetROI( int extent[6] );
237         void SetStartEnd( int start, int end );
238
239         //SIL//
240         // --------------------------------------
241         // Events captured form the barrange used configuring the ROI
242         // --------------------------------------
243         void  OnBarrange(wxCommandEvent& event);
244         void  OnActualChange_BarRange(wxCommandEvent& event);
245         void  OnStartChange_BarRange(wxCommandEvent& event);
246         void  OnEndChange_BarRange(wxCommandEvent& event);
247         void  OnBarMoved_BarRange(wxCommandEvent& event);
248         void  OnSelectionEnd_BarRange(wxCommandEvent& event);
249
250         void OnTimer(wxTimerEvent& event);
251
252 private:
253
254         wxTimer                         *_timer;
255         bool                            reseteableActual;
256         int                             _toShowSlice;
257         int                             _maxZ;
258         marFilesBase                    *_marfilesbase;
259 // EED Borrame
260 //      wxSlider                                *_sldStart;
261 //      wxSlider                                *_sldEnd;
262         int                                             _startSlice;
263         int                                             _endSlice;
264 //      wxSlider                                *_sldActual;
265         BarLoading                              *_bar;
266
267 // EED Borrame
268 //      BarRange                                *_barRange;
269
270         //SIL//
271         mBarRange                               *_sl_barRange_ROI;
272         PriorityLoadImageBar    *_priorityLoadImageBar;
273         AdminThreadEED                  *_adminThreadEED;
274         MyThread                                *_mythread;
275
276         wxFlexGridSizer                 *_sizer1a;
277         wxButton                                *_btnStart;
278         wxButton                                *_btnEnd;
279         wxStaticText                    *_textActual; 
280
281 //      wxImageViewerWidget             *_imageViewerWidget;
282
283         void    ResetLoadRegion();
284         void    _Start();
285         void    _Stop();
286
287         void    SetStartSlice(int value);
288         void    SetEndSlice(int value);
289
290
291 };
292
293
294
295
296
297
298
299 #endif // wx_Reading_Priority_Panel_H