<commit_before>#include "canvaswidget.h"

#include <QDebug>
CanvasWidget::CanvasWidget(QWidget *parent) :
    QWidget(parent), selected(NULL), transformation(NONE)
{
    epsilon.x = 50;
    epsilon.y = 50;
    creatingType = 1;
    defaultOffsetParallelogram = 30.0;
}

CanvasWidget::~CanvasWidget() {
    for (unsigned i = 0; i < shapes.size(); i++) {
        delete shapes[i];
    }
}

void CanvasWidget::changeType(int type)
{
    creatingType = type;
}

void CanvasWidget::clearSelectedShapes()
{
    for(const auto &shape: shapes) {
        (&*shape)->select(false);
    }
    selectedShapes.clear();
}
void CanvasWidget::insertShapeInSelectedShapes(QtShape2D* shape)
{
    shape->select(true);
    selectedShapes.insert(shape);
}

bool CanvasWidget::havingShapeInSelectedShapes(QtShape2D* shape) {
    size_t oldSize = selectedShapes.size();
    selectedShapesContainer tmpCont = selectedShapes;
    tmpCont.insert(shape);
    return oldSize == tmpCont.size();
}

void CanvasWidget::selectAll()
{
    clearSelectedShapes();
    for(const auto &shape: shapes) {
        (&*shape)->select(true);
        selectedShapes.insert(&*shape);
    }
    update();
}

void CanvasWidget::mousePressEvent(QMouseEvent *event) {

    pressedPoint.x = event->localPos().x();
    pressedPoint.y = event->localPos().y();

    selected = NULL;
    transformation = NONE;
    for(unsigned i = shapes.size(); i > 0; i--) {
        if(shapes[i - 1]->belongs(pressedPoint)) {
            //Нажали на фигуру
            toFront(i - 1); //переместилю фигуру вперед
            selected = shapes[shapes.size() - 1]; //Запоминаем последню выбранную фигуры

            //Проверяем нажатие на контроллер масштабирования (левый верхний)
            if(selected->isTopLeft(pressedPoint, epsilon)) {
                transformation = LEFT_RESIZE;
            }
            //Проверяем нажатие на контроллек масштабирования (правый нижний)
            else if(selected->isBottomRight(pressedPoint, epsilon)){
                transformation = RIGHT_RESIZE;
            }

            if (transformation == LEFT_RESIZE || transformation == RIGHT_RESIZE) //Оставляем только одну выделенную фигуру6 которую хотим масштабировать
                clearSelectedShapes();

             insertShapeInSelectedShapes(selected);

            if(selected->getType() == 2) {
                if(((QtParallelogram*)selected)->isControlPoint(pressedPoint, epsilon)) {<commit_msg>Moving trubles:)<commit_after>#include "canvaswidget.h"

#include <QDebug>
CanvasWidget::CanvasWidget(QWidget *parent) :
    QWidget(parent), selected(NULL), transformation(NONE)
{
    epsilon.x = 50;
    epsilon.y = 50;
    creatingType = 1;
    defaultOffsetParallelogram = 30.0;
}

CanvasWidget::~CanvasWidget() {
    for (unsigned i = 0; i < shapes.size(); i++) {
        delete shapes[i];
    }
}

void CanvasWidget::changeType(int type)
{
    creatingType = type;
}

void CanvasWidget::clearSelectedShapes()
{
    for(const auto &shape: shapes) {
        (&*shape)->select(false);
    }
    selectedShapes.clear();
}
void CanvasWidget::insertShapeInSelectedShapes(QtShape2D* shape)
{
    shape->select(true);
    selectedShapes.insert(shape);
}

bool CanvasWidget::havingShapeInSelectedShapes(QtShape2D* shape) {
    size_t oldSize = selectedShapes.size();
    selectedShapesContainer tmpCont = selectedShapes;
    tmpCont.insert(shape);
    return oldSize == tmpCont.size();
}

void CanvasWidget::selectAll()
{
    clearSelectedShapes();
    for(const auto &shape: shapes) {
        (&*shape)->select(true);
        selectedShapes.insert(&*shape);
    }
    update();
}

void CanvasWidget::mousePressEvent(QMouseEvent *event) {

    pressedPoint.x = event->localPos().x();
    pressedPoint.y = event->localPos().y();

    selected = NULL;
    transformation = NONE;
    for(unsigned i = shapes.size(); i > 0; i--) {
        if(shapes[i - 1]->belongs(pressedPoint)) {
            //Нажали на фигуру
            toFront(i - 1); //переместилю фигуру вперед
            selected = shapes[shapes.size() - 1]; //Запоминаем последню выбранную фигуры

            //Проверяем нажатие на контроллер масштабирования (левый верхний)
            if(selected->isTopLeft(pressedPoint, epsilon)) {
                transformation = LEFT_RESIZE;
            }
            //Проверяем нажатие на контроллек масштабирования (правый нижний)
            else if(selected->isBottomRight(pressedPoint, epsilon)){
                transformation = RIGHT_RESIZE;
            }

            if (transformation == LEFT_RESIZE || transformation == RIGHT_RESIZE) //Оставляем только одну выделенную фигуру6 которую хотим масштабировать
                clearSelectedShapes();
            if (havingShapeInSelectedShapes(selected))
                transformation = MOVING;
             insertShapeInSelectedShapes(selected);

            if(selected->getType() == 2) {
                if(((QtParallelogram*)selected)->isControlPoint(pressedPoint, epsilon)) {
{'fraction_non_alphanumeric': 0.12404349577124446, 'fraction_numerical': 0.00684655658477648, 'mean_word_length': 2.9736, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2798354', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1602, 'n_words': 293}