1 #pragma once
2 
3 #ifndef FXCOMMAND_INCLUDED
4 #define FXCOMMAND_INCLUDED
5 
6 // TnzCore includes
7 #include "tcommon.h"
8 
9 // TnzBase includes
10 #include "tfx.h"
11 
12 // TnzLib includes
13 #include "toonz/tapplication.h"
14 #include "toonz/txshcolumn.h"
15 
16 // Qt includes
17 #include <QPair>
18 
19 #undef DVAPI
20 #undef DVVAR
21 #ifdef TOONZLIB_EXPORTS
22 #define DVAPI DV_EXPORT_API
23 #define DVVAR DV_EXPORT_VAR
24 #else
25 #define DVAPI DV_IMPORT_API
26 #define DVVAR DV_IMPORT_VAR
27 #endif
28 
29 //=================================================
30 
31 //    Forward declarations
32 
33 class TXsheetHandle;
34 class TFxHandle;
35 class TXsheet;
36 class TFx;
37 class TMacroFx;
38 class TXshColumn;
39 
40 //=================================================
41 
42 namespace TFxCommand {
43 class DVAPI Link {
44 public:
45   TFxP m_inputFx, m_outputFx;
46   int m_index;  //!< m_outputFx's input port index
47 
Link()48   Link() : m_index(-1) {}
Link(const TFxP & inputFx,const TFxP & outputFx,int index)49   Link(const TFxP &inputFx, const TFxP &outputFx, int index)
50       : m_inputFx(inputFx), m_outputFx(outputFx), m_index(index) {}
51 
52   bool operator==(const Link &link) const {
53     return m_inputFx == link.m_inputFx && m_outputFx == link.m_outputFx &&
54            m_index == link.m_index;
55   }
56 
57   bool operator!=(const Link &link) const { return !operator==(link); }
58   bool operator<(const Link &link) const { return m_index < link.m_index; }
59 };
60 
61 //======================================================================================
62 
63 DVAPI void insertFx(TFx *newFx, const QList<TFxP> &fxs,
64                     const QList<Link> &links, TApplication *app, int colunIndex,
65                     int rowIndex);
66 DVAPI void addFx(TFx *newFx, const QList<TFxP> &fxs, TApplication *app,
67                  int colunIndex, int rowIndex);
68 DVAPI void replaceFx(TFx *newFx, const QList<TFxP> &fxs,
69                      TXsheetHandle *xshHandle, TFxHandle *fxHandle);
70 DVAPI void duplicateFx(TFx *src, TXsheetHandle *xshHandle, TFxHandle *fxHandle);
71 DVAPI void unlinkFx(TFx *fx, TFxHandle *fxHandle, TXsheetHandle *xshHandle);
72 DVAPI void makeMacroFx(const std::vector<TFxP> &fxs, TApplication *app);
73 DVAPI void explodeMacroFx(TMacroFx *macroFx, TApplication *app);
74 DVAPI void createOutputFx(TXsheetHandle *xshHandle, TFx *currentFx);
75 DVAPI void removeOutputFx(TFx *fx, TXsheetHandle *xshHandle,
76                           TFxHandle *fxHandle);
77 DVAPI void makeOutputFxCurrent(TFx *fx, TXsheetHandle *xshHandle);
78 DVAPI void disconnectNodesFromXsheet(const std::list<TFxP> &fxs,
79                                      TXsheetHandle *xshHandle);
80 DVAPI void disconnectFxs(const std::list<TFxP> &fxs, TXsheetHandle *xshHandle,
81                          const QList<QPair<TFxP, TPointD>> &fxPos);
82 DVAPI void connectFxs(const Link &link, const std::list<TFxP> &fxs,
83                       TXsheetHandle *xshHandle,
84                       const QList<QPair<TFxP, TPointD>> &fxPos);
85 DVAPI void setParent(TFx *fx, TFx *parentFx, int parentFxPort,
86                      TXsheetHandle *xshHandle);
87 DVAPI void connectNodesToXsheet(const std::list<TFxP> &fxs,
88                                 TXsheetHandle *xshHandle);
89 DVAPI void deleteSelection(const std::list<TFxP> &fxs,
90                            const std::list<Link> &links,
91                            const std::list<int> &columnIndexes,
92                            TXsheetHandle *xshHandle, TFxHandle *fxHandle);
93 DVAPI void pasteFxs(const std::list<TFxP> &fxs,
94                     const std::map<TFx *, int> &zeraryFxColumnSize,
95                     const std::list<TXshColumnP> &columns, const TPointD &pos,
96                     TXsheetHandle *xshHandle, TFxHandle *fxHandle);
97 DVAPI void insertPasteFxs(const Link &link, const std::list<TFxP> &fxs,
98                           const std::map<TFx *, int> &zeraryFxColumnSize,
99                           const std::list<TXshColumnP> &columns,
100                           TXsheetHandle *xshHandle, TFxHandle *fxHandle);
101 DVAPI void addPasteFxs(TFx *inFx, const std::list<TFxP> &fxs,
102                        const std::map<TFx *, int> &zeraryFxColumnSize,
103                        const std::list<TXshColumnP> &columns,
104                        TXsheetHandle *xshHandle, TFxHandle *fxHandle);
105 DVAPI void replacePasteFxs(TFx *inFx, const std::list<TFxP> &fxs,
106                            const std::map<TFx *, int> &zeraryFxColumnSize,
107                            const std::list<TXshColumnP> &columns,
108                            TXsheetHandle *xshHandle, TFxHandle *fxHandle);
109 DVAPI void renameFx(TFx *fx, const std::wstring &newName,
110                     TXsheetHandle *xshHandle);
111 DVAPI void groupFxs(const std::list<TFxP> &fxs, TXsheetHandle *xshHandle);
112 DVAPI void ungroupFxs(int groupId, TXsheetHandle *xshHandle);
113 DVAPI void renameGroup(const std::list<TFxP> &fxs, const std::wstring &name,
114                        bool fromEditor, TXsheetHandle *xshHandle);
115 
116 }  // namespace TFxCommand
117 
118 #endif  // FXCOMMAND_INCLUDED
119