1 #pragma once 2 3 #ifndef CHILDSTACK_INCLUDED 4 #define CHILDSTACK_INCLUDED 5 6 #include "tcommon.h" 7 8 #undef DVAPI 9 #undef DVVAR 10 #ifdef TOONZLIB_EXPORTS 11 #define DVAPI DV_EXPORT_API 12 #define DVVAR DV_EXPORT_VAR 13 #else 14 #define DVAPI DV_IMPORT_API 15 #define DVVAR DV_IMPORT_VAR 16 #endif 17 18 //============================================================================= 19 // forward declarations 20 class TXsheet; 21 class ToonzScene; 22 class TAffine; 23 class TXshChildLevel; 24 25 //============================================================================= 26 //! The ChildStack class provides a stack of xsheet and allows its management. 27 /*!The class has a vector of \b ChildStack::Node, a pointer to current \b 28 TXsheet 29 getXsheet(), and a pointer to current \b ToonzScene \b m_scene. 30 The \b ChildStack::Node vector is as a subxsheet vector. 31 32 Through this class you can create, open openChild(), close closeChild() or 33 clear clear() a sub-xsheet. 34 35 The class provides a collection of functions that return set of subxsheet 36 properties, getAncestor(), getAncestorCount(), getAncestorAffine(), 37 getTopXsheet(). 38 */ 39 //============================================================================= 40 41 class DVAPI ChildStack { 42 class Node; 43 std::vector<Node *> m_stack; 44 TXsheet *m_xsheet; 45 ToonzScene *m_scene; 46 47 public: 48 /*! 49 Constructs a ChildStack with default value and current \b scene. 50 */ 51 ChildStack(ToonzScene *scene); 52 /*! 53 Destroys the ChildStack object. 54 */ 55 ~ChildStack(); 56 57 /*! 58 Clear child stack. 59 */ 60 void clear(); 61 62 /*! 63 Open a sub-xsheet in cell \b row, \b col. Return true if it's possible. 64 \n 65 If cell \b row, \b col is empty create a new sub-xheet empty and return true, 66 if cell contains a sub-xsheet set this as current xsheet and return true, 67 if cell contains another element return false. 68 */ 69 bool openChild(int row, int col); 70 71 /*! 72 Close current xsheet if is a sub-xsheet. Return false if stack is empty. 73 Set \b row, \b col to sub-xsheet row and column. 74 */ 75 bool closeChild(int &row, int &col); 76 77 /*! 78 Create a sub-xsheet in cell \b row, \b col and returns the new child level. 79 \n 80 Column col must be empty, 81 The current xsheet remains unchanged 82 83 */ 84 TXshChildLevel *createChild(int row, int col); 85 86 /*! 87 Return ancestor number, size of \b ChildStack::Node vector. 88 */ 89 int getAncestorCount() const; 90 91 /*! 92 Return a pointer to top xsheet of stack, if stack is empty to current xsheet. 93 */ 94 TXsheet *getTopXsheet() const; 95 /*! 96 Return a pointer to current xsheet. 97 */ getXsheet()98 TXsheet *getXsheet() const { return m_xsheet; } 99 100 // NON USARE. Serve solo per un truccaccio sporchissimo in 101 // xshcolumnselection.cpp setXsheet(TXsheet * xsheet)102 void setXsheet(TXsheet *xsheet) { m_xsheet = xsheet; } 103 104 /*! 105 Return the ancestor and respective frame that contains \b row. 106 \n 107 Useful by edit in place. Oss.: \b row of current xsheet. 108 */ 109 std::pair<TXsheet *, int> getAncestor(int row) const; 110 111 /*! 112 Set aff to ancestor affine in \b row. Return true if all ancestors are 113 visibile in \b row. 114 */ 115 bool getAncestorAffine(TAffine &aff, int row) const; 116 117 private: 118 // not implemented 119 ChildStack(const ChildStack &); 120 ChildStack &operator=(const ChildStack &); 121 }; 122 123 #endif 124