fw4spl
src/fwData/Plane.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/Plane.hpp"
10 
11 #include <fwCom/Signal.hpp>
12 #include <fwCom/Signal.hxx>
13 
14 #include <fwCore/base.hpp>
15 
16 fwDataRegisterMacro( ::fwData::Plane );
17 
18 namespace fwData
19 {
20 
21 const ::fwCom::Signals::SignalKeyType Plane::s_SELECTED_SIG = "selected";
22 
23 //------------------------------------------------------------------------------
24 
25 Plane::Plane (::fwData::Object::Key key) : m_isIntersection(true)
26 {
27  m_vPoints[0] = ::fwData::Point::New();
28  m_vPoints[1] = ::fwData::Point::New();
29  m_vPoints[2] = ::fwData::Point::New();
30 
31  newSignal< SelectedSignalType >(s_SELECTED_SIG);
32 }
33 
34 //------------------------------------------------------------------------------
35 
37 {
38 }
39 
40 //------------------------------------------------------------------------------
41 
42 void Plane::shallowCopy(const Object::csptr &_source )
43 {
44  Plane::csptr other = Plane::dynamicConstCast(_source);
45  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
46  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
47  + " to " + this->getClassname()), !bool(other) );
48  this->fieldShallowCopy( _source );
49  m_vPoints = other->m_vPoints;
50 }
51 
52 //------------------------------------------------------------------------------
53 
54 void Plane::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
55 {
56  Plane::csptr other = Plane::dynamicConstCast(_source);
57  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
58  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
59  + " to " + this->getClassname()), !bool(other) );
60  this->fieldDeepCopy( _source, cache );
61  m_vPoints[0] = ::fwData::Object::copy(other->m_vPoints[0], cache);
62  m_vPoints[1] = ::fwData::Object::copy(other->m_vPoints[1], cache);
63  m_vPoints[2] = ::fwData::Object::copy(other->m_vPoints[2], cache);
64 }
65 
66 //------------------------------------------------------------------------------
67 
68 void Plane::setValue(::fwData::Point::sptr _point1, ::fwData::Point::sptr _point2, ::fwData::Point::sptr _point3)
69 {
70  m_vPoints[0] = _point1;
71  m_vPoints[1] = _point2;
72  m_vPoints[2] = _point3;
73 }
74 
75 //------------------------------------------------------------------------------
76 
77 } // namespace fwData
78 
79 
FWDATA_API Plane(::fwData::Object::Key key)
Constructor.
This class defines a plane defined by tree points.
Definition: Plane.hpp:25
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
PointContainer m_vPoints
Points container.
Definition: Plane.hpp:83
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
virtual FWDATA_API ~Plane()
Destructor.
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 const std::string & getClassname() const override
return full object&#39;s classname with its namespace, i.e. fwCore::BaseObject
Definition: Plane.hpp:29
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_SELECTED_SIG
Signal emitted when plane is selected/deselected.
Definition: Plane.hpp:75
Contains the representation of the data objects used in the framework.
FWDATA_API void setValue(::fwData::Point::sptr _point1,::fwData::Point::sptr _point2,::fwData::Point::sptr _point3)
Re-initialize the plane with 3 points.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)