1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::GPortModel
37 * Design and Developpement of BBTK GEditor
38 * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
41 #include "GPortModel.h"
46 //=========================================================================
48 GPortModel::GPortModel( ) {
52 _isConnected = false ;
57 //=========================================================================
59 GPortModel::~GPortModel( ) {
61 //=========================================================================
63 void GPortModel::registerInBox( GBoxModel *blackBox , int portType , int pos ) {
64 _parentBox = blackBox ;
65 _portType = portType ;
67 updatePortPosition( ) ;
70 //=========================================================================
72 void GPortModel::updatePortPosition( ) {
73 double xInic , yInic , zInic , xFin , yFin , zFin ;
74 _parentBox->getInicPoint( xInic , yInic , zInic ) ;
75 _parentBox->getFinalPoint( xFin , yFin , zFin ) ;
77 double posX = xInic , posY = yInic , posZ = zInic ;
78 if ( _portType == GOUTPUTPORT ) {
80 } else if ( _portType == GINPUTPORT ) {
81 posY = yInic + PORT_HEIGHT ;
84 //Attribute '_posInBox' starts with value 0 and it represents the position of the port in the box from left to right
85 posX = xInic + ( PORT_WIDTH / 2 ) + _posInBox * 1.1 * PORT_WIDTH ;
87 setInicPoint( posX , posY , posZ ) ;
89 posX = posX + PORT_WIDTH ;
90 posY = posY - PORT_HEIGHT ;
92 setFinalPoint( posX , posY , posZ ) ;
96 //=========================================================================
98 int GPortModel::getPortType( ) {
102 //=========================================================================
104 int GPortModel::getPosInBox( ) {
108 //=========================================================================
110 std::string GPortModel::getStatusText( ) {
111 std::string temp = "" ;
114 if ( isValueSet( ) ) {
125 //=========================================================================
127 GBoxModel* GPortModel::getParentBox( ) {
131 //=========================================================================
133 bool GPortModel::isConnected( ) {
134 return _isConnected ;
137 //=========================================================================
139 void GPortModel::setConnected( bool value ) {
140 _isConnected = value ;
141 notifyObservers( _objectId ) ;
144 //=========================================================================
146 void GPortModel::setValue( std::string value ) {
148 //Removing Colons JPRG
149 _parentBox->removeColons(value);
152 if ( _value == "" ) {
153 _isValueSet = false ;
157 notifyObservers( _objectId ) ;
160 //=========================================================================
162 std::string GPortModel::getValue( ) {
163 //JPRG::Adding Colons
164 std::string text = _value;
165 _parentBox->addColons(text);
170 //=========================================================================
172 bool GPortModel::isValueSet( ) {
176 //=========================================================================
178 void GPortModel::save( std::string &content ) {
179 content += "PORT\n" ;
182 content += _bbtkName ;
188 //=========================================================================
190 } // EO namespace bbtk