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 struct 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) { (void) 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;
94 QString getWorkFilePathForCustomScript() const;
96 void setViewPageX(float x);
97 void setViewPageY(float y);
98 void setViewSize(float size);
99 void setViewHeight(float height);
100 bool saveCustomScript(const QString& script);
102 /* Following methods are expected to be called from command classes (defined in dceditcommands.h).
106 * Rename receptor name
108 bool renameReceptor(const QString& oldName, const QString& newName);
111 * Remove receptor from the list
112 * Note that this remove receptor object but won't remove the axon terminal connected to the receptor.
113 * This method is expected to be only called from command classes (defined in dceditcommands.h )
115 bool removeReceptor(const QString &name);
119 * Remove receptor from the list
120 * Note that this remove receptor object but won't remove the axon terminal connected to the receptor.
121 * This method is expected to be only called from command classes (defined in dceditcommands.h )
123 bool removeReceptor(DCReceptor *receptor);
126 * Create a receptor with the given name and register it into this cell.
127 * This method is expected to be only called from command classes (defined in dceditcommands.h )
129 virtual DCReceptor* createReceptor(const QString &receptorName);
132 * Change cell code type.
133 * change of cell's own type attribute only take effort when no cell code class is assined to this cell.
134 * 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.
136 void changeType(const QString& type);
139 void cellCodeChanged();