00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #include "mitkDisplayInteractor.h" 00020 00021 #include <mitkOperationActor.h> 00022 #include <mitkEventMapper.h> 00023 #include <mitkGlobalInteraction.h> 00024 #include <mitkCoordinateSupplier.h> 00025 #include <mitkDisplayCoordinateOperation.h> 00026 #include <mitkDisplayVectorInteractor.h> 00027 #include <mitkBaseRenderer.h> 00028 #include <mitkRenderingManager.h> 00029 00030 #include <mitkInteractionConst.h> 00031 00032 mitk::DisplayInteractor::DisplayInteractor(mitk::BaseRenderer * ren) 00033 { 00034 m_ParentRenderer = ren; 00035 } 00036 00037 void mitk::DisplayInteractor::ExecuteOperation(mitk::Operation * operation) 00038 { 00039 00040 bool ok;//as return type 00041 00042 mitk::DisplayCoordinateOperation* dcOperation=dynamic_cast<mitk::DisplayCoordinateOperation*>(operation); 00043 if ( dcOperation != NULL ) 00044 { 00045 /****ZOOM & MOVE of the whole volume****/ 00046 mitk::BaseRenderer* renderer = dcOperation->GetRenderer(); 00047 if( renderer == NULL || (m_ParentRenderer != NULL && m_ParentRenderer != renderer)) 00048 return; 00049 switch (operation->GetOperationType()) 00050 { 00051 case OpMOVE : 00052 { 00053 renderer->GetDisplayGeometry()->MoveBy(dcOperation->GetLastToCurrentDisplayVector()*(-1.0)); 00054 renderer->GetRenderingManager()->RequestUpdate(renderer->GetRenderWindow()); 00055 ok = true; 00056 } 00057 break; 00058 case OpZOOM : 00059 { 00060 float distance = dcOperation->GetLastToCurrentDisplayVector()[1]; 00061 00062 //float factor= 1.0 + distance * 0.05; // stupid because factors from +1 and -1 dont give results that represent inverse zooms 00063 00064 float factor = 1.0; 00065 00066 if (distance < 0.0) 00067 { 00068 factor = 1.0 / 1.05; 00069 } 00070 else if (distance > 0.0) 00071 { 00072 factor = 1.0 * 1.05; // 5% 00073 } 00074 else // distance == 0.0 00075 { 00076 // nothing to do, factor remains 1.0 00077 } 00078 00079 renderer->GetDisplayGeometry()->ZoomWithFixedWorldCoordinates(factor, dcOperation->GetStartDisplayCoordinate(), dcOperation->GetStartCoordinateInMM()); 00080 00081 renderer->GetRenderingManager()->RequestUpdate(renderer->GetRenderWindow()); 00082 ok = true; 00083 } 00084 break; 00085 default: 00086 ; 00087 } 00088 } 00089 } 00090 00091