1 /*=========================================================================
\r
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
\r
5 - University of LYON http://www.universite-lyon.fr/
\r
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
\r
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
\r
9 This software is distributed WITHOUT ANY WARRANTY; without even
\r
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
11 PURPOSE. See the copyright notices for more information.
\r
13 It is distributed under dual licence
\r
15 - BSD See included LICENSE.txt file
\r
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
\r
17 ======================================================================-====*/
\r
19 #include "vvSlicerManager.h"
\r
20 #include "vvSlicer.h"
\r
21 #include "vvImage.h"
\r
22 #include "vvSlicerManagerCommand.h"
\r
23 #include "vvInteractorStyleNavigator.h"
\r
24 #include "vvLandmarks.h"
\r
26 #include "vvBlendImageActor.h"
\r
28 #include <vtkVersion.h>
\r
29 #include <vtkStreamingDemandDrivenPipeline.h>
\r
30 #include <vtkInformation.h>
\r
31 #include <vtkImageActor.h>
\r
32 #include <vtkImageData.h>
\r
33 #include <vtkRenderWindow.h>
\r
34 #include <vtkRendererCollection.h>
\r
35 #include <vtkRenderWindowInteractor.h>
\r
36 #include <vtkImageMapToWindowLevelColors.h>
\r
37 #include <vtkWindowLevelLookupTable.h>
\r
38 #include <vtkColorTransferFunction.h>
\r
39 #include <vtkImageClip.h>
\r
40 #include <vtkLODActor.h>
\r
41 #include <vtkPointData.h>
\r
42 #include <vtksys/SystemTools.hxx>
\r
43 #include <vtkCamera.h>
\r
45 #include <qfileinfo.h>
\r
46 #include <QMessageBox>
\r
47 //----------------------------------------------------------------------------
\r
48 vvSlicerManager::vvSlicerManager(int numberOfSlicers)
\r
51 connect(this, SIGNAL(callAddLandmark(float,float,float,float)), this, SLOT(AddLandmark(float,float,float,float)));
\r
60 mType = vvImageReader::UNDEFINEDIMAGETYPE;
\r
63 mOverlayColor = 130;
\r
65 mFusionOpacity = 30;
\r
66 mFusionThresOpacity = 1;
\r
67 mFusionColorMap = 3;
\r
68 mFusionWindow = 1000;
\r
69 mFusionLevel = 1000;
\r
70 mFusionShowLegend = true;
\r
72 mFusionSequenceInvolvementCode = -1;
\r
73 mFusionSequenceIndexLinkedManager = -1;
\r
74 mFusionSequenceFrameIndex = -1;
\r
75 mFusionSequenceNbFrames = 0;
\r
76 mFusionSequenceSpatialSyncFlag = false;
\r
77 mFusionSequenceTemporalSyncFlag = false;
\r
80 mLinkedId.resize(0);
\r
82 for ( int i = 0; i < numberOfSlicers; i++) {
\r
83 mSlicers.push_back(vtkSmartPointer<vvSlicer>::New());
\r
84 mSlicers[i]->SetSlicerNumber(i);
\r
86 mSelectedSlicer = -1;
\r
88 mPreviousSlice.resize(numberOfSlicers, 0);
\r
89 mPreviousTSlice.resize(numberOfSlicers, 0);
\r
90 mSlicingPreset = WORLD_SLICING;
\r
94 //----------------------------------------------------------------------------
\r
97 //----------------------------------------------------------------------------
\r
98 vvSlicerManager::~vvSlicerManager()
\r
103 //----------------------------------------------------------------------------
\r
106 //------------------------------------------------------------------------------
\r
107 void vvSlicerManager::SetFilename(std::string filename, int number)
\r
109 mFileName = filename;
\r
110 mFileName = vtksys::SystemTools::GetFilenameName(mFileName);
\r
111 mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName));
\r
112 mBaseFileNameNumber = number;
\r
114 mFileName = mBaseFileName;
\r
116 mFileName.append("_"+clitk::toString(number));
\r
118 mFileName.append(vtksys::SystemTools::GetFilenameLastExtension(filename));
\r
120 for(unsigned int i=0; i<mSlicers.size(); i++) {
\r
121 mSlicers[i]->SetFileName(mFileName);//vtksys::SystemTools::GetFilenameWithoutLastExtension(filename));
\r
125 //------------------------------------------------------------------------------
\r
128 //----------------------------------------------------------------------------
\r
129 void vvSlicerManager::AddContour(vvMesh::Pointer contour,bool propagate)
\r
131 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
132 mSlicers[i]->AddContour(contour,propagate);
\r
135 //----------------------------------------------------------------------------
\r
138 //----------------------------------------------------------------------------
\r
139 void vvSlicerManager::ToggleContourSuperposition()
\r
141 for ( unsigned int i = 0; i < mSlicers.size(); i++)
\r
142 mSlicers[i]->ToggleContourSuperposition();
\r
144 //----------------------------------------------------------------------------
\r
146 //----------------------------------------------------------------------------
\r
147 std::string vvSlicerManager::GetListOfAbsoluteFilePathInOneString(const std::string &actorType)
\r
149 vvImageReader *reader = NULL;
\r
151 if(actorType=="image")
\r
153 else if(actorType=="overlay")
\r
154 reader = mOverlayReader;
\r
155 else if(actorType=="fusion")
\r
156 reader = mFusionReader;
\r
157 else if(actorType=="vector")
\r
158 reader = mVectorReader;
\r
159 else if(actorType=="fusionSequence")
\r
160 reader = mFusionSequenceReader;
\r
166 for(unsigned int i=0; i<reader->GetInputFilenames().size(); i++){
\r
167 QFileInfo fileinfo(reader->GetInputFilenames()[i].c_str()); //Do not show the path
\r
170 list += fileinfo.absoluteFilePath().toStdString();
\r
174 //----------------------------------------------------------------------------
\r
177 //----------------------------------------------------------------------------
\r
178 bool vvSlicerManager::SetImage(std::string filename, vvImageReader::LoadedImageType type, int n, unsigned int slice)
\r
181 if (mReader.IsNull())
\r
182 mReader = vvImageReader::New();
\r
183 std::vector<std::string> filenames;
\r
184 filenames.push_back(filename);
\r
185 mReader->SetInputFilenames(filenames);
\r
186 mReader->SetSlice(slice); // Only used for SLICED type
\r
187 mReader->Update(type);
\r
189 SetFilename(filename, n);
\r
190 // mFileName = vtksys::SystemTools::GetFilenameName(mFileName);
\r
191 //mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName));
\r
192 //mBaseFileNameNumber = n;
\r
194 if (mReader->GetLastError().size() == 0) {
\r
195 mImage=mReader->GetOutput();
\r
196 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
197 mSlicers[i]->SetFileName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename));
\r
198 mSlicers[i]->SetImage(mReader->GetOutput());
\r
201 mLastError = mReader->GetLastError();
\r
205 // mFileName.append("_"+clitk::toString(n));
\r
209 //----------------------------------------------------------------------------
\r
212 //----------------------------------------------------------------------------
\r
213 void vvSlicerManager::SetImage(vvImage::Pointer image)
\r
216 for (unsigned int i = 0; i < mSlicers.size(); i++) {
\r
217 mSlicers[i]->SetImage(image);
\r
220 //----------------------------------------------------------------------------
\r
223 //----------------------------------------------------------------------------
\r
224 bool vvSlicerManager::SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n)
\r
227 std::string fileWithoutExtension = vtksys::SystemTools::GetFilenameWithoutExtension(filenames[0]);
\r
228 if (type == vvImageReader::DICOM)
\r
229 fileWithoutExtension += "_dicom";
\r
230 else if (type == vvImageReader::MERGED)
\r
231 fileWithoutExtension += "_merged";
\r
232 else if (type == vvImageReader::MERGEDWITHTIME)
\r
233 fileWithoutExtension += "_merged_wt";
\r
235 mFileName = vtksys::SystemTools::GetFilenameName(mFileName);
\r
236 mFileName = fileWithoutExtension + vtksys::SystemTools::GetFilenameExtension(filenames[0]);
\r
237 if (mReader.IsNull())
\r
238 mReader = vvImageReader::New();
\r
239 mReader->SetInputFilenames(filenames);
\r
240 mReader->Update(type);
\r
242 mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName));
\r
243 mBaseFileNameNumber = n;
\r
245 if (mReader->GetLastError().size() == 0) {
\r
246 mImage=mReader->GetOutput();
\r
247 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
248 mSlicers[i]->SetFileName(fileWithoutExtension);
\r
249 mSlicers[i]->SetImage(mReader->GetOutput());
\r
252 mLastError = mReader->GetLastError();
\r
256 mFileName.append("_"+clitk::toString(n));
\r
260 //----------------------------------------------------------------------------
\r
263 //----------------------------------------------------------------------------
\r
264 bool vvSlicerManager::SetOverlay(std::vector<std::string> filenames,int dim, std::string component, vvImageReader::LoadedImageType type)
\r
266 mOverlayName = filenames[0];
\r
267 mOverlayComponent = component;
\r
268 if (dim > mImage->GetNumberOfDimensions()) {
\r
269 mLastError = " Overlay dimension cannot be greater than reference image!";
\r
272 if (mOverlayReader.IsNull())
\r
273 mOverlayReader = vvImageReader::New();
\r
274 mOverlayReader->SetInputFilenames(filenames);
\r
275 mOverlayReader->Update(type);
\r
276 if (mOverlayReader->GetLastError().size() == 0) {
\r
277 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
278 mSlicers[i]->SetOverlay(mOverlayReader->GetOutput());
\r
281 mLastError = mOverlayReader->GetLastError();
\r
286 //----------------------------------------------------------------------------
\r
289 //----------------------------------------------------------------------------
\r
290 bool vvSlicerManager::SetFusion(std::vector<std::string> filenames,int dim, std::string component, vvImageReader::LoadedImageType type)
\r
292 mFusionName = filenames[0];
\r
293 mFusionComponent = component;
\r
294 if (dim > mImage->GetNumberOfDimensions()) {
\r
295 mLastError = " Fusion dimension cannot be greater than reference image!";
\r
298 if (mFusionReader.IsNull())
\r
299 mFusionReader = vvImageReader::New();
\r
300 mFusionReader->SetInputFilenames(filenames);
\r
301 mFusionReader->Update(type);
\r
302 if (mFusionReader->GetLastError().size() == 0) {
\r
303 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
304 mSlicers[i]->SetFusion(mFusionReader->GetOutput());
\r
307 mLastError = mFusionReader->GetLastError();
\r
310 double *fusRange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
\r
311 mFusionLevel = (fusRange[0]+fusRange[1])/2;
\r
312 mFusionWindow = fusRange[1]-fusRange[0];
\r
316 //----------------------------------------------------------------------------
\r
318 //----------------------------------------------------------------------------
\r
319 //this function is called by vvMainWindow::AddFusionSequence for the primary sequence (CT), while the given files constitute the secondary sequence.
\r
320 bool vvSlicerManager::SetFusionSequence(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type)
\r
322 mFusionSequenceInvolvementCode = 0;
\r
324 mFusionName = filenames[0];
\r
325 mFusionComponent = component;
\r
327 if (dim > mImage->GetNumberOfDimensions()) {
\r
328 mLastError = " Fusion Sequence dimension cannot be greater than reference image!";
\r
332 if (mFusionSequenceReader.IsNull())
\r
333 mFusionSequenceReader = vvImageReader::New();
\r
335 mFusionSequenceReader->SetInputFilenames(filenames);
\r
336 mFusionSequenceReader->Update(type);
\r
339 if (mFusionSequenceReader->GetLastError().size() == 0) {
\r
340 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
341 mSlicers[i]->SetFusion(mFusionSequenceReader->GetOutput(), mFusionSequenceInvolvementCode);
\r
344 mLastError = mFusionSequenceReader->GetLastError();
\r
347 double *fusRange = mFusionSequenceReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
\r
348 mFusionLevel = (fusRange[0]+fusRange[1])/2;
\r
349 mFusionWindow = fusRange[1]-fusRange[0];
\r
351 //store the initial transform matrices of each frame, and reset them to identity
\r
352 mFusionSequenceListInitialTransformMatrices.clear();
\r
353 for (unsigned i=0 ; i<mFusionSequenceReader->GetOutput()->GetTransform().size() ; i++) {
\r
354 AddFusionSequenceInitialTransformMatrices( mFusionSequenceReader->GetOutput()->GetTransform()[i]->GetMatrix() );
\r
355 mFusionSequenceReader->GetOutput()->GetTransform()[i]->Identity();
\r
356 mFusionSequenceReader->GetOutput()->GetTransform()[i]->Update();
\r
359 //adjust the time slider in the overlay panel
\r
360 mFusionSequenceNbFrames = mFusionSequenceReader->GetOutput()->GetTransform().size();
\r
361 mFusionSequenceFrameIndex = std::max<int>( 0, std::min<int>(mFusionSequenceFrameIndex, mFusionSequenceNbFrames));
\r
365 //----------------------------------------------------------------------------
\r
368 //----------------------------------------------------------------------------
\r
369 bool vvSlicerManager::SetVF(std::string filename)
\r
371 if (mVectorReader.IsNull())
\r
372 mVectorReader = vvImageReader::New();
\r
373 mVectorReader->SetInputFilename(filename);
\r
375 if (mType == vvImageReader::IMAGEWITHTIME)
\r
376 mVectorReader->Update(vvImageReader::VECTORFIELDWITHTIME);
\r
378 mVectorReader->Update(vvImageReader::VECTORFIELD);
\r
379 if (mVectorReader->GetLastError().size() != 0) {
\r
380 mLastError = mVectorReader->GetLastError();
\r
383 return SetVF(mVectorReader->GetOutput(),filename);
\r
385 //----------------------------------------------------------------------------
\r
388 //----------------------------------------------------------------------------
\r
389 bool vvSlicerManager::SetVF(vvImage::Pointer vf,std::string filename)
\r
391 if (vf->GetNumberOfDimensions() > mImage->GetNumberOfDimensions()) {
\r
392 mLastError = "Sorry, vector field dimension cannot be greater then reference image.";
\r
395 if (vf->GetNumberOfDimensions() == 4) {
\r
396 if (vf->GetSpacing()[3] != mImage->GetSpacing()[3]) {
\r
397 mLastError = "Sorry, vector field time spacing cannot be different from time spacing of the reference image.";
\r
400 if (vf->GetOrigin()[3] != mImage->GetOrigin()[3]) {
\r
401 mLastError = "Sorry, vector field time origin cannot be different from time origin of the reference image.";
\r
406 mVFName = filename;
\r
407 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
408 mSlicers[i]->SetVF(vf);
\r
412 //----------------------------------------------------------------------------
\r
415 //----------------------------------------------------------------------------
\r
416 vvSlicer* vvSlicerManager::GetSlicer(int i)
\r
418 return mSlicers[i];
\r
420 //----------------------------------------------------------------------------
\r
423 //----------------------------------------------------------------------------
\r
424 void vvSlicerManager::UpdateSlicer(int num, bool state)
\r
426 if (mSlicers[num]->GetImage()) {
\r
427 mSlicers[num]->SetDisplayMode(state);
\r
430 //----------------------------------------------------------------------------
\r
433 //----------------------------------------------------------------------------
\r
434 void vvSlicerManager::SetSlicerWindow(int i, vtkRenderWindow* RW)
\r
436 mSlicers[i]->SetRenderWindow(i,RW);
\r
438 //----------------------------------------------------------------------------
\r
441 //----------------------------------------------------------------------------
\r
442 void vvSlicerManager::SetInteractorStyleNavigator(int i, vtkInteractorStyle* style)
\r
444 vvSlicerManagerCommand *smc = vvSlicerManagerCommand::New();
\r
446 smc->SetSlicerNumber(i);
\r
447 mSlicers[i]->GetRenderWindow()->GetInteractor()->SetInteractorStyle(style);
\r
449 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
450 GetInteractorStyle()->AddObserver(vtkCommand::KeyPressEvent, smc);
\r
451 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
452 GetInteractorStyle()->AddObserver(vtkCommand::WindowLevelEvent, smc);
\r
453 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
454 GetInteractorStyle()->AddObserver(vtkCommand::EndWindowLevelEvent, smc);
\r
455 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
456 GetInteractorStyle()->AddObserver(vtkCommand::StartWindowLevelEvent, smc);
\r
457 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
458 GetInteractorStyle()->AddObserver(vtkCommand::PickEvent, smc);
\r
459 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
460 GetInteractorStyle()->AddObserver(vtkCommand::StartPickEvent, smc);
\r
461 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
462 GetInteractorStyle()->AddObserver(vtkCommand::LeaveEvent, smc);
\r
463 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
464 GetInteractorStyle()->AddObserver(vtkCommand::UserEvent, smc);
\r
465 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
466 GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelForwardEvent, smc);
\r
467 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
468 GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelBackwardEvent, smc);
\r
469 // mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
470 // GetInteractorStyle()->AddObserver(vtkCommand::LeftButtonReleaseEvent, smc);
\r
471 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
472 GetInteractorStyle()->AddObserver(vtkCommand::EndPickEvent, smc);
\r
473 mSlicers[i]->GetRenderWindow()->GetInteractor()->
\r
474 GetInteractorStyle()->AddObserver(vtkCommand::EndInteractionEvent, smc);
\r
477 //----------------------------------------------------------------------------
\r
480 //----------------------------------------------------------------------------
\r
481 void vvSlicerManager::LeftButtonReleaseEvent(int slicer)
\r
483 emit LeftButtonReleaseSignal(slicer);
\r
485 //----------------------------------------------------------------------------
\r
488 //----------------------------------------------------------------------------
\r
489 void vvSlicerManager::EmitMousePositionUpdated(int slicer)
\r
491 emit MousePositionUpdatedSignal(slicer);
\r
493 //----------------------------------------------------------------------------
\r
496 //----------------------------------------------------------------------------
\r
497 void vvSlicerManager::EmitKeyPressed(std::string KeyPress)
\r
499 emit KeyPressedSignal(KeyPress);
\r
501 //----------------------------------------------------------------------------
\r
504 //----------------------------------------------------------------------------
\r
505 void vvSlicerManager::SetSliceOrientation(int slicer, int orientation)
\r
507 mSlicers[slicer]->SetSliceOrientation(orientation);
\r
508 emit UpdateOrientation(slicer, orientation);
\r
510 //----------------------------------------------------------------------------
\r
512 //----------------------------------------------------------------------------
\r
513 int vvSlicerManager::GetTSlice()
\r
515 return mSlicers[0]->GetTSlice();
\r
517 //----------------------------------------------------------------------------
\r
519 //----------------------------------------------------------------------------
\r
520 void vvSlicerManager::SetTSlice(int slice, bool updateLinkedImages)
\r
522 if (!updateLinkedImages) { //for fusionSequence, TMax / MaxCurrentTSlice are irrelevant.
\r
523 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
524 mSlicers[i]->SetTSlice(slice, updateLinkedImages);
\r
532 else if (slice > mSlicers[0]->GetTMax())
\r
533 slice = mSlicers[0]->GetTMax();
\r
535 mLandmarks->SetTime(slice);
\r
536 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
537 if (slice != mSlicers[i]->GetMaxCurrentTSlice()) {
\r
538 mSlicers[i]->SetTSlice(slice, updateLinkedImages);
\r
543 //----------------------------------------------------------------------------
\r
546 //----------------------------------------------------------------------------
\r
547 void vvSlicerManager::SetFusionSequenceTSlice(int slice)
\r
549 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
550 mSlicers[i]->SetFusionSequenceTSlice(slice);
\r
554 //----------------------------------------------------------------------------
\r
557 //----------------------------------------------------------------------------
\r
558 void vvSlicerManager::SetNextTSlice(int originating_slicer)
\r
560 int t = mSlicers[0]->GetMaxCurrentTSlice();
\r
562 if (t > mSlicers[0]->GetTMax())
\r
564 emit UpdateTSlice(originating_slicer,t, mFusionSequenceInvolvementCode);
\r
566 //----------------------------------------------------------------------------
\r
569 //----------------------------------------------------------------------------
\r
570 void vvSlicerManager::SetPreviousTSlice(int originating_slicer)
\r
572 int t = mSlicers[0]->GetMaxCurrentTSlice();
\r
575 t = mSlicers[0]->GetTMax();
\r
576 emit UpdateTSlice(originating_slicer,t, mFusionSequenceInvolvementCode);
\r
578 //----------------------------------------------------------------------------
\r
581 //----------------------------------------------------------------------------
\r
582 void vvSlicerManager::ToggleInterpolation()
\r
584 bool interpolate=!(mSlicers[0]->GetImageActor()->GetInterpolate());
\r
585 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
586 mSlicers[i]->GetImageActor()->SetInterpolate(interpolate);
\r
587 if (mSlicers[i]->GetOverlayActor())
\r
588 mSlicers[i]->GetOverlayActor()->SetInterpolate(interpolate);
\r
589 if (mSlicers[i]->GetFusionActor())
\r
590 mSlicers[i]->GetFusionActor()->SetInterpolate(interpolate);
\r
593 //----------------------------------------------------------------------------
\r
596 //----------------------------------------------------------------------------
\r
597 void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer)
\r
601 else if (tslice > mSlicers[slicer]->GetTMax())
\r
602 tslice = mSlicers[slicer]->GetTMax();
\r
604 mLandmarks->SetTime(tslice);
\r
606 if (mSlicers[slicer]->GetMaxCurrentTSlice() == tslice) return;
\r
608 mSlicers[slicer]->SetTSlice(tslice);
\r
610 if(mSlicingPreset==VOXELS_SLICING) {
\r
611 vtkMatrix4x4 *imageTransformInverse = vtkMatrix4x4::New();
\r
612 mImage->GetTransform()[mSlicers[slicer]->GetTSlice()]->GetInverse(imageTransformInverse);
\r
613 this->GetSlicer(slicer)->GetSlicingTransform()->SetMatrix(imageTransformInverse);
\r
614 imageTransformInverse->Delete();
\r
617 UpdateTSlice(slicer);
\r
619 //----------------------------------------------------------------------------
\r
622 //----------------------------------------------------------------------------
\r
623 void vvSlicerManager::SetColorWindow(double s)
\r
625 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
626 mSlicers[i]->SetColorWindow(s);
\r
629 //----------------------------------------------------------------------------
\r
631 //----------------------------------------------------------------------------
\r
632 void vvSlicerManager::SetColorLevel(double s)
\r
634 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
635 mSlicers[i]->SetColorLevel(s);
\r
638 //----------------------------------------------------------------------------
\r
640 //----------------------------------------------------------------------------
\r
641 void vvSlicerManager::SetOverlayColorWindow(double s)
\r
643 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
644 mSlicers[i]->SetOverlayColorWindow(s);
\r
647 //----------------------------------------------------------------------------
\r
649 //----------------------------------------------------------------------------
\r
650 void vvSlicerManager::SetOverlayColorLevel(double s)
\r
652 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
653 mSlicers[i]->SetOverlayColorLevel(s);
\r
656 //----------------------------------------------------------------------------
\r
658 //----------------------------------------------------------------------------
\r
659 void vvSlicerManager::SetLinkOverlayWindowLevel(bool b)
\r
661 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
662 mSlicers[i]->SetLinkOverlayWindowLevel(b);
\r
665 //----------------------------------------------------------------------------
\r
667 //----------------------------------------------------------------------------
\r
668 void vvSlicerManager::SetCursorAndCornerAnnotationVisibility(int s)
\r
670 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
671 mSlicers[i]->SetCursorVisibility(s);
\r
672 mSlicers[i]->SetCornerAnnotationVisibility(s);
\r
675 //----------------------------------------------------------------------------
\r
677 //----------------------------------------------------------------------------
\r
678 void vvSlicerManager::SetOpacity(int i, double factor)
\r
680 mSlicers[i]->SetOpacity(1/factor);
\r
682 //----------------------------------------------------------------------------
\r
685 //----------------------------------------------------------------------------
\r
686 void vvSlicerManager::UpdateViews(int current,int slicer)
\r
688 double p[3], pt[3];
\r
689 p[0] = mSlicers[slicer]->GetCurrentPosition()[0];
\r
690 p[1] = mSlicers[slicer]->GetCurrentPosition()[1];
\r
691 p[2] = mSlicers[slicer]->GetCurrentPosition()[2];
\r
692 mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(p, pt);
\r
694 double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0])
\r
695 /mSlicers[slicer]->GetInput()->GetSpacing()[0];
\r
696 double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1])
\r
697 /mSlicers[slicer]->GetInput()->GetSpacing()[1];
\r
698 double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])
\r
699 /mSlicers[slicer]->GetInput()->GetSpacing()[2];
\r
700 #if VTK_MAJOR_VERSION <= 5
\r
701 if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0]-0.5 &&
\r
702 x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1]+0.5 &&
\r
703 y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 &&
\r
704 y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3]+0.5 &&
\r
705 z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 &&
\r
706 z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) {
\r
707 mSlicers[slicer]->UpdateCursorPosition();
\r
708 mSlicers[slicer]->SetCursorColor(10,212,255);
\r
709 mSelectedSlicer = slicer;
\r
711 switch (mSlicers[slicer]->GetSliceOrientation()) {
\r
712 case vtkImageViewer2::SLICE_ORIENTATION_XY:
\r
713 if (mSlicers[slicer]->GetSlice() != (int)lrint(z))
\r
714 mSlicers[slicer]->SetSlice((int)lrint(z));
\r
717 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
\r
718 if (mSlicers[slicer]->GetSlice() != (int)lrint(y))
\r
719 mSlicers[slicer]->SetSlice((int)lrint(y));
\r
722 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
\r
723 if (mSlicers[slicer]->GetSlice() != (int)lrint(x))
\r
724 mSlicers[slicer]->SetSlice((int)lrint(x));
\r
727 mSlicers[slicer]->Render();
\r
729 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
730 if (i != (unsigned int)slicer
\r
731 && mSlicers[i]->GetRenderer()->GetDraw()
\r
732 && mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2
\r
733 && mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) {
\r
734 mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice());
\r
735 mSlicers[i]->UpdateCursorPosition();
\r
736 if (current) { //do not display corner annotation if image is the one picked
\r
737 mSlicers[i]->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
\r
738 -VTK_DOUBLE_MAX, mSlicers[slicer]->GetMaxCurrentTSlice());
\r
739 mSlicers[i]->SetCursorColor(255,10,212);
\r
741 mSlicers[i]->SetCursorColor(150,10,282);
\r
743 switch (mSlicers[i]->GetSliceOrientation()) {
\r
744 case vtkImageViewer2::SLICE_ORIENTATION_XY:
\r
745 if (mSlicers[i]->GetSlice() != (int)lrint(z))
\r
746 mSlicers[i]->SetSlice((int)lrint(z));
\r
749 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
\r
750 if (mSlicers[i]->GetSlice() != (int)lrint(y))
\r
751 mSlicers[i]->SetSlice((int)lrint(y));
\r
754 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
\r
755 if (mSlicers[i]->GetSlice() != (int)lrint(x))
\r
756 mSlicers[i]->SetSlice((int)lrint(x));
\r
760 mSlicers[i]->Render();
\r
768 int extentImageReslice[6];
\r
769 mSlicers[slicer]->GetRegisterExtent(extentImageReslice);
\r
770 if (x >= extentImageReslice[0]-0.5 &&
\r
771 x <= extentImageReslice[1]+0.5 &&
\r
772 y >= extentImageReslice[2]-0.5 &&
\r
773 y <= extentImageReslice[3]+0.5 &&
\r
774 z >= extentImageReslice[4]-0.5 &&
\r
775 z <= extentImageReslice[5]+0.5) {
\r
776 mSlicers[slicer]->UpdateCursorPosition();
\r
777 mSlicers[slicer]->SetCursorColor(10,212,255);
\r
778 mSelectedSlicer = slicer;
\r
780 switch (mSlicers[slicer]->GetSliceOrientation()) {
\r
781 case vtkImageViewer2::SLICE_ORIENTATION_XY:
\r
782 if (mSlicers[slicer]->GetSlice() != (int)lrint(z))
\r
783 mSlicers[slicer]->SetSlice((int)lrint(z));
\r
786 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
\r
787 if (mSlicers[slicer]->GetSlice() != (int)lrint(y))
\r
788 mSlicers[slicer]->SetSlice((int)lrint(y));
\r
791 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
\r
792 if (mSlicers[slicer]->GetSlice() != (int)lrint(x))
\r
793 mSlicers[slicer]->SetSlice((int)lrint(x));
\r
796 mSlicers[slicer]->Render();
\r
798 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
799 if (i != (unsigned int)slicer
\r
800 && mSlicers[i]->GetRenderer()->GetDraw()
\r
801 && mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2
\r
802 && mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) {
\r
803 mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice());
\r
804 mSlicers[i]->UpdateCursorPosition();
\r
805 if (current) { //do not display corner annotation if image is the one picked
\r
806 mSlicers[i]->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
\r
807 -VTK_DOUBLE_MAX, mSlicers[slicer]->GetMaxCurrentTSlice());
\r
808 mSlicers[i]->SetCursorColor(255,10,212);
\r
810 mSlicers[i]->SetCursorColor(150,10,282);
\r
812 switch (mSlicers[i]->GetSliceOrientation()) {
\r
813 case vtkImageViewer2::SLICE_ORIENTATION_XY:
\r
814 if (mSlicers[i]->GetSlice() != (int)lrint(z))
\r
815 mSlicers[i]->SetSlice((int)lrint(z));
\r
818 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
\r
819 if (mSlicers[i]->GetSlice() != (int)lrint(y))
\r
820 mSlicers[i]->SetSlice((int)lrint(y));
\r
823 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
\r
824 if (mSlicers[i]->GetSlice() != (int)lrint(x))
\r
825 mSlicers[i]->SetSlice((int)lrint(x));
\r
829 mSlicers[i]->Render();
\r
838 //----------------------------------------------------------------------------
\r
841 //----------------------------------------------------------------------------
\r
842 void vvSlicerManager::UpdateLinked(int slicer)
\r
844 double p[3], pt[3];
\r
845 p[0] = mSlicers[slicer]->GetCurrentPosition()[0];
\r
846 p[1] = mSlicers[slicer]->GetCurrentPosition()[1];
\r
847 p[2] = mSlicers[slicer]->GetCurrentPosition()[2];
\r
848 mSlicers[slicer]->GetSlicingTransform()->GetInverse()->TransformPoint(p, pt);
\r
849 double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0]) / mSlicers[slicer]->GetInput()->GetSpacing()[0];
\r
850 double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1]) / mSlicers[slicer]->GetInput()->GetSpacing()[1];
\r
851 double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2]) / mSlicers[slicer]->GetInput()->GetSpacing()[2];
\r
852 #if VTK_MAJOR_VERSION <= 5
\r
853 if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0]-0.5 &&
\r
854 x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1]+0.5 &&
\r
855 y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 &&
\r
856 y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3]+0.5 &&
\r
857 z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4]-0.5 &&
\r
858 z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]+0.5) {
\r
859 for (std::list<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) {
\r
860 if (this->IsInvolvedInFusionSequence()) {
\r
861 //this SlicerManager is involved in fusionSequence => do not synchronize the times
\r
862 emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], -1);
\r
865 emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice());
\r
870 int extentImageReslice[6];
\r
871 mSlicers[slicer]->GetRegisterExtent(extentImageReslice);
\r
872 if (x >= extentImageReslice[0]-0.5 &&
\r
873 x <= extentImageReslice[1]+0.5 &&
\r
874 y >= extentImageReslice[2]-0.5 &&
\r
875 y <= extentImageReslice[3]+0.5 &&
\r
876 z >= extentImageReslice[4]-0.5 &&
\r
877 z <= extentImageReslice[5]+0.5) {
\r
878 for (std::list<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) {
\r
879 if (this->IsInvolvedInFusionSequence()) {
\r
880 //this SlicerManager is involved in fusionSequence => do not synchronize the times
\r
881 emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], -1);
\r
884 emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice());
\r
890 //----------------------------------------------------------------------------
\r
892 //----------------------------------------------------------------------------
\r
893 void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagate)
\r
895 vtkCamera *refCam = refSlicer->GetRenderer()->GetActiveCamera();
\r
897 double refPosition[3];
\r
898 refCam->GetPosition(refPosition);
\r
899 refPosition[refSlicer->GetSliceOrientation()] = refSlicer->GetSlice() *
\r
900 refSlicer->GetInput()->GetSpacing()[refSlicer->GetSliceOrientation()] +
\r
901 refSlicer->GetInput()->GetOrigin()[refSlicer->GetSliceOrientation()];
\r
903 refSlicer->GetSlicingTransform()->TransformPoint(refPosition, refPosition);
\r
904 mSlicers[0]->GetSlicingTransform()->GetInverse()->TransformPoint(refPosition, refPosition);
\r
906 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
907 vtkCamera *camera = mSlicers[i]->GetRenderer()->GetActiveCamera();
\r
908 camera->SetParallelScale(refCam->GetParallelScale());
\r
910 double position[3], focal[3];
\r
911 camera->GetPosition(position);
\r
912 camera->GetFocalPoint(focal);
\r
914 for(int j=0; j<3; j++) {
\r
915 if(j!=mSlicers[i]->GetSliceOrientation()) {
\r
916 position[j] = refPosition[j];
\r
917 focal[j] = refPosition[j];
\r
921 camera->SetFocalPoint(focal);
\r
922 camera->SetPosition(position);
\r
925 mSlicers[i]->ForceUpdateDisplayExtent();
\r
930 for (std::list<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++)
\r
931 emit UpdateLinkedNavigation(*i, this, refSlicer);
\r
933 //----------------------------------------------------------------------------
\r
935 //----------------------------------------------------------------------------
\r
936 double vvSlicerManager::GetColorWindow() const
\r
938 if (mSlicers.size())
\r
939 return mSlicers[0]->GetColorWindow();
\r
942 //----------------------------------------------------------------------------
\r
945 //----------------------------------------------------------------------------
\r
946 double vvSlicerManager::GetColorLevel() const
\r
948 if (mSlicers.size())
\r
949 return mSlicers[0]->GetColorLevel();
\r
952 //----------------------------------------------------------------------------
\r
954 //----------------------------------------------------------------------------
\r
955 double vvSlicerManager::GetOverlayColorWindow() const
\r
957 if (mSlicers.size())
\r
958 return mSlicers[0]->GetOverlayColorWindow();
\r
961 //----------------------------------------------------------------------------
\r
963 //----------------------------------------------------------------------------
\r
964 double vvSlicerManager::GetOverlayColorLevel() const
\r
966 if (mSlicers.size())
\r
967 return mSlicers[0]->GetOverlayColorLevel();
\r
970 //----------------------------------------------------------------------------
\r
972 //----------------------------------------------------------------------------
\r
973 bool vvSlicerManager::GetLinkOverlayWindowLevel() const
\r
975 if (mSlicers.size())
\r
976 return mSlicers[0]->GetLinkOverlayWindowLevel();
\r
979 //----------------------------------------------------------------------------
\r
981 //------------------------------------------------------------------------------
\r
982 void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType)
\r
984 if(actorType == "image")
\r
985 for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
\r
986 this->GetImage()->GetTransform()[i]->Identity();
\r
987 else if(actorType == "overlay")
\r
988 for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
\r
989 this->GetSlicer(0)->GetOverlay()->GetTransform()[i]->Identity();
\r
990 else if(actorType == "fusion")
\r
991 for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
\r
992 this->GetSlicer(0)->GetFusion()->GetTransform()[i]->Identity();
\r
993 else if(actorType == "fusionSequence") //TODO: Check what should really be done here
\r
994 for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
\r
995 this->GetSlicer(0)->GetFusion()->GetTransform()[i]->Identity();
\r
996 else if(actorType == "vf")
\r
997 for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)
\r
998 this->GetVF()->GetTransform()[i]->Identity();
\r
1002 for(int i=0; i< this->GetNumberOfSlicers(); i++){
\r
1003 this->GetSlicer(i)->ForceUpdateDisplayExtent();
\r
1004 this->GetSlicer(i)->ResetCamera();
\r
1005 this->GetSlicer(i)->Render();
\r
1008 //------------------------------------------------------------------------------
\r
1010 //----------------------------------------------------------------------------
\r
1011 void vvSlicerManager::Render()
\r
1013 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
1014 mSlicers[i]->Render();
\r
1017 //----------------------------------------------------------------------------
\r
1020 //----------------------------------------------------------------------------
\r
1021 void vvSlicerManager::GenerateDefaultLookupTable()
\r
1023 SetPreset(mPreset);
\r
1024 SetColorMap(mColorMap);
\r
1026 //----------------------------------------------------------------------------
\r
1029 //----------------------------------------------------------------------------
\r
1030 void vvSlicerManager::Reload()
\r
1032 mReader->Update(mType);
\r
1033 mImage=mReader->GetOutput();
\r
1034 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
1035 mSlicers[i]->SetImage(mImage);
\r
1038 //if this image is the primary sequence of a fusion sequence, then the main transform matrix should be updated.
\r
1039 if (this->IsMainSequenceOfFusionSequence()) {
\r
1040 SetFusionSequenceMainTransformMatrix( mImage->GetTransform()[0]->GetMatrix() );
\r
1043 //----------------------------------------------------------------------------
\r
1046 //----------------------------------------------------------------------------
\r
1047 void vvSlicerManager::ReloadFusion()
\r
1049 mFusionReader->Update(mImage->GetNumberOfDimensions(),mFusionComponent.c_str(),mType);
\r
1051 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
1052 mSlicers[i]->SetFusion(mFusionReader->GetOutput());
\r
1053 mSlicers[i]->Render();
\r
1056 //----------------------------------------------------------------------------
\r
1058 //----------------------------------------------------------------------------
\r
1059 //the secondary sequence is being reloaded.
\r
1060 void vvSlicerManager::ReloadFusionSequence()
\r
1062 // this is to keep the slice thickness, which needs to be artificially increased for visualization
\r
1063 double sp_x, sp_y, sp_z;
\r
1064 this->GetImage()->GetVTKImages()[0]->GetSpacing(sp_x, sp_y, sp_z);
\r
1066 mFusionSequenceReader->Update(mImage->GetNumberOfDimensions(),mFusionComponent.c_str(),vvImageReader::MERGEDWITHTIME);
\r
1068 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
1069 mSlicers[i]->SetFusion(mFusionSequenceReader->GetOutput(), 1);
\r
1070 mSlicers[i]->Render();
\r
1073 //Update the slider
\r
1074 mFusionSequenceNbFrames = mFusionSequenceReader->GetOutput()->GetTransform().size();
\r
1075 if (mFusionSequenceFrameIndex>=mFusionSequenceNbFrames) {
\r
1076 mFusionSequenceFrameIndex=0;
\r
1079 //Update the list of initial transforms
\r
1080 mFusionSequenceListInitialTransformMatrices.clear();
\r
1081 for (unsigned i=0 ; i<mFusionSequenceNbFrames ; i++) {
\r
1082 this->AddFusionSequenceInitialTransformMatrices( mFusionSequenceReader->GetOutput()->GetTransform()[i]->GetMatrix() );
\r
1085 // also update the slice thickness
\r
1086 for (unsigned i=0 ; i<this->GetImage()->GetTransform().size() ; i++) {
\r
1087 sp_x = this->GetImage()->GetVTKImages()[i]->GetSpacing()[0];
\r
1088 sp_y = this->GetImage()->GetVTKImages()[i]->GetSpacing()[1];
\r
1089 this->GetImage()->GetVTKImages()[i]->SetSpacing( sp_x, sp_y, sp_z);
\r
1093 //----------------------------------------------------------------------------
\r
1096 //----------------------------------------------------------------------------
\r
1097 void vvSlicerManager::ReloadOverlay()
\r
1099 mOverlayReader->Update(mImage->GetNumberOfDimensions(),mOverlayComponent.c_str(),mType);
\r
1100 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
1101 mSlicers[i]->SetOverlay(mOverlayReader->GetOutput());
\r
1102 mSlicers[i]->Render();
\r
1105 //----------------------------------------------------------------------------
\r
1108 //----------------------------------------------------------------------------
\r
1109 void vvSlicerManager::ReloadVF()
\r
1111 mVectorReader->Update(vvImageReader::VECTORFIELD); //deletes the old images through the VF::Init() function
\r
1112 mVF=mVectorReader->GetOutput();
\r
1113 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
1114 mSlicers[i]->SetVF(mVF);
\r
1115 mSlicers[i]->Render();
\r
1118 //----------------------------------------------------------------------------
\r
1121 //----------------------------------------------------------------------------
\r
1122 void vvSlicerManager::RemoveActor(const std::string& actor_type, int overlay_index)
\r
1124 if (actor_type =="overlay")
\r
1125 mOverlayReader = NULL;
\r
1127 if (actor_type =="fusion")
\r
1128 mFusionReader = NULL;
\r
1130 if (actor_type =="fusionSequence") {
\r
1131 mFusionSequenceReader = NULL;
\r
1134 for (unsigned int i = 0; i < mSlicers.size(); i++)
\r
1135 mSlicers[i]->RemoveActor(actor_type,overlay_index);
\r
1137 if (actor_type=="vector") {
\r
1139 mVectorReader=NULL;
\r
1142 //----------------------------------------------------------------------------
\r
1145 //----------------------------------------------------------------------------
\r
1146 void vvSlicerManager::RemoveActors()
\r
1148 ///This method leaks a few objects. See RemoveActor for what a
\r
1149 ///correct implementation would look like
\r
1150 //DS -> probably due to the reader (now released in the
\r
1151 //RemoveActor() function. (I hope)
\r
1152 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
1153 mSlicers[i]->SetDisplayMode(0);
\r
1154 mSlicers[i]->GetRenderer()->RemoveActor(mSlicers[i]->GetImageActor());
\r
1157 //----------------------------------------------------------------------------
\r
1160 //----------------------------------------------------------------------------
\r
1161 void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer)
\r
1163 // int view = mSlicers[slicer]->GetSliceOrientation();
\r
1164 // int slice = mSlicers[slicer]->GetSlice();
\r
1165 double x = mSlicers[slicer]->GetCursorPosition()[0];
\r
1166 double y = mSlicers[slicer]->GetCursorPosition()[1];
\r
1167 double z = mSlicers[slicer]->GetCursorPosition()[2];
\r
1168 double X = (x - mSlicers[slicer]->GetInput()->GetOrigin()[0])/
\r
1169 mSlicers[slicer]->GetInput()->GetSpacing()[0];
\r
1170 double Y = (y - mSlicers[slicer]->GetInput()->GetOrigin()[1])/
\r
1171 mSlicers[slicer]->GetInput()->GetSpacing()[1];
\r
1172 double Z = (z - mSlicers[slicer]->GetInput()->GetOrigin()[2])/
\r
1173 mSlicers[slicer]->GetInput()->GetSpacing()[2];
\r
1174 double xyz[3], xyzTransform[3];
\r
1178 mSlicers[slicer]->GetConcatenatedTransform()->TransformPoint(xyz, xyzTransform);
\r
1179 double XTransform = (xyzTransform[0] - mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetOrigin()[0])/
\r
1180 mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetSpacing()[0];
\r
1181 double YTransform = (xyzTransform[1] - mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetOrigin()[1])/
\r
1182 mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetSpacing()[1];
\r
1183 double ZTransform = (xyzTransform[2] - mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetOrigin()[2])/
\r
1184 mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetSpacing()[2];
\r
1185 double value = -VTK_DOUBLE_MAX;
\r
1186 int displayVec = 0;
\r
1187 double xVec=0, yVec=0, zVec=0, valueVec=0;
\r
1188 int displayOver = 0;
\r
1189 int displayFus = 0;
\r
1190 double valueOver=0, valueFus=0;
\r
1191 #if VTK_MAJOR_VERSION <= 5
\r
1192 if (XTransform >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] &&
\r
1193 XTransform <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] &&
\r
1194 YTransform >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] &&
\r
1195 YTransform <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&
\r
1196 ZTransform >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] &&
\r
1197 ZTransform <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {
\r
1199 value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);
\r
1201 if (mSlicers[slicer]->GetVFActor() ) {
\r
1203 unsigned int currentTime = mSlicers[slicer]->GetMaxCurrentTSlice();
\r
1204 vtkImageData *vf = NULL;
\r
1206 if (mSlicers[slicer]->GetVF()->GetVTKImages().size() > currentTime)
\r
1207 vf = mSlicers[slicer]->GetVF()->GetVTKImages()[currentTime];
\r
1209 vf = mSlicers[slicer]->GetVF()->GetVTKImages()[0];
\r
1212 double Xvf = (x - vf->GetOrigin()[0])/ vf->GetSpacing()[0];
\r
1213 double Yvf = (y - vf->GetOrigin()[1])/ vf->GetSpacing()[1];
\r
1214 double Zvf = (z - vf->GetOrigin()[2])/ vf->GetSpacing()[2];
\r
1215 xVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 0);
\r
1216 yVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 1);
\r
1217 zVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 2);
\r
1218 valueVec = sqrt(xVec*xVec + yVec*yVec + zVec*zVec);
\r
1221 if (mSlicers[slicer]->GetOverlayActor() ) {
\r
1223 vtkImageData *overlay = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetOverlayMapper()->GetInput());
\r
1224 double Xover = (x - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0];
\r
1225 double Yover = (y - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1];
\r
1226 double Zover = (z - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2];
\r
1227 valueOver = this->GetScalarComponentAsDouble(overlay, Xover, Yover, Zover);
\r
1230 if ( mSlicers[slicer]->GetFusionActor() ) {
\r
1232 vtkImageData *fusion = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput());
\r
1233 double Xover = (x - fusion->GetOrigin()[0]) / fusion->GetSpacing()[0];
\r
1234 double Yover = (y - fusion->GetOrigin()[1]) / fusion->GetSpacing()[1];
\r
1235 double Zover = (z - fusion->GetOrigin()[2]) / fusion->GetSpacing()[2];
\r
1236 valueFus = this->GetScalarComponentAsDouble(fusion, Xover, Yover, Zover);
\r
1238 else if (this->IsInvolvedInFusionSequence()) {
\r
1239 //if the cursor moves over the 'independent' version of the secondary sequence
\r
1240 //do not update the panel, just keep it as it is.
\r
1242 valueFus = std::numeric_limits<double>::quiet_NaN();
\r
1245 emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(),
\r
1246 x,y,z,XTransform,YTransform,ZTransform,value);
\r
1247 emit UpdateVector(displayVec,xVec, yVec, zVec, valueVec);
\r
1248 emit UpdateOverlay(displayOver,valueOver,value);
\r
1249 emit UpdateFusion(displayFus,valueFus);
\r
1252 int extentImageReslice[6];
\r
1253 mSlicers[slicer]->GetRegisterExtent(extentImageReslice);
\r
1254 if (XTransform >= extentImageReslice[0] &&
\r
1255 XTransform <= extentImageReslice[1] &&
\r
1256 YTransform >= extentImageReslice[2] &&
\r
1257 YTransform <= extentImageReslice[3] &&
\r
1258 ZTransform >= extentImageReslice[4] &&
\r
1259 ZTransform <= extentImageReslice[5]) {
\r
1261 value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);
\r
1263 if (mSlicers[slicer]->GetVFActor() ) {
\r
1265 unsigned int currentTime = mSlicers[slicer]->GetMaxCurrentTSlice();
\r
1266 vtkImageData *vf = NULL;
\r
1268 if (mSlicers[slicer]->GetVF()->GetVTKImages().size() > currentTime)
\r
1269 vf = mSlicers[slicer]->GetVF()->GetVTKImages()[currentTime];
\r
1271 vf = mSlicers[slicer]->GetVF()->GetVTKImages()[0];
\r
1274 double Xvf = (x - vf->GetOrigin()[0])/ vf->GetSpacing()[0];
\r
1275 double Yvf = (y - vf->GetOrigin()[1])/ vf->GetSpacing()[1];
\r
1276 double Zvf = (z - vf->GetOrigin()[2])/ vf->GetSpacing()[2];
\r
1277 xVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 0);
\r
1278 yVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 1);
\r
1279 zVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 2);
\r
1280 valueVec = sqrt(xVec*xVec + yVec*yVec + zVec*zVec);
\r
1283 if (mSlicers[slicer]->GetOverlayActor() ) {
\r
1285 vtkImageData *overlay = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetOverlayMapper()->GetInput());
\r
1286 double Xover = (x - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0];
\r
1287 double Yover = (y - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1];
\r
1288 double Zover = (z - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2];
\r
1289 valueOver = this->GetScalarComponentAsDouble(overlay, Xover, Yover, Zover);
\r
1292 if ( mSlicers[slicer]->GetFusionActor() ) {
\r
1294 vtkImageData *fusion = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput());
\r
1295 double Xover = (x - fusion->GetOrigin()[0]) / fusion->GetSpacing()[0];
\r
1296 double Yover = (y - fusion->GetOrigin()[1]) / fusion->GetSpacing()[1];
\r
1297 double Zover = (z - fusion->GetOrigin()[2]) / fusion->GetSpacing()[2];
\r
1298 valueFus = this->GetScalarComponentAsDouble(fusion, Xover, Yover, Zover);
\r
1300 else if (this->IsInvolvedInFusionSequence()) {
\r
1301 //if the cursor moves over the 'independent' version of the secondary sequence
\r
1302 //do not update the panel, just keep it as it is.
\r
1304 valueFus = std::numeric_limits<double>::quiet_NaN();
\r
1307 emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(),
\r
1308 x,y,z,XTransform,YTransform,ZTransform,value);
\r
1309 emit UpdateVector(displayVec,xVec, yVec, zVec, valueVec);
\r
1310 emit UpdateOverlay(displayOver,valueOver,value);
\r
1311 emit UpdateFusion(displayFus,valueFus);
\r
1315 //----------------------------------------------------------------------------
\r
1318 //----------------------------------------------------------------------------
\r
1319 void vvSlicerManager::Activated()
\r
1321 emit currentImageChanged(mId);
\r
1323 //----------------------------------------------------------------------------
\r
1326 //----------------------------------------------------------------------------
\r
1327 void vvSlicerManager::Picked()
\r
1329 emit currentPickedImageChanged(mId);
\r
1331 //----------------------------------------------------------------------------
\r
1334 //----------------------------------------------------------------------------
\r
1335 void vvSlicerManager::UpdateWindowLevel()
\r
1337 emit WindowLevelChanged();
\r
1339 //----------------------------------------------------------------------------
\r
1342 //----------------------------------------------------------------------------
\r
1343 void vvSlicerManager::UpdateSlice(int slicer)
\r
1345 if (mPreviousSlice[slicer] == mSlicers[slicer]->GetSlice()) {
\r
1346 //DD("============= NOTHING");
\r
1349 emit UpdateSlice(slicer, mSlicers[slicer]->GetSlice());
\r
1350 mSlicers[slicer]->Render(); // DS <-- I add this, this could/must be the only Render ...
\r
1351 mPreviousSlice[slicer] = mSlicers[slicer]->GetSlice();
\r
1353 //----------------------------------------------------------------------------
\r
1356 //----------------------------------------------------------------------------
\r
1357 void vvSlicerManager::UpdateTSlice(int slicer)
\r
1359 int slice = mSlicers[slicer]->GetSlice();
\r
1361 int tslice = mSlicers[slicer]->GetMaxCurrentTSlice();
\r
1362 //if (this->IsInvolvedInFusionSequence()) tslice = mSlicers[slicer]->GetTSlice(); //actually, this is handled by the Slicer
\r
1364 if (mPreviousSlice[slicer] == slice) {
\r
1365 if (mPreviousTSlice[slicer] == tslice) {
\r
1366 // DD("************** NOTHING ***********");
\r
1370 mPreviousSlice[slicer] = slice;
\r
1371 mPreviousTSlice[slicer] = tslice;
\r
1373 emit UpdateTSlice(slicer, tslice, mFusionSequenceInvolvementCode);
\r
1375 //----------------------------------------------------------------------------
\r
1378 //----------------------------------------------------------------------------
\r
1379 void vvSlicerManager::UpdateSliceRange(int slicer)
\r
1381 emit UpdateSliceRange(slicer,
\r
1382 mSlicers[slicer]->GetSliceRange()[0], mSlicers[slicer]->GetSliceRange()[1],
\r
1383 0,mSlicers[slicer]->GetTMax());
\r
1385 //----------------------------------------------------------------------------
\r
1387 //----------------------------------------------------------------------------
\r
1388 void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset)
\r
1390 if(mSlicingPreset==preset)
\r
1393 vtkMatrix4x4 *imageTransformInverse = vtkMatrix4x4::New();
\r
1394 mImage->GetTransform()[this->GetTSlice()]->GetInverse(imageTransformInverse);
\r
1396 for(int i=0; i< this->GetNumberOfSlicers(); i++){
\r
1397 vvSlicer *s = this->GetSlicer(i);
\r
1400 case WORLD_SLICING:
\r
1401 s->GetSlicingTransform()->Identity();
\r
1403 case VOXELS_SLICING:
\r
1404 s->GetSlicingTransform()->SetMatrix(imageTransformInverse);
\r
1407 imageTransformInverse->Delete();
\r
1410 s->ForceUpdateDisplayExtent();
\r
1411 #if VTK_MAJOR_VERSION <= 5
\r
1412 s->SetSlice((s->GetInput()->GetWholeExtent()[s->GetSliceOrientation()*2+1]
\r
1413 +s->GetInput()->GetWholeExtent()[s->GetSliceOrientation()*2])/2.0);
\r
1415 int extentImageReslice[6];
\r
1416 s->GetRegisterExtent(extentImageReslice);
\r
1417 s->SetSlice((extentImageReslice[s->GetSliceOrientation()*2+1]
\r
1418 +extentImageReslice[s->GetSliceOrientation()*2])/2.0);
\r
1424 imageTransformInverse->Delete();
\r
1425 mSlicingPreset = preset;
\r
1428 //----------------------------------------------------------------------------
\r
1430 //----------------------------------------------------------------------------
\r
1431 void vvSlicerManager::SetPreset(int preset)
\r
1434 //vtkLookupTable* LUT = static_cast<vtkLookupTable*>(mSlicers[0]->GetWindowLevel()->GetLookupTable());
\r
1435 double window = mSlicers[0]->GetColorWindow();
\r
1436 double level = mSlicers[0]->GetColorLevel();
\r
1438 std::string component_type=mImage->GetScalarTypeAsITKString();
\r
1442 mImage->GetScalarRange(range);
\r
1443 window = range[1] - range[0];
\r
1444 level = (range[1] + range[0])* 0.5;
\r
1446 case WL_HOUNSFIELD:
\r
1450 case WL_SOFTTISSUE:
\r
1454 case WL_LUNGS: // lungs (same as FOCAL)
\r
1472 case WL_VENTILATION:
\r
1478 this->SetColorWindow(window);
\r
1479 this->SetColorLevel(level);
\r
1483 // SetColorMap(-1);
\r
1486 //----------------------------------------------------------------------------
\r
1489 //----------------------------------------------------------------------------
\r
1490 void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey)
\r
1493 if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) {
\r
1494 int t = mSlicers[slicer]->GetFusionTSlice();
\r
1495 this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
\r
1496 this->mSlicers[slicer]->GetFusion()->GetVTKImages()[t],
\r
1497 this->mSlicers[slicer]->GetConcatenatedFusionTransform());
\r
1498 this->SetFusionWindow(max-min);
\r
1499 this->SetFusionLevel(0.5*(min+max));
\r
1500 this->SetColorMap(mColorMap);
\r
1502 else if(bCtrlKey && this->mSlicers[slicer]->GetOverlay()) {
\r
1503 int t = mSlicers[slicer]->GetOverlayTSlice();
\r
1504 this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
\r
1505 this->mSlicers[slicer]->GetOverlay()->GetVTKImages()[t],
\r
1506 this->mSlicers[slicer]->GetConcatenatedOverlayTransform());
\r
1507 if(this->mSlicers[slicer]->GetLinkOverlayWindowLevel()){
\r
1508 this->SetColorWindow(max-min);
\r
1509 this->SetColorLevel(0.5*(min+max));
\r
1511 this->SetOverlayColorWindow(max-min);
\r
1512 this->SetOverlayColorLevel(0.5*(min+max));
\r
1516 int t = this->GetTSlice();
\r
1517 this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max,
\r
1518 this->mSlicers[slicer]->GetImage()->GetVTKImages()[t],
\r
1519 this->mSlicers[slicer]->GetConcatenatedTransform());
\r
1520 this->SetColorWindow(max-min);
\r
1521 this->SetColorLevel(0.5*(min+max));
\r
1522 this->SetPreset(WL_USER);
\r
1525 this->UpdateWindowLevel();
\r
1527 //----------------------------------------------------------------------------
\r
1530 //----------------------------------------------------------------------------
\r
1531 void vvSlicerManager::SetColorMap(int colormap)
\r
1535 range[0] = mSlicers[0]->GetInput()->GetScalarRange()[0];
\r
1536 range[1] = mSlicers[0]->GetInput()->GetScalarRange()[1];
\r
1538 double window = mSlicers[0]->GetWindowLevel()->GetWindow();
\r
1539 double level = mSlicers[0]->GetWindowLevel()->GetLevel();
\r
1541 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(mSlicers[0]->GetWindowLevel()->GetLookupTable());
\r
1542 switch (colormap) {
\r
1550 LUT = vtkLookupTable::New();
\r
1551 LUT->SetValueRange(0,1);
\r
1552 LUT->SetSaturationRange(1,1);
\r
1553 LUT->SetHueRange(0,0.18);
\r
1557 LUT = vtkLookupTable::New();
\r
1558 LUT->SetValueRange(0,1);
\r
1559 LUT->SetSaturationRange(1,1);
\r
1560 LUT->SetHueRange(0.4,0.80);
\r
1564 LUT = vtkLookupTable::New();
\r
1565 LUT->SetValueRange(0.5,1);
\r
1566 LUT->SetSaturationRange(1,1);
\r
1567 LUT->SetHueRange(0.666,0);
\r
1571 LUT = vtkLookupTable::New();
\r
1572 LUT->SetValueRange(1,1);
\r
1573 LUT->SetSaturationRange(1,1);
\r
1574 LUT->SetHueRange(0,1);
\r
1575 LUT->SetAlphaRange(1, 1);
\r
1579 LUT = vtkLookupTable::New();
\r
1580 LUT->SetValueRange(1,1);
\r
1581 LUT->SetSaturationRange(1,1);
\r
1582 LUT->SetHueRange(1,0.1);
\r
1583 //LUT->SetRampToLinear();
\r
1587 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
\r
1590 vtkWindowLevelLookupTable* fusLUT = NULL;
\r
1592 //FUSION / FUSION SEQUENCE
\r
1593 if (mSlicers[0]->GetFusion()) { // && mFusionColorMap >= 0) {
\r
1594 fusLUT = vtkWindowLevelLookupTable::New();
\r
1595 double fusRange [2];
\r
1596 fusRange[0] = mFusionLevel - mFusionWindow/2;
\r
1597 fusRange[1] = mFusionLevel + mFusionWindow/2;
\r
1599 //check whether it is actually a fusionSequence or a fusion, before invoking mFusionReader...
\r
1601 if (this->IsInvolvedInFusionSequence())
\r
1602 frange = mFusionSequenceReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
\r
1604 frange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange();
\r
1606 fusLUT->SetTableRange(frange);
\r
1607 fusLUT->SetValueRange(1,1);
\r
1608 fusLUT->SetSaturationRange(1,1);
\r
1609 fusLUT->SetAlphaRange(1, 1);
\r
1610 fusLUT->SetWindow(mFusionWindow);
\r
1611 fusLUT->SetLevel(mFusionLevel);
\r
1612 if (mFusionColorMap == 1)
\r
1613 fusLUT->SetHueRange(0,0.18);
\r
1614 else if (mFusionColorMap == 2)
\r
1615 fusLUT->SetHueRange(0.4,0.80);
\r
1616 else if (mFusionColorMap == 3)
\r
1618 fusLUT->SetHueRange(0.666, 0);
\r
1619 fusLUT->SetValueRange(0.5, 1);
\r
1621 else if (mFusionColorMap == 4)
\r
1622 fusLUT->SetHueRange(0,1);
\r
1623 else if (mFusionColorMap <= 0)
\r
1625 fusLUT->SetValueRange(0,1);
\r
1626 fusLUT->SetSaturationRange(0,0);
\r
1629 fusLUT->ForceBuild();
\r
1631 // set color table transparency
\r
1632 //double alpha_range=(double)mFusionThresOpacity/10;
\r
1633 double range_end = fusRange[0] + (double)mFusionThresOpacity*(fusRange[1] - fusRange[0])/100;
\r
1634 double curr_value = fusRange[0];
\r
1635 int nvalues = fusLUT->GetNumberOfTableValues();
\r
1636 for (double i = 0; curr_value < range_end; i++) {
\r
1637 fusLUT->GetTableValue(i, v);
\r
1639 //if (curr_value >= -alpha_range && curr_value <= alpha_range) v[3] = pow(fabs(curr_value/alpha_range),2);
\r
1641 fusLUT->SetTableValue(i, v);
\r
1642 curr_value += (fusRange[1] - fusRange[0])/nvalues;
\r
1645 for ( unsigned int i = 0; i < mSlicers.size(); i++) {
\r
1647 if (mSlicers[i]->GetOverlay()) {
\r
1648 vtkLookupTable* supLUT = vtkLookupTable::New();
\r
1649 supLUT->SetTableRange(range[0],range[1]);
\r
1650 supLUT->SetValueRange(1,1);
\r
1651 supLUT->SetSaturationRange(1,1);
\r
1652 supLUT->SetHueRange(double(mOverlayColor)/360,double(mOverlayColor)/360);
\r
1654 vtkLookupTable* invLUT = vtkLookupTable::New();
\r
1655 invLUT->SetTableRange(range[0],range[1]);
\r
1656 invLUT->SetValueRange(1,1);
\r
1657 invLUT->SetSaturationRange(1,1);
\r
1658 invLUT->SetHueRange(double((mOverlayColor+180)%360)/360,double((mOverlayColor+180)%360)/360);
\r
1660 mSlicers[i]->GetWindowLevel()->SetLookupTable(supLUT);
\r
1661 mSlicers[i]->GetOverlayMapper()->SetLookupTable(invLUT);
\r
1664 } else if (mSlicers[i]->GetOverlay()) {
\r
1665 mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT);
\r
1667 mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT);
\r
1670 if (mSlicers[i]->GetFusion()) {
\r
1671 mSlicers[i]->ShowFusionLegend(mFusionShowLegend);
\r
1672 mSlicers[i]->GetFusionMapper()->SetLookupTable(fusLUT);
\r
1673 mSlicers[i]->GetFusionActor()->SetOpacity(double(mFusionOpacity)/100);
\r
1678 if (colormap >= 0)
\r
1679 mColorMap = colormap;
\r
1681 //----------------------------------------------------------------------------
\r
1684 //----------------------------------------------------------------------------
\r
1685 vvLandmarks* vvSlicerManager::GetLandmarks()
\r
1687 if (mLandmarks == NULL) {
\r
1688 mLandmarks = new vvLandmarks(mSlicers[0]->GetTMax()+1);
\r
1689 for (unsigned int i = 0; i < mSlicers.size(); i++)
\r
1690 mSlicers[i]->SetLandmarks(mLandmarks);
\r
1692 return mLandmarks;
\r
1694 //----------------------------------------------------------------------------
\r
1695 void vvSlicerManager::AddNewLandmark(float x,float y,float z,float t)
\r
1697 emit callAddLandmark(x,y,z,t);
\r
1700 //----------------------------------------------------------------------------
\r
1701 void vvSlicerManager::AddLandmark(float x,float y,float z,float t)
\r
1703 double x_index = (x - mSlicers[0]->GetInput()->GetOrigin()[0])/mSlicers[0]->GetInput()->GetSpacing()[0];
\r
1704 double y_index = (y - mSlicers[0]->GetInput()->GetOrigin()[1])/mSlicers[0]->GetInput()->GetSpacing()[1];
\r
1705 double z_index = (z - mSlicers[0]->GetInput()->GetOrigin()[2])/mSlicers[0]->GetInput()->GetSpacing()[2];
\r
1706 #if VTK_MAJOR_VERSION <= 5
\r
1707 if (x_index >= mSlicers[0]->GetInput()->GetWholeExtent()[0]-0.5 &&
\r
1708 x_index <= mSlicers[0]->GetInput()->GetWholeExtent()[1]+0.5 &&
\r
1709 y_index >= mSlicers[0]->GetInput()->GetWholeExtent()[2]-0.5 &&
\r
1710 y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3]+0.5 &&
\r
1711 z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4]-0.5 &&
\r
1712 z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]+0.5) {
\r
1713 double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848
\r
1714 this->GetLandmarks()->AddLandmark(x,y,z,t,value);
\r
1715 emit LandmarkAdded();
\r
1718 int extentImageReslice[6];
\r
1719 mSlicers[0]->GetRegisterExtent(extentImageReslice);
\r
1720 if (x_index >= extentImageReslice[0]-0.5 &&
\r
1721 x_index <= extentImageReslice[1]+0.5 &&
\r
1722 y_index >= extentImageReslice[2]-0.5 &&
\r
1723 y_index <= extentImageReslice[3]+0.5 &&
\r
1724 z_index >= extentImageReslice[4]-0.5 &&
\r
1725 z_index <= extentImageReslice[5]+0.5) {
\r
1726 double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848
\r
1727 this->GetLandmarks()->AddLandmark(x,y,z,t,value);
\r
1728 emit LandmarkAdded();
\r
1732 //----------------------------------------------------------------------------
\r
1734 //----------------------------------------------------------------------------
\r
1735 void vvSlicerManager::AddLandmarkProfile(float x,float y,float z,float t)
\r
1737 double x_index = (x - mSlicers[0]->GetInput()->GetOrigin()[0])/mSlicers[0]->GetInput()->GetSpacing()[0];
\r
1738 double y_index = (y - mSlicers[0]->GetInput()->GetOrigin()[1])/mSlicers[0]->GetInput()->GetSpacing()[1];
\r
1739 double z_index = (z - mSlicers[0]->GetInput()->GetOrigin()[2])/mSlicers[0]->GetInput()->GetSpacing()[2];
\r
1740 #if VTK_MAJOR_VERSION <= 5
\r
1741 if (x_index >= mSlicers[0]->GetInput()->GetWholeExtent()[0]-0.5 &&
\r
1742 x_index <= mSlicers[0]->GetInput()->GetWholeExtent()[1]+0.5 &&
\r
1743 y_index >= mSlicers[0]->GetInput()->GetWholeExtent()[2]-0.5 &&
\r
1744 y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3]+0.5 &&
\r
1745 z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4]-0.5 &&
\r
1746 z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]+0.5) {
\r
1747 double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848
\r
1748 this->GetLandmarks()->AddLandmark(x,y,z,t,value);
\r
1751 int extentImageReslice[6];
\r
1752 mSlicers[0]->GetRegisterExtent(extentImageReslice);
\r
1753 if (x_index >= extentImageReslice[0]-0.5 &&
\r
1754 x_index <= extentImageReslice[1]+0.5 &&
\r
1755 y_index >= extentImageReslice[2]-0.5 &&
\r
1756 y_index <= extentImageReslice[3]+0.5 &&
\r
1757 z_index >= extentImageReslice[4]-0.5 &&
\r
1758 z_index <= extentImageReslice[5]+0.5) {
\r
1759 double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848
\r
1760 this->GetLandmarks()->AddLandmark(x,y,z,t,value);
\r
1764 //----------------------------------------------------------------------------
\r
1766 //----------------------------------------------------------------------------
\r
1767 void vvSlicerManager::PrevImage(int slicer)
\r
1769 emit ChangeImageWithIndexOffset(this, slicer, -1);
\r
1771 //----------------------------------------------------------------------------
\r
1773 //----------------------------------------------------------------------------
\r
1774 void vvSlicerManager::NextImage(int slicer)
\r
1776 emit ChangeImageWithIndexOffset(this, slicer, 1);
\r
1778 //----------------------------------------------------------------------------
\r
1780 //----------------------------------------------------------------------------
\r
1781 void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice)
\r
1783 emit AVerticalSliderHasChanged(slicer, slice);
\r
1786 //----------------------------------------------------------------------------
\r
1788 //----------------------------------------------------------------------------
\r
1789 double vvSlicerManager::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component)
\r
1792 return mSlicers[0]->GetScalarComponentAsDouble(image, X, Y, Z, ix, iy, iz, component);
\r
1794 //----------------------------------------------------------------------------
\r