]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsKernelEditorGraphic/GConnectorModel.cxx
eed5e18f79db27d5790590b90934da68a59a666e
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsKernelEditorGraphic / GConnectorModel.cxx
1 /*=========================================================================                                                                               
2 Program:   bbtk
3 Module:    $RCSfile$
4 Language:  C++
5 Date:      $Date$
6 Version:   $Revision$
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32 *  \file 
33 *  \brief Class bbtk::GConnectorModel 
34 */
35
36
37 #include "GConnectorModel.h"
38
39 namespace bbtk
40 {
41
42         //=========================================================================
43
44         GConnectorModel::GConnectorModel()
45         {               
46                 //_startPort = NULL;
47                 //_endPort = NULL;
48         }
49
50         //=========================================================================
51
52         GConnectorModel::~GConnectorModel()
53         {
54         }
55
56         //=========================================================================
57
58         void GConnectorModel::setStartPort(GPortModel* startPort)
59         {
60                 _startPort = startPort;
61                 
62                 double xCenter,yCenter,zCenter;
63                 startPort->getCenter(xCenter,yCenter,zCenter);
64                 double xFport,yFport,zFport;
65                 startPort->getFinalPoint(xFport,yFport,zFport);
66
67                 setInicPoint(xCenter,yFport,zCenter);
68         }
69
70         //=========================================================================
71         
72         void GConnectorModel::setEndPort(GPortModel* endPort)
73         {
74                 _endPort = endPort;
75
76                 double xCenter,yCenter,zCenter;         
77                 endPort->getCenter(xCenter,yCenter,zCenter);
78                 double xIport,yIport,zIport;
79                 endPort->getInicPoint(xIport,yIport,zIport);
80
81                 setFinalPoint(xCenter,yIport,zCenter);
82
83                 manualPoint* point = _model->GetManualPoint(_model->GetSizeLstPoints()-1);
84                 point->SetPoint(xCenter,yIport,zCenter);
85         }
86
87         //=========================================================================
88         
89         GPortModel* GConnectorModel::getStartPort()
90         {
91                 return _startPort;
92         }
93
94         //=========================================================================
95         
96         GPortModel* GConnectorModel::getEndPort()
97         {
98                 return _endPort;
99         }
100         
101         //=========================================================================
102
103         manualContourModel* GConnectorModel::getManualContourModel()
104         {
105                 return _model;
106         }
107
108         //=========================================================================
109         
110         void GConnectorModel::setManualContourModel(manualContourModel* model)
111         {
112                 _model = model;
113         }
114
115         //=========================================================================
116
117         void GConnectorModel::updateStartEndPoints()
118         {
119                 //Start Point
120                 double xCenter,yCenter,zCenter;         
121                 _startPort->getCenter(xCenter,yCenter,zCenter);
122                 double xport,yport,zport;
123                 _startPort->getFinalPoint(xport,yport,zport);
124
125                 manualPoint* point = _model->GetManualPoint(0);
126                 point->SetPoint(xCenter,yport,zCenter);
127
128                 //End Point     
129                 _endPort->getCenter(xCenter,yCenter,zCenter);
130                 _endPort->getInicPoint(xport,yport,zport);
131
132                 point = _model->GetManualPoint(_model->GetSizeLstPoints()-1);
133                 point->SetPoint(xCenter,yport,zCenter);
134         }
135
136 }  // EO namespace bbtk
137
138 // EOF
139