OSDN Git Service

[denncoCreator] save functionality in progress
[dennco/denncoCreator.git] / Source / visualizer / component / dcvcomponent.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 DCVCOMPONENT_H
20 #define DCVCOMPONENT_H
21
22 #include <QtGui>
23 #include <QDomElement>
24
25 class DCVCPage;
26 class DCCell;
27
28 class DCVComponent
29 {
30 public:
31     enum DCVVisibility {DCV_VISIBLE_FULL, DCV_VISIBLE_WIREFRAME, DCV_VISIBLE_NONE };
32
33 private:
34     double          d_modelview[16];
35     DCVVisibility   d_isVisible;
36     bool            d_isSelectable;
37     bool            d_isSelected;
38
39 public:
40     DCVComponent();
41     virtual ~DCVComponent() {}
42
43     virtual DCVCPage *      getPageBelonging() const = 0;
44     virtual DCCell*         getOwnerCell() const = 0;
45     virtual bool            isResizingArea(float x, float y, float z) const = 0;
46     virtual DCVVisibility   getIsVisible() const { return d_isVisible; }
47     virtual bool            getIsSelectable() const { return d_isSelectable; }
48     virtual bool            getIsSelected() const { return d_isSelected; }
49     virtual const double *  getModelViewMatrix() const { return d_modelview; }
50
51     virtual void    prepareChildrenForDraw(bool isAnimationInterval) = 0;
52     virtual void    drawChildren(bool isAnimationInterval) = 0;
53     virtual void    drawChildrenForSelection(QList<DCVComponent*> *itemList) = 0;
54     virtual void    translate() = 0;
55     virtual void    setVisible(DCVVisibility visibleSelf, DCVVisibility childrenAreVisible) { d_isVisible = visibleSelf; }
56     virtual void    setSelectable(bool selectable) { d_isSelectable = selectable; }
57     virtual void    setSelected(bool selectedSelf, bool updateChildren) { d_isSelected = selectedSelf; }
58     virtual void    renderOwnShape(bool isAnimationInterval, bool renderAsWireframe) = 0;
59
60     virtual bool    startDrag(float x, float y, float z, bool isResizingDrag) = 0;
61     virtual bool    dragging(float x, float y, float z, bool isResizingDrag) = 0;
62     virtual bool    endDrag(float x, float y, float z, bool isResizingDrag) = 0;
63
64     virtual void    prepareForDraw(bool isAnimationInterval);
65     virtual void    draw(bool isAnimationInterval);
66     virtual void    drawForSelection(QList<DCVComponent*> *itemList);
67     virtual void    renderOwnShapeForSelection();
68     virtual void    updateShape() = 0;
69
70     virtual void    saveAttributesToXML(QDomDocument *document, QDomElement* element) = 0;
71     virtual void    loadAttributesFromXML(QDomElement element) = 0;
72
73 };
74
75 #endif // DCVCOMPONENT_H