OSDN Git Service

[denncoCreator] implemented rename receptor functionality.
[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 canInterface);
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     DCVPageComponent *  getVComponent() const { return d_vComponent; }
79     DCVCPage*           getPageBelonging() const;
80     DCCellCode*         getCellCode() const { return d_cellCode; }
81     DCAxon*             getAxon() const;
82     std::string         getReceptorName(DCReceptor *receptor) const;
83     DCReceptor*         getReceptor(const QString& receptorName);
84     QString             getCustomScript() const;
85     QString             getType() const;
86     float               getViewPageX() const;
87     float               getViewPageY() const;
88     float               getViewSize() const;
89     float               getViewHeight() const;
90     void                getViewHCrossPoint(float dx, float dz, float *outX, float *outZ) const;
91     void                getViewVCrossPoint(float dx, float dy, float *outX, float *outY) const;
92
93     void                setViewPageX(float x);
94     void                setViewPageY(float y);
95     void                setViewSize(float size);
96     void                setViewHeight(float height);
97     bool                saveCustomScript(const QString& script);
98
99     /* Following methods are expected to be called from command classes (defined in dceditcommands.h).
100      */
101
102     /**
103      * Rename receptor name
104      */
105     bool                renameReceptor(const QString& oldName, const QString& newName);
106
107     /**
108      * Remove receptor from the list
109      * Note that this remove receptor object but won't remove the axon terminal connected to the receptor.
110      * This method is expected to be only called from command classes (defined in dceditcommands.h )
111      */
112     bool                removeReceptor(const QString &name);
113
114
115     /**
116      * Remove receptor from the list
117      * Note that this remove receptor object but won't remove the axon terminal connected to the receptor.
118      * This method is expected to be only called from command classes (defined in dceditcommands.h )
119      */
120     bool                removeReceptor(DCReceptor *receptor);
121
122     /**
123      * Create a receptor with the given name and register it into this cell.
124      * This method is expected to be only called from command classes (defined in dceditcommands.h )
125      */
126     virtual DCReceptor* createReceptor(const QString &receptorName);
127
128 signals:
129     void    cellCodeChanged();
130
131
132 };
133
134 #endif // DCCELL_H