00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015 #include "wx/wxprec.h"
00016 #include <wx/thread.h>
00017
00018
00019 #ifndef WX_PRECOMP
00020 #include "wx/wx.h"
00021 #endif
00022
00023 #include "wxReadingPriorityPanel.h"
00024
00025
00026
00027
00028
00029 PriorityLoop::PriorityLoop(){
00030 _vecIdImage = NULL;
00031 _loadingSerie = false;
00032 _forceReadRegion = false;
00033 _i_forceReadReagion = -1;
00034 _needToChange = false;
00035 _deltaImg = 0;
00036 }
00037
00038 PriorityLoop::~PriorityLoop(){
00039 if (_vecIdImage!=NULL) {
00040 free(_vecIdImage);
00041 }
00042 }
00043
00044 void PriorityLoop::StopLoop(){
00045 _loadingSerie = false;
00046 }
00047
00048 bool PriorityLoop::IsLoop(){
00049 return _loadingSerie;
00050 }
00051
00052 void PriorityLoop::ForceEndLoopRegion(){
00053 _forceReadRegion=true;
00054 }
00055
00056
00057 void PriorityLoop::InitLoop(){
00058 _loadingSerie = true;
00059 NeedToChange();
00060 Create_Empty_Vector();
00061 InitConfiguration();
00062 _counterReading = 0;
00063 }
00064
00065
00066 void PriorityLoop::Iteration(){
00067
00068 NeedToChange();
00069
00070 if (_forceReadRegion==false){
00071 int ii,i=Get_i_image();
00072 for (ii=i-_deltaImg;ii<=i+_deltaImg;ii++){
00073 if (_Action_i( ii )==true){
00074 _counterReading++;
00075 }
00076 }
00077 } else {
00078 _loadingSerie=_ForceEndLoopRegion();
00079 }
00080
00081 if (_counterReading==_maxImages){
00082 _loadingSerie=false;
00083 }
00084
00085 }
00086
00087
00088 bool PriorityLoop::_ForceEndLoopRegion (){
00089 bool ok=true;
00090 if (_i_forceReadReagion==-1){
00091 _i_forceReadReagion=_start;
00092 }
00093 _Action_i( _i_forceReadReagion );
00094 _i_forceReadReagion++;
00095 if (_i_forceReadReagion>_end){
00096 ok=false;
00097 }
00098 return ok;
00099 }
00100
00101 void PriorityLoop::Create_Empty_Vector(){
00102 if (_vecIdImage!=NULL) {
00103 free(_vecIdImage);
00104 }
00105 _vecIdImage = (bool*)malloc(sizeof(bool)*(_maxImages+1) );
00106 int i;
00107 for (i=0; i<=_maxImages;i++){
00108 _vecIdImage[i]=false;
00109 }
00110
00111 }
00112
00113
00114 void PriorityLoop::SetStartEndActualMax(int start,int end, int actual, int deltaImg,int maxImages){
00115 _tstart = start;
00116 _tend = end;
00117 _tactual = actual;
00118 _tdeltaImg = deltaImg;
00119 _tmaxImages = maxImages;
00120 _needToChange = true;
00121 }
00122
00123 void PriorityLoop::NeedToChange(){
00124 if (_needToChange==true){
00125 _needToChange = false;
00126 _start = _tstart;
00127 _end = _tend;
00128 _actual = _tactual;
00129 _deltaImg = _tdeltaImg;
00130 _maxImages = _tmaxImages;
00131 InitConfiguration();
00132 }
00133 }
00134
00135
00136 void PriorityLoop::InitConfiguration(){
00137 _forceReadRegion=false;
00138 int i;
00139 for (i=0;i<PriorityLoadImage_MAX_P;i++){
00140 _dg[i]=false;
00141 _counterActual[i]=0;
00142 }
00143 _priorityType=0;
00144 _priority=9;
00145 }
00146
00147
00148 bool PriorityLoop::_Action_i( int i ){
00149 bool ok=false;
00150 if (i!=-1) {
00151 if ((i>=0) && (i<_maxImages)){
00152 if (_vecIdImage[i]==false ) {
00153 Action_i(i);
00154 _vecIdImage[i]=true;
00155 ok=true;
00156 }
00157 }
00158 }
00159 return ok;
00160 }
00161
00162
00163 void PriorityLoop::Action_i( int i ){
00164 }
00165
00166
00167 int PriorityLoop::Get_i_image(){
00168 int p=4;
00169
00170 int i=-1;
00171 while ((i==-1) || (p==4) ){
00172 if (_priorityType==0){
00173 if ((_priority<=9) && (_priority>=5)) { p=0; }
00174 if ((_priority<=4) && (_priority>=2)) { p=1; }
00175 if ((_priority<=1) && (_priority>=0)) { p=2; }
00176 }
00177 if (_priorityType==1){
00178 if ((_priority<=9) && (_priority>=4)) { p=1; }
00179 if ((_priority<=3) && (_priority>=2)) { p=2; }
00180 if ((_priority<=1) && (_priority>=0)) { p=3; }
00181 }
00182 if (_priorityType==2){
00183 if ((_priority<=9) && (_priority>=3)) { p=2; }
00184 if ((_priority<=2) && (_priority>=0)) { p=3; }
00185 }
00186 if (_priorityType==3){
00187 if ((_priority<=9) && (_priority>=0)) { p=3; }
00188 }
00189 if (_priorityType==4){
00190 p=4;
00191 }
00192 _priority--;
00193 if (_priority==-1) {_priority=9;}
00194
00195 if (p==0) { i=Geti(p,5,_start,_actual ,_actual ,_end); }
00196 if (p==1) { i=Geti(p,1,_start,_actual ,_actual ,_end); }
00197 if (p==2) { i=Geti(p,5,0 ,_start ,_end ,_maxImages); }
00198 if (p==3) { i=Geti(p,1,0 ,_start ,_end ,_maxImages); }
00199 if (p==4) { i=Geti(p,1,0 ,_maxImages ,_maxImages ,_maxImages); }
00200
00201 if ((_priorityType==0) && (p==0) && (i==-1)) { _priorityType++; _priority=9; }
00202 if ((_priorityType==1) && (p==1) && (i==-1)) { _priorityType++; _priority=9; }
00203 if ((_priorityType==2) && (p==2) && (i==-1)) { _priorityType++; _priority=9; }
00204 if ((_priorityType==3) && (p==3) && (i==-1)) { _priorityType++; _priority=9; }
00205 }
00206 return i;
00207 }
00208
00209
00210
00211 int PriorityLoop::Geti(int id,int step,int start,int actualg,int actuald,int end){
00212 int tempig=0;
00213 int tempid=0;
00214 int i=-2;
00215 while (i==-2){
00216 if (_dg[id]==true) { _counterActual[id] = _counterActual[id]+step; }
00217 tempig=actualg - _counterActual[id];
00218 tempid=actuald + _counterActual[id];
00219 if (_dg[id]==true){
00220 if (tempig>=start) {
00221 if (_vecIdImage[tempig]==false ) {
00222 i=tempig;
00223 }
00224 }
00225 }
00226 if (_dg[id]==false){
00227 if (tempid<=end) {
00228 if (_vecIdImage[tempid]==false ) {
00229 i=tempid;
00230 }
00231 }
00232 }
00233 if ((tempig<start) && (tempid>end)){
00234 i=-1;
00235 }
00236 _dg[id]=!_dg[id];
00237 }
00238 return i;
00239 }
00240
00241 void PriorityLoop::WaitUntil_i_isDone(int i){
00242 WaitUntil_segment_isDone(i-_deltaImg,i+_deltaImg,false);
00243 }
00244
00245 void PriorityLoop::WaitUntil_segment_isDone(int start, int end,bool forceEndLoopRegion){
00246 if (forceEndLoopRegion==true) { ForceEndLoopRegion(); }
00247 if (_loadingSerie==true){
00248 int s=start,e=end;
00249 if (s<0){
00250 s=0;
00251 }
00252 if (e>_maxImages-1){
00253 e=_maxImages-1;
00254 }
00255 bool ok=false;
00256 while (ok==false){
00257 int i;
00258 ok=true;
00259 for (i=s;i<=e;i++){
00260 ok = ok && _vecIdImage[i];
00261 }
00262 if (ok==false) {
00263 RefreshForce();
00264 wxThread::Sleep(100);
00265 }
00266 }
00267 }
00268 }
00269
00270
00271
00272
00273
00274
00275 PriorityLoadImageBar::PriorityLoadImageBar(marFilesBase *marfilesbase, BarLoading *bar){
00276 _marfilesbase=marfilesbase;
00277 _bar=bar;
00278 }
00279
00280 PriorityLoadImageBar::~PriorityLoadImageBar(){
00281 }
00282
00283 void PriorityLoadImageBar::Action_i(int i){
00284
00285 if (_bar!=NULL){
00286
00287
00288 _bar->SetI(i);
00289
00290 #if defined(WIN32)
00291
00292
00293
00294 #else
00295
00296
00297
00298
00299 #endif
00300 }
00301
00302
00303 if (_marfilesbase!=NULL){
00304 _marfilesbase->loadImage(i);
00305 vtkImageData *imagedata = _marfilesbase->getVolume()->castVtk();
00306 imagedata->Update();
00307 }
00308 }
00309
00310 void PriorityLoadImageBar::RefreshForce(){
00311 _bar->RefreshForce();
00312 }
00313
00314
00315
00316
00317
00318 IMPLEMENT_CLASS(BarLoading, wxPanel)
00319 BEGIN_EVENT_TABLE(BarLoading, wxPanel)
00320 EVT_PAINT(BarLoading::OnPaint)
00321 END_EVENT_TABLE()
00322
00323 static wxMutex *s_mutexProtectingTheGlobalData=NULL;
00324
00325
00326
00327 BarLoading::BarLoading(wxWindow *parent, int w, int h)
00328 :wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL)
00329 {
00330 _w=w;
00331 _h=h;
00332 SetSize(_w,_h);
00333 SetWindowStyle(wxNO_FULL_REPAINT_ON_RESIZE);
00334 _bitmap = new wxBitmap(_w,_h);
00335 _flag_bitmap=true;
00336 _flag2_bitmap=true;
00337
00338 if (s_mutexProtectingTheGlobalData!=NULL)
00339 {
00340 delete s_mutexProtectingTheGlobalData;
00341 s_mutexProtectingTheGlobalData=NULL;
00342 }
00343 s_mutexProtectingTheGlobalData = new wxMutex();
00344 Reset();
00345 }
00346
00347
00348 BarLoading::~BarLoading()
00349 {
00350 }
00351
00352 void BarLoading::SetI(int i)
00353 {
00354
00355 s_mutexProtectingTheGlobalData->Lock();
00356
00357 _flag_bitmap=false;
00358
00359 while (_flag2_bitmap==false){
00360
00361 #if defined(WIN32)
00362 Sleep(1);
00363 #else
00364
00365 #endif
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378 lstInt.push_back(i);
00379
00380 s_mutexProtectingTheGlobalData->Unlock();
00381 _flag_bitmap=true;
00382
00383 }
00384
00385 void BarLoading::RefreshForce()
00386 {
00387
00388
00389 }
00390
00391 void BarLoading::SetSizeData(int sizeData)
00392 {
00393 _sizeData=sizeData;
00394 }
00395
00396 void BarLoading::Reset()
00397 {
00398 if (_flag_bitmap==true){
00399 wxMemoryDC temp_dc;
00400 temp_dc.SelectObject( *_bitmap );
00401 temp_dc.SetBrush(wxBrush( wxColour(255,0,0),wxSOLID ));
00402 temp_dc.SetPen(wxPen( wxColour(255,0,0),1,wxSOLID ));
00403 temp_dc.DrawRectangle(0,0,_w,_h);
00404 lstInt.clear();
00405 }
00406 }
00407
00408
00409
00410 void BarLoading::Paint( )
00411 {
00412 _flag2_bitmap=false;
00413 wxMutexLocker lock(*s_mutexProtectingTheGlobalData);
00414
00415
00416 if (_flag_bitmap==true){
00417 wxMemoryDC temp_dc;
00418 temp_dc.SelectObject( *_bitmap );
00419
00420 int i,ii,size=lstInt.size();
00421 for (ii=0;ii<size; ii++)
00422 {
00423 i=lstInt[ii];
00424 int x = (_w*i)/_sizeData;
00425 int d = (_w/_sizeData)+1;
00426 temp_dc.SetBrush(wxBrush( wxColour(0,0,255),wxSOLID ));
00427 temp_dc.SetPen(wxPen( wxColour(0,0,255),1,wxSOLID ));
00428 temp_dc.DrawRectangle(x,0,d,_h);
00429 }
00430 lstInt.clear();
00431
00432
00433
00434
00435 wxPaintDC dc( this );
00436 dc.Blit(0,0, _w, _h, &temp_dc, 0, 0);
00437 }
00438 _flag2_bitmap=true;
00439 _flag2_bitmap=true;
00440 _flag2_bitmap=true;
00441 _flag2_bitmap=true;
00442 _flag2_bitmap=true;
00443 _flag2_bitmap=true;
00444
00445
00446 }
00447
00448
00449
00450 void BarLoading::OnPaint( wxPaintEvent &WXUNUSED(event) )
00451 {
00452 Paint();
00453 }
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 AdminThreadEED::AdminThreadEED()
00605 : m_condAllDone(m_mutexAllDone){
00606
00607
00608
00609 m_mutexAllDone.Lock();
00610 m_waitingUntilAllDone = FALSE;
00611
00612 }
00613
00614 AdminThreadEED::~AdminThreadEED(){
00615
00616 m_mutexAllDone.Unlock();
00617 }
00618
00619
00620
00621
00622
00623
00624 MyThread::MyThread(PriorityLoop *priorityLoop,AdminThreadEED *adminThreadEED){
00625 _priorityLoop = priorityLoop;
00626 _adminThreadEED = adminThreadEED;
00627
00628 }
00629
00630
00631 void MyThread::OnExit(){
00632 _priorityLoop->StopLoop();
00633 wxCriticalSectionLocker locker(_adminThreadEED->m_critsect);
00634 wxArrayThread& threads = _adminThreadEED->m_threads;
00635 threads.Remove(this);
00636
00637 if ( threads.IsEmpty() ) {
00638 if ( _adminThreadEED->m_waitingUntilAllDone ){
00639 _adminThreadEED->m_waitingUntilAllDone = FALSE;
00640 wxMutexLocker lock(_adminThreadEED->m_mutexAllDone);
00641 _adminThreadEED->m_condAllDone.Signal();
00642 }
00643 }
00644 }
00645
00646
00647 void *MyThread::Entry(){
00648 _priorityLoop->InitLoop();
00649 while ( _priorityLoop->IsLoop()==true ){
00650 if ( TestDestroy() ){
00651 break;
00652 }
00653 _priorityLoop->Iteration();
00654 }
00655 return NULL;
00656 }
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666 LoadRangeImage::LoadRangeImage(wxWindow *parent,marFilesBase *marfilesbase )
00667 : wxPanel(parent, -1)
00668 {
00669 _marfilesbase = marfilesbase;
00670
00671 wxPanel *panel = new wxPanel(this, -1);
00672 int wx=550;
00673 _bar = new BarLoading(panel,wx-10,15);
00674
00675
00676 _sl_barRange_ROI = new mBarRange(panel,wx-10 ,70);
00677 _sl_barRange_ROI-> SetOrientation(true);
00678 _sl_barRange_ROI -> setVisibleLabels ( true );
00679 _sl_barRange_ROI -> setActiveStateTo ( true );
00680 _sl_barRange_ROI -> setDeviceBlitStart (2,2);
00681 _sl_barRange_ROI -> setDeviceEndMargin(0);
00682 _sl_barRange_ROI -> SetTrianglesHalfWidth(5);
00683
00684
00685 parent->SetBackgroundColour(wxColour(255,255,255 )) ;
00686 panel->SetBackgroundColour(parent-> GetBackgroundColour());
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698 _sl_barRange_ROI-> setBackgroundColor( parent-> GetBackgroundColour());
00699 reseteableActual =true;
00700
00701
00702
00703
00704
00705
00706
00707
00708 _textActual = new wxStaticText(panel,-1,_T(" "));
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730 wxFlexGridSizer *sizer1 = new wxFlexGridSizer(1);
00731
00732
00733
00734 sizer1->Add(_bar);
00735
00736
00737 sizer1->Add(_sl_barRange_ROI,1,wxEXPAND,0);
00738
00739 wxFlexGridSizer *sizer = new wxFlexGridSizer(2);
00740
00741
00742 sizer->Add(_textActual);
00743 sizer->Add(sizer1,1,wxEXPAND,0);
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnBarrange );
00759 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnStartChange_BarRange );
00760 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnEndChange_BarRange );
00761 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnActualChange_BarRange );
00762 Connect(_sl_barRange_ROI->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnBarMoved_BarRange );
00763 Connect(_sl_barRange_ROI->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &LoadRangeImage::OnSelectionEnd_BarRange );
00764
00765
00766 _timer=NULL;
00767 #if defined(WIN32)
00768
00769 #else
00770 _timer = new wxTimer(this);
00771 _timer->Start(100);
00772 Connect( _timer->GetId(), wxEVT_TIMER , (wxObjectEventFunction) (wxTimerEventFunction) &LoadRangeImage::OnTimer );
00773 #endif
00774
00775
00776 panel->SetSizer(sizer);
00777 panel->SetAutoLayout( TRUE );
00778
00779 this->SetSize(wx,75);
00780 panel->SetSize(wx,75);
00781
00782 _mythread = NULL;
00783 _priorityLoadImageBar = new PriorityLoadImageBar(_marfilesbase,_bar);
00784 _adminThreadEED = new AdminThreadEED();
00785 }
00786
00787 LoadRangeImage::~LoadRangeImage()
00788 {
00789 if (_timer!=NULL){
00790 _timer->Stop();
00791 delete _timer;
00792 }
00793 _Stop();
00794 }
00795
00796
00797 void LoadRangeImage::ResetLoadRegion()
00798 {
00799 int s,e,a;
00800 s=_startSlice;
00801 e=_endSlice;
00802
00803
00804 a = _toShowSlice;
00805 if ((a<s) || (a>e))
00806 {
00807 s=0;
00808 e=_maxZ;
00809 }
00810 _priorityLoadImageBar->SetStartEndActualMax(s,e,a,0,_maxZ);
00811 }
00812
00813
00814 void LoadRangeImage::Start( )
00815 {
00816
00817 vtkImageData *vol = _marfilesbase->getVolume( )->castVtk();
00818 int dim[3];
00819 vol->GetDimensions(dim);
00820 _maxZ=dim[2]-1;
00821
00822 _startSlice = 0;
00823 _endSlice = _maxZ;
00824
00825 this->SetStartSlice(_startSlice);
00826 this->SetEndSlice(_endSlice);
00827
00828
00829 _bar -> SetSizeData(_maxZ);
00830
00831
00832
00833
00834
00835 _sl_barRange_ROI -> setRepresentedValues (0,_maxZ);
00836 _sl_barRange_ROI -> SetActual(_maxZ/2);
00837 _sl_barRange_ROI -> RefreshForce();
00838
00839
00840 SetStartSlice( 0 );
00841 SetEndSlice( _maxZ );
00842 _toShowSlice = _sl_barRange_ROI->GetActual();
00843 RefreshSlice();
00844
00845
00846 _marfilesbase->ResetLstFileNotReaded();
00847
00848 _Start();
00849 }
00850
00851 void LoadRangeImage::_Start()
00852 {
00853
00854 ResetLoadRegion();
00855 _mythread = new MyThread (_priorityLoadImageBar,_adminThreadEED);
00856 _mythread->Create();
00857 wxCriticalSectionLocker enter(_adminThreadEED->m_critsect);
00858 _adminThreadEED->m_threads.Add(_mythread);
00859 if ( _mythread->Run() != wxTHREAD_NO_ERROR ){
00860 wxLogError(wxT("Can't start thread!"));
00861 }
00862 }
00863
00864 void LoadRangeImage::_Stop( )
00865 {
00866
00867 _adminThreadEED->m_critsect.Enter();
00868
00869 if ( _adminThreadEED->m_threads.IsEmpty() ){
00870
00871 _adminThreadEED->m_critsect.Leave();
00872 } else {
00873 wxThread *_mythread = _adminThreadEED->m_threads.Last();
00874
00875
00876
00877 _adminThreadEED->m_critsect.Leave();
00878 _mythread->Delete();
00879 }
00880
00881 }
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894 void LoadRangeImage::OnSliceActual(wxScrollEvent& event)
00895 {
00896
00897 _toShowSlice = _sl_barRange_ROI->GetActual();
00898 ResetLoadRegion();
00899 RefreshSlice();
00900 }
00901
00902
00903
00904 void LoadRangeImage::OnBtnStart( wxCommandEvent & event )
00905 {
00906
00907
00908
00909
00910 }
00911
00912
00913 void LoadRangeImage::OnBtnEnd( wxCommandEvent & event )
00914 {
00915
00916
00917
00918
00919 }
00920
00921 void LoadRangeImage::SetStartEnd( int start, int end )
00922 {
00923 SetStartSlice( start );
00924 SetEndSlice( end );
00925 ResetLoadRegion();
00926 RefreshSlice();
00927 }
00928
00929
00930 void LoadRangeImage::Reset( )
00931 {
00932 int delta= (int) (_maxZ*0.1);
00933 SetStartSlice( 0 + delta );
00934 SetEndSlice( _maxZ - delta );
00935
00936
00937
00938
00939
00940
00941
00942
00943 RefreshSlice();
00944 }
00945
00946
00947 void LoadRangeImage::SetStartSlice(int value)
00948 {
00949 if (value<_endSlice){
00950 _startSlice = value;
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963 _sl_barRange_ROI->SetMax(_maxZ);
00964 _sl_barRange_ROI->SetStart(_startSlice);
00965 _sl_barRange_ROI->RefreshForce();
00966 }
00967 }
00968
00969 void LoadRangeImage::SetEndSlice(int value)
00970 {
00971 if (value>_startSlice){
00972 _endSlice = value;
00973
00974
00975
00976
00977 _sl_barRange_ROI->SetEnd(_endSlice);
00978 _sl_barRange_ROI->RefreshForce();
00979
00980 }
00981 }
00982
00983
00984 void LoadRangeImage::RefreshSlice()
00985 {
00986
00987 _priorityLoadImageBar->WaitUntil_i_isDone( _toShowSlice );
00988
00989 wxCommandEvent newevent(wxEVT_COMMAND_MENU_SELECTED,12122);
00990 this->GetParent()->ProcessEvent(newevent);
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010 _sl_barRange_ROI->RefreshForce();
01011
01012
01013
01014
01015
01016 Refresh(false);
01017
01018
01019 }
01020
01021 void LoadRangeImage::CallBackOnMouseWheel( wxMouseEvent& event )
01022 {
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045 }
01046
01047 void LoadRangeImage::ForceToFinisReadActiveImages()
01048 {
01049 int s=_startSlice;
01050 int e=_endSlice;
01051
01052 _priorityLoadImageBar->WaitUntil_segment_isDone(s,e,true);
01053
01054
01055
01056 std::string msgLstFile( _marfilesbase->GetMsgLstFile() );
01057 if ( msgLstFile!="")
01058 {
01059 wxDialog *dialog = new wxDialog( this , -1, wxString(_T("The following files doesn't exist:")), wxDefaultPosition, wxSize(550,300), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
01060 wxTextCtrl *textCtrl = new wxTextCtrl(dialog, -1, wxString (msgLstFile.c_str(), wxConvUTF8) ,wxDefaultPosition , wxSize(100,100) , wxTE_MULTILINE | wxTE_READONLY );
01061 textCtrl->SetSelection(0,0);
01062 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL );
01063 sizer->Add( textCtrl , 1, wxALL|wxEXPAND, 0);
01064 dialog->SetAutoLayout(true);
01065 dialog->SetSizer( sizer );
01066 dialog->Layout();
01067
01068
01069 dialog->ShowModal();
01070 }
01071
01072
01073
01074
01075 }
01076
01077 void LoadRangeImage::GetROI( int extent[6] )
01078 {
01079 extent[4]=_startSlice;
01080 extent[5]=_endSlice;
01081 }
01082
01083 void LoadRangeImage::SetActualSlice( int actual )
01084 {
01085
01086 if ( actual > _endSlice ){
01087 actual=_endSlice;
01088 }
01089 if ( actual < _startSlice ){
01090 actual = _startSlice;
01091 }
01092
01093
01094
01095 _sl_barRange_ROI->SetActual( actual);
01096 _toShowSlice=actual;
01097
01098 ResetLoadRegion();
01099 RefreshSlice();
01100 }
01101
01102 int LoadRangeImage::GetActualSlice( )
01103 {
01104 return _toShowSlice;;
01105 }
01106
01107
01108 void LoadRangeImage::ResetActualSlice( )
01109 {
01110 if( reseteableActual )
01111 _toShowSlice = _sl_barRange_ROI->GetActual();
01112 }
01113
01114
01115
01116
01117 void LoadRangeImage::OnBarrange(wxCommandEvent& event)
01118 {
01119
01120 }
01121 void LoadRangeImage::OnActualChange_BarRange(wxCommandEvent& event)
01122 {
01123
01124 _toShowSlice = _sl_barRange_ROI->GetActual();
01125 ResetLoadRegion();
01126 RefreshSlice();
01127 }
01128 void LoadRangeImage::OnStartChange_BarRange(wxCommandEvent& event)
01129 {
01130 reseteableActual =false;
01131 _toShowSlice = _sl_barRange_ROI->GetStart();
01132 SetStartSlice( _sl_barRange_ROI->GetStart() );
01133 ResetLoadRegion();
01134 RefreshSlice();
01135 }
01136
01137 void LoadRangeImage::OnEndChange_BarRange(wxCommandEvent& event)
01138 {
01139 reseteableActual =false;
01140 _toShowSlice = _sl_barRange_ROI->GetEnd();
01141 SetEndSlice( _sl_barRange_ROI->GetEnd() );
01142 ResetLoadRegion();
01143 RefreshSlice();
01144 }
01145 void LoadRangeImage:: OnBarMoved_BarRange (wxCommandEvent& event)
01146 {
01147 SetEndSlice( _sl_barRange_ROI->GetEnd() );
01148 SetStartSlice( _sl_barRange_ROI->GetStart() );
01149 ResetLoadRegion();
01150 RefreshSlice();
01151
01152 }
01153 void LoadRangeImage:: OnSelectionEnd_BarRange (wxCommandEvent& event)
01154 {
01155 reseteableActual = true;
01156 }
01157
01158
01159 void LoadRangeImage:: OnTimer(wxTimerEvent& event)
01160 {
01161
01162 _bar->Refresh(false);
01163 _bar->Update();
01164 RefreshSlice();
01165 }
01166
01167
01168
01169
01170
01171
01172