@@ -17,28 +17,28 @@ MagneticStates magneticStates(
17
17
const auto & scenario = pres.model ();
18
18
19
19
// Check if we keep the current magnetism
20
- if (cur.horizontal )
21
- {
22
- const auto state_date = scenario.events .at (cur.horizontal ->eventId ()).date ();
23
-
24
- const double rel_y_distance = std::abs (cur.horizontal ->heightPercentage () - pt.y );
25
- const double abs_y_distance = rel_y_distance * pres.view ().height ();
26
-
27
- if (abs_y_distance < magnetic && state_date < pt.date )
28
- {
29
- return {cur.horizontal , cur.vertical , true };
30
- }
31
- }
32
- else if (cur.vertical )
33
- {
34
- auto cur_date = Scenario::parentEvent (*cur.vertical , scenario).date ();
35
- const double abs_x_distance
36
- = std::abs ((cur_date.impl - pt.date .impl ) / pres.zoomRatio ());
37
- if (abs_x_distance < magnetic)
38
- {
39
- return {cur.horizontal , cur.vertical , true };
40
- }
41
- }
20
+ // if(cur.horizontal)
21
+ // {
22
+ // const auto state_date = scenario.events.at(cur.horizontal->eventId()).date();
23
+
24
+ // const double rel_y_distance = std::abs(cur.horizontal->heightPercentage() - pt.y);
25
+ // const double abs_y_distance = rel_y_distance * pres.view().height();
26
+
27
+ // if(abs_y_distance < magnetic && state_date < pt.date)
28
+ // {
29
+ // return {cur.horizontal, cur.vertical, true};
30
+ // }
31
+ // }
32
+ // else if(cur.vertical)
33
+ // {
34
+ // auto cur_date = Scenario::parentEvent(*cur.vertical, scenario).date();
35
+ // const double abs_x_distance
36
+ // = std::abs((cur_date.impl - pt.date.impl) / pres.zoomRatio());
37
+ // if(abs_x_distance < magnetic)
38
+ // {
39
+ // return {cur.horizontal, cur.vertical, true};
40
+ // }
41
+ // }
42
42
43
43
EventModel& start_ev = scenario.startEvent ();
44
44
SCORE_ASSERT (!start_ev.states ().empty ());
@@ -57,14 +57,18 @@ MagneticStates magneticStates(
57
57
58
58
StateModel* min_y_state = start_st;
59
59
double min_y_distance = std::numeric_limits<double >::max ();
60
+ StateModel* closest_x_y_state = start_st;
61
+ QPointF closest_x_y_distance
62
+ = {std::numeric_limits<double >::max (), std::numeric_limits<double >::max ()};
63
+
60
64
for (auto & state : scenario.states )
61
65
{
62
66
const auto state_date = eventDates[state.eventId ()];
63
67
64
68
if (state_date >= pt_msec)
65
69
continue ;
66
70
67
- const TimeVal rel_x_distance{std::abs (state_date. impl - pt. date . impl ) };
71
+ const TimeVal rel_x_distance{pt. date . impl - state_date. impl };
68
72
const double abs_x_distance = rel_x_distance.toPixels (pres.zoomRatio ());
69
73
70
74
const double rel_y_distance = std::abs (state.heightPercentage () - pt.y );
@@ -86,11 +90,11 @@ MagneticStates magneticStates(
86
90
eventDates.clear ();
87
91
if (min_x_distance < min_y_distance)
88
92
{
89
- return {nullptr , min_x_state, min_x_distance < magnetic };
93
+ return {nullptr , min_x_state, true };
90
94
}
91
95
else
92
96
{
93
- return {min_y_state, nullptr , min_y_distance < magnetic };
97
+ return {min_y_state, nullptr , true };
94
98
}
95
99
}
96
100
0 commit comments