X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaImageIOWxViewer.cpp;h=22e1b3dbe2c6fd919a28f4af747f0a42708f535e;hb=refs%2Fheads%2Fvtk8itk5wx3-macos;hp=c0180a0afd5b9cb0ff73c57d2190222d7c8ab53b;hpb=3a22e19184c369b130d4caa992a8e98e50c7a0ee;p=creaImageIO.git diff --git a/src/creaImageIOWxViewer.cpp b/src/creaImageIOWxViewer.cpp index c0180a0..22e1b3d 100644 --- a/src/creaImageIOWxViewer.cpp +++ b/src/creaImageIOWxViewer.cpp @@ -1,11 +1,36 @@ +/* +# --------------------------------------------------------------------- +# +# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image +# pour la Santé) +# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton +# Previous Authors : Laurent Guigues, Jean-Pierre Roux +# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil +# +# This software is governed by the CeCILL-B license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-B +# license as circulated by CEA, CNRS and INRIA at the following URL +# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +# or in the file LICENSE.txt. +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-B license and that you accept its terms. +# ------------------------------------------------------------------------ +*/ #include -#include + #include #include #include #include -#include #include #include #include @@ -18,7 +43,22 @@ namespace creaImageIO //===================================================================== + class wxThreadEED3 + { + public: + void Delete() { printf("EED wxThreadEED3::Delete() \n"); } + int Run() { printf("EED wxThreadEED3::Run() \n"); return 0;} + void Pause() { printf("EED wxThreadEED3::Pause() \n"); } + void Create() { printf("EED wxThreadEED3::Create() \n"); } + bool IsAlive() { printf("EED wxThreadEED3::IsAlive() \n"); return false; } + bool TestDestroy() { printf("EED wxThreadEED3::TestDestroy() \n"); return false; } + int GetCurrentId() { printf("EED wxThreadEED3::GetCurrentId() \n"); return -999; } + }; + + //===================================================================== +//EED 2018-08-20 +// class WxViewerPlayer: public wxThreadEED3 class WxViewerPlayer: public wxThread { public: @@ -53,21 +93,20 @@ namespace creaImageIO size) { wxMutexLocker lock(mMutex); - GimmickDebugMessage(6,"WxViewer::WxViewer" - <UseCaptureMouseOn(); mViewer = vtkImageViewer2::New(); mViewer->SetupInteractor ( mInteractor ); - mCurrent = 0; - mPlayer = 0; + mCurrent = 0; + mPlayer = NULL; // Grid to place checkbox and slider mflexSizer = new wxFlexGridSizer(1,2,1,1); @@ -97,8 +136,7 @@ namespace creaImageIO WxViewer::~WxViewer() { wxMutexLocker lock(mMutex); - GimmickDebugMessage(6,"WxViewer::~WxViewer" - <SetMax(pointers.size()); + mslide->SetMax((int)pointers.size()); + mslide->SetMin(1); // Refresh don't work, TO MODIFY mslide->Refresh(); mslide->ClearTicks(); @@ -132,11 +171,8 @@ namespace creaImageIO void WxViewer::ShowNextImage() { - - - mMutex.Unlock(); + mMutex.Unlock(); wxMutexLocker lock(mMutex); - GimmickMessage(2,"WxViewer::ShowNextImage() " < iph = imagePointers[mCurrent]; @@ -170,8 +204,8 @@ namespace creaImageIO mLastImageShown = currIm; } mCurrent++; - } - } + } // if mCurrent + } // if imagePointers } //================================================================ @@ -182,20 +216,40 @@ namespace creaImageIO <SetInput(im); +#else + mViewer->SetInputData(im); +#endif mViewer->SetSlice( 0 ); int x1,x2,y1,y2,z1,z2; double spx,spy,spz; +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 im->Update(); +#else + // ... +#endif + //std::cout << "in WxViewer::ShowImage PrintSelf() ="; //im->PrintSelf(std::cout, vtkIndent(2)); im->GetSpacing(spx,spy,spz); //im->GetExtent (x1,x2,y1,y2,z1,z2); // JPR + + +//EED 2017-01-01 Migration VTK7 +#if VTK_MAJOR_VERSION <= 5 im->GetWholeExtent (x1,x2,y1,y2,z1,z2); +#else + im->GetExtent (x1,x2,y1,y2,z1,z2); +#endif + + /* std::cout << "in WxViewer::ShowImage GetWholeExtent ext ="; std::cout << " [x1]=" << x1; @@ -232,6 +286,15 @@ std::cout << std::endl; mViewer->SetColorLevel(0.5 * (range[1] + range[0])); mViewer->GetRenderer()->ResetCamera(); + + //EED 21 mars 2012 FLIP problem ..PLOP.. + vtkCamera *camera =mViewer->GetRenderer()->GetActiveCamera(); + camera->SetViewUp ( 0 , -1 , 0 ); + camera->SetPosition ((x1+x2)/2 , (y1+y2)/2 , -10000); + camera->SetFocalPoint ((x1+x2)/2 , (y1+y2)/2 , 0 ); + camera->SetParallelScale( (x2-x1)/3.0 ); + + double bounds[6]; mViewer->GetRenderer()->ComputeVisiblePropBounds(bounds); @@ -245,14 +308,13 @@ std::cout << std::endl; //================================================================ bool WxViewer::RefreshIfNecessary() { - if (mNeedRefresh) - { - GimmickDebugMessage(10,"WxViewer : Refreshing"<Render(); - mNeedRefresh = false; - return true; - } + if (mNeedRefresh==true) + { + GimmickDebugMessage(10,"WxViewer : Refreshing"<Render(); + mNeedRefresh = false; + return true; + } return false; } //================================================================ @@ -261,9 +323,10 @@ std::cout << std::endl; void WxViewer::StopPlayer() { wxMutexLocker lock(mMutex); - if (mPlayer==0 ) return; + if (mPlayer==NULL ) return; mPlayer->Delete(); - mPlayer=0; + mPlayer=NULL; + mMutex.Unlock(); } //================================================================ @@ -273,15 +336,13 @@ std::cout << std::endl; if(mcheck->IsChecked()) { // wxMutexLocker lock(mMutex); - if (mPlayer != 0) return; + if (mPlayer != NULL) return; mPlayer = new WxViewerPlayer(this); mPlayer->Create(); mPlayer->Run(); - } - else - { + } else { ShowNextImage(); - } + } // if } //================================================================ @@ -294,7 +355,7 @@ std::cout << std::endl; { mPlayer->Pause(); mPlayer->Delete(); - mPlayer = 0; + mPlayer = NULL; } StartPlayer(); } @@ -305,7 +366,7 @@ std::cout << std::endl; void WxViewer::OnSlide(wxCommandEvent &Event) { - mCurrent = mslide->GetValue(); + mCurrent = mslide->GetValue() -1; StartPlayer(); } //================================================================