2 * Progam made by Olivier Bernard, associate professor
3 * at Institut National des Sciences Appliquees (INSA) Lyon,
4 * CREATIS-LRMN Laboratory,
5 * 69621 Villeurbanne, France,
9 #include <vtkRenderer.h>
10 #include <vtkRenderWindow.h>
11 #include "vtkMyInteractorStyleTrackballCameraOpenHeart.h"
17 void vtkMyInteractorStyleTrackballCameraOpenHeart::OnChar()
19 vtkRenderWindowInteractor *rwi = this->Interactor;
20 switch (rwi->GetKeyCode())
24 int val = this->window->GetCurrentFrame();
25 if ( val < (this->window->GetNumberOfFrames()-1) )
26 this->window->scrollBar->setSliderPosition(val+1);
28 this->window->SetFlagLoopEndToBegin(1);
29 this->window->scrollBar->setSliderPosition(0);
35 int val = this->window->GetCurrentFrame();
37 this->window->scrollBar->setSliderPosition(val-1);
39 this->window->SetFlagLoopBeginToEnd(1);
40 this->window->scrollBar->setSliderPosition(this->window->GetNumberOfFrames()-1);
46 /// Deal with the display of a mask overlayed on the volume data
47 this->window->InterpolationManagement();
52 /// Reset the sphere display
53 this->window->DisplayMeshManagement();
58 /// Set the display mode
59 this->window->DisplayModeManagement();
64 this->window->HidePlanModeManagement();
69 this->window->DisplayMainAxisManagement();
78 void vtkMyInteractorStyleTrackballCameraOpenHeart::OnMouseWheelForward()
81 switch ( this->window->GetSelectedButton() ) {
84 this->MoveForwardYZPlan();
89 this->MoveForwardXZPlan();
94 this->MoveForwardXYPlan();
106 void vtkMyInteractorStyleTrackballCameraOpenHeart::OnMouseWheelBackward()
109 switch ( this->window->GetSelectedButton() )
113 this->MoveBackwardYZPlan();
118 this->MoveBackwardXZPlan();
123 this->MoveBackwardXYPlan();
128 this->MoveBackward();
135 void vtkMyInteractorStyleTrackballCameraOpenHeart::MoveForward()
138 /// Get picker position
140 this->GetPickerPosition(pos);
142 /// Go back to the initial coordinate system before reslicing
144 for (int i=0; i<3; i++)
146 this->window->ComputePointBeforeRotation(posXYZ);
148 /// Compute point of interest for checking which plan is selected
150 for (int i=0; i<3; i++)
151 RefX[i] = this->window->GetRendererProperties()->xIPW->GetCenter()[i];
152 this->window->ComputePointBeforeRotation(RefX);
154 for (int i=0; i<3; i++)
155 RefY[i] = this->window->GetRendererProperties()->yIPW->GetCenter()[i];
156 this->window->ComputePointBeforeRotation(RefY);
158 for (int i=0; i<3; i++)
159 RefZ[i] = this->window->GetRendererProperties()->zIPW->GetCenter()[i];
160 this->window->ComputePointBeforeRotation(RefZ);
162 /// Update Slice image
163 if ( this->IsInside(posXYZ) )
166 if ( fabs(posXYZ[0]-RefX[0]) < this->PadSliceDetection[0] )
169 /// Compute corresponding step
170 if ( (posXYZ[1] >= this->Limits[2] ) &&
171 (posXYZ[1] <= this->Limits[3] ) &&
172 (posXYZ[2] >= this->Limits[4] ) &&
173 (posXYZ[2] <= this->Limits[5] ) )
178 /// Compute new slice position
179 double limit = this->Bounds[1];
180 posXYZ[0] += this->Step * this->SpacingImg[0];
181 if ( posXYZ[0] <= limit )
182 this->window->GetRendererProperties()->position[0] += this->Step * this->SpacingImg[0];
184 /// Update Slice text
185 if ( this->window->GetFlagDisplayText() )
187 int slice = (int)( (this->window->GetRendererProperties()->position[0] -
188 this->OriginImg[0]) /
189 this->SpacingImg[0] + 0.5f );
191 strSlice.sprintf("Slice: %d",slice);
192 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
196 this->window->GetRendererProperties()->xIPW->SetSlicePosition(this->window->GetRendererProperties()->position[0]);
197 this->window->GetRendererProperties()->yzIPW->SetSlicePosition(this->window->GetRendererProperties()->position[0]);
198 this->window->GetRenderWindow()->Render();
199 this->window->GetYZRenderer()->ResetCameraClippingRange();
200 this->window->GetRenderWindowYZ()->Render();
203 if ( fabs(posXYZ[1]-RefY[1]) < this->PadSliceDetection[1] )
206 /// Compute corresponding step
207 if ( (posXYZ[0] >= this->Limits[0] ) &&
208 (posXYZ[0] <= this->Limits[1] ) &&
209 (posXYZ[2] >= this->Limits[4] ) &&
210 (posXYZ[2] <= this->Limits[5] ) )
215 /// Compute new slice position
216 double limit = this->Bounds[3];
217 posXYZ[1] += this->Step * this->SpacingImg[1];
218 if ( posXYZ[1] <= limit )
219 this->window->GetRendererProperties()->position[1] += this->Step * this->SpacingImg[1];
221 /// Update Slice text
222 if ( this->window->GetFlagDisplayText() )
224 int slice = (int)( (this->window->GetRendererProperties()->position[1] -
225 this->OriginImg[1]) /
226 this->SpacingImg[1] + 0.5f );
228 strSlice.sprintf("Slice: %d",slice);
229 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
233 this->window->GetRendererProperties()->yIPW->SetSlicePosition(this->window->GetRendererProperties()->position[1]);
234 this->window->GetRendererProperties()->xzIPW->SetSlicePosition(this->window->GetRendererProperties()->position[1]);
235 this->window->GetRenderWindow()->Render();
236 this->window->GetXZRenderer()->ResetCameraClippingRange();
237 this->window->GetRenderWindowXZ()->Render();
240 if ( fabs(posXYZ[2]-RefZ[2]) < this->PadSliceDetection[2] )
243 /// Compute corresponding step
244 if ( (posXYZ[0] >= this->Limits[0] ) &&
245 (posXYZ[0] <= this->Limits[1] ) &&
246 (posXYZ[1] >= this->Limits[2] ) &&
247 (posXYZ[1] <= this->Limits[3] ) )
252 /// Compute new slice position
253 double limit = this->Bounds[5];
254 posXYZ[2] += this->Step * this->SpacingImg[2];
255 if ( posXYZ[2] <= limit )
256 this->window->GetRendererProperties()->position[2] += this->Step * this->SpacingImg[2];
258 /// Update Slice text
259 if ( this->window->GetFlagDisplayText() )
261 int slice = (int)( (this->window->GetRendererProperties()->position[2] -
262 this->OriginImg[2]) /
263 this->SpacingImg[2] + 0.5f );
265 strSlice.sprintf("Slice: %d",slice);
266 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
270 this->window->GetRendererProperties()->zIPW->SetSlicePosition(this->window->GetRendererProperties()->position[2]);
271 this->window->GetRendererProperties()->xyIPW->SetSlicePosition(this->window->GetRendererProperties()->position[2]);
272 this->window->GetRenderWindow()->Render();
273 this->window->GetXYRenderer()->ResetCameraClippingRange();
274 this->window->GetRenderWindowXY()->Render();
279 /// Update text display
280 this->window->UpdateCoords(pos);
285 void vtkMyInteractorStyleTrackballCameraOpenHeart::MoveForwardXYPlan()
288 /// Get picker position
290 this->GetPickerPosition(pos);
292 /// Go back to the initial coordinate system before reslicing
294 for (int i=0; i<3; i++)
296 this->window->ComputePointBeforeRotation(posXYZ);
298 /// Update Slice image
299 if ( this->IsInside(posXYZ) )
301 /// Compute corresponding step
302 if ( (posXYZ[0] >= this->Limits[0] ) &&
303 (posXYZ[0] <= this->Limits[1] ) &&
304 (posXYZ[1] >= this->Limits[2] ) &&
305 (posXYZ[1] <= this->Limits[3] ) )
310 /// Compute new slice position
311 double limit = this->Bounds[5];
312 posXYZ[2] += this->Step * this->window->GetCurrentImageData()->GetSpacing()[2];
313 if ( posXYZ[2] <= limit )
314 this->window->GetRendererProperties()->position[2] += this->Step * this->window->GetCurrentImageData()->GetSpacing()[2];
316 /// Update Slice text
317 if ( this->window->GetFlagDisplayText() )
319 int slice = (int)( (this->window->GetRendererProperties()->position[2] -
320 this->window->GetCurrentImageData()->GetOrigin()[2]) /
321 this->window->GetCurrentImageData()->GetSpacing()[2] + 0.5f );
323 strSlice.sprintf("Slice: %d",slice);
324 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
328 this->window->GetRendererProperties()->zIPW->SetSlicePosition(this->window->GetRendererProperties()->position[2]);
329 this->window->GetRendererProperties()->xyIPW->SetSlicePosition(this->window->GetRendererProperties()->position[2]);
330 this->window->GetRenderWindow()->Render();
331 this->window->GetXYRenderer()->ResetCameraClippingRange();
332 this->window->GetRenderWindowXY()->Render();
339 void vtkMyInteractorStyleTrackballCameraOpenHeart::MoveForwardXZPlan()
342 /// Get picker position
344 this->GetPickerPosition(pos);
346 /// Go back to the initial coordinate system before reslicing
348 for (int i=0; i<3; i++)
350 this->window->ComputePointBeforeRotation(posXYZ);
352 /// Update Slice image
353 if ( this->IsInside(posXYZ) )
355 /// Compute corresponding step
356 if ( (posXYZ[0] >= this->Limits[0] ) &&
357 (posXYZ[0] <= this->Limits[1] ) &&
358 (posXYZ[2] >= this->Limits[4] ) &&
359 (posXYZ[2] <= this->Limits[5] ) )
364 /// Compute new slice position
365 double limit = this->Bounds[3];
366 posXYZ[1] += this->Step * this->window->GetCurrentImageData()->GetSpacing()[1];
367 if ( posXYZ[1] <= limit )
368 this->window->GetRendererProperties()->position[1] += this->Step * this->window->GetCurrentImageData()->GetSpacing()[1];
370 /// Update Slice text
371 if ( this->window->GetFlagDisplayText() )
373 int slice = (int)( (this->window->GetRendererProperties()->position[1] -
374 this->window->GetCurrentImageData()->GetOrigin()[1]) /
375 this->window->GetCurrentImageData()->GetSpacing()[1] + 0.5f );
377 strSlice.sprintf("Slice: %d",slice);
378 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
382 this->window->GetRendererProperties()->yIPW->SetSlicePosition(this->window->GetRendererProperties()->position[1]);
383 this->window->GetRendererProperties()->xzIPW->SetSlicePosition(this->window->GetRendererProperties()->position[1]);
384 this->window->GetRenderWindow()->Render();
385 this->window->GetXZRenderer()->ResetCameraClippingRange();
386 this->window->GetRenderWindowXZ()->Render();
393 void vtkMyInteractorStyleTrackballCameraOpenHeart::MoveForwardYZPlan()
396 /// Get picker position
398 this->GetPickerPosition(pos);
400 /// Go back to the initial coordinate system before reslicing
402 for (int i=0; i<3; i++)
404 this->window->ComputePointBeforeRotation(posXYZ);
406 /// Update Slice image
407 if ( this->IsInside(posXYZ) )
409 /// Compute corresponding step
410 if ( (posXYZ[1] >= this->Limits[2] ) &&
411 (posXYZ[1] <= this->Limits[3] ) &&
412 (posXYZ[2] >= this->Limits[4] ) &&
413 (posXYZ[2] <= this->Limits[5] ) )
418 /// Compute new slice position
419 double limit = this->Bounds[1];
420 posXYZ[0] += this->Step * this->window->GetCurrentImageData()->GetSpacing()[0];
421 if ( posXYZ[0] <= limit )
422 this->window->GetRendererProperties()->position[0] += this->Step * this->window->GetCurrentImageData()->GetSpacing()[0];
424 /// Update Slice text
425 if ( this->window->GetFlagDisplayText() )
427 int slice = (int)( (this->window->GetRendererProperties()->position[0] -
428 this->window->GetCurrentImageData()->GetOrigin()[0]) /
429 this->window->GetCurrentImageData()->GetSpacing()[0] + 0.5f );
431 strSlice.sprintf("Slice: %d",slice);
432 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
436 this->window->GetRendererProperties()->xIPW->SetSlicePosition(this->window->GetRendererProperties()->position[0]);
437 this->window->GetRendererProperties()->yzIPW->SetSlicePosition(this->window->GetRendererProperties()->position[0]);
438 this->window->GetRenderWindow()->Render();
439 this->window->GetYZRenderer()->ResetCameraClippingRange();
440 this->window->GetRenderWindowYZ()->Render();
447 void vtkMyInteractorStyleTrackballCameraOpenHeart::MoveBackwardXYPlan()
450 /// Get picker position
452 this->GetPickerPosition(pos);
454 /// Go back to the initial coordinate system before reslicing
456 for (int i=0; i<3; i++)
458 this->window->ComputePointBeforeRotation(posXYZ);
460 /// Update Slice image
461 if ( this->IsInside(posXYZ) )
463 /// Compute corresponding step
464 if ( (posXYZ[0] >= this->Limits[0] ) &&
465 (posXYZ[0] <= this->Limits[1] ) &&
466 (posXYZ[1] >= this->Limits[2] ) &&
467 (posXYZ[1] <= this->Limits[3] ) )
472 /// Compute new slice position
473 posXYZ[2] -= this->Step * this->window->GetCurrentImageData()->GetSpacing()[2];
474 if ( posXYZ[2] >= 0 )
475 this->window->GetRendererProperties()->position[2] -= this->Step * this->window->GetCurrentImageData()->GetSpacing()[2];
477 /// Update Slice text
478 if ( this->window->GetFlagDisplayText() )
480 int slice = (int)( (this->window->GetRendererProperties()->position[2] -
481 this->window->GetCurrentImageData()->GetOrigin()[2]) /
482 this->window->GetCurrentImageData()->GetSpacing()[2] + 0.5f );
484 strSlice.sprintf("Slice: %d",slice);
485 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
489 this->window->GetRendererProperties()->zIPW->SetSlicePosition(this->window->GetRendererProperties()->position[2]);
490 this->window->GetRendererProperties()->xyIPW->SetSlicePosition(this->window->GetRendererProperties()->position[2]);
491 this->window->GetRenderWindow()->Render();
492 this->window->GetXYRenderer()->ResetCameraClippingRange();
493 this->window->GetRenderWindowXY()->Render();
500 void vtkMyInteractorStyleTrackballCameraOpenHeart::MoveBackwardXZPlan()
503 /// Get picker position
505 this->GetPickerPosition(pos);
507 /// Go back to the initial coordinate system before reslicing
509 for (int i=0; i<3; i++)
511 this->window->ComputePointBeforeRotation(posXYZ);
513 /// Update Slice image
514 if ( this->IsInside(posXYZ) )
516 /// Compute corresponding step
517 if ( (posXYZ[0] >= this->Limits[0] ) &&
518 (posXYZ[0] <= this->Limits[1] ) &&
519 (posXYZ[2] >= this->Limits[4] ) &&
520 (posXYZ[2] <= this->Limits[5] ) )
525 /// Compute new slice position
526 posXYZ[1] -= this->Step * this->window->GetCurrentImageData()->GetSpacing()[1];
527 if ( posXYZ[1] >= 0 )
528 this->window->GetRendererProperties()->position[1] -= this->Step * this->window->GetCurrentImageData()->GetSpacing()[1];
530 /// Update Slice text
531 if ( this->window->GetFlagDisplayText() )
533 int slice = (int)( (this->window->GetRendererProperties()->position[1] -
534 this->window->GetCurrentImageData()->GetOrigin()[1]) /
535 this->window->GetCurrentImageData()->GetSpacing()[1] + 0.5f );
537 strSlice.sprintf("Slice: %d",slice);
538 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
542 this->window->GetRendererProperties()->yIPW->SetSlicePosition(this->window->GetRendererProperties()->position[1]);
543 this->window->GetRendererProperties()->xzIPW->SetSlicePosition(this->window->GetRendererProperties()->position[1]);
544 this->window->GetRenderWindow()->Render();
545 this->window->GetXZRenderer()->ResetCameraClippingRange();
546 this->window->GetRenderWindowXZ()->Render();
553 void vtkMyInteractorStyleTrackballCameraOpenHeart::MoveBackwardYZPlan()
556 /// Get picker position
558 this->GetPickerPosition(pos);
560 /// Go back to the initial coordinate system before reslicing
562 for (int i=0; i<3; i++)
564 this->window->ComputePointBeforeRotation(posXYZ);
566 /// Update Slice image
567 if ( this->IsInside(posXYZ) )
569 /// Compute corresponding step
570 if ( (posXYZ[1] >= this->Limits[2] ) &&
571 (posXYZ[1] <= this->Limits[3] ) &&
572 (posXYZ[2] >= this->Limits[4] ) &&
573 (posXYZ[2] <= this->Limits[5] ) )
578 /// Compute new slice position
579 posXYZ[0] -= this->Step * this->window->GetCurrentImageData()->GetSpacing()[0];
580 if ( posXYZ[0] >= 0 )
581 this->window->GetRendererProperties()->position[0] -= this->Step * this->window->GetCurrentImageData()->GetSpacing()[0];
583 /// Update Slice text
584 if ( this->window->GetFlagDisplayText() )
586 int slice = (int)( (this->window->GetRendererProperties()->position[0] -
587 this->window->GetCurrentImageData()->GetOrigin()[0]) /
588 this->window->GetCurrentImageData()->GetSpacing()[0] + 0.5f );
590 strSlice.sprintf("Slice: %d",slice);
591 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
595 this->window->GetRendererProperties()->xIPW->SetSlicePosition(this->window->GetRendererProperties()->position[0]);
596 this->window->GetRendererProperties()->yzIPW->SetSlicePosition(this->window->GetRendererProperties()->position[0]);
597 this->window->GetRenderWindow()->Render();
598 this->window->GetYZRenderer()->ResetCameraClippingRange();
599 this->window->GetRenderWindowYZ()->Render();
606 void vtkMyInteractorStyleTrackballCameraOpenHeart::MoveBackward()
609 /// Get picker position
611 this->GetPickerPosition(pos);
613 /// Go back to the initial coordinate system before reslicing
615 for (int i=0; i<3; i++)
617 this->window->ComputePointBeforeRotation(posXYZ);
619 /// Compute point of interest for checking which plan is selected
621 for (int i=0; i<3; i++)
622 RefX[i] = this->window->GetRendererProperties()->xIPW->GetCenter()[i];
623 this->window->ComputePointBeforeRotation(RefX);
625 for (int i=0; i<3; i++)
626 RefY[i] = this->window->GetRendererProperties()->yIPW->GetCenter()[i];
627 this->window->ComputePointBeforeRotation(RefY);
629 for (int i=0; i<3; i++)
630 RefZ[i] = this->window->GetRendererProperties()->zIPW->GetCenter()[i];
631 this->window->ComputePointBeforeRotation(RefZ);
633 /// Update Slice image
634 if ( this->IsInside(posXYZ) )
637 if ( fabs(posXYZ[0]-RefX[0]) < this->PadSliceDetection[0] )
640 /// Compute corresponding step
641 if ( (posXYZ[1] >= this->Limits[2] ) &&
642 (posXYZ[1] <= this->Limits[3] ) &&
643 (posXYZ[2] >= this->Limits[4] ) &&
644 (posXYZ[2] <= this->Limits[5] ) )
649 /// Compute new slice position
650 posXYZ[0] -= this->Step * this->SpacingImg[0];
651 if ( posXYZ[0] >= 0 )
652 this->window->GetRendererProperties()->position[0] -= this->Step * this->SpacingImg[0];
654 /// Update Slice text
655 if ( this->window->GetFlagDisplayText() )
657 int slice = (int)( (this->window->GetRendererProperties()->position[0] -
658 this->OriginImg[0]) /
659 this->SpacingImg[0] + 0.5f );
661 strSlice.sprintf("Slice: %d",slice);
662 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
666 this->window->GetRendererProperties()->xIPW->SetSlicePosition(this->window->GetRendererProperties()->position[0]);
667 this->window->GetRendererProperties()->yzIPW->SetSlicePosition(this->window->GetRendererProperties()->position[0]);
668 this->window->GetRenderWindow()->Render();
669 this->window->GetYZRenderer()->ResetCameraClippingRange();
670 this->window->GetRenderWindowYZ()->Render();
673 if ( fabs(posXYZ[1]-RefY[1]) < this->PadSliceDetection[1] )
676 /// Compute corresponding step
677 if ( (posXYZ[0] >= this->Limits[0] ) &&
678 (posXYZ[0] <= this->Limits[1] ) &&
679 (posXYZ[2] >= this->Limits[4] ) &&
680 (posXYZ[2] <= this->Limits[5] ) )
685 /// Compute new slice position
686 posXYZ[1] -= this->Step * this->SpacingImg[1];
687 if ( posXYZ[1] >= 0 )
688 this->window->GetRendererProperties()->position[1] -= this->Step * this->SpacingImg[1];
690 /// Update Slice text
691 if ( this->window->GetFlagDisplayText() )
693 int slice = (int)( (this->window->GetRendererProperties()->position[1] -
694 this->OriginImg[1]) /
695 this->SpacingImg[1] + 0.5f );
697 strSlice.sprintf("Slice: %d",slice);
698 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
702 this->window->GetRendererProperties()->yIPW->SetSlicePosition(this->window->GetRendererProperties()->position[1]);
703 this->window->GetRendererProperties()->xzIPW->SetSlicePosition(this->window->GetRendererProperties()->position[1]);
704 this->window->GetRenderWindow()->Render();
705 this->window->GetXZRenderer()->ResetCameraClippingRange();
706 this->window->GetRenderWindowXZ()->Render();
709 if ( fabs(posXYZ[2]-RefZ[2]) < this->PadSliceDetection[2] )
712 /// Compute corresponding step
713 if ( (posXYZ[0] >= this->Limits[0] ) &&
714 (posXYZ[0] <= this->Limits[1] ) &&
715 (posXYZ[1] >= this->Limits[2] ) &&
716 (posXYZ[1] <= this->Limits[3] ) )
721 /// Compute new slice position
722 posXYZ[2] -= this->Step * this->SpacingImg[2];
723 if ( posXYZ[2] >= 0 )
724 this->window->GetRendererProperties()->position[2] -= this->Step * this->SpacingImg[2];
726 /// Update Slice text
727 if ( this->window->GetFlagDisplayText() )
729 int slice = (int)( (this->window->GetRendererProperties()->position[2] -
730 this->OriginImg[2]) /
731 this->SpacingImg[2] + 0.5f );
733 strSlice.sprintf("Slice: %d",slice);
734 this->window->GetRendererProperties()->TextMapperSlice->SetInput(strSlice.toStdString().c_str());
738 this->window->GetRendererProperties()->zIPW->SetSlicePosition(this->window->GetRendererProperties()->position[2]);
739 this->window->GetRendererProperties()->xyIPW->SetSlicePosition(this->window->GetRendererProperties()->position[2]);
740 this->window->GetRenderWindow()->Render();
741 this->window->GetXYRenderer()->ResetCameraClippingRange();
742 this->window->GetRenderWindowXY()->Render();
745 /// Update text display
746 this->window->UpdateCoords(this->window->GetRendererProperties()->position);
753 void vtkMyInteractorStyleTrackballCameraOpenHeart::OnEnter()
756 if ( !this->FlagFirstTime )
759 /// Set flag to 1 to never enter again in this part of the code
760 this->FlagFirstTime = 1;
762 this->window->GetCurrentImageData()->GetWholeBoundingBox(extend);
764 /// Save the boundary of the volume in world coordinates
765 this->Bounds[0] = this->window->GetCurrentImageData()->GetExtent()[0] * this->window->GetCurrentImageData()->GetSpacing()[0] +
766 this->window->GetCurrentImageData()->GetOrigin()[0];
767 this->Bounds[1] = this->window->GetCurrentImageData()->GetExtent()[1] * this->window->GetCurrentImageData()->GetSpacing()[0] +
768 this->window->GetCurrentImageData()->GetOrigin()[0];
769 this->Bounds[2] = this->window->GetCurrentImageData()->GetExtent()[2] * this->window->GetCurrentImageData()->GetSpacing()[1] +
770 this->window->GetCurrentImageData()->GetOrigin()[1];
771 this->Bounds[3] = this->window->GetCurrentImageData()->GetExtent()[3] * this->window->GetCurrentImageData()->GetSpacing()[1] +
772 this->window->GetCurrentImageData()->GetOrigin()[1];
773 this->Bounds[4] = this->window->GetCurrentImageData()->GetExtent()[4] * this->window->GetCurrentImageData()->GetSpacing()[2] +
774 this->window->GetCurrentImageData()->GetOrigin()[2];
775 this->Bounds[5] = this->window->GetCurrentImageData()->GetExtent()[5] * this->window->GetCurrentImageData()->GetSpacing()[2] +
776 this->window->GetCurrentImageData()->GetOrigin()[2];
778 /// Save the limit of the box to increase the scolling effect
779 this->Limits[0] = (this->Bounds[1] - this->Bounds[0]) * this->PadBound;
780 this->Limits[1] = this->Bounds[1] - (this->Bounds[1] - this->Bounds[0]) * this->PadBound;
781 this->Limits[2] = (this->Bounds[3] - this->Bounds[2]) * this->PadBound;
782 this->Limits[3] = this->Bounds[3] - (this->Bounds[3] - this->Bounds[2]) * this->PadBound;
783 this->Limits[4] = (this->Bounds[5] - this->Bounds[4]) * this->PadBound;
784 this->Limits[5] = this->Bounds[5] - (this->Bounds[5] - this->Bounds[4]) * this->PadBound;
786 /// Save usefull information
787 for ( int i=0; i<3; i++)
789 this->SpacingImg[i] = this->window->GetCurrentImageData()->GetSpacing()[i];
790 this->OriginImg[i] = this->window->GetCurrentImageData()->GetOrigin()[i];
791 this->LimitImg[i] = this->OriginImg[i] + (this->window->GetDimensions()[i]-1) *
793 this->PadSliceDetection[i] = 0.01 * this->SpacingImg[i];
798 vtkInteractorStyleTrackballCamera::OnEnter();
803 void vtkMyInteractorStyleTrackballCameraOpenHeart::OnLeave()
806 vtkInteractorStyleTrackballCamera::OnLeave();
810 void vtkMyInteractorStyleTrackballCameraOpenHeart::OnLeftButtonDown()
812 this->FlagLeftClick = true;
813 if ( this->window->GetSelectedButton() == 0 )
815 this->window->GetMainRenderer()->AddActor(this->window->GetRendererProperties()->BoundingBoxActor);
816 this->window->GetRenderWindow()->Render();
818 vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
822 void vtkMyInteractorStyleTrackballCameraOpenHeart::OnLeftButtonUp()
824 this->FlagLeftClick = false;
825 if ( this->window->GetSelectedButton() == 0 ) {
826 this->window->GetMainRenderer()->RemoveActor(this->window->GetRendererProperties()->BoundingBoxActor);
827 this->window->GetRenderWindow()->Render();
829 vtkInteractorStyleTrackballCamera::OnLeftButtonUp();
833 void vtkMyInteractorStyleTrackballCameraOpenHeart::GetPickerPosition(double *pos)
835 int X = this->Interactor->GetEventPosition()[0];
836 int Y = this->Interactor->GetEventPosition()[1];
837 this->window->GetPicker()->Pick(X,Y,0.0,this->window->GetMainRenderer());
838 this->window->GetPicker()->GetPickPosition(pos);
842 bool vtkMyInteractorStyleTrackballCameraOpenHeart::IsInside(double *pos)
844 if ( (pos[0]>=this->Bounds[0]) && (pos[0]<=this->Bounds[1]) &&
845 (pos[1]>=this->Bounds[2]) && (pos[1]<=this->Bounds[3]) &&
846 (pos[2]>=this->Bounds[4]) && (pos[2]<=this->Bounds[5]) )