//--------------------------------------------------------- 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 ); }
//--------------------------------------------------------- void CACTIVE_History::On_Mouse_RDown(wxMouseEvent &event) { wxMenu Menu(_TL("History")); CMD_Menu_Add_Item(&Menu, false, ID_CMD_DATA_HISTORY_CLEAR); Menu.AppendSeparator(); CMD_Menu_Add_Item(&Menu, false, ID_CMD_DATA_HISTORY_OPTIONS_COLLAPSE); CMD_Menu_Add_Item(&Menu, false, ID_CMD_DATA_HISTORY_OPTIONS_EXPAND); if( _Get_Object() && SG_Compare_Version(_Get_Object()->Get_History().Get_Property("saga-version"), "2.1.3") >= 0 ) // new version { Menu.AppendSeparator(); CMD_Menu_Add_Item(&Menu, false, ID_CMD_DATA_HISTORY_TO_MODEL); } PopupMenu(&Menu, event.GetPosition()); event.Skip(); }
//--------------------------------------------------------- bool CWKSP_Project::_Load_Data(CSG_MetaData &Entry, const wxString &ProjectDir, bool bLoad, const CSG_String &Version) { if( !Entry.Cmp_Name("DATASET") || !Entry("FILE") || Entry["FILE"].Get_Content().is_Empty() ) { return( false ); } TSG_Data_Object_Type Type = Entry.Cmp_Property("type", "GRID" ) ? SG_DATAOBJECT_TYPE_Grid : Entry.Cmp_Property("type", "GRIDS" ) ? SG_DATAOBJECT_TYPE_Grids : Entry.Cmp_Property("type", "TABLE" ) ? SG_DATAOBJECT_TYPE_Table : Entry.Cmp_Property("type", "SHAPES") ? SG_DATAOBJECT_TYPE_Shapes : Entry.Cmp_Property("type", "TIN" ) ? SG_DATAOBJECT_TYPE_TIN : Entry.Cmp_Property("type", "POINTS") ? SG_DATAOBJECT_TYPE_PointCloud : SG_DATAOBJECT_TYPE_Undefined; if( Type == SG_DATAOBJECT_TYPE_Undefined ) { return( false ); } //----------------------------------------------------- wxString File = Entry("FILE")->Get_Content().c_str(); if( File.Find("PGSQL") != 0 && wxFileExists(Get_FilePath_Absolute(ProjectDir, File)) ) { File = Get_FilePath_Absolute(ProjectDir, File); } //----------------------------------------------------- CWKSP_Base_Item *pItem = NULL; if( bLoad ) { if( Type == SG_DATAOBJECT_TYPE_Grid && Entry("PARAMETERS")) { for(int i=0; i<Entry["PARAMETERS"].Get_Children_Count() && !pItem; i++) { if( Entry["PARAMETERS"][i].Cmp_Property("id", "FILE_CACHE") ) { bool bCached = Entry["PARAMETERS"][i].Cmp_Content("TRUE", true); pItem = g_pData->Add(SG_Create_Grid(&File, SG_DATATYPE_Undefined, bCached)); } } } } if( !pItem ) { pItem = bLoad ? g_pData->Open(File, Type) : _Get_byFileName(File); } //----------------------------------------------------- if( !pItem || !pItem->Get_Parameters() || !Entry.Get_Child("PARAMETERS") ) { if( bLoad ) { MSG_Error_Add(wxString::Format("%s [%s]", _TL("failed to load data"), File.c_str())); } return( false ); } //----------------------------------------------------- CSG_MetaData *pEntry = Entry("PARAMETERS"); for(int i=0; i<pEntry->Get_Children_Count(); i++) { if( !pEntry->Get_Child(i)->Get_Name().CmpNoCase("DATA") && !pEntry->Get_Child(i)->Get_Content().is_Empty() && pEntry->Get_Child(i)->Get_Content().BeforeFirst(':').CmpNoCase("PGSQL") ) { wxString File(Get_FilePath_Absolute(ProjectDir, pEntry->Get_Child(i)->Get_Content().w_str())); pEntry->Get_Child(i)->Set_Content(&File); // if( SG_Compare_SAGA_Version(Version) < 0 ) { if( pEntry->Get_Child(i)->Cmp_Property("id", "OVERLAY_1") ) { pEntry->Get_Child(i)->Set_Property("id", "OVERLAY_G"); } if( pEntry->Get_Child(i)->Cmp_Property("id", "OVERLAY_2") ) { pEntry->Get_Child(i)->Set_Property("id", "OVERLAY_B"); } } } } pItem->Get_Parameters()->Serialize(*Entry.Get_Child("PARAMETERS"), false); //----------------------------------------------------- if( SG_Compare_Version(Version, "7.0.0") < 0 ) // inter-version-compatibility { CSG_Parameter *pParameter = pItem->Get_Parameter("COLORS_TYPE"); if( pParameter && Type == SG_DATAOBJECT_TYPE_Grid ) { if( pParameter->asInt() == 4 ) { pParameter->Set_Value(6); } // Shade if( pParameter->asInt() == 5 ) { pParameter->Set_Value(4); } // RGB Overlay if( pParameter->asInt() == 6 ) { pParameter->Set_Value(5); } // RGB Composite } } //----------------------------------------------------- if( Type == SG_DATAOBJECT_TYPE_Grid ) { pItem->Get_Parameter("FILE_CACHE")->Set_Value(((CWKSP_Grid *)pItem)->Get_Grid()->is_Cached()); } pItem->Parameters_Changed(); return( true ); }