/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.baselibs;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
/**
* This item class contains the methods to set, get and validate the attribute present in Detector Position Sequence .
 */


public class DetectorPositionSequenceItem extends Item{

	private static final long serialVersionUID = 1L;
	/**
	 * This constructor creates the item and internal code sequence macro with default TransferSyntax 
	 */
	DetectorPositionSequenceItem()
	{
		super();
	}


	/**
	 * This constructor creates the item and internal code sequence macro with specified TransferSyntax 
	 * and default DictionaryReader
	 * @param objITransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 */
	DetectorPositionSequenceItem(ITransferSyntax objITransferSyntax)
	{
		super(objITransferSyntax);
	}

	/**
	 * This constructor creates FillStyleSequenceItem with specified TransferSyntax and
	 * specified DictionaryReader
	 * @param objTransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 * @param objDictionaryReader specifies the DICOM Dictionary reader to be used 
	 */
	DetectorPositionSequenceItem(ITransferSyntax objTransferSyntax, IDictionaryReader objDictionaryReader)
	{
		super(objTransferSyntax,objDictionaryReader);
	}

	/**
	 * Sets DetectorPrimaryAngle.Uniquely identifies Detector Primary Angle.
	 * Angle of the X-Ray beam in the row direction in degrees relative to the normal to the detector plane. 
	 * Positive values indicate that the X-Ray beam is tilted toward higher numbered columns.
	 * Negative values indicate that the X-Ray beam is tilted toward lower numbered columns.
	 * @param strDetectorPrimaryAngle String value of Slice Thickness.
	 */
	public void setDetectorPrimaryAngle(String strDetectorPrimaryAngle)
	{
		/* Accept the strDetectorPrimaryAngle in String format of type DS.
		 * Angle of the X-Ray beam in the row direction in degrees relative to the normal to the detector plane. 
		 * Positive values indicate that the X-Ray beam is tilted toward higher numbered columns.
		 * Negative values indicate that the X-Ray beam is tilted toward lower numbered columns.
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1530, strDetectorPrimaryAngle,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1530,DicomConstants.DCM_DT_DS, strDetectorPrimaryAngle);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves DetectorPrimaryAngle.
	 * @return String - value of Detector Primary Angle.
	 */
	public String getDetectorPrimaryAngle()
	{
		Object objValue = getValue(0x0018,0x1530);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets DetectorSecondaryAngle.Uniquely identifies Detector Secondary Angle.
	 * Angle of the X-Ray beam in the column direction in degrees relative to the normal to the detector plane.
	 * @param DetectorSecondaryAngle String value of Detector Secondary Angle.
	 */
	public void setDetectorSecondaryAngle(String strDetectorPrimaryAngle)
	{
		/* Accept the Detector Secondary Angle in String format of type DS.
		 * Angle of the X-Ray beam in the column direction in degrees relative to the normal to the detector plane.
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0018,0x1531, strDetectorPrimaryAngle,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1531,DicomConstants.DCM_DT_DS, strDetectorPrimaryAngle);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves DetectorSecondaryAngle.
	 * @return String - value of Detector Secondary Angle.
	 */
	public String getDetectorSecondaryAngle()
	{
		Object objValue = getValue(0x0018,0x1531);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
}
