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 #if !defined(QMITK_POINTBASEDREGISTRATION_H__INCLUDED) 00019 #define QMITK_POINTBASEDREGISTRATION_H__INCLUDED 00020 00021 #include "QmitkFunctionality.h" 00022 00023 #include "berryISelectionListener.h" 00024 #include "berryIStructuredSelection.h" 00025 00026 //#include "mitkTestingConfig.h" // IMPORTANT: this defines or undefines BUILD_TESTING ! 00027 00028 #include <mitkPointSetInteractor.h> 00029 #include <mitkGlobalInteraction.h> 00030 #include <mitkAffineInteractor.h> 00031 #include <mitkPointSet.h> 00032 #include <vtkCellArray.h> 00033 #include <vtkLandmarkTransform.h> 00034 //#include "QmitkMessageBoxHelper.h" 00035 #include "ui_QmitkPointBasedRegistrationViewControls.h" 00036 00037 #include "../PointbasedregistrationDll.h" 00038 00054 class POINTBASEDREGISTRATION_EXPORT QmitkPointBasedRegistrationView : public QObject, public QmitkFunctionality 00055 { 00056 00057 friend struct SelListenerPointBasedRegistration; 00058 00059 Q_OBJECT 00060 00061 public: 00062 00063 static const std::string VIEW_ID; 00064 00068 QmitkPointBasedRegistrationView(QObject *parent=0, const char *name=0); 00069 00073 virtual ~QmitkPointBasedRegistrationView(); 00074 00078 virtual void CreateQtPartControl(QWidget *parent); 00079 00083 virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); 00084 00088 virtual void StdMultiWidgetNotAvailable(); 00089 00093 virtual void CreateConnections(); 00094 00095 virtual void Activated(); 00096 virtual void Deactivated(); 00097 virtual void Visible(); 00098 virtual void Hidden(); 00099 00100 // 00101 // #ifdef BUILD_TESTING 00102 // / ** 00103 // \brief Testing entry point 00104 // * / 00105 // virtual int TestYourself(); 00106 // 00107 // / ** 00108 // \brief Helper method for testing 00109 // * / 00110 // bool TestAllTools(); 00111 // 00112 // 00113 // protected slots: 00114 // /** 00115 // \brief Helper method for testing 00116 // */ 00117 // void RegistrationErrorDialogFound( QWidget* widget ); 00118 // 00119 // /** 00120 // \brief Helper method for testing 00121 // */ 00122 // void ClearPointSetDialogFound( QWidget* widget ); 00123 // 00124 // private: 00125 // bool m_MessageBox; 00126 // 00127 // 00128 // public: 00129 // #else 00130 // // slot function is needed, because moc ignores our #ifdefs 00131 // void RegistrationErrorDialogFound( QWidget* widget ) {} 00132 // // slot function is needed, because moc ignores our #ifdefs 00133 // void ClearPointSetDialogFound(QWidget* widget){} 00134 // #endif 00135 00136 void DataNodeHasBeenRemoved(const mitk::DataNode* node); 00137 00138 protected slots: 00139 00143 void FixedSelected(mitk::DataNode::Pointer fixedImage); 00144 00148 void MovingSelected(mitk::DataNode::Pointer movingImage); 00149 00153 void calculateLandmarkbased(); 00154 00158 void calculateLandmarkWarping(); 00159 00163 void calculateLandmarkbasedWithICP(); 00164 00168 void HideMovingImage(bool hide); 00169 00173 void HideFixedImage(bool hide); 00174 00178 bool CheckCalculate(); 00179 00183 void UndoTransformation(); 00184 00188 void RedoTransformation(); 00189 00195 void showRedGreen(bool show); 00196 00202 void OpacityUpdate(float opacity); 00203 00209 void OpacityUpdate(int opacity); 00210 00214 void updateMovingLandmarksList(); 00215 00219 void updateFixedLandmarksList(); 00220 00226 void setImageColor(bool redGreen); 00227 00231 void clearTransformationLists(); 00232 00236 void checkLandmarkError(); 00237 00241 void transformationChanged(int transform); 00242 00246 bool checkCalculateEnabled(); 00247 00251 void calculate(); 00252 00253 void SetImagesVisible(berry::ISelection::ConstPointer /*selection*/); 00254 00255 void SwitchImages(); 00256 00257 protected: 00258 00259 berry::ISelectionListener::Pointer m_SelListener; 00260 berry::IStructuredSelection::ConstPointer m_CurrentSelection; 00261 00266 QmitkStdMultiWidget * m_MultiWidget; 00267 00271 Ui::QmitkPointBasedRegistrationControls m_Controls; 00272 mitk::PointSet::Pointer m_FixedLandmarks; 00273 mitk::PointSet::Pointer m_MovingLandmarks; 00274 mitk::DataNode::Pointer m_MovingPointSetNode; 00275 mitk::DataNode::Pointer m_FixedPointSetNode; 00276 mitk::DataNode::Pointer m_MovingNode; 00277 mitk::DataNode::Pointer m_FixedNode; 00278 std::list<mitk::Geometry3D::Pointer> m_UndoGeometryList; 00279 std::list<mitk::Geometry3D::Pointer> m_UndoPointsGeometryList; 00280 std::list<mitk::Geometry3D::Pointer> m_RedoGeometryList; 00281 std::list<mitk::Geometry3D::Pointer> m_RedoPointsGeometryList; 00282 bool m_ShowRedGreen; 00283 float m_Opacity; 00284 float m_OriginalOpacity; 00285 mitk::Color m_FixedColor; 00286 mitk::Color m_MovingColor; 00287 int m_Transformation; 00288 bool m_HideFixedImage; 00289 bool m_HideMovingImage; 00290 std::string m_OldFixedLabel; 00291 std::string m_OldMovingLabel; 00292 bool m_Deactivated; 00293 int m_CurrentFixedLandmarksObserverID; 00294 int m_CurrentMovingLandmarksObserverID; 00295 itk::SimpleMemberCommand<QmitkPointBasedRegistrationView>::Pointer m_FixedLandmarksChangedCommand; 00296 itk::SimpleMemberCommand<QmitkPointBasedRegistrationView>::Pointer m_MovingLandmarksChangedCommand; 00297 }; 00298 #endif // !defined(QMITK_POINTBASEDREGISTRATION_H__INCLUDED)