1 // Copyright (c) 2012 Dennco Project
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.
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.
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/>.
17 // Created by tkawata on Sep-30, 2012.
19 #include "dcvcreceptor.h"
21 #include "dcvcomponent.h"
22 #include "dcaxonterminal.h"
25 #include "dcreceptor.h"
26 #include "dccontainer.h"
28 #include "dcvceditmodecursor.h"
32 DCVCReceptor::DCVCReceptor(DCReceptor *owner) : d_owner(owner), d_matrixUpdated(false), d_size(0.1)
36 void DCVCReceptor::prepareChildrenForDraw(bool isAnimationInterval)
39 glGetFloatv(GL_MODELVIEW_MATRIX, matrix);
41 DCVComponent *vterminal = getTerminalComponent();
44 ((DCAxonTerminal*)d_owner->getTarget())->setViewMatrixForReceptorPoint(matrix);
45 vterminal->prepareForDraw(isAnimationInterval);
47 if (d_owner->hasEditCursor())
49 d_owner->setEditingCursorViewMatrix(matrix);
53 void DCVCReceptor::drawChildren(bool isAnimationInterval)
55 DCVComponent *vterminal = getTerminalComponent();
58 vterminal->draw(isAnimationInterval);
62 void DCVCReceptor::drawChildrenForSelection(QList<DCVComponent *> *itemList)
64 DCVComponent *vterminal = getTerminalComponent();
67 vterminal->drawForSelection(itemList);
71 void DCVCReceptor::translate()
73 glTranslatef(0, -0.245, 0);
76 void DCVCReceptor::setSelected(bool selected, bool updateChildren)
78 DCVComponent::setSelected(selected,updateChildren);
80 DCVComponent *vterminal = getTerminalComponent();
85 vterminal->setSelected(selected, true);
90 void DCVCReceptor::setVisible(DCVVisibility visibleSelf, DCVVisibility visibleChildren)
92 DCVComponent::setVisible(visibleSelf, visibleChildren);
93 d_owner->setTerminalVisible(visibleChildren != DCV_VISIBLE_NONE);
96 void DCVCReceptor::renderOwnShape(bool isAnimationInterval, bool renderAsWireframe)
101 DCVComponent* DCVCReceptor::getTerminalComponent() const
103 DCAxonTerminal *terminal = (DCAxonTerminal*)d_owner->getTarget();
106 return terminal->getVComponent();
114 bool DCVCReceptor::isMatrixUpdated() const
116 return d_matrixUpdated;
119 const float* DCVCReceptor::getPointMatrix() const
124 DCCell* DCVCReceptor::getOwnerCell() const
126 return dynamic_cast<DCCell*>(d_owner->getOwnerCell());
129 DCVCPage* DCVCReceptor::getPageBelonging() const
131 return getOwnerCell()->getPageBelonging();
134 bool DCVCReceptor::startDrag(float x, float y, float z, bool isResizingDrag)
139 bool DCVCReceptor::dragging(float x, float y, float z, bool isResizingDrag)
144 bool DCVCReceptor::endDrag(float x, float y, float z, bool isResizingDrag)
149 void DCVCReceptor::saveAttributesToXML(QDomDocument *document, QDomElement* element)
154 void DCVCReceptor::loadAttributesFromXML(QDomElement element)