示例#1
0
//---------------------------------------------------------
bool CWKSP_Project::_Save_Map(CSG_MetaData &Entry, const wxString &ProjectDir, CWKSP_Map *pMap)
{
	if( !pMap )
	{
		return( false );
	}

	CSG_MetaData	*pEntry	= Entry.Add_Child("MAP");

	pEntry->Add_Child("XMIN", pMap->Get_Extent().Get_XMin());
	pEntry->Add_Child("XMAX", pMap->Get_Extent().Get_XMax());
	pEntry->Add_Child("YMIN", pMap->Get_Extent().Get_YMin());
	pEntry->Add_Child("YMAX", pMap->Get_Extent().Get_YMax());

	pMap->Get_Parameters()->Serialize(*pEntry->Add_Child("PARAMETERS"), true);

	pEntry	= pEntry->Add_Child("LAYERS");

	for(int i=pMap->Get_Count()-1; i>=0; i--)
	{
		if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_Layer )
		{
			CSG_Data_Object	*pObject	= ((CWKSP_Map_Layer *)pMap->Get_Item(i))->Get_Layer()->Get_Object();

			if( pObject && pObject->Get_File_Name(false) && *pObject->Get_File_Name(false) )
			{
				wxString	FileName(pObject->Get_File_Name(false));

				if( FileName.Find("PGSQL") == 0 )
				{
					pEntry->Add_Child("FILE", &FileName);
				}
				else if( wxFileExists(FileName) )
				{
					pEntry->Add_Child("FILE", SG_File_Get_Path_Relative(&ProjectDir, &FileName));
				}
			}
		}

		else if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_Graticule )
		{
			((CWKSP_Map_Graticule *)pMap->Get_Item(i))->Save(*pEntry);
		}

		else if( pMap->Get_Item(i)->Get_Type() == WKSP_ITEM_Map_BaseMap )
		{
			((CWKSP_Map_BaseMap   *)pMap->Get_Item(i))->Save(*pEntry);
		}
	}

	return( true );
}
示例#2
0
//---------------------------------------------------------
void CACTIVE_History::On_Clear(wxCommandEvent &event)
{
	CSG_Data_Object	*pObject	= _Get_Object();

	int	Depth	= 0;

	if( pObject && DLG_Get_Number(Depth, _TL("Delete History Entries"), _TL("Depth")) )
	{
		pObject->Get_History().Del_Children(Depth, Depth > 0 ? SG_T("TOOL") : SG_T(""));
		pObject->Set_Modified(true);

		Set_Item(g_pACTIVE->Get_Active());
	}
}
示例#3
0
//---------------------------------------------------------
void CACTIVE_History::On_SaveAs_Model(wxCommandEvent &event)
{
	const wxString	Filter	= wxString::Format("%s|*.xml|%s|*.*",
		_TL("XML Files"), _TL("All Files")
	);

	wxString	File;

	CSG_Data_Object	*pObject	= _Get_Object();

	if( pObject && pObject->Get_History().Get_Children_Count() > 0
	&&  DLG_Save(File, _TL("Save History as Model"), Filter)
	&&  pObject->Save_History_to_Model(&File) )
	{
		g_pTools->Open(File);
	}
}
//---------------------------------------------------------
int CTable_Field_Deletion::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
{
	if( !SG_STR_CMP(pParameter->Get_Identifier(), "TABLE") )
	{
		CSG_Data_Object	*pObject	= pParameter->asDataObject();

		pParameters->Get_Parameter("OUT_TABLE" )->Set_Enabled(pObject &&
			pObject->Get_ObjectType() == DATAOBJECT_TYPE_Table
		);

		pParameters->Get_Parameter("OUT_SHAPES")->Set_Enabled(pObject &&
			pObject->Get_ObjectType() == DATAOBJECT_TYPE_Shapes
		);
	}

	return( 1 );
}
示例#5
0
//---------------------------------------------------------
bool CACTIVE_History::_Set_History(void)
{
	Freeze();

	DeleteAllItems();

	CSG_Data_Object	*pObject	= _Get_Object();

	if( pObject == NULL || pObject->Get_History().Get_Children_Count() <= 0 )
	{
		AddRoot(_TL("no history"), IMG_ROOT);
	}
	else if( SG_Compare_Version(pObject->Get_History().Get_Property("saga-version"), "2.1.3") >= 0 )	// new version
	{
		_Add_History(AddRoot(pObject->Get_Name(), IMG_ROOT), pObject->Get_History());
	}
	else
	{
		_Add_History_OLD(AddRoot(pObject->Get_Name(), IMG_ROOT), pObject->Get_History());
	}

	Expand(GetRootItem());

	Thaw();

	return( true );
}
//---------------------------------------------------------
CWKSP_Data_Item::~CWKSP_Data_Item(void)
{
	for(int i=m_Views.GetCount()-1; i>=0; i--)
	{
		((CVIEW_Base *)m_Views[i])->Do_Destroy();
	}

	//-----------------------------------------------------
	if( m_pObject )
	{
		CSG_Data_Object	*pObject	= m_pObject;	m_pObject	= NULL;

		MSG_General_Add(wxString::Format(wxT("%s: %s..."), _TL("Close"), pObject->Get_Name()), true, true);

		SG_Get_Data_Manager().Delete(pObject);

		MSG_General_Add(_TL("okay"), false, false, SG_UI_MSG_STYLE_SUCCESS);
	}
}
示例#7
0
//---------------------------------------------------------
bool CCMD_Module::_Save_Output(CSG_Parameters *pParameters)
{
    for(int j=0; j<pParameters->Get_Count(); j++)
    {
        wxString		FileName;

        CSG_Parameter	*pParameter	= pParameters->Get_Parameter(j);

        //-------------------------------------------------
        if( pParameter->is_Input() )
        {
            if( pParameter->is_DataObject() )
            {
                CSG_Data_Object	*pObject	= pParameter->asDataObject();

                if( pObject && pObject->is_Modified() && SG_File_Exists(pObject->Get_File_Name()) )
                {
                    pObject->Save(pObject->Get_File_Name());
                }
            }

            else if( pParameter->is_DataObject_List() )
            {
                for(int i=0; i<pParameter->asList()->Get_Count(); i++)
                {
                    CSG_Data_Object	*pObject	= pParameter->asList()->asDataObject(i);

                    if( pObject->is_Modified() && SG_File_Exists(pObject->Get_File_Name()) )
                    {
                        pObject->Save(pObject->Get_File_Name());
                    }
                }
            }
        }

        //-------------------------------------------------
        else if( pParameter->is_Output() &&  m_CMD.Found(_Get_ID(pParameter), &FileName) && FileName.Length() > 0 )
        {
            if( pParameter->is_DataObject() )
            {
                if( pParameter->asDataObject() )
                {
                    pParameter->asDataObject()->Save(&FileName);
                }
            }

            else if( pParameter->is_DataObject_List() )
            {
                CSG_Strings	FileNames;

                while( FileName.Length() > 0 )
                {
                    CSG_String	s(&FileName);
                    s = s.BeforeFirst(';');

                    if( s.Length() > 0 )
                    {
                        FileNames	+= s;
                        FileName	 = FileName.AfterFirst(';');
                    }
                    else
                    {
                        FileNames	+= &FileName;
                        FileName	.Clear();
                    }
                }

                int	nFileNames	= pParameter->asList()->Get_Count() <= FileNames.Get_Count() ? FileNames.Get_Count() : FileNames.Get_Count() - 1;

                for(int i=0; i<pParameter->asList()->Get_Count(); i++)
                {
                    if( i < nFileNames )
                    {
                        pParameter->asList()->asDataObject(i)->Save(FileNames[i]);
                    }
                    else
                    {
                        pParameter->asList()->asDataObject(i)->Save(CSG_String::Format(SG_T("%s_%0*d"),
                                FileNames[FileNames.Get_Count() - 1].c_str(),
                                SG_Get_Digit_Count(pParameter->asList()->Get_Count()),
                                1 + i - nFileNames
                                                                                      ));
                    }
                }
            }
        }
    }

    return( true );
}
示例#8
0
//---------------------------------------------------------
bool CACTIVE::Set_Active(CWKSP_Base_Item *pItem)
{
	if( pItem == m_pItem )
	{
		return( true );
	}

	//-----------------------------------------------------
	m_pItem		= pItem;

	if( m_pParameters )	m_pParameters->Set_Parameters(m_pItem);

	Update_Description();

	STATUSBAR_Set_Text(SG_T(""), STATUSBAR_VIEW_X);
	STATUSBAR_Set_Text(SG_T(""), STATUSBAR_VIEW_Y);
	STATUSBAR_Set_Text(SG_T(""), STATUSBAR_VIEW_Z);

	//-----------------------------------------------------
	if( m_pItem == NULL )
	{
		if( g_pSAGA_Frame   )	g_pSAGA_Frame->Set_Pane_Caption(this, _TL("Properties"));

		if( g_pData_Buttons )	g_pData_Buttons->Refresh();
		if( g_pMap_Buttons  )	g_pMap_Buttons ->Refresh();

		_Hide_Page(m_pHistory);
		_Hide_Page(m_pLegend);
		_Hide_Page(m_pAttributes);

		SendSizeEvent();

		return( true );
	}

	//-----------------------------------------------------
	if( g_pSAGA_Frame )	g_pSAGA_Frame->Set_Pane_Caption(this, wxString(_TL("Properties")) + ": " + m_pItem->Get_Name());

	//-----------------------------------------------------
	if( Get_Active_Data_Item() )
	{	_Show_Page(m_pHistory   );	}	else	{	_Hide_Page(m_pHistory   );	}

	if( Get_Active_Layer() || Get_Active_Map() )
	{	_Show_Page(m_pLegend    );	}	else	{	_Hide_Page(m_pLegend    );	}

	if( Get_Active_Layer() )
	{	_Show_Page(m_pAttributes);	}	else	{	_Hide_Page(m_pAttributes);	}

	//-----------------------------------------------------
	if( g_pData_Buttons )	g_pData_Buttons->Refresh(false);
	if( g_pMap_Buttons  )	g_pMap_Buttons ->Refresh(false);

	if( g_pData_Source  )	g_pData_Source->Set_Data_Source(m_pItem);

	//-----------------------------------------------------
	CSG_Data_Object	*pObject	= Get_Active_Data_Item() ? Get_Active_Data_Item()->Get_Object() : NULL;

	if( SG_Get_Data_Manager().Exists(pObject) &&
	(	(pObject->Get_ObjectType() == DATAOBJECT_TYPE_Table      && ((CSG_Table      *)pObject)->Get_Selection_Count() > 0)
	||	(pObject->Get_ObjectType() == DATAOBJECT_TYPE_TIN        && ((CSG_Shapes     *)pObject)->Get_Selection_Count() > 0)
	||	(pObject->Get_ObjectType() == DATAOBJECT_TYPE_PointCloud && ((CSG_PointCloud *)pObject)->Get_Selection_Count() > 0)
	||	(pObject->Get_ObjectType() == DATAOBJECT_TYPE_Shapes     && ((CSG_Shapes     *)pObject)->Get_Selection_Count() > 0)) )
	{
		g_pData->Update_Views(pObject);
	}

	SendSizeEvent();

	return( true );
}