| 134 | } |
| 135 | |
| 136 | void Rect::setPointPosition(const UnitVector& position, const Referential& ref) |
| 137 | { |
| 138 | const UnitVector oppositePointPosition = this->getPosition(ref.flip()); |
| 139 | const double radAngle = Utils::Math::convertToRadian(-m_angle); |
| 140 | const UnitVector movedPoint |
| 141 | = rotatePointAroundCenter(position, oppositePointPosition, -radAngle); |
| 142 | |
| 143 | this->setPosition(position, ref); |
| 144 | |
| 145 | if (ref.isOnCorner()) |
| 146 | { |
| 147 | if (ref.isOnTopSide()) |
| 148 | { |
| 149 | this->setSize( |
| 150 | { movedPoint.x - position.x, movedPoint.y - position.y }, ref); |
| 151 | } |
| 152 | else |
| 153 | { |
| 154 | this->setSize( |
| 155 | { position.x - movedPoint.x, position.y - movedPoint.y }, ref); |
| 156 | } |
| 157 | } |
| 158 | if (ref.isOnLeftSide() || ref.isOnRightSide()) |
| 159 | { |
| 160 | if (ref.isOnLeftSide()) |
| 161 | { |
| 162 | this->setSize({ movedPoint.x - position.x, m_size.y }, ref); |
| 163 | } |
| 164 | else |
| 165 | { |
| 166 | this->setSize({ position.x - movedPoint.x, m_size.y }, ref); |
| 167 | } |
| 168 | } |
| 169 | else // we are on TopSide or BottomSide here, no need to specify the |
| 170 | // condition |
| 171 | { |
| 172 | if (ref.isOnTopSide()) |
| 173 | { |
| 174 | this->setSize({ m_size.x, movedPoint.y - position.y }, ref); |
| 175 | } |
| 176 | else |
| 177 | { |
| 178 | this->setSize({ m_size.x, position.y - movedPoint.y }, ref); |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | UnitVector Rect::getPosition(const Referential& ref) const |
| 184 | { |
no test coverage detected