GPortModel.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 Program:   bbtk
00003 Module:    $RCSfile: GPortModel.cxx,v $
00004 Language:  C++
00005 Date:      $Date: 2012/05/23 15:57:12 $
00006 Version:   $Revision: 1.19 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011  * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012  * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013  *
00014  *  This software is governed by the CeCILL-B license under French law and
00015  *  abiding by the rules of distribution of free software. You can  use,
00016  *  modify and/ or redistribute the software under the terms of the CeCILL-B
00017  *  license as circulated by CEA, CNRS and INRIA at the following URL
00018  *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
00019  *  or in the file LICENSE.txt.
00020  *
00021  *  As a counterpart to the access to the source code and  rights to copy,
00022  *  modify and redistribute granted by the license, users are provided only
00023  *  with a limited warranty  and the software's author,  the holder of the
00024  *  economic rights,  and the successive licensors  have only  limited
00025  *  liability.
00026  *
00027  *  The fact that you are presently reading this means that you have had
00028  *  knowledge of the CeCILL-B license and that you accept its terms.
00029  * ------------------------------------------------------------------------ */
00030 
00036 /****
00037  * Design and Developpement of BBTK GEditor
00038  * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
00039  * RaC - 2010
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         //Attribute '_posInBox' starts with value 0 and it represents the position of the port in the box from left to right
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         // Port value info
00176         content += _bbtkName ;
00177         content += ":" ;
00178         content += _value ;
00179         content += "\n" ;
00180     }
00181 
00182     //=========================================================================
00183 
00184 } // EO namespace bbtk
00185 
00186 // EOF
00187 

Generated on Thu May 31 15:12:19 2012 for bbtkGEditor by  doxygen 1.5.7.1