OSDN Git Service

[denncoCreator] refactoring
[dennco/denncoCreator.git] / Source / dcreceptor.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 "dcreceptor.h"
20
21 #include "dcvcomponent.h"
22 #include "dccell.h"
23 #include "dcvceditmodecursor.h"
24 #include "dcvceditmodeterminal.h"
25 #include "dcaxonterminal.h"
26
27 DCReceptor::DCReceptor(DCCell *owner) : TKReceptor(owner), d_vComponent(NULL), d_isTerminalVisible(true), d_editCursor(NULL)
28 {
29 }
30
31 DCReceptor::~DCReceptor()
32 {
33     if (d_vComponent)
34     {
35         delete d_vComponent;
36         d_vComponent = NULL;
37     }
38 }
39
40 DCAxonTerminal* DCReceptor::getTarget() const
41 {
42     return dynamic_cast<DCAxonTerminal*>(mTerminal);
43 }
44
45 DCCell* DCReceptor::getOwnerCell() const
46 {
47     return dynamic_cast<DCCell*>(mOwner);
48 }
49
50 DCVComponent* DCReceptor::getVComponent() const
51 {
52     return d_vComponent;
53 }
54
55 void DCReceptor::getViewReceptorOffsetPoint(float dx, float dy, float dz,float *x, float *y, float *z) const
56 {
57     *x = 0;
58     *y = 0;
59     *z = 0;
60
61     DCCell *cell = getOwnerCell();
62     if (cell)
63     {
64         float cx,cz;
65         cell->getViewHCrossPoint(dx,dz,&cx,&cz);
66         *x = cx;
67         *z = cz;
68     }
69 }
70
71 void DCReceptor::registerEditCursor(DCVCEditModeCursor *cursor)
72 {
73     d_editCursor = cursor;
74 }
75
76 void DCReceptor::unregisterEditCursor()
77 {
78     d_editCursor = NULL;
79 }
80
81 void DCReceptor::setEditingCursorViewMatrix(const float matrix[])
82 {
83     if (d_editCursor)
84     {
85         d_editCursor->getTerminal()->setViewMatrixForReceptorPoint(this, matrix);
86     }
87 }