|
- #ifndef BASEDOCUMENT_H
- #define BASEDOCUMENT_H
-
- #include <QWidget>
- #include <QString>
-
- class BaseDocument : public QWidget
- {
- Q_OBJECT
- public:
- enum DocumentType { HMI, PLC };
- BaseDocument(DocumentType type, QWidget *parent = nullptr);
- virtual ~BaseDocument() = default;
-
- DocumentType type() const;
- virtual QString title() const = 0;
- virtual QString filePath() const;
- virtual void setFilePath(const QString &path);
- virtual bool isModified() const;
- virtual void setModified(bool modified);
-
- // 保存/加载接口
- virtual bool saveToFile(const QString &filePath) = 0;
- virtual bool loadFromFile(const QString &filePath) = 0;
-
-
- // 设置变换矩阵
- virtual void setTransform(const QTransform& transform) {
- m_transform = transform;
- update();
- }
-
- // 获取文档内容尺寸(子类需要重写)
- virtual QSize getContentSize() const { return QSize(800, 600); } // 默认尺寸
-
- // 重写paintEvent应用变换
- // virtual void paintEvent(QPaintEvent *event) override {
- // QPainter painter(this);
- // painter.setTransform(m_transform);
- // // 子类应调用父类的paintEvent? 或者自行绘制
- // }
-
- protected:
- DocumentType m_type;
- QString m_filePath;
- bool m_modified = false;
- QTransform m_transform;
- };
-
- #endif // BASEDOCUMENT_H
|