/******************************************************************************
 * MarkGroup.cs 
 * 
 * <Copyright and License> 
 * 
 * This file is part of GODS, a package for annotating medical images. 
 * 
 * Copyright (C) 2004 
 * Xuedong Chen 
 * Heri Mariwa 
 * Kimmy (Hsiang-ling) Lin 
 * Rui Yu 
 * 
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 
 * of the License, or (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 *  
 * For further questions about this file, please send email to 
 * gods@cs.umb.edu or visit us at http://gods.sourceforge.net.  
 ******************************************************************************/

using System;
using System.Collections;


namespace GODS.MarkData
{
	/// <summary>
	/// Summary description for MarkGroup.
	/// </summary>
	public class MarkGroup
	{
		public const string defaultName = "Default";
		private string name;
		private MarkSet markset;
		private ArrayList marks;
		private bool removable = true;

		public MarkGroup(MarkSet markset, string name, ArrayList marks)
		{
			this.markset = markset;
			this.name = name;
			this.marks = marks;
		}

		public MarkGroup(MarkSet markset, string name) : this(markset, name, new ArrayList())
		{}

		public string GroupName
		{
			get
			{
				return this.name;
			}
			set
			{
				this.name = value;
			}
		}

		public ArrayList Marks
		{
			get 
			{
				return this.marks;
			}
		}

		public bool Removable
		{
			get 
			{
				return this.removable;
			}
		}

		private Mark getMark(string mName)
		{
			foreach (Mark mark in this.marks)
			{
				if (mName.Equals(mark.MarkName)) 
				{
					return mark;
				}
			}
			return null;
		}

		public void addMark(Mark newMark)
		{
			Mark mark = this.getMark(newMark.MarkName);
			if (mark == null) 
			{
				this.marks.Add(newMark);
			}
				/*
			else
			{
				throw new System.Exception("Dupplicate mark: Mark with the same name already exists.");
			}
			*/
		}

		public void removeMark(Mark mark)
		{
			this.marks.Remove(mark);
		}

		public override string ToString()
		{
			return this.name;
		}
	}
}

