//--------------------------------------------------------- wxString CWKSP_Module_Group::Get_Description(void) { wxString s; s += wxString::Format("<h4>%s</h4>", _TL("Tool Libraries")); s += "<table border=\"0\">"; s += SUMMARY_ADD_STR(_TL("Category" ), Get_Name().c_str()); s += SUMMARY_ADD_INT(_TL("Libraries"), Get_Count()); s += "</table>"; //----------------------------------------------------- s += wxString::Format("<hr><h4>%s</h4><table border=\"0\">", _TL("Tool Libraries")); s += wxString::Format("<tr align=\"left\"><th>%s</th><th>%s</th><th>%s</th></tr>", _TL("Library"), _TL("Name" ), _TL("Tools" ) ); for(int i=0; i<Get_Count(); i++) { s += wxString::Format("<tr><td valign=\"top\"><i>%s</i></td><td valign=\"top\">%s</td><td valign=\"top\" align=\"right\">%d</td></tr>", Get_Library(i)->Get_Library()->Get_Library_Name().c_str(), Get_Library(i)->Get_Name().c_str(), Get_Library(i)->Get_Count() ); } s += "</table>"; return( s ); }
//--------------------------------------------------------- bool CSG_PointCloud::Del_Point(int iPoint) { if( iPoint >= 0 && iPoint < Get_Count() ) { if( is_Selected(iPoint) ) { Select(iPoint, true); } m_Cursor = m_Points[iPoint]; for(int i=iPoint, j=iPoint+1; j<Get_Count(); i++, j++) { m_Points[i] = m_Points[j]; } m_Points[Get_Count() - 1] = m_Cursor; m_Cursor = NULL; _Dec_Array(); Set_Modified(); Set_Update_Flag(); _Stats_Invalidate(); return( true ); } return( false ); }
//--------------------------------------------------------- wxString CWKSP_Grid_Manager::Get_Description(void) { wxString s; s.Printf(wxT("<b>%s</b><br>%d %s"), _TL("Grids"), Get_Count(), Get_Count() == 1 ? _TL("grid system") : _TL("grid systems")); return( s ); }
//--------------------------------------------------------- wxString CWKSP_Map_Manager::Get_Description(void) { wxString s; s.Printf(wxT("%d %s"), Get_Count(), Get_Count() == 1 ? _TL("Map") : _TL("Maps")); return( s ); }
//--------------------------------------------------------- bool CSG_Module_Library::Create(const CSG_String &File_Name) { Destroy(); TSG_PFNC_MLB_Initialize MLB_Initialize; TSG_PFNC_MLB_Get_Interface MLB_Get_Interface; wxString sPath; wxFileName fName(File_Name.c_str()); fName.MakeAbsolute(); m_File_Name = fName.GetFullPath(); //----------------------------------------------------- if( wxGetEnv(ENV_LIB_PATH, &sPath) && sPath.Length() > 0 ) { wxSetEnv(ENV_LIB_PATH, CSG_String::Format(SG_T("%s%c%s"), sPath.c_str(), ENV_LIB_SEPA, SG_File_Get_Path(m_File_Name).c_str())); } else { wxSetEnv(ENV_LIB_PATH, SG_File_Get_Path(m_File_Name).c_str()); } //----------------------------------------------------- if( m_pLibrary->Load(m_File_Name.c_str()) && (MLB_Get_Interface = (TSG_PFNC_MLB_Get_Interface) m_pLibrary->GetSymbol(SYMBOL_MLB_Get_Interface)) != NULL && (MLB_Initialize = (TSG_PFNC_MLB_Initialize) m_pLibrary->GetSymbol(SYMBOL_MLB_Initialize) ) != NULL && MLB_Initialize(m_File_Name) ) { m_pInterface = MLB_Get_Interface(); } //----------------------------------------------------- if( sPath.Length() > 0 ) { wxSetEnv(ENV_LIB_PATH, sPath); } else { wxUnsetEnv(ENV_LIB_PATH); } //----------------------------------------------------- if( Get_Count() > 0 ) { for(int i=0; i<Get_Count(); i++) Get_Module(i)->Set_Managed(false); return( true ); } Destroy(); return( false ); }
//--------------------------------------------------------- bool CSG_PointCloud::_Save(const CSG_String &File_Name) { CSG_File Stream; SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), _TL("Save point cloud"), File_Name.c_str()), true); CSG_String sFile_Name = SG_File_Make_Path(NULL, File_Name, SG_T("spc")); if( Stream.Open(sFile_Name, SG_FILE_W, true) == false ) { SG_UI_Msg_Add(_TL("failed"), false, SG_UI_MSG_STYLE_FAILURE); SG_UI_Msg_Add_Error(_TL("unable to create file.")); return( false ); } int i, iBuffer, nPointBytes = m_nPointBytes - 1; Stream.Write((void *)PC_FILE_VERSION, 6); Stream.Write(&nPointBytes , sizeof(int)); Stream.Write(&m_nFields , sizeof(int)); for(i=0; i<m_nFields; i++) { Stream.Write(&m_Field_Type[i], sizeof(TSG_Data_Type)); iBuffer = (int)m_Field_Name[i]->Length(); if( iBuffer >= 1024 - 1 ) iBuffer = 1024 - 1; Stream.Write(&iBuffer, sizeof(int)); Stream.Write((void *)m_Field_Name[i]->b_str(), sizeof(char), iBuffer); } _Set_Shape(m_Shapes_Index); for(i=0; i<Get_Count() && SG_UI_Process_Set_Progress(i, Get_Count()); i++) { Stream.Write(m_Points[i] + 1, nPointBytes); } Set_Modified(false); Set_File_Name(sFile_Name, true); Save_MetaData(File_Name); Get_Projection().Save(SG_File_Make_Path(NULL, File_Name, SG_T("prj")), SG_PROJ_FMT_WKT); SG_UI_Msg_Add(_TL("okay"), false, SG_UI_MSG_STYLE_SUCCESS); SG_UI_Process_Set_Ready(); return( true ); }
//--------------------------------------------------------- bool CSG_Shapes::Make_Clean(void) { if( m_Type != SHAPE_TYPE_Polygon ) { return( true ); } for(int iShape=0; iShape<Get_Count() && SG_UI_Process_Set_Progress(iShape, Get_Count()); iShape++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)Get_Shape(iShape); for(int iPart=0; iPart<pPolygon->Get_Part_Count(); iPart++) { if( m_Vertex_Type == SG_VERTEX_TYPE_XY ) // currently we have to disable this check for 3D shapefiles since the // _Update_Area() method can not handle polygons with no horizontal extent { //-------------------------------------------- // ring direction: outer rings > clockwise, inner rings (lakes) > counterclockwise ! if( (pPolygon->is_Lake(iPart) == pPolygon->is_Clockwise(iPart)) ) { pPolygon->Revert_Points(iPart); } } //-------------------------------------------- // last point == first point ! if( !CSG_Point(pPolygon->Get_Point(0, iPart)).is_Equal(pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart)) ) { ((CSG_Shape *)pPolygon)->Add_Point(pPolygon->Get_Point(0, iPart), iPart); if( m_Vertex_Type != SG_VERTEX_TYPE_XY ) { pPolygon->Set_Z(pPolygon->Get_Z(0, iPart), pPolygon->Get_Point_Count(iPart) - 1, iPart); if( m_Vertex_Type == SG_VERTEX_TYPE_XYZM ) { pPolygon->Set_M(pPolygon->Get_M(0, iPart), pPolygon->Get_Point_Count(iPart) - 1, iPart); } } } //-------------------------------------------- // no self intersection ! } } return( true ); }
//--------------------------------------------------------- wxString CWKSP_Grid_System::Get_Description(void) { wxString s; s.Printf(wxT("<b>%s</b><table border=\"0\">"), LNG("[CAP] Grid System")); s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"), LNG("[CAP] Name") , Get_Name().c_str() )); s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%d</td></tr>"), LNG("[CAP] Number Of Grids") , Get_Count() )); s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%d (x) * %d (y) = %ld</td></tr>"), LNG("[CAP] Number Of Cells") , m_System.Get_NX(), m_System.Get_NY(), m_System.Get_NCells() )); s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%f</td></tr>"), LNG("[CAP] Cell Size") , m_System.Get_Cellsize() )); s.Append(wxString::Format(wxT("<tr><td>%s</td><td>[%f] - [%f] = [%f]</td></tr>"), LNG("[CAP] West-East") , m_System.Get_XMin(), m_System.Get_XMax(), m_System.Get_XRange() )); s.Append(wxString::Format(wxT("<tr><td>%s</td><td>[%f] - [%f] = [%f]</td></tr>"), LNG("[CAP] South-North") , m_System.Get_YMin(), m_System.Get_YMax(), m_System.Get_YRange() )); s.Append(wxT("</table>")); //----------------------------------------------------- return( s ); }
//--------------------------------------------------------- CSG_Shape * CSG_PointCloud::Get_Shape(TSG_Point Point, double Epsilon) { CSG_Rect r(Point.x - Epsilon, Point.y - Epsilon, Point.x + Epsilon, Point.y + Epsilon); if( r.Intersects(Get_Extent()) != INTERSECTION_None ) { int iPoint = -1; double iDistance = -1.0; for(int iRecord=0; iRecord<Get_Count(); iRecord++) { Set_Cursor(iRecord); if( r.Contains(Get_X(), Get_Y()) ) { if( iPoint < 0 || iDistance > SG_Get_Distance(Point.x, Point.y, Get_X(), Get_Y()) ) { iPoint = iRecord; iDistance = SG_Get_Distance(Point.x, Point.y, Get_X(), Get_Y()); } } } if( iPoint >= 0 ) { return( CSG_Shapes::Get_Shape(iPoint) ); } } return( NULL ); }
//--------------------------------------------------------- bool CWKSP_Module_Manager::Finalise(void) { CONFIG_Write("/MODULES", &m_Parameters); CONFIG_Delete(CFG_LIBS); for(int i=0, n=0; i<Get_Count(); i++) { CWKSP_Module_Group *pGroup = Get_Group(i); for(int j=0; j<pGroup->Get_Count(); j++) { CSG_Module_Library *pLibrary = pGroup->Get_Library(j)->Get_Library(); if( pLibrary->Get_Type() == MODULE_CHAINS ) { for(int j=0; j<pLibrary->Get_Count(); j++) { CONFIG_Write(CFG_LIBS, wxString::Format(CFG_LIBF, n++), GET_LIBPATH(pLibrary->Get_File_Name(j))); } } else { CONFIG_Write(CFG_LIBS, wxString::Format(CFG_LIBF, n++), GET_LIBPATH(pLibrary->Get_File_Name())); } } } return( true ); }
//--------------------------------------------------------- CSG_String CSG_Module_Library::Get_Summary(bool bHTML) { CSG_String s; if( bHTML ) { s.Printf( SG_T("%s: <b>%s</b><br>%s: <i>%s</i><br>%s: <i>%s</i><br>%s: <i>%s</i><hr>%s"), LNG("[CAP] Module Library") , Get_Info(MLB_INFO_Name), LNG("[CAP] Author") , Get_Info(MLB_INFO_Author), LNG("[CAP] Version") , Get_Info(MLB_INFO_Version), LNG("[CAP] File") , Get_File_Name().c_str(), Get_Info(MLB_INFO_Description) ); s.Append(CSG_String::Format(SG_T("<hr><b>%s:<ul>"), LNG("[CAP] Modules"))); for(int i=0; i<Get_Count(); i++) { s.Append(CSG_String::Format(SG_T("<li>%s</li>"), Get_Module(i)->Get_Name())); } s.Append(SG_T("</ul>")); s.Replace(SG_T("\n"), SG_T("<br>")); } else { s.Printf( SG_T("%s: %s\n%s: %s\n%s: %s\n%s: %s\n\n%s"), LNG("[CAP] Module Library") , Get_Info(MLB_INFO_Name), LNG("[CAP] Author") , Get_Info(MLB_INFO_Author), LNG("[CAP] Version") , Get_Info(MLB_INFO_Version), LNG("[CAP] File") , Get_File_Name().c_str(), Get_Info(MLB_INFO_Description) ); s.Append(CSG_String::Format(SG_T("\n\n%s:\n"), LNG("[CAP] Modules"))); for(int i=0; i<Get_Count(); i++) { s.Append(CSG_String::Format(SG_T("- %s\n"), Get_Module(i)->Get_Name())); } } return( s ); }
//--------------------------------------------------------- wxString CWKSP_TIN_Manager::Get_Description(void) { wxString s; s.Printf(wxT("<b>%s</b>:%d<br>"), LNG("[CAP] TIN"), Get_Count()); return( s ); }
//--------------------------------------------------------- wxString CWKSP_PointCloud_Manager::Get_Description(void) { wxString s; s.Printf(wxT("<b>%s</b>:%d<br>"), _TL("PointCloud"), Get_Count()); return( s ); }
//--------------------------------------------------------- wxString CWKSP_Table_Manager::Get_Description(void) { wxString s; s.Printf(wxT("<b>%s</b>: %d<br>"), _TL("Tables"), Get_Count()); return( s ); }
//--------------------------------------------------------- void CWKSP_Tool_Library::Update(void) { int i; for(i=Get_Count()-1; i>=0; i--) // first remove tools that are not available anymore { CWKSP_Tool *pItem = Get_Tool(i); if( !m_pLibrary->Get_Tool(pItem->Get_Tool()->Get_Name()) ) { Del_Item(pItem); Get_Control()->Delete(pItem->GetId()); } } for(i=0; i<m_pLibrary->Get_Count(); i++) // then add tools that are not yet present in the list { CSG_Tool *pTool = m_pLibrary->Get_Tool(i); if( pTool != NULL && pTool != TLB_INTERFACE_SKIP_TOOL ) { for(int j=0; j<Get_Count() && pTool; j++) { if( pTool == Get_Tool(j)->Get_Tool() ) { Get_Control()->SetItemText(Get_Tool(j)->GetId(), Get_Tool(j)->Get_Name()); // just in case name has changed pTool = NULL; } } if( pTool ) { CWKSP_Tool *pItem = new CWKSP_Tool(pTool, m_pLibrary->Get_Menu().w_str()); Add_Item(pItem); g_pTool_Ctrl->Add_Tool(GetId(), pItem); } } } Get_Control()->SortChildren(GetId()); }
//--------------------------------------------------------- wxString CWKSP_Module_Manager::Get_Description(void) { wxString s; s.Printf(wxT("<b>%s: %d</b><br><br>%s %d<br>"), LNG("[CAP] Module Libraries") , Get_Count(), LNG("[CAP] Modules") , Get_Items_Count() ); return( s ); }
//--------------------------------------------------------- bool CWKSP_Base_Manager::Move_Bottom(CWKSP_Base_Item *pItem) { int Index, i; if( pItem && (Index = pItem->Get_Index()) < Get_Count() - 1 ) { for(i=Index; i<Get_Count()-1; i++) { m_Items[i] = m_Items[i + 1]; } m_Items[Get_Count() - 1] = pItem; Get_Control()->SortChildren(GetId()); return( true ); } return( false ); }
//--------------------------------------------------------- CWKSP_Grid * CWKSP_Grid_Manager::Get_Data(CSG_Grid *pObject) { CWKSP_Grid *pItem = NULL; for(int i=0; !pItem && i<Get_Count(); i++) { pItem = ((CWKSP_Grid_System *)Get_Item(i))->Get_Data(pObject); } return( pItem ); }
//--------------------------------------------------------- CWKSP_Module_Group * CWKSP_Module_Manager::Get_Group(const wxString &Group) { for(int i=0; i<Get_Count(); i++) { if( !Group.Cmp(Get_Group(i)->Get_Name()) ) { return( Get_Group(i) ); } } return( NULL ); }
//--------------------------------------------------------- bool CWKSP_Module_Manager::Exists(CWKSP_Module *pModule) { for(int i=0; i<Get_Count(); i++) { if( Get_Library(i)->Exists(pModule) ) { return( true ); } } return( false ); }
//--------------------------------------------------------- CWKSP_Tool * CWKSP_Tool_Library::Get_Tool_byID(int CMD_ID) { for(int i=0; i<Get_Count(); i++) { if( Get_Tool(i)->Get_Menu_ID() == CMD_ID ) { return( Get_Tool(i) ); } } return( NULL ); }
//--------------------------------------------------------- CWKSP_Tool * CWKSP_Tool_Library::Get_Tool(CWKSP_Tool *pTool) { for(int i=0; i<Get_Count(); i++) { if( pTool == Get_Tool(i) ) { return( pTool ); } } return( NULL ); }
//--------------------------------------------------------- void CWKSP_Tool_Library::_Del_Tools(void) { for(int i=Get_Count()-1; i>=0; i--) { CWKSP_Tool *pItem = Get_Tool(i); Del_Item(pItem); // Get_Control()->Delete(pItem->GetId()); // delete(pItem); } }
//--------------------------------------------------------- CWKSP_Grid_System * CWKSP_Grid_Manager::Get_System(const CSG_Grid_System &System) { for(int i=0; i<Get_Count(); i++) { if( System == ((CWKSP_Grid_System *)Get_Item(i))->Get_System() ) { return( (CWKSP_Grid_System *)Get_Item(i) ); } } return( NULL ); }
//--------------------------------------------------------- CWKSP_PointCloud * CWKSP_PointCloud_Manager::Get_Data(CSG_PointCloud *pObject) { for(int i=0; i<Get_Count(); i++) { if( pObject == Get_Data(i)->Get_Object() ) { return( Get_Data(i) ); } } return( NULL ); }
//--------------------------------------------------------- CWKSP_TIN * CWKSP_TIN_Manager::Get_TIN(CSG_TIN *pTIN) { for(int i=0; i<Get_Count(); i++) { if( pTIN == Get_TIN(i)->Get_TIN() ) { return( Get_TIN(i) ); } } return( NULL ); }
//--------------------------------------------------------- CSG_Module * CSG_Module_Library::Get_Module(const SG_Char *Name) { for(int i=0; i<Get_Count(); i++) { if( !SG_STR_CMP(Name, Get_Module(i)->Get_Name()) ) { return( Get_Module(i) ); } } return( NULL ); }
//--------------------------------------------------------- CWKSP_Shapes_Type * CWKSP_Shapes_Manager::Get_Shapes_Type(TSG_Shape_Type Type) { for(int i=0; i<Get_Count(); i++) { if( Type == ((CWKSP_Shapes_Type *)Get_Item(i))->Get_Shape_Type() ) { return( (CWKSP_Shapes_Type *)Get_Item(i) ); } } return( NULL ); }
//--------------------------------------------------------- CWKSP_Module_Library * CWKSP_Module_Group::Get_Library(CSG_Module_Library *pLibrary) { for(int i=0; i<Get_Count(); i++) { if( pLibrary == Get_Library(i)->Get_Library() ) { return( Get_Library(i) ); } } return( NULL ); }
//--------------------------------------------------------- CWKSP_Table * CWKSP_Table_Manager::Get_Data(CSG_Table *pObject) { for(int i=0; i<Get_Count(); i++) { if( pObject == Get_Data(i)->Get_Object() ) { return( Get_Data(i) ); } } return( NULL ); }