00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F
00020 #define SLICENAVIGATIONCONTROLLER_H_HEADER_INCLUDED_C1C55A2F
00021
00022 #include "mitkCommon.h"
00023 #include "mitkBaseController.h"
00024 #include "mitkRenderingManager.h"
00025 #include "mitkTimeSlicedGeometry.h"
00026 #include <itkEventObject.h>
00027 #include <itkCommand.h>
00028 #include <mitkIpPicTypeMultiplex.h>
00029 #include <sstream>
00030
00031
00032 namespace mitk {
00033
00034 #define mitkTimeSlicedGeometryEventMacro( classname , super ) \
00035 class MITK_CORE_EXPORT classname : public super { \
00036 public: \
00037 typedef classname Self; \
00038 typedef super Superclass; \
00039 classname(TimeSlicedGeometry* aTimeSlicedGeometry, unsigned int aPos) \
00040 : Superclass(aTimeSlicedGeometry, aPos) {} \
00041 virtual ~classname() {} \
00042 virtual const char * GetEventName() const { return #classname; } \
00043 virtual bool CheckEvent(const ::itk::EventObject* e) const \
00044 { return dynamic_cast<const Self*>(e); } \
00045 virtual ::itk::EventObject* MakeObject() const \
00046 { return new Self(GetTimeSlicedGeometry(), GetPos()); } \
00047 private: \
00048 void operator=(const Self&); \
00049 }
00050
00051 class PlaneGeometry;
00052 class Geometry3D;
00053 class BaseRenderer;
00054
00141 class MITK_CORE_EXPORT SliceNavigationController : public BaseController
00142 {
00143 public:
00144 mitkClassMacro(SliceNavigationController,BaseController);
00145 itkNewMacro(Self);
00146 mitkNewMacro1Param(Self, const char *);
00147
00153 enum ViewDirection{Transversal, Sagittal, Frontal, Original};
00154
00159 void SetInputWorldGeometry(const mitk::Geometry3D* geometry);
00160 itkGetConstObjectMacro(InputWorldGeometry, mitk::Geometry3D);
00161
00165 itkGetConstObjectMacro(CreatedWorldGeometry, mitk::Geometry3D);
00166
00174 itkSetMacro(ViewDirection, ViewDirection);
00175 itkGetMacro(ViewDirection, ViewDirection);
00176
00187 itkSetMacro(DefaultViewDirection, ViewDirection);
00188 itkGetMacro(DefaultViewDirection, ViewDirection);
00189
00190 virtual void SetViewDirectionToDefault();
00191
00197 virtual void Update();
00198
00204 virtual void Update(ViewDirection viewDirection, bool top = true,
00205 bool frontside = true, bool rotated = false);
00206
00213 virtual void SendCreatedWorldGeometry();
00214
00220 virtual void SendCreatedWorldGeometryUpdate();
00221
00228 virtual void SendSlice();
00229
00236 virtual void SendTime();
00237
00243 itkSetObjectMacro(RenderingManager, RenderingManager);
00244 mitk::RenderingManager* GetRenderingManager() const;
00245
00246 itkEventMacro( UpdateEvent, itk::AnyEvent );
00247
00248 class MITK_CORE_EXPORT TimeSlicedGeometryEvent : public itk::AnyEvent
00249 {
00250 public:
00251 typedef TimeSlicedGeometryEvent Self;
00252 typedef itk::AnyEvent Superclass;
00253
00254 TimeSlicedGeometryEvent(
00255 TimeSlicedGeometry* aTimeSlicedGeometry, unsigned int aPos)
00256 : m_TimeSlicedGeometry(aTimeSlicedGeometry), m_Pos(aPos)
00257 {}
00258
00259 virtual ~TimeSlicedGeometryEvent()
00260 {}
00261
00262 virtual const char * GetEventName() const
00263 { return "TimeSlicedGeometryEvent"; }
00264
00265 virtual bool CheckEvent(const ::itk::EventObject* e) const
00266 { return dynamic_cast<const Self*>(e); }
00267
00268 virtual ::itk::EventObject* MakeObject() const
00269 { return new Self(m_TimeSlicedGeometry, m_Pos); }
00270
00271 TimeSlicedGeometry* GetTimeSlicedGeometry() const
00272 { return m_TimeSlicedGeometry; }
00273
00274 unsigned int GetPos() const
00275 { return m_Pos; }
00276
00277 private:
00278 TimeSlicedGeometry::Pointer m_TimeSlicedGeometry;
00279 unsigned int m_Pos;
00280
00281 void operator=(const Self&);
00282 };
00283
00284 mitkTimeSlicedGeometryEventMacro(
00285 GeometrySendEvent,TimeSlicedGeometryEvent );
00286 mitkTimeSlicedGeometryEventMacro(
00287 GeometryUpdateEvent, TimeSlicedGeometryEvent );
00288 mitkTimeSlicedGeometryEventMacro(
00289 GeometryTimeEvent, TimeSlicedGeometryEvent );
00290 mitkTimeSlicedGeometryEventMacro(
00291 GeometrySliceEvent, TimeSlicedGeometryEvent );
00292
00293 template <typename T>
00294 void ConnectGeometrySendEvent(T* receiver)
00295 {
00296 typedef typename itk::ReceptorMemberCommand<T>::Pointer
00297 ReceptorMemberCommandPointer;
00298 ReceptorMemberCommandPointer eventReceptorCommand =
00299 itk::ReceptorMemberCommand<T>::New();
00300 eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometry);
00301 AddObserver(GeometrySendEvent(NULL,0), eventReceptorCommand);
00302 }
00303
00304 template <typename T>
00305 void ConnectGeometryUpdateEvent(T* receiver)
00306 {
00307 typedef typename itk::ReceptorMemberCommand<T>::Pointer
00308 ReceptorMemberCommandPointer;
00309 ReceptorMemberCommandPointer eventReceptorCommand =
00310 itk::ReceptorMemberCommand<T>::New();
00311 eventReceptorCommand->SetCallbackFunction(receiver, &T::UpdateGeometry);
00312 AddObserver(GeometryUpdateEvent(NULL,0), eventReceptorCommand);
00313 }
00314
00315 template <typename T>
00316 void ConnectGeometrySliceEvent(T* receiver, bool connectSendEvent=true)
00317 {
00318 typedef typename itk::ReceptorMemberCommand<T>::Pointer
00319 ReceptorMemberCommandPointer;
00320 ReceptorMemberCommandPointer eventReceptorCommand =
00321 itk::ReceptorMemberCommand<T>::New();
00322 eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometrySlice);
00323 AddObserver(GeometrySliceEvent(NULL,0), eventReceptorCommand);
00324 if(connectSendEvent)
00325 ConnectGeometrySendEvent(receiver);
00326 }
00327
00328 template <typename T>
00329 void ConnectGeometryTimeEvent(T* receiver, bool connectSendEvent=true)
00330 {
00331 typedef typename itk::ReceptorMemberCommand<T>::Pointer
00332 ReceptorMemberCommandPointer;
00333 ReceptorMemberCommandPointer eventReceptorCommand =
00334 itk::ReceptorMemberCommand<T>::New();
00335 eventReceptorCommand->SetCallbackFunction(receiver, &T::SetGeometryTime);
00336 AddObserver(GeometryTimeEvent(NULL,0), eventReceptorCommand);
00337 if(connectSendEvent)
00338 ConnectGeometrySendEvent(receiver);
00339 }
00340
00341 template <typename T>
00342 void ConnectGeometryEvents(T* receiver)
00343 {
00344
00345 ConnectGeometrySliceEvent(receiver, false);
00346 ConnectGeometryTimeEvent(receiver);
00347 }
00348
00354 virtual void SetGeometry(const itk::EventObject & geometrySliceEvent);
00355
00360 virtual void SetGeometrySlice(const itk::EventObject & geometrySliceEvent);
00361
00366 virtual void SetGeometryTime(const itk::EventObject & geometryTimeEvent);
00367
00368
00370 void SelectSliceByPoint( const mitk::Point3D &point );
00371
00372
00374 const mitk::TimeSlicedGeometry *GetCreatedWorldGeometry();
00375
00376
00378 const mitk::Geometry3D *GetCurrentGeometry3D();
00379
00380
00384 const mitk::PlaneGeometry *GetCurrentPlaneGeometry();
00385
00389 void SetRenderer( BaseRenderer *renderer );
00390
00395 BaseRenderer *GetRenderer() const;
00396
00400 void ReorientSlices(
00401 const mitk::Point3D &point, const mitk::Vector3D &normal );
00402
00403
00404 virtual bool ExecuteAction(
00405 Action* action, mitk::StateEvent const* stateEvent);
00406
00407 void ExecuteOperation(Operation* operation);
00408
00414 itkSetMacro(SliceLocked, bool);
00415 itkGetMacro(SliceLocked, bool);
00416 itkBooleanMacro(SliceLocked);
00417
00424 itkSetMacro(SliceRotationLocked, bool);
00425 itkGetMacro(SliceRotationLocked, bool);
00426 itkBooleanMacro(SliceRotationLocked);
00427
00432 void AdjustSliceStepperRange();
00433
00434
00435 protected:
00436 SliceNavigationController(const char * type = NULL);
00437 virtual ~SliceNavigationController();
00438
00439 template <class T>
00440 static void buildstring( mitkIpPicDescriptor *pic, itk::Point<int, 3> p, std::string &s, T = 0)
00441 {
00442 std::string value;
00443 std::stringstream stream;
00444 stream<<s<<"; Pixelvalue: ";
00445
00446 if ( (p[0]>=0 && p[1] >=0 && p[2]>=0) && (unsigned int)p[0] < pic->n[0] && (unsigned int)p[1] < pic->n[1] && (unsigned int)p[2] < pic->n[2] )
00447 {
00448 if(pic->bpe!=24)
00449 {
00450 stream<<(((T*) pic->data)[ p[0] + p[1]*pic->n[0] + p[2]*pic->n[0]*pic->n[1] ]);
00451 }
00452 else
00453 {
00454 stream<<(((T*) pic->data)[p[0]*3 + 0 + p[1]*pic->n[0]*3 + p[2]*pic->n[0]*pic->n[1]*3 ]);
00455 stream<<(((T*) pic->data)[p[0]*3 + 1 + p[1]*pic->n[0]*3 + p[2]*pic->n[0]*pic->n[1]*3 ]);
00456 stream<<(((T*) pic->data)[p[0]*3 + 2 + p[1]*pic->n[0]*3 + p[2]*pic->n[0]*pic->n[1]*3 ]);
00457 }
00458
00459 s = stream.str();
00460 }
00461 else
00462 {
00463 s+= "point out of data";
00464 }
00465 };
00466
00467 mitk::Geometry3D::ConstPointer m_InputWorldGeometry;
00468 mitk::Geometry3D::Pointer m_ExtendedInputWorldGeometry;
00469
00470 mitk::TimeSlicedGeometry::Pointer m_CreatedWorldGeometry;
00471
00472 ViewDirection m_ViewDirection;
00473 ViewDirection m_DefaultViewDirection;
00474
00475 mitk::RenderingManager::Pointer m_RenderingManager;
00476
00477 mitk::BaseRenderer *m_Renderer;
00478
00479 itkSetMacro(Top, bool);
00480 itkGetMacro(Top, bool);
00481 itkBooleanMacro(Top);
00482
00483 itkSetMacro(FrontSide, bool);
00484 itkGetMacro(FrontSide, bool);
00485 itkBooleanMacro(FrontSide);
00486
00487 itkSetMacro(Rotated, bool);
00488 itkGetMacro(Rotated, bool);
00489 itkBooleanMacro(Rotated);
00490
00491 bool m_Top;
00492 bool m_FrontSide;
00493 bool m_Rotated;
00494
00495 bool m_BlockUpdate;
00496
00497 bool m_SliceLocked;
00498 bool m_SliceRotationLocked;
00499 unsigned int m_OldPos;
00500 };
00501
00502 }
00503
00504 #endif