This repository has been archived on 2026-05-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
DRAwer_2_0/System.h

73 lines
2.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#define WIDGET_POSITION event->pos()
#define UCS_POSITION screenToLogical(WIDGET_POSITION)
#define CURVE_AS_LINE(CURVE) dynamic_cast<Line*>(CURVE)
#define CURVE_AS_CIRCLE(CURVE) dynamic_cast<Circle*>(CURVE)
// GCS — геометрический солвер из FreeCAD
#include "GCS/Geo.h"
#include "GCS/GCS.h"
using namespace GCS;
/// Удобный тип для хранения пары линий (порядок не важен)
using LinePair = std::pair<Line*, Line*>;
/// Удобный тип для хранения пары точек (порядок не важен)
using PointPair = std::pair<Point*, Point*>;
/// Удобный тип для хранения пары кривых (порядок не важен)
using CurvePair = std::pair<Curve*, Curve*>;
#include <QWidget>
#include <QMouseEvent>
#include <QPointF>
#include <QMessageBox>
#include <QToolTip>
#include <QKeyEvent>
#ifdef _DEBUG
#include <QDebug>
#endif
constexpr auto EPS = 1e-9;
constexpr auto ZOOM_STEP = 0.05;
// ===================================================================
// Типы и перечисления
// ===================================================================
/**
* @brief Режимы работы с холстом
*/
enum class Mode : int
{
None = 0, ///< Режим отсутствия действия
DrawingLine = 1, ///< Режим рисования линии
Parallel = 2, ///< Режим задания параллельности
Coincedent = 3, ///< Режим задания совпадения точек
Horizontal = 4, ///< Режим задания горизонтальности
Vertical = 5, ///< Режим задания вертикальности
Perpendicular = 6, ///< Режим задания перпендикулярности
DrawingCircle = 7, ///< Режим рисования окружности
Tangent = 8 //< Режим задания касательности
};
struct TextObject {
QPointF pos; ///< Логическая позиция (левый верхний угол)
QString text; ///< Текст
int tag; ///< Тег для идентификации
QFont font{ QFont("Arial", 12) }; ///< Шрифт (можно менять позже)
};
/**
* @brief Структура для хранения информации об ограничении
*/
struct ConstraintInfo {
Mode mode; ///< Тип ограничения
std::variant<LinePair, PointPair, CurvePair> data; ///< Данные ограничения
};
// ===================================================================
// Типы и перечисления
// ===================================================================