OSDN Git Service

[denncoCreator] implemented the logic to check the update of the content files and...
[dennco/denncoCreator.git] / Source / visualizer / component / dcvcpage.h
1 //  Copyright (c) 2012 Dennco Project
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 //
17 //  Created by tkawata on Sep-30, 2012.
18 //
19 #ifndef DCVCPAGE_H
20 #define DCVCPAGE_H
21
22 #include "dcvcomponent.h"
23
24 class DCVPageComponent;
25 class DCContainer;
26
27 class DCVCPage : public DCVComponent
28 {
29     QString d_locationPath;
30     float   d_height;
31     float   d_width;
32     float   d_depth;
33     bool    d_shouldUpdateShape;
34     float   d_colorR;
35     float   d_colorG;
36     float   d_colorB;
37     float   d_colorA;
38
39     QList<DCVPageComponent*> d_cells;
40     QList<DCVPageComponent*> d_cellCodeClasses;
41
42     DCVPageComponent *d_editCursor;
43
44     QString d_hash;
45
46 public:
47     DCVCPage(const QString &locationPath);
48     virtual ~DCVCPage();
49
50     virtual DCVCPage *      getPageBelonging() const { return const_cast<DCVCPage*>(this);}
51     virtual DCCell*         getOwnerCell() const { return NULL; }
52     virtual DCVVisibility   getIsVisible() const { return d_colorA == 0 ?  DCV_VISIBLE_NONE : DCVComponent::getIsVisible(); }
53     virtual bool            isResizingArea(float x, float y, float z) const { return false; }
54     QString                 getLocationPath() const { return d_locationPath; }
55     bool                    getIsModified(DCContainer *container) const;
56
57     const QList<DCVPageComponent*>* getCells() const { return &d_cells; }
58     const QList<DCVPageComponent*>* getCellCodeClasses() const { return &d_cellCodeClasses; }
59
60     // register / unregister cell to this page.
61     // They are called from DCVCCell.
62     // Other classes shouldn't call this directly.
63     // To change the page a cell belonging,
64     // DCMoveCellCommand() should be used instead.
65     void registerCell(DCVPageComponent *cell);
66     void unregisterCell(DCVPageComponent *cell);
67
68     // register / unregister cellcode to this page.
69     // They are called from DCVCCellCode.
70     // Other classes shouldn't call this directly.
71     // To change the page a cell code class belonging,
72     // DCMoveCellCodeClassCommand should be used instead.
73     void registerCellCodeClass(DCVPageComponent *cellCodeClass);
74     void unregisterCellCodeClass(DCVPageComponent *cellCodeClass);
75
76     // register / unregister cellcode to this page.
77     // They are called from DCVCEditModeCursor.
78     // Other classes shouldn't call this directly.
79     // To change the page a cell code class belonging,
80     // DCVCEditModeCursor::changePageBelonging() should be called instead.
81     void registerEditCursor(DCVPageComponent *ecursor);
82     void unregisterEditCursor();
83
84     /**
85      * @brief Move cells and cell codes belong to this page to newPage.
86      * @param newPage : the target page cells and cell codes are moving into.
87      *
88      * This will move cells, cell codes and connections belong to this page to the page passed in the parameter.
89      * This expected to be called from DCContainer.
90      * This shouldn't be called directly.
91      * To change the path / file name for a container file, DCMovePageCommand should be used.
92      *
93      * @return true for succuss, false for failure.
94      */
95     bool moveComponentsTo(DCVCPage *newPage);
96
97     void updateVisiblity(bool linkedCellVisible, bool linkedCellRenderFull, bool linkedCellSelectable, bool otherCellVisible, bool otherCellRenderFull, bool otherCellSelectable);
98
99     virtual void    prepareChildrenForDraw(bool isAnimationInterval);
100     virtual void    drawChildren(bool isAnimationInterval);
101     virtual void    drawChildrenForSelection(QList<DCVComponent*> *itemList);
102     virtual void    translate();
103     virtual void    setSelected(bool selected, bool updateChildren);
104     virtual void    setVisible(DCVVisibility visibleSelf, DCVVisibility visibleChildren);
105     virtual void    renderOwnShape(bool isAnimationInterval, bool renderAsWireframe);
106
107     virtual bool    startDrag(float x, float y, float z, bool isResizingDrag);
108     virtual bool    dragging(float x, float y, float z, bool isResizingDrag);
109     virtual bool    endDrag(float x, float y, float z, bool isResizingDrag);
110     virtual void    updateShape() {}
111
112     virtual void    saveAttributesToXML(QDomDocument *document, QDomElement* element) const;
113     virtual void    loadAttributesFromXML(QDomElement element);
114
115     void setHeight(float height);
116     void setWidth(float width);
117     void setDepth(float depth);
118     void setColor(float r, float g, float b, float a);
119
120     void updateSavedState(DCContainer *container);
121 };
122
123 #endif // DCVCPAGE_H