erlu/src/items/BlockItem.h

73 lines
2.4 KiB
C
Raw Normal View History

#pragma once
#include <QGraphicsObject>
#include <QSet>
#include <optional>
#include <QColor>
class ArrowItem;
class BlockItem final : public QGraphicsObject {
Q_OBJECT
public:
enum class Port { Input, Control, Output, Mechanism };
enum { Type = UserType + 1 };
explicit BlockItem(QString title = "Function", QGraphicsItem* parent = nullptr, int id = -1);
QRectF boundingRect() const override;
void paint(QPainter* p, const QStyleOptionGraphicsItem*, QWidget*) override;
int type() const override { return Type; }
QString title() const { return m_title; }
void setTitle(const QString& t);
QString number() const { return m_number; }
void setNumber(const QString& n);
bool hasDecomposition() const { return m_hasDecomposition; }
void setHasDecomposition(bool v) { m_hasDecomposition = v; update(); }
int id() const { return m_id; }
void setId(int id) { m_id = id; }
QPointF portScenePos(Port p) const;
удалено: build/.qt/QtDeploySupport.cmake удалено: build/.qt/QtDeployTargets.cmake удалено: build/CMakeCache.txt удалено: build/CMakeFiles/4.1.2/CMakeCXXCompiler.cmake удалено: build/CMakeFiles/4.1.2/CMakeDetermineCompilerABI_CXX.bin удалено: build/CMakeFiles/4.1.2/CMakeSystem.cmake удалено: build/CMakeFiles/4.1.2/CompilerIdCXX/CMakeCXXCompilerId.cpp удалено: build/CMakeFiles/4.1.2/CompilerIdCXX/a.out удалено: build/CMakeFiles/CMakeConfigureLog.yaml удалено: build/CMakeFiles/CMakeDirectoryInformation.cmake удалено: build/CMakeFiles/CMakeRuleHashes.txt удалено: build/CMakeFiles/InstallScripts.json удалено: build/CMakeFiles/Makefile.cmake удалено: build/CMakeFiles/Makefile2 удалено: build/CMakeFiles/TargetDirectories.txt удалено: build/CMakeFiles/cmake.check_cache удалено: build/CMakeFiles/idef0_editor.dir/DependInfo.cmake удалено: build/CMakeFiles/idef0_editor.dir/build.make удалено: build/CMakeFiles/idef0_editor.dir/cmake_clean.cmake удалено: build/CMakeFiles/idef0_editor.dir/compiler_depend.internal удалено: build/CMakeFiles/idef0_editor.dir/compiler_depend.make удалено: build/CMakeFiles/idef0_editor.dir/compiler_depend.ts удалено: build/CMakeFiles/idef0_editor.dir/depend.make удалено: build/CMakeFiles/idef0_editor.dir/flags.make удалено: build/CMakeFiles/idef0_editor.dir/idef0_editor_autogen/mocs_compilation.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/idef0_editor_autogen/mocs_compilation.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/link.d удалено: build/CMakeFiles/idef0_editor.dir/link.txt удалено: build/CMakeFiles/idef0_editor.dir/progress.make удалено: build/CMakeFiles/idef0_editor.dir/src/MainWindow.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/MainWindow.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/items/ArrowItem.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/items/ArrowItem.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/items/BlockItem.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/items/BlockItem.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/items/DiagramScene.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/items/DiagramScene.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/items/JunctionItem.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/items/JunctionItem.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/main.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/main.cpp.o.d удалено: build/CMakeFiles/idef0_editor_autogen.dir/AutogenInfo.json удалено: build/CMakeFiles/idef0_editor_autogen.dir/AutogenUsed.txt удалено: build/CMakeFiles/idef0_editor_autogen.dir/DependInfo.cmake удалено: build/CMakeFiles/idef0_editor_autogen.dir/ParseCache.txt удалено: build/CMakeFiles/idef0_editor_autogen.dir/build.make удалено: build/CMakeFiles/idef0_editor_autogen.dir/cmake_clean.cmake удалено: build/CMakeFiles/idef0_editor_autogen.dir/compiler_depend.internal удалено: build/CMakeFiles/idef0_editor_autogen.dir/compiler_depend.make удалено: build/CMakeFiles/idef0_editor_autogen.dir/compiler_depend.ts удалено: build/CMakeFiles/idef0_editor_autogen.dir/progress.make удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/DependInfo.cmake удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/build.make удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/cmake_clean.cmake удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/compiler_depend.make удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/compiler_depend.ts удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/progress.make удалено: build/CMakeFiles/progress.marks удалено: build/Makefile удалено: build/cmake_install.cmake удалено: build/idef0_editor удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_BlockItem.cpp удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_BlockItem.cpp.d удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_DiagramScene.cpp удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_DiagramScene.cpp.d удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_JunctionItem.cpp удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_JunctionItem.cpp.d удалено: build/idef0_editor_autogen/UVLADIE3JM/moc_MainWindow.cpp удалено: build/idef0_editor_autogen/UVLADIE3JM/moc_MainWindow.cpp.d удалено: build/idef0_editor_autogen/deps удалено: build/idef0_editor_autogen/moc_predefs.h удалено: build/idef0_editor_autogen/mocs_compilation.cpp удалено: build/idef0_editor_autogen/timestamp удалено: codex изменено: src/items/ArrowItem.cpp изменено: src/items/ArrowItem.h изменено: src/items/BlockItem.h изменено: src/items/DiagramScene.cpp изменено: src/items/DiagramScene.h
2026-02-23 00:23:03 +03:00
QPair<QPointF, QPointF> portSegment(Port p) const;
bool hitTestPort(const QPointF& scenePos, Port* outPort, QPointF* outLocalPos = nullptr, qreal radiusPx = 10.0) const;
удалено: build/.qt/QtDeploySupport.cmake удалено: build/.qt/QtDeployTargets.cmake удалено: build/CMakeCache.txt удалено: build/CMakeFiles/4.1.2/CMakeCXXCompiler.cmake удалено: build/CMakeFiles/4.1.2/CMakeDetermineCompilerABI_CXX.bin удалено: build/CMakeFiles/4.1.2/CMakeSystem.cmake удалено: build/CMakeFiles/4.1.2/CompilerIdCXX/CMakeCXXCompilerId.cpp удалено: build/CMakeFiles/4.1.2/CompilerIdCXX/a.out удалено: build/CMakeFiles/CMakeConfigureLog.yaml удалено: build/CMakeFiles/CMakeDirectoryInformation.cmake удалено: build/CMakeFiles/CMakeRuleHashes.txt удалено: build/CMakeFiles/InstallScripts.json удалено: build/CMakeFiles/Makefile.cmake удалено: build/CMakeFiles/Makefile2 удалено: build/CMakeFiles/TargetDirectories.txt удалено: build/CMakeFiles/cmake.check_cache удалено: build/CMakeFiles/idef0_editor.dir/DependInfo.cmake удалено: build/CMakeFiles/idef0_editor.dir/build.make удалено: build/CMakeFiles/idef0_editor.dir/cmake_clean.cmake удалено: build/CMakeFiles/idef0_editor.dir/compiler_depend.internal удалено: build/CMakeFiles/idef0_editor.dir/compiler_depend.make удалено: build/CMakeFiles/idef0_editor.dir/compiler_depend.ts удалено: build/CMakeFiles/idef0_editor.dir/depend.make удалено: build/CMakeFiles/idef0_editor.dir/flags.make удалено: build/CMakeFiles/idef0_editor.dir/idef0_editor_autogen/mocs_compilation.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/idef0_editor_autogen/mocs_compilation.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/link.d удалено: build/CMakeFiles/idef0_editor.dir/link.txt удалено: build/CMakeFiles/idef0_editor.dir/progress.make удалено: build/CMakeFiles/idef0_editor.dir/src/MainWindow.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/MainWindow.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/items/ArrowItem.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/items/ArrowItem.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/items/BlockItem.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/items/BlockItem.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/items/DiagramScene.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/items/DiagramScene.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/items/JunctionItem.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/items/JunctionItem.cpp.o.d удалено: build/CMakeFiles/idef0_editor.dir/src/main.cpp.o удалено: build/CMakeFiles/idef0_editor.dir/src/main.cpp.o.d удалено: build/CMakeFiles/idef0_editor_autogen.dir/AutogenInfo.json удалено: build/CMakeFiles/idef0_editor_autogen.dir/AutogenUsed.txt удалено: build/CMakeFiles/idef0_editor_autogen.dir/DependInfo.cmake удалено: build/CMakeFiles/idef0_editor_autogen.dir/ParseCache.txt удалено: build/CMakeFiles/idef0_editor_autogen.dir/build.make удалено: build/CMakeFiles/idef0_editor_autogen.dir/cmake_clean.cmake удалено: build/CMakeFiles/idef0_editor_autogen.dir/compiler_depend.internal удалено: build/CMakeFiles/idef0_editor_autogen.dir/compiler_depend.make удалено: build/CMakeFiles/idef0_editor_autogen.dir/compiler_depend.ts удалено: build/CMakeFiles/idef0_editor_autogen.dir/progress.make удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/DependInfo.cmake удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/build.make удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/cmake_clean.cmake удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/compiler_depend.make удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/compiler_depend.ts удалено: build/CMakeFiles/idef0_editor_autogen_timestamp_deps.dir/progress.make удалено: build/CMakeFiles/progress.marks удалено: build/Makefile удалено: build/cmake_install.cmake удалено: build/idef0_editor удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_BlockItem.cpp удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_BlockItem.cpp.d удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_DiagramScene.cpp удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_DiagramScene.cpp.d удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_JunctionItem.cpp удалено: build/idef0_editor_autogen/DWIBBXP2LJ/moc_JunctionItem.cpp.d удалено: build/idef0_editor_autogen/UVLADIE3JM/moc_MainWindow.cpp удалено: build/idef0_editor_autogen/UVLADIE3JM/moc_MainWindow.cpp.d удалено: build/idef0_editor_autogen/deps удалено: build/idef0_editor_autogen/moc_predefs.h удалено: build/idef0_editor_autogen/mocs_compilation.cpp удалено: build/idef0_editor_autogen/timestamp удалено: codex изменено: src/items/ArrowItem.cpp изменено: src/items/ArrowItem.h изменено: src/items/BlockItem.h изменено: src/items/DiagramScene.cpp изменено: src/items/DiagramScene.h
2026-02-23 00:23:03 +03:00
QPointF portLocalPos(Port p) const;
void addArrow(ArrowItem* a);
void removeArrow(ArrowItem* a);
std::optional<qreal> price() const { return m_price; }
void setPrice(std::optional<qreal> price);
static void setCurrencyFormat(const QString& symbol, const QString& placement);
static void setVisualTheme(const QColor& foreground,
const QColor& background,
const QColor& border,
const QColor& font,
const QColor& selectedBackground);
signals:
void geometryChanged();
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* e) override;
private:
QString formattedPrice() const;
static QPair<QString, QString> currencyAffixes();
QString m_title;
QString m_number;
QRectF m_rect; // local rect
int m_id;
bool m_hasDecomposition = false;
QSet<ArrowItem*> m_arrows;
std::optional<qreal> m_price;
static QString s_currencySymbol;
static QString s_currencyPlacement;
static QColor s_foregroundColor;
static QColor s_backgroundColor;
static QColor s_borderColor;
static QColor s_fontColor;
static QColor s_selectedBackgroundColor;
};