//function is used to draw a line while moving cursor from the one point to find place to click for another point void passiveLineMotion(Linked_list* linked_list, Point* point1, Point* point2) { size_t number_of_nodes = count(linked_list); Node* indexNode = linked_list->head; if ((mapState.DrawingLine == START) && (number_of_nodes != 0)) { drawingLine(point1->x, point1->y, point2->x, point2->y); } }
void AddLine(const std::vector<std::string> & inputParts, std::vector<std::shared_ptr<CShape>> & figures, std::vector<std::shared_ptr<sf::Shape>> & shapes) { CPoint p1 = CPoint(std::stod(inputParts[1]), std::stod(inputParts[2])); CPoint p2 = CPoint(std::stod(inputParts[3]), std::stod(inputParts[4])); std::string outlineColor = inputParts[5]; CLineSegment line = CLineSegment(p1, p2, outlineColor); sf::RectangleShape drawingLine(sf::Vector2f((float)line.GetPerimeter(), (float)2)); sf::RectangleShape(sf::Vector2f((float)line.GetPerimeter(), 3.f)); p2.GetPosition().first < p1.GetPosition().first ? drawingLine.setPosition(float(p2.GetPosition().first), float(p2.GetPosition().second)) : drawingLine.setPosition(float(p1.GetPosition().first), float(p1.GetPosition().second)); drawingLine.setRotation(float(std::atan((p2.GetPosition().second - p1.GetPosition().second) / (p2.GetPosition().first - p1.GetPosition().first)) * 180 / boost::math::constants::pi<double>())); drawingLine.setFillColor(ConvertHexToRgb(inputParts[5])); drawingLine.setOutlineThickness(3.f); figures.push_back(std::make_shared<CLineSegment>(line)); shapes.push_back(std::make_shared<sf::RectangleShape>(drawingLine)); }