Apollo 11.0
自动驾驶开放平台
FixedAspectRatioWidget类 参考

#include <fixedaspectratiowidget.h>

类 FixedAspectRatioWidget 继承关系图:
FixedAspectRatioWidget 的协作图:

信号

void focusOnThis (FixedAspectRatioWidget *)
 

Public 成员函数

 FixedAspectRatioWidget (QWidget *parent=nullptr, int index=0)
 
bool is_init (void) const
 
void SetupDynamicTexture (const std::shared_ptr< Texture > &textureObj)
 
void set_index (int i)
 
int index (void) const
 
void StartOrStopUpdate (bool b)
 
int innerHeight (void)
 

Protected 成员函数

void mouseDoubleClickEvent (QMouseEvent *event) override
 
void contextMenuEvent (QContextMenuEvent *) override
 
void resizeEvent (QResizeEvent *) override
 
void paintEvent (QPaintEvent *event) override
 

详细描述

在文件 fixedaspectratiowidget.h 第 24 行定义.

构造及析构函数说明

◆ FixedAspectRatioWidget()

FixedAspectRatioWidget::FixedAspectRatioWidget ( QWidget *  parent = nullptr,
int  index = 0 
)
explicit

在文件 fixedaspectratiowidget.cc 第 24 行定义.

25 : QWidget(parent), index_(index), refresh_timer_(this), viewer_() {
26 viewer_.setParent(this);
27 viewer_.setGeometry(geometry());
28
29 refresh_timer_.setObjectName(tr("_refreshTimer"));
30 refresh_timer_.setInterval(40);
31 connect(&refresh_timer_, SIGNAL(timeout()), &viewer_, SLOT(repaint()));
32 setAutoFillBackground(true);
33}

成员函数说明

◆ contextMenuEvent()

void FixedAspectRatioWidget::contextMenuEvent ( QContextMenuEvent *  event)
overrideprotected

在文件 fixedaspectratiowidget.cc 第 62 行定义.

62 {
63 emit focusOnThis(this);
64 QMenu m;
65 m.addActions(actions());
66 m.exec(event->globalPos());
67 m.clear();
68
69 QWidget::contextMenuEvent(event);
70}
void focusOnThis(FixedAspectRatioWidget *)

◆ focusOnThis

void FixedAspectRatioWidget::focusOnThis ( FixedAspectRatioWidget *  )
signal

◆ index()

int FixedAspectRatioWidget::index ( void  ) const
inline

在文件 fixedaspectratiowidget.h 第 34 行定义.

34{ return index_; }

◆ innerHeight()

int FixedAspectRatioWidget::innerHeight ( void  )
inline

在文件 fixedaspectratiowidget.h 第 37 行定义.

37{ return viewer_.plane_.texHeight(); }
GLsizei texHeight(void) const
Definition plane.h:48

◆ is_init()

bool FixedAspectRatioWidget::is_init ( void  ) const
inline

在文件 fixedaspectratiowidget.h 第 30 行定义.

30{ return viewer_.is_init_; }

◆ mouseDoubleClickEvent()

void FixedAspectRatioWidget::mouseDoubleClickEvent ( QMouseEvent *  event)
overrideprotected

在文件 fixedaspectratiowidget.cc 第 55 行定义.

55 {
56 if (event->button() == Qt::LeftButton) {
57 emit focusOnThis(this);
58 QWidget::mouseDoubleClickEvent(event);
59 }
60}

◆ paintEvent()

void FixedAspectRatioWidget::paintEvent ( QPaintEvent *  event)
overrideprotected

在文件 fixedaspectratiowidget.cc 第 112 行定义.

112 {
113 QStyleOption opt;
114 opt.init(this);
115 QPainter p(this);
116 style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
117
118 QWidget::paintEvent(event);
119}

◆ resizeEvent()

void FixedAspectRatioWidget::resizeEvent ( QResizeEvent *  revent)
overrideprotected

在文件 fixedaspectratiowidget.cc 第 72 行定义.

72 {
73 QSize size = revent->size();
74
75 {
76 double aspect = static_cast<double>(viewer_.plane_.texWidth()) /
77 static_cast<double>(viewer_.plane_.texHeight());
78
79 int wc = 4;
80 int hc = 9;
81 if (aspect == 4.0 / 3.0) {
82 wc = 2;
83 hc = 3;
84 } else if (aspect == 16.0 / 10.0) {
85 wc = 4;
86 hc = 10;
87 }
88
89 int w = size.width();
90 int h = size.height();
91
92 int tmpH = w >> wc;
93 w = tmpH << wc;
94 size.setWidth(w);
95 tmpH *= hc;
96 if (tmpH <= h) {
97 size.setHeight(tmpH);
98 } else {
99 tmpH = h / hc;
100 h = tmpH * hc;
101 size.setHeight(h);
102 size.setWidth(tmpH << wc);
103 }
104 }
105
106 viewer_.setGeometry((revent->size().width() - size.width()) / 2,
107 (revent->size().height() - size.height()) / 2,
108 size.width(), size.height());
109 QWidget::resizeEvent(revent);
110}
GLsizei texWidth(void) const
Definition plane.h:47

◆ set_index()

void FixedAspectRatioWidget::set_index ( int  i)
inline

在文件 fixedaspectratiowidget.h 第 33 行定义.

33{ index_ = i; }

◆ SetupDynamicTexture()

void FixedAspectRatioWidget::SetupDynamicTexture ( const std::shared_ptr< Texture > &  textureObj)

在文件 fixedaspectratiowidget.cc 第 45 行定义.

46 {
47 if (textureObj == nullptr) {
48 viewer_.default_image_->setSizeChanged();
49 viewer_.plane_.set_texture(viewer_.default_image_);
50 } else {
51 viewer_.plane_.set_texture(textureObj);
52 }
53}
void set_texture(const std::shared_ptr< Texture > &t)
Definition plane.h:40

◆ StartOrStopUpdate()

void FixedAspectRatioWidget::StartOrStopUpdate ( bool  b)

在文件 fixedaspectratiowidget.cc 第 35 行定义.

35 {
36 if (viewer_.is_init_) {
37 if (b) {
38 refresh_timer_.start();
39 } else {
40 refresh_timer_.stop();
41 }
42 }
43}

该类的文档由以下文件生成: