9 Star 40 Fork 8

sinriv / meshlang

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
node.h 3.45 KB
一键复制 编辑 原始数据 按行查看 历史
#ifndef MESHLANG_NODE
#define MESHLANG_NODE
#include "hbb.h"
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <QDebug>
namespace meshlang{
struct variable{//变量
std::string name,type;
inline variable():name(),type(){}
inline variable(const std::string & n,const std::string & t){
name = n;
type = t;
}
inline variable(const variable & n){
name = n.name;
type = n.type;
}
inline const variable & operator=(const variable & n){
name = n.name;
type = n.type;
return * this;
}
};
struct function{//函数
std::string name;
std::vector<variable> input,output;
HBB::vec size;//方框大小
std::unordered_map<std::string,std::string> types;
bool isPrivate;
};
struct node;
struct line;
struct line{//连线
variable var;
node * start , * end;
int startId , endId;
HBB::vec startPosi;
HBB::vec endPosi;
HBB::AABB * em;
void remove(bool erst=true,bool ered=true);
};
struct node{
function * type;
HBB::vec position; //在图中的位置
std::vector<std::set<line*> > input , output;
std::unordered_map<std::string,std::string> initval;
line * trueThen;
line * falseThen;
int id;
std::set<line*> last;
HBB::AABB * em;
std::string name;
void getClickStatus(const HBB::vec & p , int & mode /* 1 input , 2 output , 3 center */ , int & port);
void getPortPosition(HBB::vec & p , int mode /* 1 input , 2 output , 3 center */ , int port);
int compileFlag;
};
struct functions{
std::map<std::string,function * > funcs;
function * addFunc(const std::string & name,const std::vector<variable> & input,const std::vector<variable> & output);
~functions();
};
struct program:functions{
std::set<node * > nodes;
std::map<int,node * > nodeMap;
std::set<line * > lines;
HBB elements;
HBB elementlines;
node * addNode(const std::string & name,const HBB::vec & tposition,int id=0);
void addModule(const std::string & name,const std::vector<variable> & input,const std::vector<variable> & output,const HBB::vec & posi);
void removeNode(node *);
virtual void editNode(node *)=0;
line * link(node * a,int ida,node * b,int idb);
line * link(int a,int ida,int b,int idb);
void removeLine(line * ,bool erst=true,bool ered=true);
program();
~program();
void clickTwoPoint(const HBB::vec & a , const HBB::vec & b);
void clickToEdit(const HBB::vec & a);
void clickToRemove(const HBB::vec & a);
virtual void getInsertingName(std::string & name)=0;
virtual void showMenu()=0;
virtual void saveNotes(FILE * fp)=0;
virtual void addNote(const std::string & text,const HBB::vec & posi)=0;
virtual bool editNote(const HBB::vec & a)=0;
void import(const std::string & path);
void save(const std::string & path);
private:
int lineNum;
int nodeId;
};
}
#endif
C++
1
https://gitee.com/sinriv/meshlang.git
git@gitee.com:sinriv/meshlang.git
sinriv
meshlang
meshlang
master

搜索帮助