MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / paintEvent

Method paintEvent

cp-profiler/src/cpprofiler/tree/tree_scroll_area.cpp:56–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void TreeScrollArea::paintEvent(QPaintEvent *event)
57{
58
59 QPainter painter(this->viewport());
60
61 painter.setRenderHint(QPainter::Antialiasing);
62
63 if (m_start_node == NodeID::NoNode)
64 {
65 return;
66 }
67
68 painter.scale(m_options.scale, m_options.scale);
69
70 if (!m_layout.ready(m_start_node) || !m_layout.getLayoutDone(m_start_node))
71 {
72 return;
73 }
74
75 auto bb = m_layout.getBoundingBox(m_start_node);
76
77 auto tree_width = bb.right - bb.left;
78
79 auto tree_height = m_layout.getHeight(m_start_node) * layout::dist_y;
80
81 auto viewport_size = viewport()->size();
82
83 auto h_page_step = viewport_size.width() / m_options.scale;
84 auto v_page_step = viewport_size.height() / m_options.scale;
85
86 /// set range in real pixels
87 horizontalScrollBar()->setRange(0, tree_width - h_page_step);
88 horizontalScrollBar()->setPageStep(h_page_step);
89
90 verticalScrollBar()->setRange(0, tree_height + y_margin / m_options.scale - v_page_step);
91 verticalScrollBar()->setPageStep(v_page_step);
92
93 horizontalScrollBar()->setSingleStep(layout::min_dist_x);
94 verticalScrollBar()->setSingleStep(layout::dist_y);
95
96 {
97 QPen pen = painter.pen();
98 pen.setWidth(2);
99 painter.setPen(pen);
100 }
101
102 auto x_off = horizontalScrollBar()->value();
103 auto y_off = verticalScrollBar()->value();
104 painter.translate(-x_off, -y_off);
105 /// TODO: this need to aquire layout mutex
106
107 auto half_w = viewport()->width() / 2;
108 auto half_h = viewport()->height() / 2;
109
110 auto displayed_width = static_cast<int>(viewport()->size().width() / m_options.scale);
111 auto displayed_height = static_cast<int>(viewport()->size().height() / m_options.scale);
112
113 // auto start_x = m_options.x_off + displayed_width / 2;

Callers

nothing calls this directly

Calls 11

readyMethod · 0.80
getLayoutDoneMethod · 0.80
getHeightMethod · 0.80
setRangeMethod · 0.80
setWidthMethod · 0.80
drawRectMethod · 0.80
sizeMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
valueMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected