59 Q_ASSERT_X(
isVertical(),
"ConductorSegment::canMove1stPointX",
"segment non vertical");
70 possible_dx = asked_dx;
78 possible_dx = asked_dx;
85 qreal first_x =
point1.x();
90 if (first_x + asked_dx < prev_segment_first_x + 12.0) {
91 possible_dx = -first_x + prev_segment_first_x + 12.0;
94 possible_dx = asked_dx;
98 if (first_x + asked_dx >= prev_segment_first_x - 12.0) {
99 possible_dx = prev_segment_first_x - 12.0 - first_x;
102 possible_dx = asked_dx;
118 Q_ASSERT_X(
isVertical(),
"ConductorSegment::canMove2ndPointX",
"segment non vertical");
129 possible_dx = asked_dx;
137 possible_dx = asked_dx;
144 qreal second_x =
point2.x();
149 if (second_x + asked_dx < next_segment_second_x + 12.0) {
150 possible_dx = -second_x + next_segment_second_x + 12.0;
153 possible_dx = asked_dx;
157 if (second_x + asked_dx >= next_segment_second_x - 12.0) {
158 possible_dx = next_segment_second_x - 12.0 - second_x;
161 possible_dx = asked_dx;
177 Q_ASSERT_X(
isHorizontal(),
"ConductorSegment::canMove1stPointY",
"segment non horizontal");
188 possible_dy = asked_dy;
196 possible_dy = asked_dy;
203 qreal first_y =
point1.y();
208 if (first_y + asked_dy < prev_segment_first_y + 12.0) {
209 possible_dy = -first_y + prev_segment_first_y + 12.0;
212 possible_dy = asked_dy;
216 if (first_y + asked_dy >= prev_segment_first_y - 12.0) {
217 possible_dy = prev_segment_first_y - 12.0 - first_y;
220 possible_dy = asked_dy;
236 Q_ASSERT_X(
isHorizontal(),
"ConductorSegment::canMove2ndPointY",
"segment non horizontal");
247 possible_dy = asked_dy;
255 possible_dy = asked_dy;
262 qreal second_y =
point2.y();
267 if (second_y + asked_dy < next_segment_second_y + 12.0) {
268 possible_dy = -second_y + next_segment_second_y + 12.0;
271 possible_dy = asked_dy;
275 if (second_y + asked_dy >= next_segment_second_y - 12.0) {
276 possible_dy = next_segment_second_y - 12.0 - second_y;
279 possible_dy = asked_dy;
291 Q_ASSERT_X(
isVertical(),
"ConductorSegment::moveX",
"segment non vertical");
299 qreal real_dx_for_1st_point = 0.0;
300 qreal real_dx_for_2nd_point = 0.0;
304 qreal final_movement = (dx <= 0.0) ? qMax(real_dx_for_1st_point, real_dx_for_2nd_point) : qMin(real_dx_for_1st_point, real_dx_for_2nd_point);
307 if (has_prev_segment) {
308 point1.rx() += final_movement;
320 if (has_next_segment) {
321 point2.rx() += final_movement;
339 Q_ASSERT_X(
isHorizontal(),
"ConductorSegment::moveY",
"segment non horizontal");
347 qreal real_dy_for_1st_point = 0.0;
348 qreal real_dy_for_2nd_point = 0.0;
352 qreal final_movement = (dy <= 0.0) ? qMax(real_dy_for_1st_point, real_dy_for_2nd_point) : qMin(real_dy_for_1st_point, real_dy_for_2nd_point);
355 if (has_prev_segment) {
356 point1.ry() += final_movement;
368 if (has_next_segment) {
369 point2.ry() += final_movement;
bool canMove1stPointY(const qreal &, qreal &) const
QPointF firstPoint() const
void setSecondPoint(const QPointF &)
virtual ~ConductorSegment()
ConductorSegment * previousSegment() const
void setFirstPoint(const QPointF &)
bool isHorizontal() const
bool hasPreviousSegment() const
bool hasNextSegment() const
void setPreviousSegment(ConductorSegment *)
bool canMove1stPointX(const qreal &, qreal &) const
ConductorSegmentType
Known kinds of conductor segments.
bool canMove2ndPointX(const qreal &, qreal &) const
bool canMove2ndPointY(const qreal &, qreal &) const
bool isFirstSegment() const
void setNextSegment(ConductorSegment *)
ConductorSegment * previous_segment
ConductorSegment(const QPointF &, const QPointF &, ConductorSegment *=nullptr, ConductorSegment *=nullptr)
void moveY(const qreal &)
ConductorSegment * nextSegment() const
void moveX(const qreal &)
ConductorSegment * next_segment
QET::ConductorSegmentType type() const
bool isLastSegment() const
QPointF secondPoint() const