1 #pragma once 2 3 #ifndef STAGEOBJECT_DATA_H 4 #define STAGEOBJECT_DATA_H 5 6 // TnzCore includes 7 #include "tconst.h" 8 9 // TnzLib includes 10 #include "toonz/tstageobjectid.h" 11 #include "toonz/txshcolumn.h" 12 #include "toonz/tcamera.h" 13 14 // TnzQt includes 15 #include "toonzqt/dvmimedata.h" 16 17 // STL include 18 #include <set> 19 20 // Qt includes 21 #include <QList> 22 #include <QMap> 23 24 #undef DVAPI 25 #undef DVVAR 26 #ifdef TOONZQT_EXPORTS 27 #define DVAPI DV_EXPORT_API 28 #define DVVAR DV_EXPORT_VAR 29 #else 30 #define DVAPI DV_IMPORT_API 31 #define DVVAR DV_IMPORT_VAR 32 #endif 33 34 //================================================= 35 36 // Forward declarations 37 38 class TStageObject; 39 class TStageObjectParams; 40 class TStageObjectDataElement; 41 class TSplineDataElement; 42 class TXsheet; 43 class TFx; 44 class TFxSet; 45 46 //================================================= 47 48 //******************************************************************************** 49 // StageObjectsData declaration 50 //******************************************************************************** 51 52 //! StageObjectsData is the class used to store multiple schematic stage 53 //! object's relational data. 54 class DVAPI StageObjectsData final : public DvMimeData { 55 QList<TStageObjectDataElement *> 56 m_elements; //!< The collection of single stage object 57 //!< relational data (owned) 58 QList<TSplineDataElement *> 59 m_splines; //!< The collection of single spline (owned) 60 61 // Fxs are not assumed to be stage objects. So, they must be stored 62 // independently. 63 64 std::set<TFx *> m_fxs; //!< Supplied Fx objects (cloned, shared ownership) 65 std::set<TFx *> m_originalColumnFxs; //!< Column Fxs of the supplied column 66 //! objects (originals, 'owned' due to 67 //! m_elements) 68 std::set<TFx *> m_terminalFxs; //!< Selection-terminal fxs (from both the 69 //! above) (cloned, shared ownership) 70 71 std::map<TFx *, TFx *> m_fxTable; //!< Original fxs/Cloned fxs pairings 72 73 public: 74 enum FxFlags { 75 eDoClone = 0x1, // Clones sensible stored data 76 eResetFxDagPositions = 77 0x2 // Accepts default positions for newly created FX objects 78 }; 79 80 public: 81 StageObjectsData(); 82 ~StageObjectsData(); 83 84 //! Clones this object. 85 //! \note Clones stored fxs, columns, etc. too. 86 StageObjectsData *clone() const override; 87 isEmpty()88 bool isEmpty() const { return m_elements.isEmpty() && m_splines.isEmpty(); } 89 90 //! Stores the xsheet's specified stage objects (be them cameras, columns, 91 //! pegbars or else). 92 //! Additional flags support TXshColumn cloning for columns. 93 void storeObjects(const std::vector<TStageObjectId> &ids, TXsheet *xsheet, 94 int fxFlags); 95 96 //! Overloaded function, stores the specified columns in the supplied xsheet 97 void storeColumns(const std::set<int> &columnIndexes, TXsheet *xsheet, 98 int fxFlags); 99 100 //! Stores the specified fxs from the xsheet. 101 void storeFxs(const std::set<TFx *> &fxs, TXsheet *xsheet, int fxFlags); 102 103 //! Stores the column fxs \it{and their upstream fxs} associated to the 104 //! specified column indices, 105 //! \b without storing the columns stage objects. 106 void storeColumnFxs(const std::set<int> &columnIndexes, TXsheet *xsh, 107 int fxFlags); 108 109 //! Stores the splines identified by the \b splineIds 110 //! NOTE: a spline will be stored only if no TStageObject is connected to it, 111 //! or if no TStageObject connected is stored 112 //! by this StageObjectsData. 113 void storeSplines(const std::list<int> &splineIds, TXsheet *xsh, int fxFlags); 114 115 //! Scans the stored column elements to verify if the specified xsheet is a 116 //! sub-xsheet 117 //! in of them (thus creating an impossible '\it{circular reference}'). 118 bool checkCircularReferences(TXsheet *xsheet) const; 119 120 //! Restores the stored objects in the supplied xsheet, inserting columns with 121 //! the specified 122 //! indices. In case there are more stored columns than specified column 123 //! indices, the remaining 124 //! columns are inserted right after the last specified index. 125 //! Returns the inserted stage object identifiers and updates the 126 //! columnIndices with all 127 //! the newly inserted column indices. 128 //! Additional flags support TXshColumn cloning before insertion. 129 std::vector<TStageObjectId> restoreObjects( 130 std::set<int> &columnIndices, std::list<int> &restoredSplinIds, 131 TXsheet *xsheet, int fxFlags, const TPointD &pos = TConst::nowhere) const; 132 133 std::vector<TStageObjectId> restoreObjects( 134 std::set<int> &columnIndices, std::list<int> &restoredSplinIds, 135 TXsheet *xsheet, int fxFlags, 136 QMap<TStageObjectId, TStageObjectId> &idTable, 137 QMap<TFx *, TFx *> &fxTable, const TPointD &pos = TConst::nowhere) const; 138 }; 139 140 #endif // STAGEOBJECT_DATA_H 141