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

Method findNodeClicked

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

Make sure the layout for nodes is done

Source from the content-addressed store, hash-verified

180
181/// Make sure the layout for nodes is done
182NodeID TreeScrollArea::findNodeClicked(int x, int y)
183{
184 utils::MutexLocker tree_lock(&m_tree.treeMutex());
185 utils::MutexLocker layout_lock(&m_layout.getMutex());
186
187 using namespace traditional;
188
189 /// TODO: disable while constructing
190 /// calculate real x and y
191 auto x_off = horizontalScrollBar()->value();
192 auto y_off = verticalScrollBar()->value();
193
194 x = x / m_options.scale + x_off;
195 y = y / m_options.scale + y_off;
196
197 std::queue<NodeID> queue;
198
199 auto root = m_tree.getRoot();
200
201 if (root == NodeID::NoNode)
202 {
203 return NodeID::NoNode;
204 }
205
206 queue.push(root);
207
208 while (!queue.empty())
209 {
210
211 auto node = queue.front();
212 queue.pop();
213 auto node_pos = getNodeCoordinate(node);
214
215 const auto hidden = m_vis_flags.isHidden(node);
216
217 QRect node_area;
218 if (hidden)
219 {
220 auto node_pos_tl = node_pos - QPoint{HALF_COLLAPSED_WIDTH, 0};
221 node_area = QRect(node_pos_tl, QSize{COLLAPSED_WIDTH, COLLAPSED_DEPTH});
222 }
223 else
224 {
225 auto node_pos_tl = node_pos - QPoint{MAX_NODE_W / 2, 0};
226 node_area = QRect(node_pos_tl, QSize{MAX_NODE_W, MAX_NODE_W});
227 }
228
229 if (node_area.contains(x, y))
230 {
231 return node;
232 }
233 else if (!hidden)
234 {
235
236 auto kids = m_tree.childrenCount(node);
237
238 for (auto i = 0; i < kids; ++i)
239 {

Callers

nothing calls this directly

Calls 8

getRealBBFunction · 0.85
isHiddenMethod · 0.80
containsMethod · 0.80
getLayoutDoneMethod · 0.80
valueMethod · 0.45
getRootMethod · 0.45
childrenCountMethod · 0.45
getChildMethod · 0.45

Tested by

no test coverage detected