86 lines
2.2 KiB
C++
86 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <QtCore>
|
|
#include <QObject>
|
|
#include <QWidget>
|
|
#include <QEvent>
|
|
#include <QMouseEvent>
|
|
#include <QWheelEvent>
|
|
#include <QHBoxLayout>
|
|
#include <QVBoxLayout>
|
|
#include <QGridLayout>
|
|
|
|
#include <QtWidgets/QGraphicsView>
|
|
//#include <QtWidgets/QDoubleSpinBox>
|
|
#include <QtWidgets/QLabel>
|
|
#include <QtWidgets/QSlider>
|
|
|
|
#include "DataModelRegistry.hpp"
|
|
#include "NodeDataModel.hpp"
|
|
#include "Connection.hpp"
|
|
|
|
#include "opcv/CvImageData.h"
|
|
#include "opcv/CvGraphicsViewWidget.h"
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
using QtNodes::PortType;
|
|
using QtNodes::PortIndex;
|
|
using QtNodes::NodeData;
|
|
using QtNodes::NodeDataType;
|
|
using QtNodes::NodeDataModel;
|
|
using QtNodes::NodeValidationState;
|
|
using QtNodes::Connection;
|
|
|
|
class CvGraphicsShowModel :public NodeDataModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CvGraphicsShowModel();
|
|
virtual ~CvGraphicsShowModel() {}
|
|
|
|
public:
|
|
QString caption() const override { return QStringLiteral("cv图像Graphics显示"); }
|
|
QString name() const override { return QStringLiteral("cv图像Graphics显示"); }
|
|
virtual QString modelName() const { return QStringLiteral("cv图像Graphics显示"); }
|
|
|
|
QWidget* embeddedWidget() override { return widget; }
|
|
//bool resizable() const override { return true; }
|
|
bool resizable() const override { return false; }
|
|
|
|
NodeValidationState validationState() const override { return modelValidationState; }
|
|
QString validationMessage() const override { return modelValidationError; }
|
|
|
|
unsigned int nPorts(PortType portType) const override;
|
|
NodeDataType dataType(PortType portType, PortIndex portIndex) const override;
|
|
|
|
|
|
public Q_SLOTS:
|
|
void onQSliderValueChanged(int val);
|
|
|
|
//void onInputConnectionDeleted();
|
|
|
|
void inputConnectionDeleted(QtNodes::Connection const&) override;
|
|
|
|
protected:
|
|
bool RunTask();
|
|
bool eventFilter(QObject* watched, QEvent* event) override;
|
|
|
|
public:
|
|
NodeValidationState modelValidationState = NodeValidationState::Warning;
|
|
QString modelValidationError = QStringLiteral("图片输入未连接!");
|
|
|
|
private:
|
|
qreal mScaledNum = 1.0; //视口缩放倍数
|
|
|
|
QSlider* horizontalSlider;
|
|
QWidget* widget;
|
|
CvGraphicsViewWidget* mCvGraphicsView;
|
|
std::shared_ptr<CvImageData> mCvImageData;
|
|
|
|
public:
|
|
void setInData(std::shared_ptr<NodeData>, int) override;
|
|
std::shared_ptr<NodeData> outData(PortIndex port) override;
|
|
|
|
}; |