Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkRenderWindowMenu.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "QmitkRenderWindowMenu.h"
18 
19 #include "mitkProperties.h"
21 
22 #include <QHBoxLayout>
23 #include <QPainter>
24 #include <QSize>
25 #include <QSpacerItem>
26 
27 #include <QAction>
28 #include <QGroupBox>
29 #include <QLabel>
30 #include <QLine>
31 #include <QRadioButton>
32 #include <QWidgetAction>
33 
34 #include <QTimer>
35 
36 #include "QmitkStdMultiWidget.h"
37 
38 //#include"iconClose.xpm"
39 #include "iconCrosshairMode.xpm"
40 #include "iconFullScreen.xpm"
41 //#include"iconHoriSplit.xpm"
42 #include "iconSettings.xpm"
43 //#include"iconVertiSplit.xpm"
44 #include "iconLeaveFullScreen.xpm"
45 
46 #include <math.h>
47 
48 #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU
50  Qt::WindowFlags f,
53  : QWidget(NULL, Qt::Tool | Qt::FramelessWindowHint),
54 
55 #else
57  Qt::WindowFlags f,
58  mitk::BaseRenderer *b,
60  : QWidget(parent, f),
61 #endif
62 
63  m_Settings(NULL),
64  m_CrosshairMenu(NULL),
65  m_Layout(0),
66  m_LayoutDesign(0),
67  m_OldLayoutDesign(0),
68  m_FullScreenMode(false),
69  m_Entered(false),
70  m_Renderer(b),
71  m_MultiWidget(mw),
72  m_Parent(parent)
73 {
74  MITK_DEBUG << "creating renderwindow menu on baserenderer " << b;
75 
76  // Create Menu Widget
77  this->CreateMenuWidget();
78  this->setMinimumWidth(61); // DIRTY.. If you add or remove a button, you need to change the size.
79  this->setMaximumWidth(61);
80  this->setAutoFillBackground(true);
81 
82 // Else part fixes the render window menu issue on Linux bug but caused bugs on Mac OS and Windows
83 // for Mac OS see bug 3192
84 // for Windows see bug 12130
85 //... so Mac OS and Windows must be treated differently:
86 #if defined(Q_OS_MAC)
87  this->show();
88  this->setWindowOpacity(0.0f);
89 #else
90  this->setVisible(false);
91 #endif
92 
93  // this->setAttribute( Qt::WA_NoSystemBackground );
94  // this->setBackgroundRole( QPalette::Dark );
95  // this->update();
96 
97  // SetOpacity -- its just posible if the widget is a window.
98  // Windows indicates that the widget is a window, usually with a window system frame and a title bar,
99  // irrespective of whether the widget has a parent or not.
100  /*
101  this->setWindowFlags( Qt::Window | Qt::FramelessWindowHint);
102  */
103  // this->setAttribute(Qt::WA_TranslucentBackground);
104  // this->setWindowOpacity(0.75);
105 
106  currentCrosshairRotationMode = 0;
107 
108  // for autorotating
109  m_AutoRotationTimer.setInterval(75);
110  connect(&m_AutoRotationTimer, SIGNAL(timeout()), this, SLOT(AutoRotateNextStep()));
111  m_HideTimer.setSingleShot(true);
112  connect(&m_HideTimer, SIGNAL(timeout()), this, SLOT(DeferredHideMenu()));
113  connect(m_Parent, SIGNAL(destroyed()), this, SLOT(deleteLater()));
114 }
115 
117 {
118  if (m_AutoRotationTimer.isActive())
119  m_AutoRotationTimer.stop();
120 }
121 
123 {
124  QHBoxLayout *layout = new QHBoxLayout(this);
125  layout->setAlignment(Qt::AlignRight);
126  layout->setContentsMargins(1, 1, 1, 1);
127 
128  QSize size(13, 13);
129 
130  m_CrosshairMenu = new QMenu(this);
131  connect(m_CrosshairMenu, SIGNAL(aboutToShow()), this, SLOT(OnCrossHairMenuAboutToShow()));
132 
133  // button for changing rotation mode
134  m_CrosshairModeButton = new QToolButton(this);
135  m_CrosshairModeButton->setMaximumSize(15, 15);
136  m_CrosshairModeButton->setIconSize(size);
138  m_CrosshairModeButton->setIcon(QIcon(QPixmap(iconCrosshairMode_xpm)));
139  m_CrosshairModeButton->setPopupMode(QToolButton::InstantPopup);
140  m_CrosshairModeButton->setStyleSheet("QToolButton::menu-indicator { image: none; }");
141  m_CrosshairModeButton->setAutoRaise(true);
142  layout->addWidget(m_CrosshairModeButton);
143 
144  // fullScreenButton
145  m_FullScreenButton = new QToolButton(this);
146  m_FullScreenButton->setMaximumSize(15, 15);
147  m_FullScreenButton->setIconSize(size);
148  m_FullScreenButton->setIcon(QIcon(QPixmap(iconFullScreen_xpm)));
149  m_FullScreenButton->setAutoRaise(true);
150  layout->addWidget(m_FullScreenButton);
151 
152  // settingsButton
153  m_SettingsButton = new QToolButton(this);
154  m_SettingsButton->setMaximumSize(15, 15);
155  m_SettingsButton->setIconSize(size);
156  m_SettingsButton->setIcon(QIcon(QPixmap(iconSettings_xpm)));
157  m_SettingsButton->setAutoRaise(true);
158  layout->addWidget(m_SettingsButton);
159 
160  // Create Connections -- coming soon?
161  connect(m_FullScreenButton, SIGNAL(clicked(bool)), this, SLOT(OnFullScreenButton(bool)));
162  connect(m_SettingsButton, SIGNAL(clicked(bool)), this, SLOT(OnSettingsButton(bool)));
163 }
164 
166 {
167  m_Settings = new QMenu(this);
168 
169  m_DefaultLayoutAction = new QAction("standard layout", m_Settings);
170  m_DefaultLayoutAction->setDisabled(true);
171 
172  m_2DImagesUpLayoutAction = new QAction("2D images top, 3D bottom", m_Settings);
173  m_2DImagesUpLayoutAction->setDisabled(false);
174 
175  m_2DImagesLeftLayoutAction = new QAction("2D images left, 3D right", m_Settings);
176  m_2DImagesLeftLayoutAction->setDisabled(false);
177 
178  m_Big3DLayoutAction = new QAction("Big 3D", m_Settings);
179  m_Big3DLayoutAction->setDisabled(false);
180 
181  m_Widget1LayoutAction = new QAction("Axial plane", m_Settings);
182  m_Widget1LayoutAction->setDisabled(false);
183 
184  m_Widget2LayoutAction = new QAction("Sagittal plane", m_Settings);
185  m_Widget2LayoutAction->setDisabled(false);
186 
187  m_Widget3LayoutAction = new QAction("Coronal plane", m_Settings);
188  m_Widget3LayoutAction->setDisabled(false);
189 
190  m_RowWidget3And4LayoutAction = new QAction("Coronal top, 3D bottom", m_Settings);
191  m_RowWidget3And4LayoutAction->setDisabled(false);
192 
193  m_ColumnWidget3And4LayoutAction = new QAction("Coronal left, 3D right", m_Settings);
194  m_ColumnWidget3And4LayoutAction->setDisabled(false);
195 
196  m_SmallUpperWidget2Big3and4LayoutAction = new QAction("Sagittal top, Coronal n 3D bottom", m_Settings);
197  m_SmallUpperWidget2Big3and4LayoutAction->setDisabled(false);
198 
199  m_2x2Dand3DWidgetLayoutAction = new QAction("Axial n Sagittal left, 3D right", m_Settings);
200  m_2x2Dand3DWidgetLayoutAction->setDisabled(false);
201 
202  m_Left2Dand3DRight2DLayoutAction = new QAction("Axial n 3D left, Sagittal right", m_Settings);
203  m_Left2Dand3DRight2DLayoutAction->setDisabled(false);
204 
205  m_Settings->addAction(m_DefaultLayoutAction);
208  m_Settings->addAction(m_Big3DLayoutAction);
209  m_Settings->addAction(m_Widget1LayoutAction);
210  m_Settings->addAction(m_Widget2LayoutAction);
211  m_Settings->addAction(m_Widget3LayoutAction);
217 
218  m_Settings->setVisible(false);
219 
220  connect(m_DefaultLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToDefault(bool)));
221  connect(m_2DImagesUpLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutTo2DImagesUp(bool)));
222  connect(m_2DImagesLeftLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutTo2DImagesLeft(bool)));
223  connect(m_Big3DLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToBig3D(bool)));
224  connect(m_Widget1LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToWidget1(bool)));
225  connect(m_Widget2LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToWidget2(bool)));
226  connect(m_Widget3LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToWidget3(bool)));
227  connect(m_RowWidget3And4LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToRowWidget3And4(bool)));
228  connect(
229  m_ColumnWidget3And4LayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToColumnWidget3And4(bool)));
231  SIGNAL(triggered(bool)),
232  this,
234  connect(m_2x2Dand3DWidgetLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutTo2x2Dand3DWidget(bool)));
235  connect(
236  m_Left2Dand3DRight2DLayoutAction, SIGNAL(triggered(bool)), this, SLOT(OnChangeLayoutToLeft2Dand3DRight2D(bool)));
237 }
238 
239 void QmitkRenderWindowMenu::paintEvent(QPaintEvent * /*e*/)
240 {
241  QPainter painter(this);
242  QColor semiTransparentColor = Qt::black;
243  semiTransparentColor.setAlpha(255);
244  painter.fillRect(rect(), semiTransparentColor);
245 }
246 
247 void QmitkRenderWindowMenu::SetLayoutIndex(unsigned int layoutIndex)
248 {
249  m_Layout = layoutIndex;
250 }
251 
253 {
254  MITK_DEBUG << "menu hideEvent";
256 }
257 
259 {
260  MITK_DEBUG << "menu showMenu";
262 }
263 
265 {
266  MITK_DEBUG << "menu enterEvent";
268 
269  m_Entered = true;
270 }
271 
273 {
274  MITK_DEBUG << "menu deferredhidemenu";
275 // Else part fixes the render window menu issue on Linux bug but caused bugs on Mac OS and Windows
276 // for Mac OS see bug 3192
277 // for Windows see bug 12130
278 //... so Mac OS and Windows must be treated differently:
279 #if defined(Q_OS_MAC)
280  this->setWindowOpacity(0.0f);
281 #else
282  this->setVisible(false);
283 #endif
284 
285  // setVisible(false);
286  // setWindowOpacity(0.0f);
288 }
289 
291 {
292  MITK_DEBUG << "menu leaveEvent";
293 
294  m_Entered = false;
295  smoothHide();
296 }
297 
298 /* This method is responsible for non fluttering of
299  the renderWindowMenu when mouse cursor moves along the renderWindowMenu*/
301 {
302  MITK_DEBUG << "menu leaveEvent";
303  m_HideTimer.start(10);
304 }
305 
307 {
308  this->OnFullScreenButton(state);
309 }
312 {
313  if (!m_FullScreenMode)
314  {
315  m_FullScreenMode = true;
317 
318  switch (m_Layout)
319  {
320  case AXIAL:
321  {
323  break;
324  }
325 
326  case SAGITTAL:
327  {
329  break;
330  }
331  case CORONAL:
332  {
334  break;
335  }
336  case THREE_D:
337  {
339  break;
340  }
341  }
342 
343  // Move Widget and show again
344  this->MoveWidgetToCorrectPos(1.0f);
345 
346  // change icon
347  this->ChangeFullScreenIcon();
348  }
349  else
350  {
351  m_FullScreenMode = false;
353 
354  // Move Widget and show again
355  this->MoveWidgetToCorrectPos(1.0f);
356 
357  // change icon
358  this->ChangeFullScreenIcon();
359  }
360 
362 }
363 
366 {
367  if (m_Settings == NULL)
368  this->CreateSettingsWidget();
369 
370  QPoint point = this->mapToGlobal(m_SettingsButton->geometry().topLeft());
371  m_Settings->setVisible(true);
372  m_Settings->exec(point);
373 }
374 
376 {
377  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
378  m_FullScreenMode = false;
379  this->ChangeFullScreenIcon();
380 
383 
385 }
387 {
388  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
389  m_FullScreenMode = false;
390  this->ChangeFullScreenIcon();
391 
394 
396 }
398 {
399  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
400  m_FullScreenMode = false;
401  this->ChangeFullScreenIcon();
402 
405 
407 }
408 
410 {
411  MITK_DEBUG << "deferred show menu";
412  m_HideTimer.stop();
413 
414 // Else part fixes the render window menu issue on Linux bug but caused bugs on Mac OS and Windows
415 // for Mac OS see bug 3192
416 // for Windows see bug 12130
417 //... so Mac OS and Windows must be treated differently:
418 #if defined(Q_OS_MAC)
419  this->setWindowOpacity(1.0f);
420 #else
421  this->setVisible(true);
422  this->raise();
423 #endif
424 }
425 
427 {
428  MITK_DEBUG << "OnChangeLayoutToBig3D";
429 
430  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
431  m_FullScreenMode = false;
432  this->ChangeFullScreenIcon();
433 
436 
438 }
439 
441 {
442  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
443  m_FullScreenMode = false;
444  this->ChangeFullScreenIcon();
445 
448 
450 }
452 {
453  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
454  m_FullScreenMode = false;
455  this->ChangeFullScreenIcon();
456 
459 
461 }
463 {
464  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
465  m_FullScreenMode = false;
466  this->ChangeFullScreenIcon();
467 
470 
472 }
474 {
475  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
476  m_FullScreenMode = false;
477  this->ChangeFullScreenIcon();
478 
481 
483 }
485 {
486  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
487  m_FullScreenMode = false;
488  this->ChangeFullScreenIcon();
489 
492 
494 }
495 
497 {
498  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
499  m_FullScreenMode = false;
500  this->ChangeFullScreenIcon();
501 
504 
506 }
508 {
509  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
510  m_FullScreenMode = false;
511  this->ChangeFullScreenIcon();
512 
515 
517 }
519 {
520  // set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List
521  m_FullScreenMode = false;
522  this->ChangeFullScreenIcon();
523 
526 
528 }
529 
531 {
532  m_LayoutDesign = layoutDesignIndex;
533 
534  if (m_Settings == NULL)
535  this->CreateSettingsWidget();
536 
537  switch (m_LayoutDesign)
538  {
539  case LAYOUT_DEFAULT:
540  {
541  m_DefaultLayoutAction->setEnabled(false);
542  m_2DImagesUpLayoutAction->setEnabled(true);
543  m_2DImagesLeftLayoutAction->setEnabled(true);
544  m_Big3DLayoutAction->setEnabled(true);
545  m_Widget1LayoutAction->setEnabled(true);
546  m_Widget2LayoutAction->setEnabled(true);
547  m_Widget3LayoutAction->setEnabled(true);
548  m_RowWidget3And4LayoutAction->setEnabled(true);
549  m_ColumnWidget3And4LayoutAction->setEnabled(true);
550  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
551  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
552  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
553  break;
554  }
555 
556  case LAYOUT_2DIMAGEUP:
557  {
558  m_DefaultLayoutAction->setEnabled(true);
559  m_2DImagesUpLayoutAction->setEnabled(false);
560  m_2DImagesLeftLayoutAction->setEnabled(true);
561  m_Big3DLayoutAction->setEnabled(true);
562  m_Widget1LayoutAction->setEnabled(true);
563  m_Widget2LayoutAction->setEnabled(true);
564  m_Widget3LayoutAction->setEnabled(true);
565  m_RowWidget3And4LayoutAction->setEnabled(true);
566  m_ColumnWidget3And4LayoutAction->setEnabled(true);
567  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
568  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
569  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
570  break;
571  }
572  case LAYOUT_2DIMAGELEFT:
573  {
574  m_DefaultLayoutAction->setEnabled(true);
575  m_2DImagesUpLayoutAction->setEnabled(true);
576  m_2DImagesLeftLayoutAction->setEnabled(false);
577  m_Big3DLayoutAction->setEnabled(true);
578  m_Widget1LayoutAction->setEnabled(true);
579  m_Widget2LayoutAction->setEnabled(true);
580  m_Widget3LayoutAction->setEnabled(true);
581  m_RowWidget3And4LayoutAction->setEnabled(true);
582  m_ColumnWidget3And4LayoutAction->setEnabled(true);
583  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
584  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
585  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
586  break;
587  }
588  case LAYOUT_BIG3D:
589  {
590  m_DefaultLayoutAction->setEnabled(true);
591  m_2DImagesUpLayoutAction->setEnabled(true);
592  m_2DImagesLeftLayoutAction->setEnabled(true);
593  m_Big3DLayoutAction->setEnabled(false);
594  m_Widget1LayoutAction->setEnabled(true);
595  m_Widget2LayoutAction->setEnabled(true);
596  m_Widget3LayoutAction->setEnabled(true);
597  m_RowWidget3And4LayoutAction->setEnabled(true);
598  m_ColumnWidget3And4LayoutAction->setEnabled(true);
599  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
600  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
601  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
602  break;
603  }
604  case LAYOUT_AXIAL:
605  {
606  m_DefaultLayoutAction->setEnabled(true);
607  m_2DImagesUpLayoutAction->setEnabled(true);
608  m_2DImagesLeftLayoutAction->setEnabled(true);
609  m_Big3DLayoutAction->setEnabled(true);
610  m_Widget1LayoutAction->setEnabled(false);
611  m_Widget2LayoutAction->setEnabled(true);
612  m_Widget3LayoutAction->setEnabled(true);
613  m_RowWidget3And4LayoutAction->setEnabled(true);
614  m_ColumnWidget3And4LayoutAction->setEnabled(true);
615  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
616  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
617  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
618  break;
619  }
620  case LAYOUT_SAGITTAL:
621  {
622  m_DefaultLayoutAction->setEnabled(true);
623  m_2DImagesUpLayoutAction->setEnabled(true);
624  m_2DImagesLeftLayoutAction->setEnabled(true);
625  m_Big3DLayoutAction->setEnabled(true);
626  m_Widget1LayoutAction->setEnabled(true);
627  m_Widget2LayoutAction->setEnabled(false);
628  m_Widget3LayoutAction->setEnabled(true);
629  m_RowWidget3And4LayoutAction->setEnabled(true);
630  m_ColumnWidget3And4LayoutAction->setEnabled(true);
631  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
632  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
633  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
634  break;
635  }
636  case LAYOUT_CORONAL:
637  {
638  m_DefaultLayoutAction->setEnabled(true);
639  m_2DImagesUpLayoutAction->setEnabled(true);
640  m_2DImagesLeftLayoutAction->setEnabled(true);
641  m_Big3DLayoutAction->setEnabled(true);
642  m_Widget1LayoutAction->setEnabled(true);
643  m_Widget2LayoutAction->setEnabled(true);
644  m_Widget3LayoutAction->setEnabled(false);
645  m_RowWidget3And4LayoutAction->setEnabled(true);
646  m_ColumnWidget3And4LayoutAction->setEnabled(true);
647  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
648  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
649  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
650  break;
651  }
653  {
654  m_DefaultLayoutAction->setEnabled(true);
655  m_2DImagesUpLayoutAction->setEnabled(true);
656  m_2DImagesLeftLayoutAction->setEnabled(true);
657  m_Big3DLayoutAction->setEnabled(true);
658  m_Widget1LayoutAction->setEnabled(true);
659  m_Widget2LayoutAction->setEnabled(true);
660  m_Widget3LayoutAction->setEnabled(true);
661  m_RowWidget3And4LayoutAction->setEnabled(true);
662  m_ColumnWidget3And4LayoutAction->setEnabled(true);
663  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
664  m_2x2Dand3DWidgetLayoutAction->setEnabled(false);
665  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
666  break;
667  }
669  {
670  m_DefaultLayoutAction->setEnabled(true);
671  m_2DImagesUpLayoutAction->setEnabled(true);
672  m_2DImagesLeftLayoutAction->setEnabled(true);
673  m_Big3DLayoutAction->setEnabled(true);
674  m_Widget1LayoutAction->setEnabled(true);
675  m_Widget2LayoutAction->setEnabled(true);
676  m_Widget3LayoutAction->setEnabled(true);
677  m_RowWidget3And4LayoutAction->setEnabled(false);
678  m_ColumnWidget3And4LayoutAction->setEnabled(true);
679  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
680  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
681  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
682  break;
683  }
685  {
686  m_DefaultLayoutAction->setEnabled(true);
687  m_2DImagesUpLayoutAction->setEnabled(true);
688  m_2DImagesLeftLayoutAction->setEnabled(true);
689  m_Big3DLayoutAction->setEnabled(true);
690  m_Widget1LayoutAction->setEnabled(true);
691  m_Widget2LayoutAction->setEnabled(true);
692  m_Widget3LayoutAction->setEnabled(true);
693  m_RowWidget3And4LayoutAction->setEnabled(true);
694  m_ColumnWidget3And4LayoutAction->setEnabled(false);
695  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
696  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
697  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
698  break;
699  }
701  {
702  m_DefaultLayoutAction->setEnabled(true);
703  m_2DImagesUpLayoutAction->setEnabled(true);
704  m_2DImagesLeftLayoutAction->setEnabled(true);
705  m_Big3DLayoutAction->setEnabled(true);
706  m_Widget1LayoutAction->setEnabled(true);
707  m_Widget2LayoutAction->setEnabled(true);
708  m_Widget3LayoutAction->setEnabled(true);
709  m_RowWidget3And4LayoutAction->setEnabled(true);
710  m_ColumnWidget3And4LayoutAction->setEnabled(true);
711  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(false);
712  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
713  m_Left2Dand3DRight2DLayoutAction->setEnabled(true);
714  break;
715  }
717  {
718  m_DefaultLayoutAction->setEnabled(true);
719  m_2DImagesUpLayoutAction->setEnabled(true);
720  m_2DImagesLeftLayoutAction->setEnabled(true);
721  m_Big3DLayoutAction->setEnabled(true);
722  m_Widget1LayoutAction->setEnabled(true);
723  m_Widget2LayoutAction->setEnabled(true);
724  m_Widget3LayoutAction->setEnabled(true);
725  m_RowWidget3And4LayoutAction->setEnabled(true);
726  m_ColumnWidget3And4LayoutAction->setEnabled(true);
727  m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true);
728  m_2x2Dand3DWidgetLayoutAction->setEnabled(true);
729  m_Left2Dand3DRight2DLayoutAction->setEnabled(false);
730  break;
731  }
732  }
733 }
734 
735 #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU
737 #else
739 #endif
740 {
741 #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU
742  int X = floor(double(this->m_Parent->width() - this->width() - 8.0));
743  int Y = 7;
744 
745  QPoint pos = this->m_Parent->mapToGlobal(QPoint(0, 0));
746 
747  this->move(X + pos.x(), Y + pos.y());
748 
749  if (opacity < 0)
750  opacity = 0;
751  else if (opacity > 1)
752  opacity = 1;
753 
754  this->setWindowOpacity(opacity);
755 #else
756  int moveX = floor(double(this->m_Parent->width() - this->width() - 4.0));
757  this->move(moveX, 3);
758  this->show();
759 #endif
760 }
761 
763 {
764  m_FullScreenButton->setIcon(m_FullScreenMode ? QPixmap(iconLeaveFullScreen_xpm) : QPixmap(iconFullScreen_xpm));
765 }
766 
768 {
769  MITK_DEBUG << "selected crosshair mode " << action->data().toInt();
770  emit ChangeCrosshairRotationMode(action->data().toInt());
771 }
772 
774 {
775  if (m_Renderer.IsNotNull())
776  {
777  mitk::DataNode *n;
778  if (this->m_MultiWidget)
779  {
780  n = this->m_MultiWidget->GetWidgetPlane1();
781  if (n)
782  n->SetVisibility(state);
783  n = this->m_MultiWidget->GetWidgetPlane2();
784  if (n)
785  n->SetVisibility(state);
786  n = this->m_MultiWidget->GetWidgetPlane3();
787  if (n)
788  n->SetVisibility(state);
789  m_Renderer->GetRenderingManager()->RequestUpdateAll();
790  }
791  }
792 }
793 
795 {
796  MITK_DEBUG << "Thickslices num: " << num << " on renderer " << m_Renderer.GetPointer();
797 
798  if (m_Renderer.IsNotNull())
799  {
800  if (num == 0)
801  {
802  m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices",
804  m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices.num",
806  m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices.showarea",
807  mitk::BoolProperty::New(false));
808  }
809  else
810  {
811  m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices",
813  m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices.num",
815  m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty("reslice.thickslices.showarea",
817  }
818  m_TSLabel->setText(QString::number(num * 2 + 1));
819  m_Renderer->SendUpdateSlice();
820  m_Renderer->GetRenderingManager()->RequestUpdateAll();
821  }
822 }
823 
825 {
826  QMenu *crosshairModesMenu = m_CrosshairMenu;
827 
828  crosshairModesMenu->clear();
829 
830  QAction *resetViewAction = new QAction(crosshairModesMenu);
831  resetViewAction->setText("Reset view");
832  crosshairModesMenu->addAction(resetViewAction);
833  connect(resetViewAction, SIGNAL(triggered()), this, SIGNAL(ResetView()));
834 
835  // Show hide crosshairs
836  {
837  bool currentState = true;
838 
839  if (m_Renderer.IsNotNull())
840  {
841  mitk::DataStorage *ds = m_Renderer->GetDataStorage();
842  mitk::DataNode *n;
843  if (ds)
844  {
845  n = this->m_MultiWidget->GetWidgetPlane1();
846  if (n)
847  {
848  bool v;
849  if (n->GetVisibility(v, 0))
850  currentState &= v;
851  }
852  n = this->m_MultiWidget->GetWidgetPlane2();
853  if (n)
854  {
855  bool v;
856  if (n->GetVisibility(v, 0))
857  currentState &= v;
858  }
859  n = this->m_MultiWidget->GetWidgetPlane3();
860  if (n)
861  {
862  bool v;
863  if (n->GetVisibility(v, 0))
864  currentState &= v;
865  }
866  }
867  }
868 
869  QAction *showHideCrosshairVisibilityAction = new QAction(crosshairModesMenu);
870  showHideCrosshairVisibilityAction->setText("Show crosshair");
871  showHideCrosshairVisibilityAction->setCheckable(true);
872  showHideCrosshairVisibilityAction->setChecked(currentState);
873  crosshairModesMenu->addAction(showHideCrosshairVisibilityAction);
874  connect(showHideCrosshairVisibilityAction, SIGNAL(toggled(bool)), this, SLOT(SetCrossHairVisibility(bool)));
875  }
876 
877  // Rotation mode
878  {
879  QAction *rotationGroupSeparator = new QAction(crosshairModesMenu);
880  rotationGroupSeparator->setSeparator(true);
881  rotationGroupSeparator->setText("Rotation mode");
882  crosshairModesMenu->addAction(rotationGroupSeparator);
883 
884  QActionGroup *rotationModeActionGroup = new QActionGroup(crosshairModesMenu);
885  rotationModeActionGroup->setExclusive(true);
886 
887  QAction *noCrosshairRotation = new QAction(crosshairModesMenu);
888  noCrosshairRotation->setActionGroup(rotationModeActionGroup);
889  noCrosshairRotation->setText("No crosshair rotation");
890  noCrosshairRotation->setCheckable(true);
891  noCrosshairRotation->setChecked(currentCrosshairRotationMode == 0);
892  noCrosshairRotation->setData(0);
893  crosshairModesMenu->addAction(noCrosshairRotation);
894 
895  QAction *singleCrosshairRotation = new QAction(crosshairModesMenu);
896  singleCrosshairRotation->setActionGroup(rotationModeActionGroup);
897  singleCrosshairRotation->setText("Crosshair rotation");
898  singleCrosshairRotation->setCheckable(true);
899  singleCrosshairRotation->setChecked(currentCrosshairRotationMode == 1);
900  singleCrosshairRotation->setData(1);
901  crosshairModesMenu->addAction(singleCrosshairRotation);
902 
903  QAction *coupledCrosshairRotation = new QAction(crosshairModesMenu);
904  coupledCrosshairRotation->setActionGroup(rotationModeActionGroup);
905  coupledCrosshairRotation->setText("Coupled crosshair rotation");
906  coupledCrosshairRotation->setCheckable(true);
907  coupledCrosshairRotation->setChecked(currentCrosshairRotationMode == 2);
908  coupledCrosshairRotation->setData(2);
909  crosshairModesMenu->addAction(coupledCrosshairRotation);
910 
911  QAction *swivelMode = new QAction(crosshairModesMenu);
912  swivelMode->setActionGroup(rotationModeActionGroup);
913  swivelMode->setText("Swivel mode");
914  swivelMode->setCheckable(true);
915  swivelMode->setChecked(currentCrosshairRotationMode == 3);
916  swivelMode->setData(3);
917  crosshairModesMenu->addAction(swivelMode);
918 
919  connect(
920  rotationModeActionGroup, SIGNAL(triggered(QAction *)), this, SLOT(OnCrosshairRotationModeSelected(QAction *)));
921  }
922 
923  // auto rotation support
924  if (m_Renderer.IsNotNull() && m_Renderer->GetMapperID() == mitk::BaseRenderer::Standard3D)
925  {
926  QAction *autoRotationGroupSeparator = new QAction(crosshairModesMenu);
927  autoRotationGroupSeparator->setSeparator(true);
928  crosshairModesMenu->addAction(autoRotationGroupSeparator);
929 
930  QAction *autoRotationAction = crosshairModesMenu->addAction("Auto Rotation");
931  autoRotationAction->setCheckable(true);
932  autoRotationAction->setChecked(m_AutoRotationTimer.isActive());
933  connect(autoRotationAction, SIGNAL(triggered()), this, SLOT(OnAutoRotationActionTriggered()));
934  }
935 
936  // Thickslices support
937  if (m_Renderer.IsNotNull() && m_Renderer->GetMapperID() == mitk::BaseRenderer::Standard2D)
938  {
939  QAction *thickSlicesGroupSeparator = new QAction(crosshairModesMenu);
940  thickSlicesGroupSeparator->setSeparator(true);
941  thickSlicesGroupSeparator->setText("ThickSlices mode");
942  crosshairModesMenu->addAction(thickSlicesGroupSeparator);
943 
944  QActionGroup *thickSlicesActionGroup = new QActionGroup(crosshairModesMenu);
945  thickSlicesActionGroup->setExclusive(true);
946 
947  int currentMode = 0;
948  {
950  m_Renderer->GetCurrentWorldPlaneGeometryNode()->GetProperty("reslice.thickslices"));
951  if (m.IsNotNull())
952  currentMode = m->GetValueAsId();
953  }
954 
955  int currentNum = 1;
956  {
957  mitk::IntProperty::Pointer m = dynamic_cast<mitk::IntProperty *>(
958  m_Renderer->GetCurrentWorldPlaneGeometryNode()->GetProperty("reslice.thickslices.num"));
959  if (m.IsNotNull())
960  {
961  currentNum = m->GetValue();
962  if (currentNum < 1)
963  currentNum = 1;
964  if (currentNum > 10)
965  currentNum = 10;
966  }
967  }
968 
969  if (currentMode == 0)
970  currentNum = 0;
971 
972  QSlider *m_TSSlider = new QSlider(crosshairModesMenu);
973  m_TSSlider->setMinimum(0);
974  m_TSSlider->setMaximum(9);
975  m_TSSlider->setValue(currentNum);
976 
977  m_TSSlider->setOrientation(Qt::Horizontal);
978 
979  connect(m_TSSlider, SIGNAL(valueChanged(int)), this, SLOT(OnTSNumChanged(int)));
980 
981  QHBoxLayout *_TSLayout = new QHBoxLayout;
982  _TSLayout->setContentsMargins(4, 4, 4, 4);
983  _TSLayout->addWidget(new QLabel("TS: "));
984  _TSLayout->addWidget(m_TSSlider);
985  _TSLayout->addWidget(m_TSLabel = new QLabel(QString::number(currentNum * 2 + 1), this));
986 
987  QWidget *_TSWidget = new QWidget;
988  _TSWidget->setLayout(_TSLayout);
989 
990  QWidgetAction *m_TSSliderAction = new QWidgetAction(crosshairModesMenu);
991  m_TSSliderAction->setDefaultWidget(_TSWidget);
992  crosshairModesMenu->addAction(m_TSSliderAction);
993  }
994 }
995 
997 {
999 }
1000 
1002 {
1003  if (m_AutoRotationTimer.isActive())
1004  {
1005  m_AutoRotationTimer.stop();
1006  m_Renderer->GetCameraRotationController()->GetSlice()->PingPongOff();
1007  }
1008  else
1009  {
1010  m_Renderer->GetCameraRotationController()->GetSlice()->PingPongOn();
1011  m_AutoRotationTimer.start();
1012  }
1013 }
1014 
1016 {
1017  if (m_Renderer->GetCameraRotationController())
1018  m_Renderer->GetCameraRotationController()->GetSlice()->Next();
1019 }
Data management class that handles 'was created by' relations.
The QmitkRenderWindowMenu is a popup Widget which shows up when the mouse curser enter a QmitkRenderW...
void OnCrosshairRotationModeSelected(QAction *)
void leaveEvent(QEvent *) override
void enterEvent(QEvent *) override
void SetVisibility(bool visible, const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="visible")
Convenience method for setting visibility properties (instances of BoolProperty)
Organizes the rendering process.
#define MITK_DEBUG
Definition: mitkLogMacros.h:26
DataCollection - Class to facilitate loading/accessing structured data.
void UpdateLayoutDesignList(int layoutDesignIndex)
void SetCrossHairVisibility(bool state)
void OnSettingsButton(bool checked)
static Pointer New()
void NotifyNewWidgetPlanesMode(int mode)
void OnFullScreenButton(bool checked)
QmitkRenderWindowMenu(QWidget *parent=0, Qt::WindowFlags f=0, mitk::BaseRenderer *b=0, QmitkStdMultiWidget *mw=0)
void SetLayoutIndex(unsigned int layoutIndex)
mitk::DataNode::Pointer GetWidgetPlane1()
Access node of widget plane 1.
mitk::DataNode::Pointer GetWidgetPlane2()
Access node of widget plane 2.
mitk::DataNode::Pointer GetWidgetPlane3()
Access node of widget plane 3.
static Pointer New()
void ChangeCrosshairRotationMode(int)
QAction * m_SmallUpperWidget2Big3and4LayoutAction
void SignalChangeLayoutDesign(int layoutDesign)
void paintEvent(QPaintEvent *event)
bool GetVisibility(bool &visible, const mitk::BaseRenderer *renderer, const char *propertyKey="visible") const
Convenience access method for visibility properties (instances of BoolProperty with property-key "vis...
Definition: mitkDataNode.h:413
void OnChangeLayoutToSmallUpperWidget2Big3and4(bool)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
void ChangeFullScreenMode(bool state)