MCPcopy Create free account
hub / github.com/antvis/F2Native / handleClick

Method handleClick

core/graphics/interaction/Tap.cpp:21–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21const std::string interaction::Tap::handleClick(const util::Point &point) {
22 util::Point _point = point;
23
24 utils::Tracer *tracer = this->chart_->GetLogTracer();
25
26 nlohmann::json callbackGeomRecords;
27 nlohmann::json geomRecords;
28 // 先处理坐标轴点击
29// bool handleTap = false;
30// bool isSelect = true;
31 nlohmann::json tickInfo;
32 scale::Tick tick;
33
34 // 新逻辑
35 bool geomsHandleTap = false;
36 for (auto &geom : this->chart_->geoms_) {
37 if (!geom->isSelectionEnable()) {
38 break;
39 }
40
41 nlohmann::json newSelectedArray;
42 bool geomHandleTap = false;
43
44 const nlohmann::json records = geom->GetSnapRecords(this->chart_, _point, true);
45 tracer->trace("%s GetSnapRecords: %s", "#Tap handleClick", records.dump().c_str());
46 if (records.size() > 0) {
47 geomHandleTap = true;
48 for (std::size_t index = 0; index < records.size(); ++index) {
49 const nlohmann::json &record = records[index];
50 if (!geom->isSelected(record)) {
51 geomRecords.push_back(record);
52 newSelectedArray.push_back(record);
53 nlohmann::json tr;
54 for (const auto &el : record.items()) {
55 if (el.key().substr(0, 1) != "_") {
56 tr[el.key()] = el.value();
57 }
58 }
59 callbackGeomRecords.push_back(tr);
60 } else if (!geom->isDeselect()) {
61 geomHandleTap = false;
62 }
63 }
64 }
65
66 if (geomHandleTap) {
67 geomsHandleTap = true;
68 geom->SetSelectedArray(newSelectedArray, true);
69 }
70 }
71
72 if (geomsHandleTap) {
73 this->chart_->axisController_->associateGeomTap(this->chart_, _point, geomRecords);
74 chart_->Repaint();
75 nlohmann::json rst = {};
76 if (callbackGeomRecords.size() > 0) {
77 rst["geomRecords"] = callbackGeomRecords;
78 }

Callers 1

onClickMethod · 0.95

Calls 15

GetStringFunction · 0.85
GetLogTracerMethod · 0.80
isSelectionEnableMethod · 0.80
GetSnapRecordsMethod · 0.80
traceMethod · 0.80
dumpMethod · 0.80
isSelectedMethod · 0.80
push_backMethod · 0.80
isDeselectMethod · 0.80
SetSelectedArrayMethod · 0.80
associateGeomTapMethod · 0.80
onTapMethod · 0.80

Tested by

no test coverage detected