68 lines
1.8 KiB
C++
68 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
#include <QObject>
|
|
#include <QWidget>
|
|
#include <QLabel>
|
|
#include <QThread>
|
|
|
|
#include "DataModelRegistry.hpp"
|
|
#include "NodeDataModel.hpp"
|
|
|
|
#include "opcv/CvImageViewWidget.h"
|
|
#include "opcv/CvImageData.h"
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
using QtNodes::PortType;
|
|
using QtNodes::PortIndex;
|
|
using QtNodes::NodeData;
|
|
using QtNodes::NodeDataType;
|
|
using QtNodes::NodeDataModel;
|
|
using QtNodes::NodeValidationState;
|
|
|
|
class CvImageShowModel :public NodeDataModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CvImageShowModel();
|
|
virtual ~CvImageShowModel() {}
|
|
|
|
public:
|
|
QString caption() const override { return QStringLiteral("cvͼÏñÏÔʾ"); }
|
|
QString name() const override { return QStringLiteral("cvͼÏñÏÔʾ"); }
|
|
virtual QString modelName() const { return QStringLiteral("cvͼÏñÏÔʾ"); }
|
|
|
|
QWidget* embeddedWidget() override { return mCvImageView; }
|
|
bool resizable() const override { return false; }
|
|
|
|
unsigned int nPorts(PortType portType) const override;
|
|
NodeDataType dataType(PortType portType, PortIndex portIndex) const override;
|
|
|
|
NodeValidationState validationState() const override { return modelValidationState; }
|
|
QString validationMessage() const override { return modelValidationError; }
|
|
|
|
public Q_SLOTS:
|
|
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:
|
|
CvImageViewWidget* mCvImageView;
|
|
|
|
std::shared_ptr<CvImageData> mCvImageData;
|
|
//std::shared_ptr<HRegionData> mCvRect;
|
|
|
|
public:
|
|
std::shared_ptr<NodeData> outData(PortIndex port) override;
|
|
void setInData(std::shared_ptr<NodeData>, int) override;
|
|
|
|
}; |