///////////////////////////////////////////////////////////
// Author:			Stefan Liersch
// Contact:			stefan.liersch@googlemail.com,
//					stefan.liersch@ufz.de
//
// Date:			2008-04-10
// last modified:	2008-04-10
//
//---------------------------------------------------------
// DESCRIPTION
//---------------------------------------------------------
//
//---------------------------------------------------------
// ToDo
//---------------------------------------------------------
//	- 
///////////////////////////////////////////////////////////

#include "pg_soil_salinity_dlg_base.h"

CSoilSalinityDlgBase::CSoilSalinityDlgBase()
{
	m_pSimpleFeature = NULL;

}

CSoilSalinityDlgBase::CSoilSalinityDlgBase(CSoilSalinityMap* pSSMap)
{
	m_pSSMap				= pSSMap;

	m_pSimpleFeature		= pSSMap->Get_SimpleFeature();

	m_pWKSP_SimpleFeature	= _Get_WKSP_SimpleFeature(m_pSimpleFeature);

	m_CurrentSelection		= _Get_Selection(m_pSimpleFeature);
}

CSoilSalinityDlgBase::~CSoilSalinityDlgBase()
{
}

///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------------------
CWKSP_SimpleFeature* CSoilSalinityDlgBase::_Get_WKSP_SimpleFeature(CSG_SimpleFeature* pSimpleFeature)
{
	if (Get_Active_Layer())	// CWKSP_Layer
	{
		m_pSimpleFeatureManager = g_pData->Get_SimpleFeatures();
		return( m_pSimpleFeatureManager->Get_Shapes(pSimpleFeature) );
	} else {
		return(NULL);
	}
}
//---------------------------------------------------------------------
int CSoilSalinityDlgBase::_Get_Selection(CSG_SimpleFeature* pSimpleFeature)
{
	for (int i = 0; i < pSimpleFeature->Get_Count(); i++) {
		if ( pSimpleFeature->Get_Shape(i)->is_Selected() ) {
			return(i);
		}
	}
	return(0);
}
//---------------------------------------------------------------------

wxArrayString CSoilSalinityDlgBase::_Get_ColumnNames(CSG_SimpleFeature* pSimpleFeature)
{
	wxArrayString astr;
	for (int i = 0; i < pSimpleFeature->Get_Table().Get_Field_Count(); i++) {
		astr.Add(pSimpleFeature->Get_Table().Get_Field_Name(i));
	}
	return(astr);
}

////---------------------------------------------------------------------
//CSG_String CSoilSalinityDlgBase::_Get_AttributeTableName()
//{
//	CSG_String attr_name;
//	attr_name.Append("_attr_");
//	return(attr_name.Append(m_pSimpleFeature->Get_Name()));
//}
////---------------------------------------------------------------------
//CSG_String CSoilSalinityDlgBase::_Get_SettingsTableName()
//{
//	CSG_String attr_name;
//	attr_name.Append("_settings_");
//	return(attr_name.Append(m_pSimpleFeature->Get_Name()));
//}
////---------------------------------------------------------------------
//CSG_String CSoilSalinityDlgBase::_Get_WeightsTableName()
//{
//	CSG_String attr_name;
//	attr_name.Append("_weights_");
//	return(attr_name.Append(m_pSimpleFeature->Get_Name()));
//}
//---------------------------------------------------------------------

wxArrayString CSoilSalinityDlgBase::_Get_FeatureIDs(CSG_SimpleFeature *pSimpleFeature, int col)
{
	wxArrayString	astr;
	CSG_String		str;
	for (int i = 0; i < pSimpleFeature->Get_Count(); i++) {
		if ( pSimpleFeature->Get_Table().Get_Value(i,col,str) ) {
			astr.Add(str.c_str());
		}
	}
	return(astr);
}
//---------------------------------------------------------------------

wxArrayString CSoilSalinityDlgBase::_Get_Month_Array()
{
	wxArrayString	astr;
	astr.Add("Jan");
	astr.Add("Feb");
	astr.Add("Mar");
	astr.Add("Apr");
	astr.Add("May");
	astr.Add("Jun");
	astr.Add("Jul");
	astr.Add("Aug");
	astr.Add("Sep");
	astr.Add("Oct");
	astr.Add("Nov");
	astr.Add("Dec");

	return(astr);
}

///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////


//---------------------------------------------------------------------
void CSoilSalinityDlgBase::_Set_ChoiceBox(wxChoice* pChoice, wxArrayString astr, int selection)
{
	pChoice->Clear();
	for (unsigned int i = 0; i < astr.size(); i++) {
		pChoice->Append(astr[i]);
	}
	pChoice->SetSelection(selection);
}


//---------------------------------------------------------------------

void CSoilSalinityDlgBase::_Zero_Controls()
{
	//m_pTXTCtrlResultStr->SetValue("");
	//m_pTXTCtrlResult->SetValue("");
	//m_pTXTCtrl_MSLOW->SetValue("");
	//m_pTXTCtrl_MSMEDIUM->SetValue("");
	//m_pTXTCtrl_MSHIGH->SetValue("");
}
//---------------------------------------------------------------------
