FlowTemplateDataModel.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. #ifndef FLOWTEMPLARTEDATAMODEL_H
  2. #define FLOWTEMPLARTEDATAMODEL_H
  3. #include <QtNodes/NodeDelegateModel>
  4. #include <QObject>
  5. #include <QLabel>
  6. #include <QComboBox>
  7. #include <Widgets/ComboBox.h>
  8. #include <Widgets/Menu.h>
  9. using QtNodes::NodeData;
  10. using QtNodes::NodeDataType;
  11. using QtNodes::NodeDelegateModel;
  12. using QtNodes::PortIndex;
  13. using QtNodes::PortType;
  14. class FlowTemplateData : public NodeData
  15. {
  16. public:
  17. NodeDataType type() const override { return NodeDataType { "FlowTemplateData", "" }; }
  18. };
  19. class FlowTemplateDataModel : public NodeDelegateModel
  20. {
  21. Q_OBJECT
  22. public:
  23. FlowTemplateDataModel();
  24. ~FlowTemplateDataModel() = default;
  25. QString caption() const override { return QString("流程样板模型"); }
  26. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  27. QString portCaption(PortType pt, PortIndex) const override
  28. {
  29. if (pt == PortType::In) {
  30. return "输入";
  31. } else if (pt == PortType::Out) {
  32. return "输出";
  33. }
  34. return "";
  35. }
  36. QString name() const override { return QString("FlowTemplateData"); }
  37. unsigned int nPorts(PortType const /*portType*/) const override { return 1; }
  38. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  39. {
  40. return FlowTemplateData().type();
  41. }
  42. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowTemplateData>(); }
  43. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  44. QWidget *embeddedWidget() override;
  45. };
  46. class FlowIndexData : public NodeData
  47. {
  48. public:
  49. NodeDataType type() const override { return NodeDataType { "FlowIndexData", "" }; }
  50. };
  51. class FlowIndexDataModel : public NodeDelegateModel
  52. {
  53. Q_OBJECT
  54. public:
  55. FlowIndexDataModel();
  56. ~FlowIndexDataModel() = default;
  57. QString caption() const override { return QString("构建指标体系"); }
  58. bool captionVisible() const override { return false; }
  59. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  60. QString portCaption(PortType pt, PortIndex) const override
  61. {
  62. if (pt == PortType::In) {
  63. return "输入";
  64. } else if (pt == PortType::Out) {
  65. return "输出";
  66. }
  67. return "";
  68. }
  69. QString name() const override { return QString("FlowIndexData"); }
  70. unsigned int nPorts(PortType const portType) const override
  71. {
  72. if (portType == PortType::In) {
  73. return 0;
  74. }
  75. return 1;
  76. }
  77. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  78. {
  79. return FlowIndexData().type();
  80. }
  81. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowIndexData>(); }
  82. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  83. QWidget *embeddedWidget() override;
  84. };
  85. class FlowSampleData : public NodeData
  86. {
  87. public:
  88. NodeDataType type() const override { return NodeDataType { "FlowSampleData", "" }; }
  89. };
  90. class FlowSampleDataModel : public NodeDelegateModel
  91. {
  92. Q_OBJECT
  93. public:
  94. FlowSampleDataModel() : NodeDelegateModel() { }
  95. ~FlowSampleDataModel() = default;
  96. QString caption() const override { return QString("收集数据"); }
  97. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  98. QString portCaption(PortType pt, PortIndex) const override
  99. {
  100. if (pt == PortType::In) {
  101. return "输入";
  102. } else if (pt == PortType::Out) {
  103. return "输出";
  104. }
  105. return "";
  106. }
  107. QString name() const override { return QString("FlowSampleData"); }
  108. unsigned int nPorts(PortType const /*portType*/) const override { return 1; }
  109. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  110. {
  111. return FlowSampleData().type();
  112. }
  113. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowSampleData>(); }
  114. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  115. QWidget *embeddedWidget() override;
  116. };
  117. class FlowPCAData : public NodeData
  118. {
  119. public:
  120. NodeDataType type() const override { return NodeDataType { "FlowPCAData", "" }; }
  121. };
  122. class FlowPCADataModel : public NodeDelegateModel
  123. {
  124. Q_OBJECT
  125. public:
  126. FlowPCADataModel() : NodeDelegateModel() { }
  127. ~FlowPCADataModel() = default;
  128. QString caption() const override { return QString("主成分分析法"); }
  129. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  130. QString portCaption(PortType pt, PortIndex) const override
  131. {
  132. if (pt == PortType::In) {
  133. return "输入";
  134. } else if (pt == PortType::Out) {
  135. return "输出";
  136. }
  137. return "";
  138. }
  139. QString name() const override { return QString("FlowPCAData"); }
  140. unsigned int nPorts(PortType const /*portType*/) const override { return 1; }
  141. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  142. {
  143. return FlowPCAData().type();
  144. }
  145. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowPCAData>(); }
  146. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  147. QWidget *embeddedWidget() override;
  148. };
  149. class FlowWeightData : public NodeData
  150. {
  151. public:
  152. NodeDataType type() const override { return NodeDataType { "FlowWeightData", "" }; }
  153. };
  154. class FlowWeightDataModel : public NodeDelegateModel
  155. {
  156. Q_OBJECT
  157. public:
  158. FlowWeightDataModel() : NodeDelegateModel() { }
  159. ~FlowWeightDataModel() = default;
  160. QString caption() const override { return QString("权重计算"); }
  161. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  162. QString portCaption(PortType pt, PortIndex) const override
  163. {
  164. if (pt == PortType::In) {
  165. return "输入";
  166. } else if (pt == PortType::Out) {
  167. return "输出";
  168. }
  169. return "";
  170. }
  171. QString name() const override { return QString("FlowWeightData"); }
  172. unsigned int nPorts(PortType const /*portType*/) const override { return 1; }
  173. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  174. {
  175. return FlowWeightData().type();
  176. }
  177. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowWeightData>(); }
  178. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  179. QWidget *embeddedWidget() override;
  180. };
  181. class FlowSchemeData : public NodeData
  182. {
  183. public:
  184. NodeDataType type() const override { return NodeDataType { "FlowSchemeData", "" }; }
  185. };
  186. class FlowSchemeDataModel : public NodeDelegateModel
  187. {
  188. Q_OBJECT
  189. public:
  190. FlowSchemeDataModel() : NodeDelegateModel() { }
  191. ~FlowSchemeDataModel() = default;
  192. QString caption() const override { return QString("算法"); }
  193. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  194. QString portCaption(PortType pt, PortIndex) const override
  195. {
  196. if (pt == PortType::In) {
  197. return "输入";
  198. } else if (pt == PortType::Out) {
  199. return "输出";
  200. }
  201. return "";
  202. }
  203. QString name() const override { return QString("FlowSchemeData"); }
  204. unsigned int nPorts(PortType const /*portType*/) const override { return 1; }
  205. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  206. {
  207. return FlowSchemeData().type();
  208. }
  209. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowSchemeData>(); }
  210. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  211. QWidget *embeddedWidget() override;
  212. };
  213. class FlowEffiData : public NodeData
  214. {
  215. public:
  216. NodeDataType type() const override { return NodeDataType { "FlowEffiData", "" }; }
  217. };
  218. class FlowEffiDataModel : public NodeDelegateModel
  219. {
  220. Q_OBJECT
  221. public:
  222. FlowEffiDataModel() : NodeDelegateModel() { }
  223. ~FlowEffiDataModel() = default;
  224. QString caption() const override { return QString("算法"); }
  225. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  226. QString portCaption(PortType pt, PortIndex) const override
  227. {
  228. if (pt == PortType::In) {
  229. return "输入";
  230. } else if (pt == PortType::Out) {
  231. return "输出";
  232. }
  233. return "";
  234. }
  235. QString name() const override { return QString("FlowEffiData"); }
  236. unsigned int nPorts(PortType const /*portType*/) const override { return 1; }
  237. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  238. {
  239. return FlowEffiData().type();
  240. }
  241. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowEffiData>(); }
  242. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  243. QWidget *embeddedWidget() override;
  244. };
  245. class FlowResultData : public NodeData
  246. {
  247. public:
  248. NodeDataType type() const override { return NodeDataType { "FlowResultData", "" }; }
  249. };
  250. class FlowResultDataModel : public NodeDelegateModel
  251. {
  252. Q_OBJECT
  253. public:
  254. FlowResultDataModel() : NodeDelegateModel() { }
  255. ~FlowResultDataModel() = default;
  256. QString caption() const override { return QString("结果展示"); }
  257. bool captionVisible() const override { return false; }
  258. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  259. QString portCaption(PortType pt, PortIndex) const override
  260. {
  261. if (pt == PortType::In) {
  262. return "输入";
  263. } else if (pt == PortType::Out) {
  264. return "输出";
  265. }
  266. return "";
  267. }
  268. QString name() const override { return QString("FlowResultData"); }
  269. unsigned int nPorts(PortType const /*portType*/) const override { return 1; }
  270. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  271. {
  272. return FlowResultData().type();
  273. }
  274. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowResultData>(); }
  275. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  276. QWidget *embeddedWidget() override;
  277. };
  278. class FlowReportData : public NodeData
  279. {
  280. public:
  281. NodeDataType type() const override { return NodeDataType { "FlowReportData", "" }; }
  282. };
  283. class FlowReportDataModel : public NodeDelegateModel
  284. {
  285. Q_OBJECT
  286. public:
  287. FlowReportDataModel() : NodeDelegateModel() { }
  288. ~FlowReportDataModel() = default;
  289. QString caption() const override { return QString("生成报告"); }
  290. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  291. QString portCaption(PortType pt, PortIndex) const override
  292. {
  293. if (pt == PortType::In) {
  294. return "输入";
  295. } else if (pt == PortType::Out) {
  296. return "输出";
  297. }
  298. return "";
  299. }
  300. QString name() const override { return QString("FlowReportData"); }
  301. unsigned int nPorts(PortType const pt) const override
  302. {
  303. if (pt == PortType::In) {
  304. return 1;
  305. }
  306. return 0;
  307. }
  308. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  309. {
  310. return FlowReportData().type();
  311. }
  312. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowReportData>(); }
  313. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  314. QWidget *embeddedWidget() override;
  315. };
  316. class FlowEffiLevData : public NodeData
  317. {
  318. public:
  319. NodeDataType type() const override { return NodeDataType { "FlowEffiLevData", "" }; }
  320. };
  321. class FlowEffiLevDataModel : public NodeDelegateModel
  322. {
  323. Q_OBJECT
  324. public:
  325. FlowEffiLevDataModel() : NodeDelegateModel() { }
  326. ~FlowEffiLevDataModel() = default;
  327. QString caption() const override { return QString("效能分级"); }
  328. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  329. QString portCaption(PortType pt, PortIndex) const override
  330. {
  331. if (pt == PortType::In) {
  332. return "输入";
  333. } else if (pt == PortType::Out) {
  334. return "输出";
  335. }
  336. return "";
  337. }
  338. QString name() const override { return QString("FlowEffiLevData"); }
  339. unsigned int nPorts(PortType const /*portType*/) const override { return 1; }
  340. NodeDataType dataType(PortType const portType, PortIndex const portIndex) const override
  341. {
  342. return FlowEffiLevData().type();
  343. }
  344. std::shared_ptr<NodeData> outData(PortIndex const port) override { return std::make_shared<FlowEffiLevData>(); }
  345. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  346. QWidget *embeddedWidget() override;
  347. };
  348. class FlowCommonData : public NodeData
  349. {
  350. public:
  351. NodeDataType type() const override { return NodeDataType { "FlowCommonData", "" }; }
  352. };
  353. class FlowCommonDataModel : public NodeDelegateModel
  354. {
  355. Q_OBJECT
  356. public:
  357. FlowCommonDataModel() : NodeDelegateModel() {};
  358. ~FlowCommonDataModel() = default;
  359. QString caption() const override { return QString(""); }
  360. bool captionVisible() const override { return true; }
  361. bool portCaptionVisible(PortType, PortIndex) const override { return false; }
  362. QString portCaption(PortType, PortIndex) const override { return ""; }
  363. QString name() const override { return QString("FlowCommonData"); }
  364. unsigned int nPorts(PortType const) const override { return 0; }
  365. NodeDataType dataType(PortType const, PortIndex const) const override { return FlowCommonData().type(); }
  366. std::shared_ptr<NodeData> outData(PortIndex const) override { return std::make_shared<FlowCommonData>(); }
  367. void setInData(std::shared_ptr<NodeData>, PortIndex const) override { }
  368. QWidget *embeddedWidget() override { return nullptr; };
  369. };
  370. #endif // FLOWTEMPLARTEDATAMODEL_H