ctkModalityWidget.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkModalityWidget_h
  15. #define __ctkModalityWidget_h
  16. // Qt includes
  17. #include <QWidget>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class ctkModalityWidgetPrivate;
  21. /// \ingroup Widgets
  22. ///
  23. /// ctkModalityWidget allows the user to select DICOM modalities
  24. class CTK_WIDGETS_EXPORT ctkModalityWidget : public QWidget
  25. {
  26. Q_OBJECT
  27. Q_PROPERTY(QStringList selectedModalities READ selectedModalities WRITE setSelectedModalities)
  28. Q_PROPERTY(QStringList visibleModalities READ visibleModalities WRITE setVisibleModalities)
  29. public:
  30. /// Superclass typedef
  31. typedef QWidget Superclass;
  32. /// Constructor
  33. /// If \li parent is null, ctkModalityWidget will be a top-level widget
  34. /// \note The \li parent can be set later using QWidget::setParent()
  35. /// By default, all the modalities are selected and only the following list
  36. /// of modalities is visible: ("CT", "MR", "US", "CR", "XA", "NM", "PT")
  37. explicit ctkModalityWidget(QWidget* parent = 0);
  38. /// Destructor
  39. virtual ~ctkModalityWidget();
  40. /// Return the current list of selected modalities, e.g. ("CR", "CT", "NM")
  41. QStringList selectedModalities()const;
  42. /// Select a list of modalities, e.g ("XA", "RX", "MG")
  43. void setSelectedModalities(const QStringList& modalities);
  44. /// Return the current list of visible modalities
  45. QStringList visibleModalities()const;
  46. /// Show a list of modalities
  47. void setVisibleModalities(const QStringList& modalities);
  48. /// Select a modality (visible or not). Does nothing if \a modality doesn't
  49. /// exist.
  50. void selectModality(const QString& modality, bool select = true);
  51. /// Select a modality. Does nothing if \a modality doesn't exist.
  52. void showModality(const QString& modality, bool show = true);
  53. /// Show all the modalities
  54. void showAll();
  55. /// Hide all the modalities
  56. void hideAll();
  57. /// Return true if all the modalities (visible or not) are selected.
  58. bool areAllModalitiesSelected() const;
  59. /// Return true if all the modalities (checked or not) are visible.
  60. bool areAllModalitiesVisible() const;
  61. /// Return a list of all the modalities: visible or not, selected or not.
  62. /// Please note the order of the modalities might be different than in
  63. /// selectedModalities and visibleModalities.
  64. QStringList modalities() const;
  65. public Q_SLOTS:
  66. /// Select all the modalities (visible or not)
  67. /// Note: only emit the signal selectedModalitiesChanged once.
  68. void selectAll();
  69. /// Unselect all the modalities (visible or not)
  70. /// Note: only emit the signal selectedModalitiesChanged once.
  71. void unselectAll();
  72. Q_SIGNALS:
  73. /// Fired anytime a modality is selected or unselected.
  74. /// Note: When the user click on "Any", it only emits the signal
  75. /// once (and not after each item is selected/unselected).
  76. void selectedModalitiesChanged(const QStringList modalities);
  77. protected Q_SLOTS:
  78. void onAnyChanged(int state);
  79. void onModalityChecked(bool);
  80. protected:
  81. QScopedPointer<ctkModalityWidgetPrivate> d_ptr;
  82. private:
  83. Q_DECLARE_PRIVATE(ctkModalityWidget);
  84. Q_DISABLE_COPY(ctkModalityWidget);
  85. };
  86. #endif