GBoxModel.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00037 #include "GBoxModel.h"
00038
00039 namespace bbtk
00040 {
00041
00042
00043 GBoxModel::GBoxModel()
00044 {
00045 }
00046
00047
00048
00049 GBoxModel::~GBoxModel()
00050 {
00051 }
00052
00053
00054
00055 void GBoxModel::setInicPoint(double& x, double& y, double& z)
00056 {
00057 GObjectModel::setInicPoint(x,y,z);
00058
00059 double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT;
00060 setFinalPoint(xFin,yFin,z);
00061 }
00062
00063
00064
00065 void GBoxModel::addInputPort(GPortModel *inputport)
00066 {
00067 _inputs.push_back(inputport);
00068 }
00069
00070
00071
00072 void GBoxModel::addOutputPort(GPortModel *outputport)
00073 {
00074 _outputs.push_back(outputport);
00075 }
00076
00077
00078
00079 int GBoxModel::getNumInputPorts()
00080 {
00081 return _inputs.size();
00082 }
00083
00084
00085
00086 int GBoxModel::getNumOutputPorts()
00087 {
00088 return _outputs.size();
00089 }
00090
00091
00092
00093 void GBoxModel::move(double xx,double yy,double zz)
00094 {
00095 setInicPoint(xx,yy,zz);
00096
00097
00098 int i;
00099 for(i=0;i<(int)_inputs.size();i++)
00100 {
00101 _inputs[i]->updatePortPosition();
00102 }
00103
00104
00105 for(i=0;i<(int)_outputs.size();i++)
00106 {
00107 _outputs[i]->updatePortPosition();
00108 }
00109
00110 }
00111
00112
00113
00114 std::string GBoxModel::getStatusText()
00115 {
00116 std::string temp = "";
00117
00118 return temp;
00119 }
00120
00121
00122
00123 std::vector<GPortModel*> GBoxModel::getInputPorts()
00124 {
00125 return _inputs;
00126 }
00127
00128
00129
00130 std::vector<GPortModel*> GBoxModel::getOutputPorts()
00131 {
00132 return _outputs;
00133 }
00134
00135
00136
00137 void GBoxModel::save(std::string &content)
00138 {
00139 content+="\n";
00140 }
00141
00142
00143
00144
00145 GPortModel* GBoxModel::getInputPort(std::string name)
00146 {
00147 for(int i = 0; i<(int)_inputs.size();i++)
00148 {
00149 if(_inputs[i]->getBBTKName()==name)
00150 {
00151 return _inputs[i];
00152 }
00153 }
00154 return NULL;
00155 }
00156
00157
00158
00159 GPortModel* GBoxModel::getOutputPort(std::string name)
00160 {
00161 for(int i = 0; i<(int)_outputs.size();i++)
00162 {
00163 if(_outputs[i]->getBBTKName()==name)
00164 {
00165 return _outputs[i];
00166 }
00167 }
00168 return NULL;
00169 }
00170
00171
00172
00173 GPortModel* GBoxModel::getInputPort(int pos)
00174 {
00175 return _inputs[pos];
00176 }
00177
00178
00179
00180 GPortModel* GBoxModel::getOutputPort(int pos)
00181 {
00182 return _outputs[pos];
00183 }
00184
00185
00186
00187 void GBoxModel::updatePorts()
00188 {
00189 for(int i = 0; i<(int)_inputs.size();i++)
00190 {
00191 _inputs[i]->updatePortPosition();
00192 _inputs[i]->notifyObservers(_objectId);
00193 }
00194
00195 for(int i = 0; i<_outputs.size();i++)
00196 {
00197 _outputs[i]->updatePortPosition();
00198 _outputs[i]->notifyObservers(_objectId);
00199 }
00200 }
00201
00202 void GBoxModel::addColons(std::string &text)
00203 {
00204 std::string character("&&2P&&");
00205 size_t pos;
00206 pos = text.find(character);
00207 while(pos != std::string::npos)
00208 {
00209
00210 text.replace(pos, character.length(),":");
00211 pos = text.find(character, pos);
00212 }
00213 }
00214
00215 void GBoxModel::removeColons(std::string &text)
00216 {
00217 std::string character(":");
00218 size_t pos;
00219 pos = text.find(character);
00220 while(pos != std::string::npos)
00221 {
00222
00223 text.replace(pos, character.length(),"&&2P&&");
00224 pos = text.find(character, pos);
00225 }
00226 }
00227
00228
00229
00230
00231 }
00232
00233
00234