X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FGPortModel.cxx;h=fa208106e601938876cc21b4f7fb467c6fb7dec3;hb=10fae0f9392e3eaf390fd4cc0ac0a888b9d103e0;hp=8672eedafa918db517bcf5bbbcdf57f08269982a;hpb=5df5effdcd9f09c81c68fd63b1f0359593a823bd;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx index 8672eed..fa20810 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GPortModel.cxx @@ -45,6 +45,10 @@ namespace bbtk { _parentBox = NULL; _portType=-1; + _posInBox=0; + _isConnected=false; + _value=""; + _isValueSet=false; } //========================================================================= @@ -57,14 +61,15 @@ namespace bbtk { _parentBox = blackBox; _portType = portType; + _posInBox = pos; - updatePortPosition(pos); + updatePortPosition(); } //========================================================================= - void GPortModel::updatePortPosition(int pos) + void GPortModel::updatePortPosition() { double xInic, yInic,zInic,xFin,yFin,zFin; _parentBox->getInicPoint(xInic,yInic,zInic); @@ -73,15 +78,15 @@ namespace bbtk double posX=xInic,posY=yInic,posZ=zInic; if(_portType==GOUTPUTPORT) { - posY = yInic+PORT_HEIGHT; + posY = yFin; } else if(_portType==GINPUTPORT) { - posY = yFin; + posY = yInic+PORT_HEIGHT; } - //Variable 'pos' starts with value 0 and it represents the position of the port in the box from left to right - posX = xInic + PORT_WIDTH + pos*2*PORT_WIDTH; + //Attribute '_posInBox' starts with value 0 and it represents the position of the port in the box from left to right + posX = xInic + PORT_WIDTH + _posInBox*2*PORT_WIDTH; setInicPoint(posX,posY,posZ); @@ -90,8 +95,6 @@ namespace bbtk setFinalPoint(posX,posY,posZ); - setChanged(); - notifyObservers(); } //========================================================================= @@ -101,6 +104,88 @@ namespace bbtk return _portType; } + //========================================================================= + + std::string GPortModel::getStatusText() + { + std::string temp = "Name:"; + + temp+=_bbtkName; + temp+=" Type:"; + temp+=_bbtkType; + temp+=" Box:"; + temp+=_parentBox->getBBTKType(); + if(_portType==GOUTPUTPORT) + { + temp+=" [Output Port]"; + } + else if(_portType==GINPUTPORT) + { + if(isValueSet()) + { + temp+=" Value:"; + temp+=_value; + } + temp+=" [Input Port]"; + } + + return temp; + } + + //========================================================================= + + GBlackBoxModel* GPortModel::getParentBox() + { + return _parentBox; + } + + //========================================================================= + + bool GPortModel::isConnected() + { + return _isConnected; + } + + //========================================================================= + + void GPortModel::setConnected(bool value) + { + _isConnected=value; + notifyObservers(_objectId); + } + + //========================================================================= + + void GPortModel::setValue(std::string value) + { + _value = value; + if(_value=="") + { + _isValueSet=false; + } + else + { + _isValueSet=true; + } + notifyObservers(_objectId); + } + + //========================================================================= + + std::string GPortModel::getValue() + { + return _value; + } + + //========================================================================= + + bool GPortModel::isValueSet() + { + return _isValueSet; + } + + //========================================================================= + } // EO namespace bbtk // EOF