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 #ifndef wx_Reading_Priority_Panel_H
27 #define wx_Reading_Priority_Panel_H
30 #include <wx/slider.h>
35 // #include "wxImageViewerWidget.h"
36 #include "InterfaceVtkPanelWidgets.h"
38 #include "marGdcmDicom.h"
39 #include "pPlotter/mBarRange.h"//SIL//
41 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
43 // ----------------------------------------------------------------------------
46 #define PriorityLoadImage_MAX_P 5
51 virtual ~PriorityLoop();
52 void SetStartEndActualMax(int start,int end, int actual,int deltaImg, int maxImages);
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() {};
82 int _i_forceReadReagion;
87 bool _dg[PriorityLoadImage_MAX_P]; // right - left
88 int _counterActual[PriorityLoadImage_MAX_P]; //
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();
100 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
102 // ----------------------------------------------------------------------------
104 class BarLoading :public wxPanel{
106 BarLoading(wxWindow *parent, int w, int h);
107 virtual ~BarLoading();
111 virtual void OnPaint( wxPaintEvent &WXUNUSED(event) );
112 void SetSizeData(int sizeData);
115 std::vector<int> lstInt;
122 DECLARE_CLASS(BarLoading)
123 // any class wishing to process wxWindows events must use this macro
124 DECLARE_EVENT_TABLE()
128 // ----------------------------------------------------------------------------
129 // ----------------------------------------------------------------------------
130 // ----------------------------------------------------------------------------
132 class BarRange :public wxPanel{
134 BarRange(wxWindow *parent, int w, int h);
136 void SetActual(int i);
137 void SetStart(int i);
140 void OnPaint( wxPaintEvent &WXUNUSED(event) );
152 DECLARE_CLASS(BarRange)
153 // any class wishing to process wxWindows events must use this macro
154 DECLARE_EVENT_TABLE()
159 // ----------------------------------------------------------------------------
160 // ----------------------------------------------------------------------------
161 // ----------------------------------------------------------------------------
163 class PriorityLoadImageBar : public PriorityLoop{
165 PriorityLoadImageBar(marFilesBase *marfilesbase, BarLoading *bar);
166 virtual ~PriorityLoadImageBar();
167 void Action_i(int i);
168 virtual void RefreshForce();
171 marFilesBase *_marfilesbase;
178 // ----------------------------------------------------------------------------
179 // ----------------------------------------------------------------------------
180 // ----------------------------------------------------------------------------
183 class PriorityBar : public PriorityLoop{
185 PriorityBar(BarLoading *bar);
187 void Action_i(int i);
188 virtual void RefreshForce();
194 // ----------------------------------------------------------------------------
195 // ----------------------------------------------------------------------------
196 // ----------------------------------------------------------------------------
198 WX_DEFINE_ARRAY(wxThread *, wxArrayThread);
200 class AdminThreadEED{
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
215 wxMutex m_mutexAllDone;
220 // ----------------------------------------------------------------------------
221 // ----------------------------------------------------------------------------
222 // ----------------------------------------------------------------------------
224 class MyThread : public wxThread{
226 MyThread(PriorityLoop *priorityLoop, AdminThreadEED *adminThreadEED);
227 virtual void* Entry();
228 virtual void OnExit();
230 PriorityLoop *_priorityLoop;
231 AdminThreadEED *_adminThreadEED;
235 // ----------------------------------------------------------------------------
236 // ----------------------------------------------------------------------------
237 // ----------------------------------------------------------------------------
239 class LoadRangeImage : public wxPanel, InterfaceVtkPanelWidgets{
241 LoadRangeImage(wxWindow *parent,marFilesBase *marfilesbase/*,wxImageViewerWidget *imageViewerWidget*/);
242 virtual ~LoadRangeImage();
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);
253 void SetActualSlice(int actual);
254 int GetActualSlice();
255 void ResetActualSlice();
257 virtual void CallBackOnMouseWheel( wxMouseEvent& event );
259 void ForceToFinisReadActiveImages();
260 void GetROI( int extent[6] );
261 void SetStartEnd( int start, int end );
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);
274 void OnTimer(wxTimerEvent& event);
279 bool reseteableActual;
282 marFilesBase *_marfilesbase;
284 // wxSlider *_sldStart;
285 // wxSlider *_sldEnd;
288 // wxSlider *_sldActual;
292 // BarRange *_barRange;
295 mBarRange *_sl_barRange_ROI;
296 PriorityLoadImageBar *_priorityLoadImageBar;
297 AdminThreadEED *_adminThreadEED;
300 wxFlexGridSizer *_sizer1a;
303 wxStaticText *_textActual;
305 // wxImageViewerWidget *_imageViewerWidget;
307 void ResetLoadRegion();
311 void SetStartSlice(int value);
312 void SetEndSlice(int value);
323 #endif // wx_Reading_Priority_Panel_H