fw4spl
src/fwData/Line.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwData/registry/macros.hpp"
8 #include "fwData/Exception.hpp"
9 #include "fwData/Line.hpp"
10 
11 #include <fwCore/base.hpp>
12 
13 fwDataRegisterMacro( ::fwData::Line );
14 
15 namespace fwData
16 {
17 
18 //------------------------------------------------------------------------------
19 
21 {
23 }
24 
25 //------------------------------------------------------------------------------
26 
28 {
30 }
31 
32 //------------------------------------------------------------------------------
33 
34 void Line::shallowCopy(const Object::csptr &_source )
35 {
36  Line::csptr other = Line::dynamicConstCast(_source);
37  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
38  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
39  + " to " + this->getClassname()), !bool(other) );
40  this->fieldShallowCopy( _source );
41  m_position = other->m_position;
42  m_direction = other->m_direction;
43 }
44 
45 //------------------------------------------------------------------------------
46 
47 void Line::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
48 {
49  Line::csptr other = Line::dynamicConstCast(_source);
50  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
51  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
52  + " to " + this->getClassname()), !bool(other) );
53  this->fieldDeepCopy( _source, cache );
54  m_position = ::fwData::Object::copy( other->m_position, cache );
55  m_direction = ::fwData::Object::copy( other->m_direction, cache );
56 }
57 
58 //------------------------------------------------------------------------------
59 
60 void Line::setValue(const ::fwData::Point::sptr& _position, const ::fwData::Point::sptr& _direction)
61 {
62  m_position = _position;
63  m_direction = _direction;
64 }
65 
66 } // namespace fwData
67 
68 
virtual const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
#define SLM_TRACE_FUNC()
Trace contextual function signature.
Definition: spyLog.hpp:329
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
Implements data exception class.
::fwData::Point::sptr m_position
Points container.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
static FWDATA_API::fwData::Object::sptr copy(const ::fwData::Object::csptr &source)
return a copy of the source. if source is a null pointer, return a null pointer.
virtual FWDATA_API ~Line()
Destructor.
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
Contains the representation of the data objects used in the framework.
This class defines a Line defined by two points.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)
FWDATA_API Line(::fwData::Object::Key key)
Constructor.