OSDN Git Service

[denncoCreator] integrated dennco engine changes into dennco creator.
[dennco/denncoCreator.git] / Source / dccell.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 DCCELL_H
20 #define DCCELL_H
21
22 #include "TKCell.h"
23
24 class DCContainer;
25 class DCAxon;
26 class DCAxonTerminal;
27 class DCReceptor;
28 class DCCellCode;
29 class DCVComponent;
30 class DCVPageComponent;
31 class DCVCPage;
32
33 #include <QObject>
34 #include <QString>
35
36 class DCCell : public QObject, public TKCell
37 {
38     Q_OBJECT
39
40     friend class DCComponentUtil;
41     friend class DCContainer;
42
43     DCCell(DCContainer *container, std::string location, std::string name, std::string type, bool canInputInterface, bool canOutputInterface);
44     void bindComponent(DCVPageComponent *component);
45
46     DCVPageComponent    *d_vComponent;
47     DCCellCode          *d_cellCode;
48     QString             d_type;
49     float               d_viewSize;
50     float               d_viewHeight;
51
52     const static float S_MINSIZE;
53     const static float S_MAXSIZE;
54
55     bool                removeAllConnections();
56
57     /**
58       * Change name of this cell.
59       * DCContainer will call this method.
60       */
61     void                changeName(const QString& newName);
62
63     /**
64       * Change the location path for this cell.
65       * DCContainer will call this method.
66       */
67     void                changePath(const QString& newPath);
68
69
70 public:
71     virtual ~DCCell();
72
73     virtual bool        doTick(float time) {return false;}
74     virtual bool        doInit() {return false;}
75     virtual bool        doDestroy() {return false;}
76     virtual bool        setCellCode(TKCellCode *code, const void *data);
77
78     std::string         getLocation() const { return mLocation; }
79     DCVPageComponent *  getVComponent() const { return d_vComponent; }
80     DCVCPage*           getPageBelonging() const;
81     DCCellCode*         getCellCode() const { return d_cellCode; }
82     bool                getIsCellCodeAssgined() const;
83     DCAxon*             getAxon() const;
84     std::string         getReceptorName(DCReceptor *receptor) const;
85     DCReceptor*         getReceptor(const QString& receptorName);
86     QString             getCustomScript() const;
87     QString             getType() const;
88     float               getViewPageX() const;
89     float               getViewPageY() const;
90     float               getViewSize() const;
91     float               getViewHeight() const;
92     void                getViewHCrossPoint(float dx, float dz, float *outX, float *outZ) const;
93     void                getViewVCrossPoint(float dx, float dy, float *outX, float *outY) const;
94
95     void                setViewPageX(float x);
96     void                setViewPageY(float y);
97     void                setViewSize(float size);
98     void                setViewHeight(float height);
99     bool                saveCustomScript(const QString& script);
100
101     /* Following methods are expected to be called from command classes (defined in dceditcommands.h).
102      */
103
104     /**
105      * Rename receptor name
106      */
107     bool                renameReceptor(const QString& oldName, const QString& newName);
108
109     /**
110      * Remove receptor from the list
111      * Note that this remove receptor object but won't remove the axon terminal connected to the receptor.
112      * This method is expected to be only called from command classes (defined in dceditcommands.h )
113      */
114     bool                removeReceptor(const QString &name);
115
116
117     /**
118      * Remove receptor from the list
119      * Note that this remove receptor object but won't remove the axon terminal connected to the receptor.
120      * This method is expected to be only called from command classes (defined in dceditcommands.h )
121      */
122     bool                removeReceptor(DCReceptor *receptor);
123
124     /**
125      * Create a receptor with the given name and register it into this cell.
126      * This method is expected to be only called from command classes (defined in dceditcommands.h )
127      */
128     virtual DCReceptor* createReceptor(const QString &receptorName);
129
130     /**
131      * Change cell code type.
132      * change of cell's own type attribute only take effort when no cell code class is assined to this cell.
133      * In the case a cell code class is assiend to this cell, type of this cell rely on the cell code class's API type.
134      */
135     void                changeType(const QString& type);
136
137 signals:
138     void    cellCodeChanged();
139
140
141 };
142
143 #endif // DCCELL_H