Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qMRMLTransformItemDelegate.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6  Queen's University, Kingston, ON, Canada. All Rights Reserved.
7 
8  See COPYRIGHT.txt
9  or http://www.slicer.org/copyright/copyright.txt for details.
10 
11  Unless required by applicable law or agreed to in writing, software
12  distributed under the License is distributed on an "AS IS" BASIS,
13  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  See the License for the specific language governing permissions and
15  limitations under the License.
16 
17  This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18  and was supported through the Applied Cancer Research Unit program of Cancer Care
19  Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20 
21 ==============================================================================*/
22 
23 #ifndef __qMRMLTransformItemDelegate_h
24 #define __qMRMLTransformItemDelegate_h
25 
26 // Qt includes
27 #include <QStyledItemDelegate>
28 #include <QMenu>
29 
30 // SubjectHierarchy includes
31 #include "qSlicerSubjectHierarchyModuleWidgetsExport.h"
32 
33 class vtkMRMLScene;
34 class QActionGroup;
35 class QCloseEvent;
36 class QShowEvent;
37 
39 class Q_SLICER_MODULE_SUBJECTHIERARCHY_WIDGETS_EXPORT qMRMLTransformItemDelegate: public QStyledItemDelegate
40 {
41  Q_OBJECT
42 public:
43  qMRMLTransformItemDelegate(QObject *parent = 0);
44  virtual ~qMRMLTransformItemDelegate();
45 
46  void setMRMLScene(vtkMRMLScene* scene);
47 
49  bool isTransform(const QModelIndex& index)const;
50 
51  virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
52  const QModelIndex &index) const;
53 
54  virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
55  virtual void setModelData(QWidget *editor, QAbstractItemModel *model,
56  const QModelIndex &index) const;
57 
58  virtual QSize sizeHint(const QStyleOptionViewItem &option,
59  const QModelIndex &index) const;
60 
61  void updateEditorGeometry(QWidget *editor,
62  const QStyleOptionViewItem &option, const QModelIndex &index) const;
63 
64  virtual bool eventFilter(QObject *object, QEvent *event);
65 
69  void setFixedRowHeight(int height);
70 
71  // We make initStyleOption public so it can be used by the tree view
72  using QStyledItemDelegate::initStyleOption;
73 
74 signals:
75  void removeTransformsFromBranchOfCurrentItem();
76  void hardenTransformOnBranchOfCurrentItem();
77 
78 protected slots:
79  void commitAndClose();
80 
81  void transformActionSelected();
82 
83 protected:
85  QActionGroup* TransformActionGroup;
86  QAction* NoneAction;
87  QAction* HardenAction;
89 };
90 
91 //------------------------------------------------------------------------------
97 class DelegateMenu : public QMenu
98 {
99  Q_OBJECT
100 public:
101  explicit DelegateMenu(QWidget* parent = 0);
103 protected:
104  virtual void showEvent(QShowEvent* event);
105 signals:
106  void closed();
107 };
108 
109 #endif
Item Delegate for MRML parent transform property.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
virtual void showEvent(QShowEvent *event)
Special menu class that repositions itself to the cursor position when shown.
DelegateMenu(QWidget *parent=0)