📄 helper.cpp
字号:
///////////////////////////////////////////////////////////
// //
// SAGA //
// //
// System for Automated Geoscientific Analyses //
// //
// User Interface //
// //
// Program: SAGA //
// //
//-------------------------------------------------------//
// //
// Helper.cpp //
// //
// Copyright (C) 2005 by Olaf Conrad //
// //
//-------------------------------------------------------//
// //
// This file is part of 'SAGA - System for Automated //
// Geoscientific Analyses'. SAGA is free software; you //
// can redistribute it and/or modify it under the terms //
// of the GNU General Public License as published by the //
// Free Software Foundation; version 2 of the License. //
// //
// SAGA is distributed in the hope that it will be //
// useful, but WITHOUT ANY WARRANTY; without even the //
// implied warranty of MERCHANTABILITY or FITNESS FOR A //
// PARTICULAR PURPOSE. See the GNU General Public //
// License for more details. //
// //
// You should have received a copy of the GNU General //
// Public License along with this program; if not, //
// write to the Free Software Foundation, Inc., //
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
// USA. //
// //
//-------------------------------------------------------//
// //
// contact: Olaf Conrad //
// Institute of Geography //
// University of Goettingen //
// Goldschmidtstr. 5 //
// 37077 Goettingen //
// Germany //
// //
// e-mail: oconrad@saga-gis.org //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
#include <wx/config.h>
#include <wx/cursor.h>
#include <wx/utils.h>
#include <wx/mimetype.h>
#include <saga_api/saga_api.h>
#include "helper.h"
#include "saga.h"
#include "saga_frame.h"
#include "info.h"
#include "info_messages.h"
#include "wksp_module.h"
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
wxString Get_SignificantDecimals_String(double Value, int maxDecimals)
{
wxString s;
s.Printf(wxT("%.*f"), SG_Get_Significant_Decimals(Value, maxDecimals), Value);
return( s );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
double Degree_To_Decimal(double Deg, double Min, double Sec)
{
return( Deg > 0.0
? (Deg + Min / 60.0 + Sec / (60.0 * 60.0))
: (Deg - Min / 60.0 - Sec / (60.0 * 60.0))
);
}
//---------------------------------------------------------
void Decimal_To_Degree(double Value, double &Deg, double &Min, double &Sec)
{
Value = fmod(Value, 360.0);
Deg = (int)Value;
Value = 60.0 * (Value - Deg);
Min = (int)Value;
Value = 60.0 * (Value - Min);
Sec = Value;
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
wxString Get_FilePath_Relative(const wxChar *Directory, const wxChar *FileName)
{
int i, n;
if( Directory && FileName && (n = SG_STR_LEN(Directory)) < (int)SG_STR_LEN(FileName) )
{
for(i=0; i<n; i++)
{
if( Directory[i] != FileName[i] )
{
return( FileName );
}
}
return( FileName + n );
}
return( FileName );
}
//---------------------------------------------------------
wxString Get_FilePath_Absolute(const wxChar *Directory, const wxChar *FileName)
{
if( wxIsAbsolutePath(FileName) )
{
return( FileName );
}
return( wxString::Format(wxT("%s%s"), Directory, FileName) );
// return( SG_File_Make_Path(Directory, FileName, NULL).c_str() );
}
//---------------------------------------------------------
wxString Get_TableInfo_asHTML(CSG_Table *pTable)
{
wxString s;
if( pTable && pTable->is_Valid() )
{
s.Append(wxString::Format(wxT("<table border=\"1\"><tr><th>%s</th><th>%s</th><th>%s</th>"),
LNG("[CAP] Field"), LNG("[CAP] Name"), LNG("[CAP] Type")
));
for(int i=0; i<pTable->Get_Field_Count(); i++)
{
s.Append(wxString::Format(wxT("<tr><td>%d</td><td>%s</td><td>%s</td></tr>"),
i + 1, pTable->Get_Field_Name(i), gSG_Table_Field_Type_Names[pTable->Get_Field_Type(i)]
));
}
s.Append(wxT("</table>"));
}
return( s );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
wxColour Get_Color_asWX(int Color)
{
return( wxColour(SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color)) );
}
//---------------------------------------------------------
int Get_Color_asInt(wxColour Color)
{
return( SG_GET_RGB(Color.Red(), Color.Green(), Color.Blue()) );
}
//---------------------------------------------------------
wxColour SYS_Get_Color(wxSystemColour index)
{
return( wxSystemSettings::GetColour(index) );
}
//---------------------------------------------------------
void SYS_Set_Color_BG(wxWindow *pWindow, wxSystemColour index)
{
if( pWindow )
{
pWindow->SetBackgroundColour(SYS_Get_Color(index));
}
}
//---------------------------------------------------------
void SYS_Set_Color_BG_Window(wxWindow *pWindow)
{
if( pWindow )
{
#if defined(__WXMSW__)
pWindow->SetBackgroundColour(SYS_Get_Color(wxSYS_COLOUR_WINDOW));
#else
pWindow->SetBackgroundColour(*wxWHITE);
#endif
}
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
wxWindow * MDI_Get_Frame(void)
{
return( g_pSAGA_Frame );
}
//---------------------------------------------------------
wxPoint MDI_Get_Def_Position(void)
{
static int n = 0;
int Height = wxSystemSettings::GetMetric(wxSYS_CAPTION_Y);
wxPoint p(n * Height, n * Height);
n = n < 10 ? n + 1 : 0;
return( p );
}
//---------------------------------------------------------
wxSize MDI_Get_Def_Size(void)
{
return( wxSize(400, 300) );
}
//---------------------------------------------------------
void MDI_Top_Window_Push(wxWindow *pWindow)
{
if( g_pSAGA_Frame )
{
g_pSAGA_Frame->Top_Window_Push(pWindow);
}
}
//---------------------------------------------------------
void MDI_Top_Window_Pop(wxWindow *pWindow)
{
if( g_pSAGA_Frame )
{
g_pSAGA_Frame->Top_Window_Pop(pWindow);
}
}
//---------------------------------------------------------
wxWindow * MDI_Get_Top_Window(void)
{
return( g_pSAGA_Frame ? g_pSAGA_Frame->Top_Window_Get() : NULL );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
void Set_Buisy_Cursor(bool bOn)
{
if( g_pSAGA_Frame )
{
g_pSAGA_Frame->SetCursor(bOn ? *wxHOURGLASS_CURSOR : *wxSTANDARD_CURSOR);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -