00001 /*========================================================================= 00002 00003 Program: BlueBerry Platform 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkDataNodeSelection.h" 00019 00020 #include "mitkDataNodeObject.h" 00021 00022 namespace mitk 00023 { 00024 00025 DataNodeSelection::DataNodeSelection() : 00026 m_Selection(new ContainerType()) 00027 { 00028 00029 } 00030 00031 DataNodeSelection::DataNodeSelection(DataNode::Pointer node) : 00032 m_Selection(new ContainerType()) 00033 { 00034 DataNodeObject::Pointer obj(new DataNodeObject(node)); 00035 m_Selection->push_back(obj); 00036 } 00037 00038 DataNodeSelection::DataNodeSelection(const std::vector<DataNode::Pointer>& nodes) : 00039 m_Selection(new ContainerType()) 00040 { 00041 for (std::vector<DataNode::Pointer>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) 00042 { 00043 DataNodeObject::Pointer obj(new DataNodeObject(*i)); 00044 m_Selection->push_back(obj); 00045 } 00046 } 00047 00048 berry::Object::Pointer DataNodeSelection::GetFirstElement() const 00049 { 00050 if (m_Selection->empty()) 00051 return berry::Object::Pointer(); 00052 00053 return *(m_Selection->begin()); 00054 } 00055 00056 berry::IStructuredSelection::iterator DataNodeSelection::Begin() const 00057 { 00058 return m_Selection->begin(); 00059 } 00060 00061 berry::IStructuredSelection::iterator DataNodeSelection::End() const 00062 { 00063 return m_Selection->end(); 00064 } 00065 00066 int DataNodeSelection::Size() const 00067 { 00068 return m_Selection->size(); 00069 } 00070 00071 berry::IStructuredSelection::ContainerType::Pointer DataNodeSelection::ToVector() const 00072 { 00073 return m_Selection; 00074 } 00075 00076 bool DataNodeSelection::IsEmpty() const 00077 { 00078 return m_Selection->empty(); 00079 } 00080 00081 bool DataNodeSelection::operator==(const berry::Object* obj) const 00082 { 00083 if (const berry::IStructuredSelection* other = dynamic_cast<const berry::IStructuredSelection*>(obj)) 00084 { 00085 return m_Selection == other->ToVector(); 00086 } 00087 00088 return false; 00089 } 00090 00091 }