Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "QmitkStandardViews.h"
00019
00020 #include "mitkBaseRenderer.h"
00021
00022 #include <QHBoxLayout>
00023 #include <QVBoxLayout>
00024 #include <QPixmap>
00025 #include <qclickablelabel.h>
00026
00027 QmitkStandardViews::QmitkStandardViews( QWidget* parent, Qt::WindowFlags f )
00028 :QWidget(parent, f)
00029 {
00030 QVBoxLayout *vlayout = new QVBoxLayout(this);
00031 QWidget *labelContainer = new QWidget(this);
00032 vlayout->addStretch(1);
00033 vlayout->addWidget(labelContainer);
00034 vlayout->addStretch(1);
00035
00036 QHBoxLayout *hlayout = new QHBoxLayout(labelContainer);
00037
00038
00039 QPixmap pixmap(":QmitkStandardViews.png");
00040
00041
00042 m_ClickablePicture = new QClickableLabel(labelContainer);
00043
00044
00045 m_ClickablePicture->setPixmap( pixmap );
00046
00047 m_ClickablePicture->AddHotspot( "Left", QRect(QPoint(0,64),
00048 QPoint(21, 83)) );
00049
00050 m_ClickablePicture->AddHotspot( "Right", QRect(QPoint(128, 64),
00051 QPoint(149, 83)) );
00052
00053 m_ClickablePicture->AddHotspot( "Top", QRect(QPoint(66, 0),
00054 QPoint(83, 75)) );
00055
00056 m_ClickablePicture->AddHotspot( "Bottom", QRect(QPoint(66, 128),
00057 QPoint(83, 149)) );
00058
00059 m_ClickablePicture->AddHotspot( "Front", QRect(QPoint(10, 102),
00060 QPoint(29, 119)) );
00061
00062 m_ClickablePicture->AddHotspot( "Back", QRect(QPoint(119, 30),
00063 QPoint(138, 48)) );
00064
00065 connect( m_ClickablePicture, SIGNAL( mouseReleased(const QString&)), this, SLOT(hotspotClicked(const QString&)) );
00066
00067 hlayout->addStretch(1);
00068 hlayout->addWidget( m_ClickablePicture );
00069 hlayout->addStretch(1);
00070 }
00071
00072
00073
00074 QmitkStandardViews::~QmitkStandardViews()
00075 {
00076
00077 }
00078
00079
00080
00081 void QmitkStandardViews::SetCameraController( mitk::CameraController* controller )
00082 {
00083 m_CameraController = controller;
00084 }
00085
00086
00087 void QmitkStandardViews::SetCameraControllerFromRenderWindow( vtkRenderWindow* window )
00088 {
00089 if ( window != NULL )
00090 {
00091 if ( mitk::BaseRenderer::GetInstance(window) != NULL )
00092 if ( mitk::BaseRenderer::GetInstance(window)->GetCameraController() != NULL )
00093 m_CameraController = mitk::BaseRenderer::GetInstance(window)->GetCameraController();
00094
00095 }
00096 else
00097 {
00098 std::cerr << "Warning in "<<__FILE__<<", "<<__LINE__<<": render window is NULL!" << std::endl;
00099 }
00100 }
00101
00102 void QmitkStandardViews::hotspotClicked(const QString& s)
00103 {
00104 mitk::CameraController::StandardView view;
00105 bool good(true);
00106
00107 if ( s == "Left" ) view = mitk::CameraController::DEXTER;
00108 else if ( s == "Right" ) view = mitk::CameraController::SINISTER;
00109 else if ( s == "Top" ) view = mitk::CameraController::CRANIAL;
00110 else if ( s == "Bottom" ) view = mitk::CameraController::CAUDAL;
00111 else if ( s == "Front" ) view = mitk::CameraController::ANTERIOR;
00112 else if ( s == "Back" ) view = mitk::CameraController::POSTERIOR;
00113 else
00114 {
00115 std::cerr << "Warning in "<<__FILE__<<", "<<__LINE__<<": unknown standard view '" << s.toStdString() << "'" << std::endl;
00116 view = mitk::CameraController::ANTERIOR;
00117 good = false;
00118 }
00119
00120 if (good)
00121 {
00122 if ( m_CameraController.IsNotNull() )
00123 {
00124 m_CameraController->SetStandardView( view );
00125 }
00126
00127 emit StandardViewDefined( view );
00128 }
00129 }
00130
00131
00132