GPortModel.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
00036
00037
00038
00039
00040
00041 #include "GPortModel.h"
00042
00043 namespace bbtk {
00044
00045
00046
00047
00048 GPortModel::GPortModel( ) {
00049 _parentBox = NULL ;
00050 _portType = -1 ;
00051 _posInBox = 0 ;
00052 _isConnected = false ;
00053 _value = "" ;
00054 _isValueSet = false ;
00055 }
00056
00057
00058
00059 GPortModel::~GPortModel( ) {
00060 }
00061
00062
00063 void GPortModel::registerInBox( GBoxModel *blackBox , int portType , int pos ) {
00064 _parentBox = blackBox ;
00065 _portType = portType ;
00066 _posInBox = pos ;
00067
00068 updatePortPosition( ) ;
00069
00070 }
00071
00072
00073
00074 void GPortModel::updatePortPosition( ) {
00075 double xInic , yInic , zInic , xFin , yFin , zFin ;
00076 _parentBox->getInicPoint( xInic , yInic , zInic ) ;
00077 _parentBox->getFinalPoint( xFin , yFin , zFin ) ;
00078
00079 double posX = xInic , posY = yInic , posZ = zInic ;
00080 if ( _portType == GOUTPUTPORT ) {
00081 posY = yFin ;
00082 } else if ( _portType == GINPUTPORT ) {
00083 posY = yInic + PORT_HEIGHT ;
00084 }
00085
00086
00087 posX = xInic + ( PORT_WIDTH / 2 ) + _posInBox * 1.1 * PORT_WIDTH ;
00088
00089 setInicPoint( posX , posY , posZ ) ;
00090
00091 posX = posX + PORT_WIDTH ;
00092 posY = posY - PORT_HEIGHT ;
00093
00094 setFinalPoint( posX , posY , posZ ) ;
00095
00096 }
00097
00098
00099
00100 int GPortModel::getPortType( ) {
00101 return _portType ;
00102 }
00103
00104
00105
00106 int GPortModel::getPosInBox( ) {
00107 return _posInBox ;
00108 }
00109
00110
00111
00112 std::string GPortModel::getStatusText( ) {
00113 std::string temp = "" ;
00114
00115 temp += _bbtkName ;
00116 if ( isValueSet( ) ) {
00117 temp += "(" ;
00118 temp += _value ;
00119 temp += ")" ;
00120 }
00121 temp += " " ;
00122 temp += _bbtkType ;
00123
00124 return temp ;
00125 }
00126
00127
00128
00129 GBoxModel* GPortModel::getParentBox( ) {
00130 return _parentBox ;
00131 }
00132
00133
00134
00135 bool GPortModel::isConnected( ) {
00136 return _isConnected ;
00137 }
00138
00139
00140
00141 void GPortModel::setConnected( bool value ) {
00142 _isConnected = value ;
00143 notifyObservers( _objectId ) ;
00144 }
00145
00146
00147
00148 void GPortModel::setValue( std::string value ) {
00149 _value = value ;
00150 if ( _value == "" ) {
00151 _isValueSet = false ;
00152 } else {
00153 _isValueSet = true ;
00154 }
00155 notifyObservers( _objectId ) ;
00156 }
00157
00158
00159
00160 std::string GPortModel::getValue( ) {
00161 return _value ;
00162 }
00163
00164
00165
00166 bool GPortModel::isValueSet( ) {
00167 return _isValueSet ;
00168 }
00169
00170
00171
00172 void GPortModel::save( std::string &content ) {
00173 content += "PORT\n" ;
00174
00175
00176 content += _bbtkName ;
00177 content += ":" ;
00178 content += _value ;
00179 content += "\n" ;
00180 }
00181
00182
00183
00184 }
00185
00186
00187