1 /////////////////////////////////////////////////////////////////////////////
2 // Name: Test_ReadingPriorityFrm.cpp
10 /////////////////////////////////////////////////////////////////////////////
12 // ----------------------------------------------------------------------------
14 // ----------------------------------------------------------------------------
15 #include "wx/wxprec.h"
16 #include <wx/thread.h>
23 #include "wxReadingPriorityPanel.h"
26 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
28 // ----------------------------------------------------------------------------
29 PriorityLoop::PriorityLoop(){
31 _loadingSerie = false;
32 _forceReadRegion = false;
33 _i_forceReadReagion = -1;
34 _needToChange = false;
37 // ----------------------------------------------------------------------------
38 PriorityLoop::~PriorityLoop(){
39 if (_vecIdImage!=NULL) {
43 // ----------------------------------------------------------------------------
44 void PriorityLoop::StopLoop(){
45 _loadingSerie = false;
47 // ----------------------------------------------------------------------------
48 bool PriorityLoop::IsLoop(){
51 // ----------------------------------------------------------------------------
52 void PriorityLoop::ForceEndLoopRegion(){
53 _forceReadRegion=true;
56 // ----------------------------------------------------------------------------
57 void PriorityLoop::InitLoop(){
60 Create_Empty_Vector();
65 // ----------------------------------------------------------------------------
66 void PriorityLoop::Iteration(){
70 if (_forceReadRegion==false){
71 int ii,i=Get_i_image();
72 for (ii=i-_deltaImg;ii<=i+_deltaImg;ii++){
73 if (_Action_i( ii )==true){
78 _loadingSerie=_ForceEndLoopRegion();
81 if (_counterReading==_maxImages){
87 // ----------------------------------------------------------------------------
88 bool PriorityLoop::_ForceEndLoopRegion (){
90 if (_i_forceReadReagion==-1){
91 _i_forceReadReagion=_start;
93 _Action_i( _i_forceReadReagion );
94 _i_forceReadReagion++;
95 if (_i_forceReadReagion>_end){
100 // ----------------------------------------------------------------------------
101 void PriorityLoop::Create_Empty_Vector(){
102 if (_vecIdImage!=NULL) {
105 _vecIdImage = (bool*)malloc(sizeof(bool)*(_maxImages+1) );
107 for (i=0; i<=_maxImages;i++){
108 _vecIdImage[i]=false;
113 // ----------------------------------------------------------------------------
114 void PriorityLoop::SetStartEndActualMax(int start,int end, int actual, int deltaImg,int maxImages){
118 _tdeltaImg = deltaImg;
119 _tmaxImages = maxImages;
120 _needToChange = true;
122 // ----------------------------------------------------------------------------
123 void PriorityLoop::NeedToChange(){
124 if (_needToChange==true){
125 _needToChange = false;
129 _deltaImg = _tdeltaImg;
130 _maxImages = _tmaxImages;
135 // ----------------------------------------------------------------------------
136 void PriorityLoop::InitConfiguration(){
137 _forceReadRegion=false;
139 for (i=0;i<PriorityLoadImage_MAX_P;i++){
147 // ----------------------------------------------------------------------------
148 bool PriorityLoop::_Action_i( int i ){
151 if ((i>=0) && (i<_maxImages)){
152 if (_vecIdImage[i]==false ) {
162 // ----------------------------------------------------------------------------
163 void PriorityLoop::Action_i( int i ){
166 // ----------------------------------------------------------------------------
167 int PriorityLoop::Get_i_image(){
171 while ((i==-1) || (p==4) ){
172 if (_priorityType==0){
173 if ((_priority<=9) && (_priority>=5)) { p=0; }
174 if ((_priority<=4) && (_priority>=2)) { p=1; }
175 if ((_priority<=1) && (_priority>=0)) { p=2; }
177 if (_priorityType==1){
178 if ((_priority<=9) && (_priority>=4)) { p=1; }
179 if ((_priority<=3) && (_priority>=2)) { p=2; }
180 if ((_priority<=1) && (_priority>=0)) { p=3; }
182 if (_priorityType==2){
183 if ((_priority<=9) && (_priority>=3)) { p=2; }
184 if ((_priority<=2) && (_priority>=0)) { p=3; }
186 if (_priorityType==3){
187 if ((_priority<=9) && (_priority>=0)) { p=3; }
189 if (_priorityType==4){
193 if (_priority==-1) {_priority=9;}
195 if (p==0) { i=Geti(p,5,_start,_actual ,_actual ,_end); }
196 if (p==1) { i=Geti(p,1,_start,_actual ,_actual ,_end); }
197 if (p==2) { i=Geti(p,5,0 ,_start ,_end ,_maxImages); }
198 if (p==3) { i=Geti(p,1,0 ,_start ,_end ,_maxImages); }
199 if (p==4) { i=Geti(p,1,0 ,_maxImages ,_maxImages ,_maxImages); }
201 if ((_priorityType==0) && (p==0) && (i==-1)) { _priorityType++; _priority=9; }
202 if ((_priorityType==1) && (p==1) && (i==-1)) { _priorityType++; _priority=9; }
203 if ((_priorityType==2) && (p==2) && (i==-1)) { _priorityType++; _priority=9; }
204 if ((_priorityType==3) && (p==3) && (i==-1)) { _priorityType++; _priority=9; }
209 // ----------------------------------------------------------------------------
211 int PriorityLoop::Geti(int id,int step,int start,int actualg,int actuald,int end){
216 if (_dg[id]==true) { _counterActual[id] = _counterActual[id]+step; }
217 tempig=actualg - _counterActual[id];
218 tempid=actuald + _counterActual[id];
221 if (_vecIdImage[tempig]==false ) {
228 if (_vecIdImage[tempid]==false ) {
233 if ((tempig<start) && (tempid>end)){
240 // ----------------------------------------------------------------------------
241 void PriorityLoop::WaitUntil_i_isDone(int i){
242 WaitUntil_segment_isDone(i-_deltaImg,i+_deltaImg,false);
244 // ----------------------------------------------------------------------------
245 void PriorityLoop::WaitUntil_segment_isDone(int start, int end,bool forceEndLoopRegion){
246 if (forceEndLoopRegion==true) { ForceEndLoopRegion(); }
247 if (_loadingSerie==true){
260 ok = ok && _vecIdImage[i];
264 wxThread::Sleep(100);
270 // ----------------------------------------------------------------------------
271 // ----------------------------------------------------------------------------
272 // ----------------------------------------------------------------------------
274 // ----------------------------------------------------------------------------
275 PriorityLoadImageBar::PriorityLoadImageBar(marFilesBase *marfilesbase, BarLoading *bar){
276 _marfilesbase=marfilesbase;
279 // ----------------------------------------------------------------------------
280 PriorityLoadImageBar::~PriorityLoadImageBar(){
282 // ----------------------------------------------------------------------------
283 void PriorityLoadImageBar::Action_i(int i){
291 // _bar->Refresh(false);
295 // _bar->Refresh(false);
303 if (_marfilesbase!=NULL){
304 _marfilesbase->loadImage(i);
305 vtkImageData *imagedata = _marfilesbase->getVolume()->castVtk();
309 // ----------------------------------------------------------------------------
310 void PriorityLoadImageBar::RefreshForce(){
311 _bar->RefreshForce();
314 // ----------------------------------------------------------------------------
315 // ----------------------------------------------------------------------------
316 // ----------------------------------------------------------------------------
318 IMPLEMENT_CLASS(BarLoading, wxPanel)
319 BEGIN_EVENT_TABLE(BarLoading, wxPanel)
320 EVT_PAINT(BarLoading::OnPaint)
323 static wxMutex *s_mutexProtectingTheGlobalData=NULL;
326 // ----------------------------------------------------------------------------
327 BarLoading::BarLoading(wxWindow *parent, int w, int h)
328 :wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL)
333 SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
334 _bitmap = new wxBitmap(_w,_h);
338 if (s_mutexProtectingTheGlobalData!=NULL)
340 delete s_mutexProtectingTheGlobalData;
341 s_mutexProtectingTheGlobalData=NULL;
343 s_mutexProtectingTheGlobalData = new wxMutex();
347 // ----------------------------------------------------------------------------
348 BarLoading::~BarLoading()
351 // ----------------------------------------------------------------------------
352 void BarLoading::SetI(int i)
355 s_mutexProtectingTheGlobalData->Lock();
359 while (_flag2_bitmap==false){
370 temp_dc.SelectObject( *_bitmap );
371 int x = (_w*i)/_sizeData;
372 int d = (_w/_sizeData)+1;
373 temp_dc.SetBrush(wxBrush( wxColour(0,0,255),wxSOLID ));
374 temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID ));
375 temp_dc.DrawRectangle(x,0,d,_h);
380 s_mutexProtectingTheGlobalData->Unlock();
384 // ----------------------------------------------------------------------------
385 void BarLoading::RefreshForce()
390 // ----------------------------------------------------------------------------
391 void BarLoading::SetSizeData(int sizeData)
395 // ----------------------------------------------------------------------------
396 void BarLoading::Reset()
398 if (_flag_bitmap==true){
400 temp_dc.SelectObject( *_bitmap );
401 temp_dc.SetBrush(wxBrush( wxColour(255,0,0),wxSOLID ));
402 temp_dc.SetPen(wxPen( wxColour(255,0,0),1,wxSOLID ));
403 temp_dc.DrawRectangle(0,0,_w,_h);
409 // ----------------------------------------------------------------------------
410 void BarLoading::Paint( )
413 wxMutexLocker lock(*s_mutexProtectingTheGlobalData);
416 if (_flag_bitmap==true){
418 temp_dc.SelectObject( *_bitmap );
420 int i,ii,size=lstInt.size();
421 for (ii=0;ii<size; ii++)
424 int x = (_w*i)/_sizeData;
425 int d = (_w/_sizeData)+1;
426 temp_dc.SetBrush(wxBrush( wxColour(0,0,255),wxSOLID ));
427 temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID ));
428 temp_dc.DrawRectangle(x,0,d,_h);
435 wxPaintDC dc( this );
436 dc.Blit(0,0, _w, _h, &temp_dc, 0, 0);
438 _flag2_bitmap=true;//SIL//POR QUE TANTAS VECES LO MISMO??????
449 // ----------------------------------------------------------------------------
450 void BarLoading::OnPaint( wxPaintEvent &WXUNUSED(event) )
456 // ----------------------------------------------------------------------------
457 // ----------------------------------------------------------------------------
458 // ----------------------------------------------------------------------------
459 // ----------------------------------------------------------------------------
461 IMPLEMENT_CLASS(BarRange, wxPanel)
462 BEGIN_EVENT_TABLE(BarRange, wxPanel)
463 EVT_PAINT(BarRange::OnPaint)
467 BarRange::BarRange(wxWindow *parent, int w, int h)
468 :wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL)
473 SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
474 _bitmap = new wxBitmap(_w,_h);
480 // ----------------------------------------------------------------------------
481 BarRange::~BarRange()
484 // ----------------------------------------------------------------------------
485 void BarRange::SetStart(int i)
489 // ----------------------------------------------------------------------------
490 void BarRange::SetActual(int i)
494 // ----------------------------------------------------------------------------
495 void BarRange::SetEnd(int i)
499 // ----------------------------------------------------------------------------
500 void BarRange::SetMax(int i)
504 // ----------------------------------------------------------------------------
505 void BarRange::OnPaint( wxPaintEvent &WXUNUSED(event) )
511 temp_dc.SelectObject( *_bitmap );
512 wxPaintDC dc( this );
513 dc.Blit(0,0, _w, _h, &temp_dc, 0, 0);
516 // ----------------------------------------------------------------------------
518 void BarRange::RefreshView()
522 int px1=(_w*_start)/_max;
523 int px2=(_w*_end)/_max;
524 int px3=(_w*_actual)/_max;
527 temp_dc.SelectObject( *_bitmap );
530 wxColour colourParent = GetParent()->GetBackgroundColour();
531 temp_dc.SetBrush(wxBrush( colourParent ,wxSOLID ));
532 temp_dc.SetPen(wxPen( colourParent ,1,wxSOLID ));
533 temp_dc.DrawRectangle(0,0,_w,_h);
536 temp_dc.SetBrush(wxBrush( wxColour(255,0,255),wxSOLID ));
537 temp_dc.SetPen(wxPen( wxColour(255,0,255),1,wxSOLID ));
538 temp_dc.DrawRectangle( px1 , 0 , px2-px1 , _h );
540 // 2 Start End ( triangles )
541 temp_dc.SetBrush(wxBrush( wxColour(0,0,255),wxSOLID ));
542 temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID ));
549 temp_dc.DrawPolygon(3,points,px1,0);
550 temp_dc.DrawPolygon(3,points,px2,0);
552 // Actual ( black triangles )
553 // 2 Start End ( yellow triangles )
554 temp_dc.SetBrush(wxBrush( wxColour(255,255,0),wxSOLID ));
555 temp_dc.SetPen(wxPen( wxColour(255,255,0),1,wxSOLID ));
562 temp_dc.DrawPolygon(3,points,px3,0);
565 // ----------------------------------------------------------------------------
566 void BarRange::RefreshForce()
571 // ----------------------------------------------------------------------------
574 // ----------------------------------------------------------------------------
575 // ----------------------------------------------------------------------------
576 // ----------------------------------------------------------------------------
581 PriorityBar::PriorityBar(BarLoading *bar){
584 // ----------------------------------------------------------------------------
585 PriorityBar::~PriorityBar(){
587 // ----------------------------------------------------------------------------
588 void PriorityBar::Action_i(int i){
591 wxThread::Sleep(100);
593 // ----------------------------------------------------------------------------
594 void PriorityBar::RefreshForce(){
595 _bar->RefreshForce();
599 // ----------------------------------------------------------------------------
600 // ----------------------------------------------------------------------------
601 // ----------------------------------------------------------------------------
603 // ----------------------------------------------------------------------------
604 AdminThreadEED::AdminThreadEED()
605 : m_condAllDone(m_mutexAllDone){
607 // the mutex associated with a condition must be initially locked, it will
608 // only be unlocked when we call Wait()
609 m_mutexAllDone.Lock();
610 m_waitingUntilAllDone = FALSE;
613 // ----------------------------------------------------------------------------
614 AdminThreadEED::~AdminThreadEED(){
615 // the mutex must be unlocked before being destroyed
616 m_mutexAllDone.Unlock();
619 // ----------------------------------------------------------------------------
620 // ----------------------------------------------------------------------------
621 // ----------------------------------------------------------------------------
623 // ----------------------------------------------------------------------------
624 MyThread::MyThread(PriorityLoop *priorityLoop,AdminThreadEED *adminThreadEED){
625 _priorityLoop = priorityLoop;
626 _adminThreadEED = adminThreadEED;
630 // ----------------------------------------------------------------------------
631 void MyThread::OnExit(){
632 _priorityLoop->StopLoop();
633 wxCriticalSectionLocker locker(_adminThreadEED->m_critsect);
634 wxArrayThread& threads = _adminThreadEED->m_threads;
635 threads.Remove(this);
637 if ( threads.IsEmpty() ) {
638 if ( _adminThreadEED->m_waitingUntilAllDone ){
639 _adminThreadEED->m_waitingUntilAllDone = FALSE;
640 wxMutexLocker lock(_adminThreadEED->m_mutexAllDone);
641 _adminThreadEED->m_condAllDone.Signal();
645 // ----------------------------------------------------------------------------
647 void *MyThread::Entry(){
648 _priorityLoop->InitLoop();
649 while ( _priorityLoop->IsLoop()==true ){
650 if ( TestDestroy() ){
653 _priorityLoop->Iteration();
660 // ----------------------------------------------------------------------------
661 // ----------------------------------------------------------------------------
662 // ----------------------------------------------------------------------------
665 // ----------------------------------------------------------------------------
666 LoadRangeImage::LoadRangeImage(wxWindow *parent,marFilesBase *marfilesbase )
667 : wxPanel(parent, -1)
669 _marfilesbase = marfilesbase;
671 wxPanel *panel = new wxPanel(this, -1);
673 _bar = new BarLoading(panel,wx-10,15);
674 //SIL//_barRange = new BarRange(panel,wx-10,5);
676 _sl_barRange_ROI = new mBarRange(panel,wx-10 ,70);
677 _sl_barRange_ROI-> SetOrientation(true);
678 _sl_barRange_ROI -> setVisibleLabels ( true );
679 _sl_barRange_ROI -> setActiveStateTo ( true );
680 _sl_barRange_ROI -> setDeviceBlitStart (2,2);
681 _sl_barRange_ROI -> setDeviceEndMargin(0);
682 _sl_barRange_ROI -> SetTrianglesHalfWidth(5);
685 parent->SetBackgroundColour(wxColour(255,255,255 )) ;
686 panel->SetBackgroundColour(parent-> GetBackgroundColour());
689 parent->SetBackgroundColour(wxColour(255,0,0 )) ;
690 panel->SetBackgroundColour(wxColour(0,255,0 )) ;*/
692 panel->SetBackgroundColour(wxColour(0,0,0 ));
693 parent->SetBackgroundColour(wxColour(255,0,0 ));
694 (parent->GetParent())->SetBackgroundColour(wxColour(0,255,0 )) ;
695 ((parent->GetParent())->GetParent())->SetBackgroundColour(wxColour(0,0,255 )) ;*/
698 _sl_barRange_ROI-> setBackgroundColor( parent-> GetBackgroundColour()/*wxColour(255,255,255 )*/);
699 reseteableActual =true;
703 _sldActual = new wxSlider(panel,-1,0,0,10000,wxDefaultPosition,wxSize(wx-10,20),wxSL_HORIZONTAL);
705 _btnStart = new wxButton(panel,-1,_T("Start:"),wxDefaultPosition, wxSize(70,20) );
706 _btnEnd = new wxButton(panel,-1,_T("End:"),wxDefaultPosition, wxSize(70,20) );
707 _textActual = new wxStaticText(panel,-1,_T("Actual: 0000000000"));*/
708 _textActual = new wxStaticText(panel,-1,_T(" "));
711 // _sldActual ->SetSize(wx-10,20);
712 // _btnStart ->SetSize(70,20);
713 // _btnEnd ->SetSize(70,20);
715 //SIL//_sizer1a = new wxFlexGridSizer(1);
716 //SIL//_sizer1a->Add(_btnStart );
717 //SIL//_sizer1a->Add(_textActual ,wxALIGN_CENTER,0 );
718 //SIL//_sizer1a->Add(_btnEnd );
720 // _btnStart ->Show(true);
721 // _btnEnd ->Show(true);
723 //SIL//_sizer1a->Show(_btnStart, false);
724 //SIL//_sizer1a->Show(_btnEnd, false);
727 // _sizer1a = new wxFlexGridSizer(1);
728 // _sizer1a->Add(_textActual ,wxALIGN_CENTER,0 );
730 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
731 // sizer1->AddGrowableRow(1);
732 // wxBoxSizer *sizer1 = new wxBoxSizer(wxVERTICAL );
733 //SIL//sizer1->Add(_sldActual);
735 //SIL//sizer1->Add(_barRange);
737 sizer1->Add(_sl_barRange_ROI,1,wxEXPAND,0);
739 wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
740 // sizer -> AddGrowableRow(1);//SIL//
741 // sizer->Add(_sizer1a, 1, wxALL , 5 );
742 sizer->Add(_textActual);
743 sizer->Add(sizer1,1,wxEXPAND,0);
747 /*wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
748 sizer->Add(_bar, 0, wxEXPAND);
749 sizer->Add(_sl_barRange_ROI, 0, wxEXPAND);*/
753 Connect(_btnStart->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnBtnStart );
754 Connect(_btnEnd->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnBtnEnd );
756 //Connect(_sldActual->GetId() , wxEVT_COMMAND_SLIDER_UPDATED , (wxObjectEventFunction) (wxEventFunction) (wxScrollEventFunction) &LoadRangeImage::OnSliceActual );
758 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnBarrange );
759 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnStartChange_BarRange );
760 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnEndChange_BarRange );
761 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnActualChange_BarRange );
762 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnBarMoved_BarRange );
763 Connect(_sl_barRange_ROI->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnSelectionEnd_BarRange );
770 _timer = new wxTimer(this);
772 Connect( _timer->GetId(), wxEVT_TIMER , (wxObjectEventFunction) (wxTimerEventFunction) &LoadRangeImage::OnTimer );
776 panel->SetSizer(sizer);
777 panel->SetAutoLayout( TRUE );
779 this->SetSize(wx,75);
780 panel->SetSize(wx,75);
783 _priorityLoadImageBar = new PriorityLoadImageBar(_marfilesbase,_bar);
784 _adminThreadEED = new AdminThreadEED();
786 // ----------------------------------------------------------------------------
787 LoadRangeImage::~LoadRangeImage()
796 // ----------------------------------------------------------------------------
797 void LoadRangeImage::ResetLoadRegion()
802 //SIL//a=_sldActual->GetValue();
803 //a=_sl_barRange_ROI->GetActual();
810 _priorityLoadImageBar->SetStartEndActualMax(s,e,a,0,_maxZ);
813 // ----------------------------------------------------------------------------
814 void LoadRangeImage::Start( )
817 vtkImageData *vol = _marfilesbase->getVolume( )->castVtk();
819 vol->GetDimensions(dim);
825 this->SetStartSlice(_startSlice);
826 this->SetEndSlice(_endSlice);
829 _bar -> SetSizeData(_maxZ);
830 //SIL// Para quitar luego als siguientes dos lineas
831 /*_sldActual -> SetRange(0, _maxZ);
832 _sldActual -> SetValue( _maxZ/2 );*/
835 _sl_barRange_ROI -> setRepresentedValues (0,_maxZ);
836 _sl_barRange_ROI -> SetActual(_maxZ/2);
837 _sl_barRange_ROI -> RefreshForce();
841 SetEndSlice( _maxZ );
842 _toShowSlice = _sl_barRange_ROI->GetActual();
846 _marfilesbase->ResetLstFileNotReaded();
850 // ----------------------------------------------------------------------------
851 void LoadRangeImage::_Start()
855 _mythread = new MyThread (_priorityLoadImageBar,_adminThreadEED);
857 wxCriticalSectionLocker enter(_adminThreadEED->m_critsect);
858 _adminThreadEED->m_threads.Add(_mythread);
859 if ( _mythread->Run() != wxTHREAD_NO_ERROR ){
860 wxLogError(wxT("Can't start thread!"));
863 // ----------------------------------------------------------------------------
864 void LoadRangeImage::_Stop( )
867 _adminThreadEED->m_critsect.Enter();
868 // stop the last thread
869 if ( _adminThreadEED->m_threads.IsEmpty() ){
870 //wxLogError(wxT("No thread to stop!"));
871 _adminThreadEED->m_critsect.Leave();
873 wxThread *_mythread = _adminThreadEED->m_threads.Last();
874 // it's important to leave critical section before calling Delete()
875 // because delete will (implicitly) call OnExit() which also tries
876 // to enter the same crit section - would dead lock.
877 _adminThreadEED->m_critsect.Leave();
883 // ----------------------------------------------------------------------------
885 void LoadRangeImage::OnBtnRestart( wxCommandEvent& event ){
886 _priorityLoadImageBar->WaitUntil_segment_isDone( _sldStart->GetValue(),_sldEnd->GetValue() );
893 // ----------------------------------------------------------------------------
894 void LoadRangeImage::OnSliceActual(wxScrollEvent& event)
896 //SIL// metodo para quitar
897 _toShowSlice = _sl_barRange_ROI->GetActual();
902 // ----------------------------------------------------------------------------
904 void LoadRangeImage::OnBtnStart( wxCommandEvent & event )
906 //SIL// metodo para quitar
907 /*SetStartSlice( _sldActual->GetValue() );
912 // ----------------------------------------------------------------------------
913 void LoadRangeImage::OnBtnEnd( wxCommandEvent & event )
915 //SIL// metodo para quitar
916 /*SetEndSlice( _sldActual->GetValue() );
920 // ----------------------------------------------------------------------------
921 void LoadRangeImage::SetStartEnd( int start, int end )
923 SetStartSlice( start );
929 // ----------------------------------------------------------------------------
930 void LoadRangeImage::Reset( )
932 int delta= (int) (_maxZ*0.1);
933 SetStartSlice( 0 + delta );
934 SetEndSlice( _maxZ - delta );
937 // _btnStart ->Show(true);
938 // _btnEnd ->Show(true);
940 //SIL//_sizer1a->Show(_btnStart, true );
941 //SIL//_sizer1a->Show(_btnEnd , true );
942 // _sizer1a->Layout();
946 // ----------------------------------------------------------------------------
947 void LoadRangeImage::SetStartSlice(int value)
949 if (value<_endSlice){
952 txt.Printf(_T("%d"),_startSlice);
953 _textActual->SetLabel(txt);*/
955 //SIL// para quitar las siguientes 4 lineas
957 _btnStart->SetLabel(_T("Start: ")+txt);
958 _barRange->SetMax(_maxZ);
959 _barRange->SetStart(_startSlice);
960 _barRange->RefreshForce();*/
963 _sl_barRange_ROI->SetMax(_maxZ);
964 _sl_barRange_ROI->SetStart(_startSlice);
965 _sl_barRange_ROI->RefreshForce();
968 // ----------------------------------------------------------------------------
969 void LoadRangeImage::SetEndSlice(int value)
971 if (value>_startSlice){
974 txt.Printf(_T("%d"),_endSlice);
975 _textActual->SetLabel(txt);*/
976 //SIL//_btnEnd->SetLabel(_T("End: ")+txt);
977 _sl_barRange_ROI->SetEnd(_endSlice);
978 _sl_barRange_ROI->RefreshForce();
983 // ----------------------------------------------------------------------------
984 void LoadRangeImage::RefreshSlice()
986 //SIL// _priorityLoadImageBar->WaitUntil_i_isDone( _sldActual->GetValue() );
987 _priorityLoadImageBar->WaitUntil_i_isDone( _toShowSlice );
989 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12122);
990 this->GetParent()->ProcessEvent(newevent);
993 //SIL//text.Printf(_T("Actual: %d "), _sldActual->GetValue() );
994 text.Printf(_T("Start: %d\n Actual: %d\n End: %d"), _sl_barRange_ROI->GetStart(),_sl_barRange_ROI->GetActual(),_sl_barRange_ROI->GetEnd() );
995 _textActual->SetLabel(text);*/
997 //SIL// Para borrar las lineas de barrange
998 /*_barRange->SetMax(_maxZ);
999 _barRange->SetActual( _sldActual->GetValue() );
1000 _barRange->SetStart(_startSlice);
1001 _barRange->SetEnd(_endSlice);
1002 _barRange->RefreshForce();*/
1006 // _sl_barRange_ROI->SetMax(_maxZ);
1007 //_sl_barRange_ROI->SetActual( _sldActual->GetValue() );
1008 // _sl_barRange_ROI->SetStart(_startSlice);
1009 // _sl_barRange_ROI->SetEnd(_endSlice);
1010 _sl_barRange_ROI->RefreshForce();
1017 // _imageViewerWidget->SetZSlice( _sldActual->GetValue() );
1018 // _imageViewerWidget->Render();
1020 // ----------------------------------------------------------------------------
1021 void LoadRangeImage::CallBackOnMouseWheel( wxMouseEvent& event )
1023 /* //SIL ImageViewer no existe//int actual = _imageViewerWidget->GetZSlice();
1024 if (actual<_sl_barRange_ROI->GetActual()) {
1025 actual = _sl_barRange_ROI->GetActual();
1027 if (actual>_sl_barRange_ROI->GetEnd()) {
1028 actual = _sl_barRange_ROI->GetEnd();
1030 _sl_barRange_ROI->SetActual( actual );
1034 /*int actual = _imageViewerWidget->GetZSlice();
1035 if (actual<_sldStart->GetValue()) {
1036 actual = _sldStart->GetValue();
1038 if (actual>_sldEnd->GetValue()) {
1039 actual = _sldEnd->GetValue();
1041 _sldActual->SetValue( actual );
1046 // ----------------------------------------------------------------------------
1047 void LoadRangeImage::ForceToFinisReadActiveImages()
1052 _priorityLoadImageBar->WaitUntil_segment_isDone(s,e,true);
1056 std::string msgLstFile( _marfilesbase->GetMsgLstFile() );
1057 if ( msgLstFile!="")
1059 wxDialog *dialog = new wxDialog( this , -1, wxString(_T("The following files doesn't exist:")), wxDefaultPosition, wxSize(550,300), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
1060 wxTextCtrl *textCtrl = new wxTextCtrl(dialog, -1, wxString (msgLstFile.c_str(), wxConvUTF8) ,wxDefaultPosition , wxSize(100,100) , wxTE_MULTILINE | wxTE_READONLY );
1061 textCtrl->SetSelection(0,0);
1062 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL );
1063 sizer->Add( textCtrl , 1, wxALL|wxEXPAND, 0);
1064 dialog->SetAutoLayout(true);
1065 dialog->SetSizer( sizer ); // use the sizer for layout
1068 // dialog->FitInside();
1069 dialog->ShowModal();
1076 // ----------------------------------------------------------------------------
1077 void LoadRangeImage::GetROI( int extent[6] )
1079 extent[4]=_startSlice;
1080 extent[5]=_endSlice;
1082 // ----------------------------------------------------------------------------
1083 void LoadRangeImage::SetActualSlice( int actual )
1086 if ( actual > _endSlice ){
1089 if ( actual < _startSlice ){
1090 actual = _startSlice;
1093 //SIL//_sldActual->SetValue( actual );//SIL// para quitar esta linea
1095 _sl_barRange_ROI->SetActual( actual);//de pronto no se necesita aca
1096 _toShowSlice=actual;
1101 // ----------------------------------------------------------------------------
1102 int LoadRangeImage::GetActualSlice( )
1104 return _toShowSlice;/*_sl_barRange_ROI->GetActual()*/;
1106 // ----------------------------------------------------------------------------
1108 void LoadRangeImage::ResetActualSlice( )
1110 if( reseteableActual )
1111 _toShowSlice = _sl_barRange_ROI->GetActual();
1114 //------------------------------------------------------------------------
1115 // Events captured form the barrange used configuring the ROI
1116 //------------------------------------------------------------------------
1117 void LoadRangeImage::OnBarrange(wxCommandEvent& event)
1121 void LoadRangeImage::OnActualChange_BarRange(wxCommandEvent& event)
1123 //reseteableActual =true;
1124 _toShowSlice = _sl_barRange_ROI->GetActual();
1128 void LoadRangeImage::OnStartChange_BarRange(wxCommandEvent& event)
1130 reseteableActual =false;
1131 _toShowSlice = _sl_barRange_ROI->GetStart();
1132 SetStartSlice( _sl_barRange_ROI->GetStart() );
1137 void LoadRangeImage::OnEndChange_BarRange(wxCommandEvent& event)
1139 reseteableActual =false;
1140 _toShowSlice = _sl_barRange_ROI->GetEnd();
1141 SetEndSlice( _sl_barRange_ROI->GetEnd() );
1145 void LoadRangeImage:: OnBarMoved_BarRange (wxCommandEvent& event)
1147 SetEndSlice( _sl_barRange_ROI->GetEnd() );
1148 SetStartSlice( _sl_barRange_ROI->GetStart() );
1153 void LoadRangeImage:: OnSelectionEnd_BarRange (wxCommandEvent& event)
1155 reseteableActual = true;
1159 void LoadRangeImage:: OnTimer(wxTimerEvent& event)
1161 // EED used in linux (see constructor)
1162 _bar->Refresh(false);
1168 // ----------------------------------------------------------------------------
1169 // ----------------------------------------------------------------------------
1170 // ----------------------------------------------------------------------------