Code Planet

为了发现更大的世界


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

医学影像W/L算法

发表于 2013-12-29 | 更新于 2015-08-15 | 分类于 vtk

 

窗宽与窗位

</header>

CT能识别人体内2000个不同灰阶的密度差别。而人的眼睛却只能分辨16 个灰阶度。因此,人眼在CT图像上能分辨的CT值应为125 Hu ( 2000 / 16 )。换句话说,人体内不同组织CT 值只有相差125Hu 以上,才能为人眼所识别。人体软组织CT值多变化在20 – 50 Hu之间,人眼就无法识别。为此,必须进行分段观察,才能使CT 的优点反映出来。观察的CT 值范围,人们称之为窗宽;观察的中心CT值即为窗位或窗中心。 (一)窗宽指CT图像所显示的CT 值范围。在此CT值范围内的组织结构按其密度高低从白到黑分为16 个灰阶以供观察对比。例如,窗宽选定为100 Hu ,则人眼可分辨的CT值为100 / 16 =6 . 25 Hu ,即2 种组织CT值相差在6 . 25Hu以上者即可为人眼所识别。因此,窗宽的宽窄直接影响图像的清晰度与对比度。如果使用窄的窗宽,则显示的CT 值范围小,每一灰阶代表的CT 值幅度小,对比度强,适于观察密度接近的组织结构(如脑组织)。反之,如果使用宽的窗宽,则显示的CT值范围大,每一灰阶代表的CT 值幅度大,则图像对比度差,但密度均匀,适于观察密度差别大的结构(如骨与软组织)。 (二)窗位(窗中心)指窗宽范围内均值或中心值。比如一幅CT图像,窗宽为100Hu,窗位选在0Hu;则以窗位为中心(0Hu),向上包括+50Hu,向下包括-50Hu,凡是在这个100Hu 范围内的组织均可显示出来并为人眼所识别。凡是大于+50Hu 的组织均为白色;凡是小子-50Hu 的组织均为黑色,其密度差异无法显示。人眼只能识别土50Hu 范围内的CT 值,每一个灰阶的CT 值范围是100 / 16=6 . 25 Hu 。 原则上说窗位应该等于或接近需要观察的CT 值;窗宽应能反映该组织或病变的CT 值变化范围。   **技术问题:** 显示器往往只有 8-bit, 而数据有 12- 至 16-bits。 如果将数据的 min 和 max 间 (dynamic range) 的之间转换到 8-bit 0-255 去,过程是个有损转换,而且出来的图像往往突出的是些噪音。 针对这些问题,研究人员先提出一些要求 (requirements),然后根据这些要求提出了一些算法。这些算法现在都很成熟。 要求一:充分利用 0-255 间的显示有效值域 要求二:尽量减少值域压缩带来的损失 要求三:不能损失应该突出的组织部分 **算法分析: A. 16-bit 到 8-bit 直接转换:** computeMinMax(pixel_val, min, max); // 先算图像的最大和最小值 for (i = 0; i < nNumPixels; i++) disp_pixel_val = (pixel_val – min)*255.0/(double)(max – min); 这个算法必须有,对不少种类的图像是很有效的:如 8-bit 图像,MRI, ECT, CR 等等。 **B. Window-leveling 算法**: W/L 是专门为 CT 设计的。原理很简单:CT 图像里不同组织的密度 (用 Hounsfield 单位) 是在固定的值域, 与具体设备和成像软件没有关系。因此,要看头颅时, 我们只需将头颅的值域转换到 0-255 就行了。 CT W/L 不讲头颅值域的 min 和 max, 而说 max – min (即 window_width) 和 (max+min)/2 (即 window_center)。 我们还可以用原来的公式,只是 min 和 max 的算法不一样。 // 先算图像的最大和最小值 min = (2*window_center – window_width)/2.0 + 0.5; max = (2*window_center + window_width)/2.0 + 0.5; for (i = 0; i < nNumPixels; i++) disp_pixel_val = (pixel_val – min)*255.0/(double)(max – min); 请注意,CT 图像必须先转换成 Hounsfield 值再做 window-level。 这个转换包括将多余高位 bits 变成 0 (clipping), 和用 recale slope 和 rescale intercept 来做单位转换。 HU = pixel_val*rescale_slope + rescale_intercept **C.非线性转换** 我刚刚说的是将 min 和 max 间的数值线性转换到 0-255 之间。 如果 max – min 出来是个很大的数值,比如说 25500, 那就说每 100 原始密度会压缩成一个显示灰度。 这样的损失可能会很大。 因为人眼对灰度地反应式是非线性的,非线性转换可以解决一些问题。 常用算法有 log 和 gamma 两种。gamma 比较好调 gamma 值,因此用得比较多。 for (i = 0; i < nNumPixels; i++) disp_pixel_val = 255.0 * pow(pixel_value/(max-min), 1.0/gamma); **D. 有效值域**:CT 的 Window-level 有标准的定义,请参看 “Practical CT Techniques”, by Wladyslaw Gedroyc and Sheila Rankin, Springer-Verlag。最常用到的有 WW = 400, WL = 40 (实用许多部位); WW = 100, WL = 36 (头);WW = 3200, WL = 200 (骨头),等等。   **补充几点:** * **在做任何转换时要注意有效灰度域外的数值的处理。** 最好先用 int 而非 unsigned char 来算,再转入矩阵,以避免 overflow 和 underflow。 double dFactor = 255.0/(double)(max – min); int nPixelVal; for (i = 0; i < nNumPixels; i++) { nPixelVal = (int) ((pixel_val – min)*dFactor); if (nPixelVal < 0) disp_pixel_val = 0; else if (nPixelVal > 255) disp_pixel_val = 255; else disp_pixel_val = nPixelVal; } * **做 window-level 时要注意 min 和 max 之外原始数据的处理** double dFactor, min, max; int nPixelVal; min = (2*window_center – window_width)/2.0 + 0.5; max = (2*window_center + window_width)/2.0 + 0.5; dFactor = 255.0/(double)(max – min); for (i = 0; i < nNumPixels; i++) { if (pixel_val < min) { disp_pixel_val = 0; continue; } if (pixel_val > max) { disp_pixel_val = 255; continue; } nPixelVal = (int)((pixel_val – min)*dFactor); if (nPixelVal < 0) disp_pixel_val = 0; else if (nPixelVal > 255) disp_pixel_val = 255; else disp_pixel_val = nPixelVal; } 摘自:http://www.cnblogs.com/okaimee/archive/2010/12/31/1922648.html

The Road Not Taken

发表于 2013-12-29 | 更新于 2015-08-15 | 分类于 poem

_——by _</span>_Robert Frost_

_Two roads diverged in a yellow wood,_
_And sorry I could not travel both_
_And be one traveler, long I stood_
_And looked down one as far as I could_
_To where it bent in the undergrowth;_
_Then took the other, as just as fair,_
_And having perhaps the better claim,_
_Because it was grassy and wanted wear;_
_Though as for that the passing there_
_Had worn them really about the same,_
_And both that morning equally lay_
_In leaves no step had trodden black._
_Oh, I kept the first for another day!_
_Yet knowing how way leads on to way,_
_I doubted if I should ever come back._
_I shall be telling this with a sigh_
_Somewhere ages and ages hence:_
_Two roads diverged in a wood, and I--_
_I took the one less traveled by,_
_And that has made all the difference._

ITK读写ImageFileReaderException问题

发表于 2013-12-20 | 更新于 2015-08-15 | 分类于 itk
**用户层面**:itkImageFileReader(读) itkImageFileWriter(写)
**内部实现**:由内部ImageIO对象具体负责图像文件读写操作,该对象通过对象工厂根据用户输入文件类型生成相应的ImageIO对象
阅读全文 »

CMake范例

发表于 2013-12-19 | 更新于 2015-08-15 | 分类于 cmake
## 基础 ### 设置cmake变量
阅读全文 »

ITK文件格式和像素类型对应关系

发表于 2013-12-17 | 更新于 2015-08-15 | 分类于 itk

**格式名称**

** 后缀**

** 支持像素格式**
</tr>

BMP

.bmp

阅读全文 »

Qt自定义窗口部件

发表于 2013-12-12 | 更新于 2015-08-15 | 分类于 qt

**一、单一继承方式: **</span>

即将ui作为类的成员变量使用。优点是,能够控制用户界面的外观和显示方式,并能够与用户交互;同事还允许使用同样的ui文件生成多个不同的自定义界面类。
阅读全文 »

Qt ui设置centralwidget布局

发表于 2013-12-10 | 更新于 2015-08-15 | 分类于 qt

Qt的Designer设计窗口的时候,主窗口中的centralWidget不能设置布局,这直接导致不能良好布局,比如实现窗口部件随整个窗口自动缩放等,如下图:</span>

**解决方法:**

1.使用文本编辑器打开ui界面</span>

2.找到对应的centralWidget,在属性/property与结尾/widget之间加上下面这句话:

<layout class="QGridLayout" name="gridLayout"/>
其中QGridLayout可以写成水平、垂直其他风格。
![](http://codeplanet-wordpress.stor.sinaapp.com/uploads/2013/12/wpid-e58d64432b85cd0f976c9308819f92a8_23902223.png)
3.保存后,再使用界面编辑器打开ui,centralWidget被成功设置了对应的布局了。可以自动适应屏幕大小。
_来源:http://klqulei23.blog.163.com/blog/static/132315337201391844235992/_

Qt中父窗口处理子窗口事件

发表于 2013-12-03 | 更新于 2015-08-15 | 分类于 qt
1)在子窗口里面增加一个signal,在父窗口里面增加一个响应slot用于接收这个信号。
2)子窗口的按钮slot函数中emit这个signal。
3)在父窗口中把子窗口的这个signal连到自己的响应slot。
// 子窗口 **class** ChildWindow : **public** QWidget { Q_OBJECT **public**: ChildWindow(QWidget* p = 0) :QWidget(p) { QVBoxLayout* l = **new** QVBoxLayout(**this**); QPushButton* btn = **new** QPushButton("btn", **this**); l->addWidget(btn);connect(btn, SIGNAL(clicked()), SLOT(ClickedBtn()); }signals: ** // 这个信号是发给父窗口的。 void ChildWindowEvent();** **protected** slots: // 点击子窗口中按钮的slot ** void ClickedBtn() { // 触发子窗口的信号给父窗口接收。 emit ChildWindowEvent(); }** }
// 父窗口 **class** ParentWindow : **public** QWidget { Q_OBJECT **public**: ParentWindow(QWidget* p = 0) :QWidget(p) { QVBoxLayout* l = **new** QVBoxLayout(**this**); w = **new** ChildWindow(**this**); l->addWidget(w);** // 把子窗口的信号连接到父窗口来。 connect(w, SIGNAL(ChildWindowEvent()), SLOT(ChildWindowEventSlot());** }**protected**: ChildWindow* w; **protected** slots: // 父窗口用于接收子窗口信号的slot。 ** void ChildWindowEventSlot() { //子窗口的按钮被点击了。 }** }
来源:http://zhidao.baidu.com/link?url=UfBe2D6gR-qCnB0cKOnUYcmMuqjuZPpWZLvE6Q9CGDGe6iAriihkQny4TV61t4UNSpxkNhiIcyeve_HXYUQEY_

QT自定义事件类型

发表于 2013-12-02 | 更新于 2015-08-15 | 分类于 qt

Constant

Value

Description
</tr>

QEvent::None

0

Not an event.
</tr>

QEvent::ActionAdded

114

A new action has been added ([QActionEvent](http://qt-project.org/doc/qt-5.1/qtgui/qactionevent.html)).
</tr>

QEvent::ActionChanged

113

An action has been changed ([QActionEvent](http://qt-project.org/doc/qt-5.1/qtgui/qactionevent.html)).
</tr>

QEvent::ActionRemoved

115

An action has been removed ([QActionEvent](http://qt-project.org/doc/qt-5.1/qtgui/qactionevent.html)).
</tr>

QEvent::ActivationChange

99

A widget's top-level window activation state has changed.
</tr>

QEvent::ApplicationActivate

121

This enum has been deprecated. Use ApplicationStateChange instead.
</tr>

QEvent::ApplicationActivated

ApplicationActivate

This enum has been deprecated. Use ApplicationStateChange instead.
</tr>

QEvent::ApplicationDeactivate

122

This enum has been deprecated. Use ApplicationStateChange instead.
</tr>

QEvent::ApplicationFontChange

36

The default application font has changed.
</tr>

QEvent::ApplicationLayoutDirectionChange

37

The default application layout direction has changed.
</tr>

QEvent::ApplicationPaletteChange

38

The default application palette has changed.
</tr>

QEvent::ApplicationStateChange

214

The state of the application has changed.
</tr>

QEvent::ApplicationWindowIconChange

35

The application's icon has changed.
</tr>

QEvent::ChildAdded

68

An object gets a child ([QChildEvent](http://qt-project.org/doc/qt-5.1/qtcore/qchildevent.html)).
</tr>

QEvent::ChildPolished

69

A widget child gets polished ([QChildEvent](http://qt-project.org/doc/qt-5.1/qtcore/qchildevent.html)).
</tr>

QEvent::ChildRemoved

71

An object loses a child ([QChildEvent](http://qt-project.org/doc/qt-5.1/qtcore/qchildevent.html)).
</tr>

QEvent::Clipboard

40

The clipboard contents have changed (QClipboardEvent).
</tr>

QEvent::Close

19

Widget was closed ([QCloseEvent](http://qt-project.org/doc/qt-5.1/qtgui/qcloseevent.html)).
</tr>

QEvent::CloseSoftwareInputPanel

200

A widget wants to close the software input panel (SIP).
</tr>

QEvent::ContentsRectChange

178

The margins of the widget's content rect changed.
</tr>

QEvent::ContextMenu

82

Context popup menu ([QContextMenuEvent](http://qt-project.org/doc/qt-5.1/qtgui/qcontextmenuevent.html)).
</tr>

QEvent::CursorChange

183

The widget's cursor has changed.
</tr>

QEvent::DeferredDelete

52

The object will be deleted after it has cleaned up (QDeferredDeleteEvent).
</tr>

QEvent::DragEnter

60

The cursor enters a widget during a drag and drop operation ([QDragEnterEvent](http://qt-project.org/doc/qt-5.1/qtgui/qdragenterevent.html)).
</tr>

QEvent::DragLeave

62

The cursor leaves a widget during a drag and drop operation ([QDragLeaveEvent](http://qt-project.org/doc/qt-5.1/qtgui/qdragleaveevent.html)).
</tr>

QEvent::DragMove

61

A drag and drop operation is in progress ([QDragMoveEvent](http://qt-project.org/doc/qt-5.1/qtgui/qdragmoveevent.html)).
</tr>

QEvent::Drop

63

A drag and drop operation is completed ([QDropEvent](http://qt-project.org/doc/qt-5.1/qtgui/qdropevent.html)).
</tr>

QEvent::DynamicPropertyChange

170

A dynamic property was added, changed, or removed from the object.
</tr>

QEvent::EnabledChange

98

Widget's enabled state has changed.
</tr>

QEvent::Enter

10

Mouse enters widget's boundaries ([QEnterEvent](http://qt-project.org/doc/qt-5.1/qtgui/qenterevent.html)).
</tr>

QEvent::EnterEditFocus

150

An editor widget gains focus for editing. QT_KEYPAD_NAVIGATION must be defined.
</tr>

QEvent::EnterWhatsThisMode

124

Send to toplevel widgets when the application enters "What's This?" mode.
</tr>

QEvent::Expose

206

Sent to a window when its on-screen contents are invalidated and need to be flushed from the backing store.
</tr>

QEvent::FileOpen

116

File open request ([QFileOpenEvent](http://qt-project.org/doc/qt-5.1/qtgui/qfileopenevent.html)).
</tr>

QEvent::FocusIn

8

Widget or Window gains keyboard focus ([QFocusEvent](http://qt-project.org/doc/qt-5.1/qtgui/qfocusevent.html)).
</tr>

QEvent::FocusOut

9

Widget or Window loses keyboard focus ([QFocusEvent](http://qt-project.org/doc/qt-5.1/qtgui/qfocusevent.html)).
</tr>

QEvent::FocusAboutToChange

23

Widget or Window focus is about to change ([QFocusEvent](http://qt-project.org/doc/qt-5.1/qtgui/qfocusevent.html))
</tr>

QEvent::FontChange

97

Widget's font has changed.
</tr>

QEvent::Gesture

198

A gesture was triggered ([QGestureEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgestureevent.html)).
</tr>

QEvent::GestureOverride

202

A gesture override was triggered ([QGestureEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgestureevent.html)).
</tr>

QEvent::GrabKeyboard

188

Item gains keyboard grab ([QGraphicsItem](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsitem.html) only).
</tr>

QEvent::GrabMouse

186

Item gains mouse grab ([QGraphicsItem](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsitem.html) only).
</tr>

QEvent::GraphicsSceneContextMenu

159

Context popup menu over a graphics scene ([QGraphicsSceneContextMenuEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenecontextmenuevent.html)).
</tr>

QEvent::GraphicsSceneDragEnter

164

The cursor enters a graphics scene during a drag and drop operation ([QGraphicsSceneDragDropEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenedragdropevent.html)).
</tr>

QEvent::GraphicsSceneDragLeave

166

The cursor leaves a graphics scene during a drag and drop operation ([QGraphicsSceneDragDropEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenedragdropevent.html)).
</tr>

QEvent::GraphicsSceneDragMove

165

A drag and drop operation is in progress over a scene ([QGraphicsSceneDragDropEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenedragdropevent.html)).
</tr>

QEvent::GraphicsSceneDrop

167

A drag and drop operation is completed over a scene ([QGraphicsSceneDragDropEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenedragdropevent.html)).
</tr>

QEvent::GraphicsSceneHelp

163

The user requests help for a graphics scene ([QHelpEvent](http://qt-project.org/doc/qt-5.1/qtgui/qhelpevent.html)).
</tr>

QEvent::GraphicsSceneHoverEnter

160

The mouse cursor enters a hover item in a graphics scene ([QGraphicsSceneHoverEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenehoverevent.html)).
</tr>

QEvent::GraphicsSceneHoverLeave

162

The mouse cursor leaves a hover item in a graphics scene ([QGraphicsSceneHoverEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenehoverevent.html)).
</tr>

QEvent::GraphicsSceneHoverMove

161

The mouse cursor moves inside a hover item in a graphics scene ([QGraphicsSceneHoverEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenehoverevent.html)).
</tr>

QEvent::GraphicsSceneMouseDoubleClick

158

Mouse press again (double click) in a graphics scene ([QGraphicsSceneMouseEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenemouseevent.html)).
</tr>

QEvent::GraphicsSceneMouseMove

155

Move mouse in a graphics scene ([QGraphicsSceneMouseEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenemouseevent.html)).
</tr>

QEvent::GraphicsSceneMousePress

156

Mouse press in a graphics scene ([QGraphicsSceneMouseEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenemouseevent.html)).
</tr>

QEvent::GraphicsSceneMouseRelease

157

Mouse release in a graphics scene ([QGraphicsSceneMouseEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenemouseevent.html)).
</tr>

QEvent::GraphicsSceneMove

182

Widget was moved ([QGraphicsSceneMoveEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenemoveevent.html)).
</tr>

QEvent::GraphicsSceneResize

181

Widget was resized ([QGraphicsSceneResizeEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicssceneresizeevent.html)).
</tr>

QEvent::GraphicsSceneWheel

168

Mouse wheel rolled in a graphics scene ([QGraphicsSceneWheelEvent](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsscenewheelevent.html)).
</tr>

QEvent::Hide

18

Widget was hidden ([QHideEvent](http://qt-project.org/doc/qt-5.1/qtgui/qhideevent.html)).
</tr>

QEvent::HideToParent

27

A child widget has been hidden.
</tr>

QEvent::HoverEnter

127

The mouse cursor enters a hover widget ([QHoverEvent](http://qt-project.org/doc/qt-5.1/qtgui/qhoverevent.html)).
</tr>

QEvent::HoverLeave

128

The mouse cursor leaves a hover widget ([QHoverEvent](http://qt-project.org/doc/qt-5.1/qtgui/qhoverevent.html)).
</tr>

QEvent::HoverMove

129

The mouse cursor moves inside a hover widget ([QHoverEvent](http://qt-project.org/doc/qt-5.1/qtgui/qhoverevent.html)).
</tr>

QEvent::IconDrag

96

The main icon of a window has been dragged away ([QIconDragEvent](http://qt-project.org/doc/qt-5.1/qtgui/qicondragevent.html)).
</tr>

QEvent::IconTextChange

101

Widget's icon text has been changed.
</tr>

QEvent::InputMethod

83

An input method is being used ([QInputMethodEvent](http://qt-project.org/doc/qt-5.1/qtgui/qinputmethodevent.html)).
</tr>

QEvent::InputMethodQuery

207

A input method query event ([QInputMethodQueryEvent](http://qt-project.org/doc/qt-5.1/qtgui/qinputmethodqueryevent.html))
</tr>

QEvent::KeyboardLayoutChange

169

The keyboard layout has changed.
</tr>

QEvent::KeyPress

6

Key press ([QKeyEvent](http://qt-project.org/doc/qt-5.1/qtgui/qkeyevent.html)).
</tr>

QEvent::KeyRelease

7

Key release ([QKeyEvent](http://qt-project.org/doc/qt-5.1/qtgui/qkeyevent.html)).
</tr>

QEvent::LanguageChange

89

The application translation changed.
</tr>

QEvent::LayoutDirectionChange

90

The direction of layouts changed.
</tr>

QEvent::LayoutRequest

76

Widget layout needs to be redone.
</tr>

QEvent::Leave

11

Mouse leaves widget's boundaries.
</tr>

QEvent::LeaveEditFocus

151

An editor widget loses focus for editing. QT_KEYPAD_NAVIGATION must be defined.
</tr>

QEvent::LeaveWhatsThisMode

125

Send to toplevel widgets when the application leaves "What's This?" mode.
</tr>

QEvent::LocaleChange

88

The system locale has changed.
</tr>

QEvent::NonClientAreaMouseButtonDblClick

176

A mouse double click occurred outside the client area.
</tr>

QEvent::NonClientAreaMouseButtonPress

174

A mouse button press occurred outside the client area.
</tr>

QEvent::NonClientAreaMouseButtonRelease

175

A mouse button release occurred outside the client area.
</tr>

QEvent::NonClientAreaMouseMove

173

A mouse move occurred outside the client area.
</tr>

QEvent::MacSizeChange

177

The user changed his widget sizes (Mac OS X only).
</tr>

QEvent::MetaCall

43

An asynchronous method invocation via[QMetaObject::invokeMethod](http://qt-project.org/doc/qt-5.1/qtcore/qmetaobject.html#invokeMethod)().
</tr>

QEvent::ModifiedChange

102

Widgets modification state has been changed.
</tr>

QEvent::MouseButtonDblClick

4

Mouse press again ([QMouseEvent](http://qt-project.org/doc/qt-5.1/qtgui/qmouseevent.html)).
</tr>

QEvent::MouseButtonPress

2

Mouse press ([QMouseEvent](http://qt-project.org/doc/qt-5.1/qtgui/qmouseevent.html)).
</tr>

QEvent::MouseButtonRelease

3

Mouse release ([QMouseEvent](http://qt-project.org/doc/qt-5.1/qtgui/qmouseevent.html)).
</tr>

QEvent::MouseMove

5

Mouse move ([QMouseEvent](http://qt-project.org/doc/qt-5.1/qtgui/qmouseevent.html)).
</tr>

QEvent::MouseTrackingChange

109

The mouse tracking state has changed.
</tr>

QEvent::Move

13

Widget's position changed ([QMoveEvent](http://qt-project.org/doc/qt-5.1/qtgui/qmoveevent.html)).
</tr>

QEvent::OrientationChange

208

The screens orientation has changes (QScreenOrientationChangeEvent)
</tr>

QEvent::Paint

12

Screen update necessary ([QPaintEvent](http://qt-project.org/doc/qt-5.1/qtgui/qpaintevent.html)).
</tr>

QEvent::PaletteChange

39

Palette of the widget changed.
</tr>

QEvent::ParentAboutToChange

131

The widget parent is about to change.
</tr>

QEvent::ParentChange

21

The widget parent has changed.
</tr>

QEvent::PlatformPanel

212

A platform specific panel has been requested.
</tr>

QEvent::Polish

75

The widget is polished.
</tr>

QEvent::PolishRequest

74

The widget should be polished.
</tr>

QEvent::QueryWhatsThis

123

The widget should accept the event if it has "What's This?" help.
</tr>

QEvent::RequestSoftwareInputPanel

199

A widget wants to open a software input panel (SIP).
</tr>

QEvent::Resize

14

Widget's size changed ([QResizeEvent](http://qt-project.org/doc/qt-5.1/qtgui/qresizeevent.html)).
</tr>

QEvent::ScrollPrepare

204

The object needs to fill in its geometry information ([QScrollPrepareEvent](http://qt-project.org/doc/qt-5.1/qtgui/qscrollprepareevent.html)).
</tr>

QEvent::Scroll

205

The object needs to scroll to the supplied position ([QScrollEvent](http://qt-project.org/doc/qt-5.1/qtgui/qscrollevent.html)).
</tr>

QEvent::Shortcut

117

Key press in child for shortcut key handling ([QShortcutEvent](http://qt-project.org/doc/qt-5.1/qtgui/qshortcutevent.html)).
</tr>

QEvent::ShortcutOverride

51

Key press in child, for overriding shortcut key handling ([QKeyEvent](http://qt-project.org/doc/qt-5.1/qtgui/qkeyevent.html)).
</tr>

QEvent::Show

17

Widget was shown on screen ([QShowEvent](http://qt-project.org/doc/qt-5.1/qtgui/qshowevent.html)).
</tr>

QEvent::ShowToParent

26

A child widget has been shown.
</tr>

QEvent::SockAct

50

Socket activated, used to implement[QSocketNotifier](http://qt-project.org/doc/qt-5.1/qtcore/qsocketnotifier.html).
</tr>

QEvent::StateMachineSignal

192

A signal delivered to a state machine ([QStateMachine::SignalEvent](http://qt-project.org/doc/qt-5.1/qtcore/qstatemachine-signalevent.html)).
</tr>

QEvent::StateMachineWrapped

193

The event is a wrapper for, i.e., contains, another event ([QStateMachine::WrappedEvent](http://qt-project.org/doc/qt-5.1/qtcore/qstatemachine-wrappedevent.html)).
</tr>

QEvent::StatusTip

112

A status tip is requested ([QStatusTipEvent](http://qt-project.org/doc/qt-5.1/qtgui/qstatustipevent.html)).
</tr>

QEvent::StyleChange

100

Widget's style has been changed.
</tr>

QEvent::TabletMove

87

Wacom tablet move ([QTabletEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtabletevent.html)).
</tr>

QEvent::TabletPress

92

Wacom tablet press ([QTabletEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtabletevent.html)).
</tr>

QEvent::TabletRelease

93

Wacom tablet release ([QTabletEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtabletevent.html)).
</tr>

QEvent::OkRequest

94

Ok button in decoration pressed. Supported only for Windows CE.
</tr>

QEvent::TabletEnterProximity

171

Wacom tablet enter proximity event ([QTabletEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtabletevent.html)), sent to [QApplication](http://qt-project.org/doc/qt-5.1/qtwidgets/qapplication.html).
</tr>

QEvent::TabletLeaveProximity

172

Wacom tablet leave proximity event ([QTabletEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtabletevent.html)), sent to [QApplication](http://qt-project.org/doc/qt-5.1/qtwidgets/qapplication.html).
</tr>

QEvent::ThreadChange

22

The object is moved to another thread. This is the last event sent to this object in the previous thread. See [QObject::moveToThread](http://qt-project.org/doc/qt-5.1/qtcore/qobject.html#moveToThread)().
</tr>

QEvent::Timer

1

Regular timer events ([QTimerEvent](http://qt-project.org/doc/qt-5.1/qtcore/qtimerevent.html)).
</tr>

QEvent::ToolBarChange

120

The toolbar button is toggled on Mac OS X.
</tr>

QEvent::ToolTip

110

A tooltip was requested ([QHelpEvent](http://qt-project.org/doc/qt-5.1/qtgui/qhelpevent.html)).
</tr>

QEvent::ToolTipChange

184

The widget's tooltip has changed.
</tr>

QEvent::TouchBegin

194

Beginning of a sequence of touch-screen or track-pad events ([QTouchEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtouchevent.html)).
</tr>

QEvent::TouchCancel

209

Cancellation of touch-event sequence ([QTouchEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtouchevent.html)).
</tr>

QEvent::TouchEnd

196

End of touch-event sequence ([QTouchEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtouchevent.html)).
</tr>

QEvent::TouchUpdate

195

Touch-screen event ([QTouchEvent](http://qt-project.org/doc/qt-5.1/qtgui/qtouchevent.html)).
</tr>

QEvent::UngrabKeyboard

189

Item loses keyboard grab ([QGraphicsItem](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsitem.html) only).
</tr>

QEvent::UngrabMouse

187

Item loses mouse grab ([QGraphicsItem](http://qt-project.org/doc/qt-5.1/qtwidgets/qgraphicsitem.html) only).
</tr>

QEvent::UpdateLater

78

The widget should be queued to be repainted at a later time.
</tr>

QEvent::UpdateRequest

77

The widget should be repainted.
</tr>

QEvent::WhatsThis

111

The widget should reveal "What's This?" help ([QHelpEvent](http://qt-project.org/doc/qt-5.1/qtgui/qhelpevent.html)).
</tr>

QEvent::WhatsThisClicked

118

A link in a widget's "What's This?" help was clicked.
</tr>

QEvent::Wheel

31

Mouse wheel rolled ([QWheelEvent](http://qt-project.org/doc/qt-5.1/qtgui/qwheelevent.html)).
</tr>

QEvent::WinEventAct

132

A Windows-specific activation event has occurred.
</tr>

QEvent::WindowActivate

24

Window was activated.
</tr>

QEvent::WindowBlocked

103

The window is blocked by a modal dialog.
</tr>

QEvent::WindowDeactivate

25

Window was deactivated.
</tr>

QEvent::WindowIconChange

34

The window's icon has changed.
</tr>

QEvent::WindowStateChange

105

The [window's state](http://qt-project.org/doc/qt-5.1/qtgui/qwindow.html#windowState) (minimized, maximized or full-screen) has changed ([QWindowStateChangeEvent](http://qt-project.org/doc/qt-5.1/qtgui/qwindowstatechangeevent.html)).
</tr>

QEvent::WindowTitleChange

33

The window title has changed.
</tr>

QEvent::WindowUnblocked

104

The window is unblocked after a modal dialog exited.
</tr>

QEvent::WinIdChange

203

The window system identifer for this native widget has changed.
</tr>

QEvent::ZOrderChange

126

The widget’s z-order has changed. This event is never sent to top level windows.

智能指针有一个让人困惑的地方:当你创建一个智能指针类型的对象

发表于 2013-11-29 | 更新于 2015-08-15 | 分类于 c/cpp , vtk

智能指针有一个让人困惑的地方:当你创建一个智能指针类型的对象,然后改变它的指向,这时引用计数就会出错。例如:

vtkSmartPointer<vtkImageData>imageData = vtkSmartPointer<vtkImageData>::New();

imageData= Reader->GetOutput();

上面两行代码里,我们首先创建一个imageData,并给他分配好了内存,接着我们又把imageData指向Reader的输出,而不是一直指向我们创建的那块内存。对于这种情况,我们只要简单地调用:

vtkImageData*imageData = Reader->GetOutput();

这里没有必要使用智能指针,因为我们没有实际创建任何新的对象。

综上所述,可以看出引用计数和智能指针是息息相关的,它们主要都是用于内存管理。使用智能指针可以免去很多手动删除变量的烦恼,所以在本教程里,我们从一开始都使用智能指针来创建VTK对象。如果你想了解更多关于引用计数和智能指针的内容,可以参考C++的经典著作《</a>More Effective C++》这本书。

来源: <[http://blog.csdn.net/www_doling_net/article/details/8540242](http://blog.csdn.net/www_doling_net/article/details/8540242)>
1…9101112
Lu Xiaohua

Lu Xiaohua

116 日志
33 分类
86 标签
GitHub E-Mail
© 2019 Lu Xiaohua
由 Hexo 强力驱动 v3.8.0
|
主题 – NexT.Muse v7.0.0