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.
30 class DCVPageComponent;
36 class DCCell : public QObject, public TKCell
40 friend class DCComponentUtil;
41 friend class DCContainer;
43 DCCell(DCContainer *container, std::string location, std::string name, std::string type, bool canInputInterface, bool canOutputInterface);
44 void bindComponent(DCVPageComponent *component);
46 DCVPageComponent *d_vComponent;
47 DCCellCode *d_cellCode;
52 const static float S_MINSIZE;
53 const static float S_MAXSIZE;
55 bool removeAllConnections();
58 * Change name of this cell.
59 * DCContainer will call this method.
61 void changeName(const QString& newName);
64 * Change the location path for this cell.
65 * DCContainer will call this method.
67 void changePath(const QString& newPath);
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);
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;
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);
101 /* Following methods are expected to be called from command classes (defined in dceditcommands.h).
105 * Rename receptor name
107 bool renameReceptor(const QString& oldName, const QString& newName);
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 )
114 bool removeReceptor(const QString &name);
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 )
122 bool removeReceptor(DCReceptor *receptor);
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 )
128 virtual DCReceptor* createReceptor(const QString &receptorName);
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.
135 void changeType(const QString& type);
138 void cellCodeChanged();