7 #include "fwData/Landmarks.hpp" 9 #include "fwData/Exception.hpp" 10 #include "fwData/registry/macros.hpp" 12 #include <fwCom/Signal.hpp> 13 #include <fwCom/Signal.hxx> 57 Landmarks::csptr other = Landmarks::dynamicConstCast(_source);
59 "Unable to copy" + (_source ? _source->getClassname() : std::string(
"<NULL>"))
63 m_landmarks = other->m_landmarks;
70 Landmarks::csptr other = Landmarks::dynamicConstCast(_source);
72 "Unable to copy" + (_source ? _source->getClassname() : std::string(
"<NULL>"))
76 m_landmarks = other->m_landmarks;
81 void Landmarks::addGroup(
const std::string& name,
const Landmarks::ColorType& color,
const Landmarks::SizeType size,
82 const Landmarks::Shape shape,
const bool visibility)
85 const auto iter = m_landmarks.find(name);
86 FW_RAISE_EXCEPTION_IF(::
fwData::Exception(
"Group '" + name +
"' already exists"), iter != m_landmarks.end());
87 m_landmarks.insert(std::make_pair(name, group));
94 Landmarks::GroupNameContainer names;
99 std::back_inserter(names),
100 [](
const LandmarksContainer::value_type& pair){
return pair.first; });
109 const auto iter = m_landmarks.find(name);
110 FW_RAISE_EXCEPTION_IF(::
fwData::Exception(
"Group '" + name +
"' does not exist"), iter == m_landmarks.end());
119 auto iter = m_landmarks.find(name);
120 FW_RAISE_EXCEPTION_IF(::
fwData::Exception(
"Group '" + name +
"' does not exist"), iter == m_landmarks.end());
130 const auto iter = m_landmarks.find(oldName);
131 FW_RAISE_EXCEPTION_IF(::
fwData::Exception(
"Group '" + oldName +
"' does not exist"), iter == m_landmarks.end());
132 const auto iter2 = m_landmarks.find(newName);
133 FW_RAISE_EXCEPTION_IF(::
fwData::Exception(
"Group '" + newName +
"' already exists"), iter2 != m_landmarks.end());
136 m_landmarks.insert(std::make_pair(newName, group));
137 m_landmarks.erase(oldName);
144 const auto iter = m_landmarks.find(name);
145 FW_RAISE_EXCEPTION_IF(::
fwData::Exception(
"Group '" + name +
"' does not exist"), iter == m_landmarks.end());
147 m_landmarks.erase(name);
155 group.m_color = color;
171 group.m_shape = shape;
179 group.m_visibility = visibility;
187 group.m_points.push_back(point);
195 auto iter = group.m_points.begin() +
static_cast< PointContainer::difference_type
>(index);
196 group.m_points.insert(iter, point);
204 return group.m_points.at(index);
212 return group.m_points.at(index);
220 return group.m_points;
229 FW_RAISE_EXCEPTION_IF(std::out_of_range(
"index out of range in group '" + name +
"'"),
230 index >= group.m_points.size());
232 auto iter = group.m_points.begin() +
static_cast< PointContainer::difference_type
>(index);
233 group.m_points.erase(iter);
241 group.m_points.clear();
249 for (
const auto& elt: m_landmarks)
252 nb += group.m_points.size();
262 return group.m_points.size();
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_INSERTED_SIG
Type of signal when a group is added.
FWDATA_API void setGroupSize(const std::string &name, const SizeType size)
Set the group's landmark size.
This class defines a list of 3D points inside groups.
FWDATA_API const LandmarksGroup & getGroup(const std::string &name) const
Get the group properties.
FWDATA_API void clearPoints(const std::string &name)
Remove all the group's points.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_DESELECTED_SIG
Type of signal when a group is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_ADDED_SIG
Type of signal when a group is added.
FWDATA_API void removeGroup(const std::string &name)
Remove the group.
virtual const std::string & getClassname() const override
return full object's classname with its namespace, i.e. fwCore::BaseObject
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
FWDATA_API const PointContainer & getPoints(const std::string &name) const
Get all group's points.
FWDATA_API void addPoint(const std::string &name, const PointType &point)
Add a point to the group.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_REMOVED_SIG
Type of signal when a group is added.
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_SELECTED_SIG
Type of signal when a group is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_ADDED_SIG
Type of signal when a group is added.
FWDATA_API Landmarks(::fwData::Object::Key key)
Constructor.
FWDATA_API void setGroupColor(const std::string &name, const ColorType &color)
Set the group's color.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_RENAMED_SIG
Type of signal when a group is added.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
FWDATA_API void removePoint(const std::string &name, size_t index)
Remove the point at the given index.
FWDATA_API const GroupNameContainer getGroupNames() const
Return all group names.
FWDATA_API size_t getNumberOfPoints() const
Return the number of points in the entire structure.
virtual FWDATA_API ~Landmarks()
Destructor.
FWDATA_API void renameGroup(const std::string &oldName, const std::string &newName)
Rename the group.
Contains the representation of the data objects used in the framework.
FWDATA_API const PointType & getPoint(const std::string &name, size_t index) const
Get the point at the given index.
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_MODIFIED_SIG
Type of signal when a group is added.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_GROUP_MODIFIED_SIG
Type of signal when a group is added.
FWDATA_API void addGroup(const std::string &name, const ColorType &color={{1.0f, 1.0f, 1.0f, 1.0f}}, const SizeType size=1.0f, const Shape shape=Shape::SPHERE, const bool visibility=true)
Add a new landmark group.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_REMOVED_SIG
Type of signal when a group is added.
FWDATA_API void insertPoint(const std::string &name, const size_t index, const PointType &point)
Insert a point to the group at the given index.
FWDATA_API void setGroupVisibility(const std::string &name, const bool visibility)
Set the group's visibility.
FWDATA_API void setGroupShape(const std::string &name, const Shape shape)
Set the group's shape (SPHERE or CUBE)