Skip to content

Commit

Permalink
cv complete 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
SoTosorrow committed May 22, 2021
1 parent 27264ce commit 9a3a639
Show file tree
Hide file tree
Showing 13 changed files with 491 additions and 68 deletions.
File renamed without changes.
76 changes: 65 additions & 11 deletions src/vapour_action_cv.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,78 @@ class VapourActionCvShow : public VapourAction
{
public:
VapourActionCvShow(cv::Mat m,int n=1){
for(int i=0;i<n;i++){
QPushButton *temp = new QPushButton("button",this);
temp->setStyleSheet("QPushButton { background-color:gray; border-radius:5px;font-size:20px; }");
temp->setGeometry(0,i*30,100,25);
edits.append(temp);
}
connect(this->edits[0], &QPushButton::clicked, this, [=](){
this->edits[0]->setText("CV Test");
cv::imshow("test",m);
});
Q_UNUSED(n);
QLineEdit* edit1 = new QLineEdit("1",this);
edit1->setAlignment(Qt::AlignLeft);
edit1->setGeometry(0,0,150,25);
QLineEdit* edit2 = new QLineEdit("1",this);
edit2->setAlignment(Qt::AlignLeft);
edit2->setGeometry(0,30,150,25);
QLineEdit* edit3 = new QLineEdit("1",this);
edit3->setAlignment(Qt::AlignLeft);
edit3->setGeometry(0,60,150,25);
QLineEdit* edit4 = new QLineEdit("1",this);
edit4->setAlignment(Qt::AlignLeft);
edit4->setGeometry(0,90,150,25);
edits.append(edit1);
edits.append(edit2);
edits.append(edit3);
edits.append(edit4);

// button = new QPushButton("button",this);
// button->setGeometry(0,30,100,25);
// button->setStyleSheet("QPushButton { background-color:gray; border-radius:5px;font-size:20px; }");

// connect(button, &QPushButton::clicked, this, [=](){
// button->setText("CV Test");
// cv::imshow("test",tm);
// });
}
~VapourActionCvShow(){
qDeleteAll(edits);
edits.clear();
}

public:
QList<QPushButton*> edits;
QList<QLineEdit*> edits;
// QPushButton* button;
cv::Mat tm;
//QLineEdit* edit;



};


class VapourActionCvInput : public VapourAction
{
public:
VapourActionCvInput(cv::Mat m,int n=1){
Q_UNUSED(n);
QLineEdit* edit = new QLineEdit("C:\\Users\\Cuimi\\Desktop\\1.png",this);
edit->setAlignment(Qt::AlignLeft);
edit->setGeometry(0,0,150,25);
edits.append(edit);

// button = new QPushButton("button",this);
// button->setGeometry(0,30,100,25);
// button->setStyleSheet("QPushButton { background-color:gray; border-radius:5px;font-size:20px; }");

// connect(button, &QPushButton::clicked, this, [=](){
// button->setText("CV Test");
// cv::imshow("test",tm);
// });
}
~VapourActionCvInput(){
qDeleteAll(edits);
edits.clear();
}

public:
QList<QLineEdit*> edits;
// QPushButton* button;
cv::Mat tm;
//QLineEdit* edit;



Expand Down
47 changes: 47 additions & 0 deletions src/vapour_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,48 @@

using namespace cv;

class A{
public:
A(){
qDebug()<<a;
}
virtual void p(){
this->a = 7;
qDebug()<<a;
}

int a=5;
};
class B : public A{
public:
B(){
qDebug()<<a;
}
void p(){
this->a = 6;
qDebug()<<a;
}

int a=8;
};
class C{
public:
C(){
this->a = new B();
}
A *a;
};

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDir::setCurrent(a.applicationDirPath()); // 设置相对路径:是必需的、但能否改动?

// C c;
// c.a->p();
// qDebug()<<c.a->a;


// VideoCapture cap;
// cap.open(0);
// qDebug()<<cap.open(0);
Expand All @@ -29,5 +66,15 @@ int main(int argc, char *argv[])
VapourWin win;
win.show();



return a.exec();
}








2 changes: 1 addition & 1 deletion src/vapour_descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ VapourDescriptor::VapourDescriptor(int in_num, int out_num, QString node_name,in
// setDescHeight(150);

// 定义交互部分
this->interaction = new VapourActionButton(edit_number);
this->interaction = new VapourActionEdit(edit_number);
this->interaction->setGeometry(edge_size, title_height+0.5*edge_size,
width - 2*edge_size,height - 2*edge_size - title_height);
this->proxyContent->setWidget(this->interaction);
Expand Down
26 changes: 22 additions & 4 deletions src/vapour_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class VapourDescriptor : public QGraphicsItem
VapourDescriptor(int in_num,int out_num,QString node_name,int edit_number=1);
VapourDescriptor(const VapourDescriptor& desc);
void operator=(const VapourDescriptor &desc);
~VapourDescriptor();
virtual ~VapourDescriptor();

void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) override;
Expand Down Expand Up @@ -67,15 +67,33 @@ class VapourDescriptor : public QGraphicsItem

}
}
virtual QPointF getPos(){
return this->pos();
}
virtual void setText(int n,QString t){
this->interaction->edits[n]->setText(t);
}
virtual double getText(int n){
return this->interaction->edits[n]->text().toDouble();
}
virtual QString getFile(){
// return this->interaction->edits[0]->text();
}
virtual void test_T_image(cv::Mat m){

}
virtual QList<QString> getParams(){

}



public:
// QList<QString> params;
QList<VapourSocket*> input_sockets;
QList<VapourSocket*> output_sockets;
//VapourAction* interaction;
VapourActionButton* interaction;

VapourActionEdit* interaction;


bool can_compute = true;
Expand All @@ -95,7 +113,7 @@ class VapourDescriptor : public QGraphicsItem
public:
float width = 180; // 节点宽度
float title_height = 24;
float height = 100;
float height = 200;
float edge_size = 10.0;
};

Expand Down
58 changes: 58 additions & 0 deletions src/vapour_descriptor_cv.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,41 @@ class VapourDescriptorCvInput : public VapourDescriptor
public:
VapourDescriptorCvInput();
VapourDescriptorCvInput(int in_num,int out_num,QString node_name,int edit_number=1)
:VapourDescriptor(in_num,out_num,node_name,edit_number){
// cv::Mat m(250, 250, CV_8UC3, cv::Scalar(255, 255, 255));
cv::Mat m = cv::imread("C:\\Users\\Cuimi\\Desktop\\111.jpg");
interaction = new VapourActionCvInput(m,edit_number);
this->interaction->setGeometry(edge_size, title_height+0.5*edge_size,
width - 2*edge_size,height - 2*edge_size - title_height);
this->proxyContent->setWidget(this->interaction);
}
QPointF getPos() override{
return this->pos();
}
void setText(int n,QString t) override{
Q_UNUSED(n);
Q_UNUSED(t);
//this->interaction->edits[n]->setText(t);
}
QString getFile() override{
return this->interaction->edits[0]->text();
}
void test_T_image(cv::Mat m) override{
this->interaction->tm = m;
}


public:
//VapourActionCvShow* interaction;
VapourActionCvInput* interaction;

};

class VapourDescriptorCvAdd : public VapourDescriptor
{
public:
VapourDescriptorCvAdd();
VapourDescriptorCvAdd(int in_num,int out_num,QString node_name,int edit_number=1)
:VapourDescriptor(in_num,out_num,node_name,edit_number){
// cv::Mat m(250, 250, CV_8UC3, cv::Scalar(255, 255, 255));
cv::Mat m = cv::imread("C:\\Users\\Cuimi\\Desktop\\111.jpg");
Expand All @@ -17,8 +52,31 @@ class VapourDescriptorCvInput : public VapourDescriptor
width - 2*edge_size,height - 2*edge_size - title_height);
this->proxyContent->setWidget(this->interaction);
}
QPointF getPos() override{
return this->pos();
}
void setText(int n,QString t) override{
Q_UNUSED(n);
Q_UNUSED(t);
//this->interaction->edits[n]->setText(t);
}
void test_T_image(cv::Mat m) override{
this->interaction->tm = m;
}
QList<QString> getParams() override{
QList<QString> a;
a.append(this->interaction->edits[0]->text());
a.append(this->interaction->edits[1]->text());
a.append(this->interaction->edits[2]->text());
a.append(this->interaction->edits[3]->text());
return a;
}


public:
//VapourActionCvShow* interaction;
VapourActionCvShow* interaction;

};

#endif // VAPOUR_DESCRIPTOR_CV_H
55 changes: 55 additions & 0 deletions src/vapour_descriptor_develop.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@
#ifndef VAPOUR_DESCRIPTOR_DEVELOP_H
#define VAPOUR_DESCRIPTOR_DEVELOP_H


#include"vapour_descriptor.h"

class VapourDescriptorInput : public VapourDescriptor
{
public:
VapourDescriptorInput(int in_num,int out_num,QString node_name,int edit_number=1)
:VapourDescriptor(in_num,out_num,node_name,edit_number)
{
this->interaction = new VapourActionEdit(edit_number);
this->interaction->setGeometry(edge_size, title_height+0.5*edge_size,
width - 2*edge_size,height - 2*edge_size - title_height);
this->proxyContent->setWidget(this->interaction);
}
QPointF getPos() override{
return this->pos();
}
void setText(int n,QString t) override{
this->interaction->edits[n]->setText(t);
}
double getText(int n) override{
return this->interaction->edits[n]->text().toDouble();
}

public:
VapourActionEdit* interaction;

};

class VapourDescriptorOutput : public VapourDescriptor
{
public:
VapourDescriptorOutput(int in_num,int out_num,QString node_name,int edit_number=1)
:VapourDescriptor(in_num,out_num,node_name,edit_number)
{
this->interaction = new VapourActionText(edit_number);
this->interaction->setGeometry(edge_size, title_height+0.5*edge_size,
width - 2*edge_size,height - 2*edge_size - title_height);
this->proxyContent->setWidget(this->interaction);
}
QPointF getPos() override{
return this->pos();
}
void setText(int n,QString t) override{
this->interaction->edits[n]->setText(t);
}
double getText(int n) override{
return this->interaction->edits[n]->text().toDouble();
}

public:
VapourActionText* interaction;

};

#endif // VAPOUR_DESCRIPTOR_DEVELOP_H
8 changes: 4 additions & 4 deletions src/vapour_edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ VapourEdge::VapourEdge(VapourNode *start_node, VapourNode *end_node, VapourSocke

this->start_socket_pos = start_socket->pos();
this->end_socket_pos = end_socket->pos();
this->start_pos = start_node->desc->pos() + start_socket_pos;
this->end_pos = end_node->desc->pos() + end_socket_pos;
this->start_pos = start_node->desc->getPos() + start_socket_pos;
this->end_pos = end_node->desc->getPos() + end_socket_pos;
this->path = QPainterPath(start_pos);

this->setFlag(QGraphicsItem::ItemIsSelectable);
Expand Down Expand Up @@ -69,8 +69,8 @@ void VapourEdge::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
pen1.setWidth(2);
QPen pen2(QColor("#228B22"));
pen2.setWidth(2);
this->start_pos = this->input_node->desc->pos() + start_socket_pos;
this->end_pos = this->output_node->desc->pos() + end_socket_pos;
this->start_pos = this->input_node->desc->getPos() + start_socket_pos;
this->end_pos = this->output_node->desc->getPos() + end_socket_pos;
path = QPainterPath(start_pos);


Expand Down
2 changes: 1 addition & 1 deletion src/vapour_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VapourNode::VapourNode(QWidget *parent)
{
// qDebug()<<"Create: Basic Vapour-node";
initDesc(1,1);
this->desc = new VapourDescriptor(input_socket_number,output_socket_number,"test",1);
this->desc = new VapourDescriptorInput(input_socket_number,output_socket_number,"test",1);
}

VapourNode::VapourNode(const VapourNode &node, QWidget *parent)
Expand Down
Loading

0 comments on commit 9a3a639

Please sign in to comment.