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