OSDN Git Service

[denncoCreator] alpha 2.0 - wrap up
[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 struct 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) { (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);
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     QString             getWorkFilePathForCustomScript() const;
95
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);
101
102     /* Following methods are expected to be called from command classes (defined in dceditcommands.h).
103      */
104
105     /**
106      * Rename receptor name
107      */
108     bool                renameReceptor(const QString& oldName, const QString& newName);
109
110     /**
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 )
114      */
115     bool                removeReceptor(const QString &name);
116
117
118     /**
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 )
122      */
123     bool                removeReceptor(DCReceptor *receptor);
124
125     /**
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 )
128      */
129     virtual DCReceptor* createReceptor(const QString &receptorName);
130
131     /**
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.
135      */
136     void                changeType(const QString& type);
137
138 signals:
139     void    cellCodeChanged();
140
141
142 };
143
144 #endif // DCCELL_H