OSDN Git Service

[denncoCreator] save functionality in progress
[dennco/denncoCreator.git] / Source / visualizer / component / dcvcreceptor.cpp
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 #include "dcvcreceptor.h"
20
21 #include "dcvcomponent.h"
22 #include "dcaxonterminal.h"
23 #include "dccell.h"
24
25 #include "dcreceptor.h"
26 #include "dccontainer.h"
27
28 #include "dcvceditmodecursor.h"
29
30 #include <QtOpenGL>
31
32 DCVCReceptor::DCVCReceptor(DCReceptor *owner)  : d_owner(owner), d_matrixUpdated(false), d_size(0.1)
33 {
34 }
35
36 void DCVCReceptor::prepareChildrenForDraw(bool isAnimationInterval)
37 {
38     float matrix[16];
39     glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
40
41     DCVComponent *vterminal = getTerminalComponent();
42     if (vterminal)
43     {
44         ((DCAxonTerminal*)d_owner->getTarget())->setViewMatrixForReceptorPoint(matrix);
45         vterminal->prepareForDraw(isAnimationInterval);
46     }
47     if (d_owner->hasEditCursor())
48     {
49         d_owner->setEditingCursorViewMatrix(matrix);
50     }
51 }
52
53 void DCVCReceptor::drawChildren(bool isAnimationInterval)
54 {
55     DCVComponent *vterminal = getTerminalComponent();
56     if (vterminal)
57     {
58         vterminal->draw(isAnimationInterval);
59     }
60 }
61
62 void DCVCReceptor::drawChildrenForSelection(QList<DCVComponent *> *itemList)
63 {
64     DCVComponent *vterminal = getTerminalComponent();
65     if (vterminal)
66     {
67         vterminal->drawForSelection(itemList);
68     }
69 }
70
71 void DCVCReceptor::translate()
72 {
73     glTranslatef(0, -0.245, 0);
74 }
75
76 void DCVCReceptor::setSelected(bool selected, bool updateChildren)
77 {
78     DCVComponent::setSelected(selected,updateChildren);
79
80     DCVComponent *vterminal = getTerminalComponent();
81     if (updateChildren)
82     {
83         if (vterminal)
84         {
85             vterminal->setSelected(selected, true);
86         }
87     }
88 }
89
90 void DCVCReceptor::setVisible(DCVVisibility visibleSelf, DCVVisibility visibleChildren)
91 {
92     DCVComponent::setVisible(visibleSelf, visibleChildren);
93     d_owner->setTerminalVisible(visibleChildren != DCV_VISIBLE_NONE);
94 }
95
96 void DCVCReceptor::renderOwnShape(bool isAnimationInterval, bool renderAsWireframe)
97 {
98     //TODO
99 }
100
101 DCVComponent* DCVCReceptor::getTerminalComponent() const
102 {
103     DCAxonTerminal *terminal = (DCAxonTerminal*)d_owner->getTarget();
104     if (terminal)
105     {
106         return terminal->getVComponent();
107     }
108     else
109     {
110         return NULL;
111     }
112 }
113
114 bool DCVCReceptor::isMatrixUpdated() const
115 {
116     return d_matrixUpdated;
117 }
118
119 const float* DCVCReceptor::getPointMatrix() const
120 {
121     return &d_matrix[0];
122 }
123
124 DCCell* DCVCReceptor::getOwnerCell() const
125 {
126     return dynamic_cast<DCCell*>(d_owner->getOwnerCell());
127 }
128
129 DCVCPage* DCVCReceptor::getPageBelonging() const
130 {
131     return getOwnerCell()->getPageBelonging();
132 }
133
134 bool DCVCReceptor::startDrag(float x, float y, float z, bool isResizingDrag)
135 {
136     return false;
137 }
138
139 bool DCVCReceptor::dragging(float x, float y, float z, bool isResizingDrag)
140 {
141     return false;
142 }
143
144 bool DCVCReceptor::endDrag(float x, float y, float z, bool isResizingDrag)
145 {
146     return false;
147 }
148
149 void DCVCReceptor::saveAttributesToXML(QDomDocument *document, QDomElement* element)
150 {
151
152 }
153
154 void DCVCReceptor::loadAttributesFromXML(QDomElement element)
155 {
156
157 }