📄 saga_frame.cpp
字号:
///////////////////////////////////////////////////////////
// //
// SAGA //
// //
// System for Automated Geoscientific Analyses //
// //
// User Interface //
// //
// Program: SAGA //
// //
//-------------------------------------------------------//
// //
// SAGA_Frame.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/wx.h>
#include <wx/frame.h>
#include <wx/filename.h>
#include <wx/statusbr.h>
#include <wx/icon.h>
#include <wx/gauge.h>
#include <wx/choicdlg.h>
#include <wx/toolbar.h>
#include <wx/tipdlg.h>
#include <wx/aui/aui.h>
#include <saga_api/saga_api.h>
#include "callback.h"
#include "res_commands.h"
#include "res_controls.h"
#include "res_dialogs.h"
#include "res_images.h"
#include "helper.h"
#include "saga.h"
#include "saga_frame.h"
#include "saga_frame_droptarget.h"
#include "info.h"
#include "wksp.h"
#include "active.h"
#include "wksp_module_manager.h"
#include "wksp_module.h"
#include "wksp_module_menu.h"
#include "wksp_data_manager.h"
#include "wksp_data_menu_files.h"
#include "wksp_map_manager.h"
#include "view_map.h"
#include "view_map_3d.h"
#include "view_table.h"
#include "view_table_diagram.h"
#include "view_histogram.h"
#include "view_scatterplot.h"
#include "view_layout.h"
#include "dlg_about.h"
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
#ifdef _DEBUG
#define SAGA_CAPTION wxT("SAGA [Debug]")
#else
#define SAGA_CAPTION wxT("SAGA")
#endif
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
class CSAGA_Frame_StatusBar : public wxStatusBar
{
public:
CSAGA_Frame_StatusBar(wxWindow *parent, wxWindowID id, long style = wxST_SIZEGRIP, const wxString& name = wxT("statusBar"))
: wxStatusBar(parent, id, style, name)
{
m_pProgressBar = new wxGauge(this, ID_WND_PROGRESSBAR, 100);
}
void On_Size (wxSizeEvent &event)
{
wxRect r;
if( m_pProgressBar && GetFieldRect(STATUSBAR_PROGRESS, r) )
{
m_pProgressBar->SetSize(r);
}
event.Skip();
}
wxGauge *m_pProgressBar;
DECLARE_EVENT_TABLE()
};
//---------------------------------------------------------
BEGIN_EVENT_TABLE(CSAGA_Frame_StatusBar, wxStatusBar)
EVT_SIZE (CSAGA_Frame_StatusBar::On_Size)
END_EVENT_TABLE()
//---------------------------------------------------------
wxStatusBar * CSAGA_Frame::OnCreateStatusBar(int number, long style, wxWindowID id, const wxString& name)
{
CSAGA_Frame_StatusBar *sb = new CSAGA_Frame_StatusBar(this, id, style, name);
sb->SetFieldsCount(number);
return( sb );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CSAGA_Frame *g_pSAGA_Frame = NULL;
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
BEGIN_EVENT_TABLE(CSAGA_Frame, wxMDIParentFrame)
EVT_CLOSE (CSAGA_Frame::On_Close)
EVT_SIZE (CSAGA_Frame::On_Size)
EVT_MENU (ID_CMD_FRAME_QUIT , CSAGA_Frame::On_Quit)
EVT_MENU (ID_CMD_FRAME_HELP , CSAGA_Frame::On_Help)
EVT_MENU (ID_CMD_FRAME_ABOUT , CSAGA_Frame::On_About)
EVT_MENU (ID_CMD_FRAME_TIPS , CSAGA_Frame::On_Tips)
EVT_MENU (ID_CMD_FRAME_CASCADE , CSAGA_Frame::On_Frame_Cascade)
EVT_UPDATE_UI (ID_CMD_FRAME_CASCADE , CSAGA_Frame::On_Frame_Cascade_UI)
EVT_MENU (ID_CMD_FRAME_TILE_HORZ , CSAGA_Frame::On_Frame_hTile)
EVT_UPDATE_UI (ID_CMD_FRAME_TILE_HORZ , CSAGA_Frame::On_Frame_hTile_UI)
EVT_MENU (ID_CMD_FRAME_TILE_VERT , CSAGA_Frame::On_Frame_vTile)
EVT_UPDATE_UI (ID_CMD_FRAME_TILE_VERT , CSAGA_Frame::On_Frame_vTile_UI)
EVT_MENU (ID_CMD_FRAME_ARRANGEICONS , CSAGA_Frame::On_Frame_ArrangeIcons)
EVT_UPDATE_UI (ID_CMD_FRAME_ARRANGEICONS , CSAGA_Frame::On_Frame_ArrangeIcons_UI)
EVT_MENU (ID_CMD_FRAME_NEXT , CSAGA_Frame::On_Frame_Next)
EVT_UPDATE_UI (ID_CMD_FRAME_NEXT , CSAGA_Frame::On_Frame_Next_UI)
EVT_MENU (ID_CMD_FRAME_PREVIOUS , CSAGA_Frame::On_Frame_Previous)
EVT_UPDATE_UI (ID_CMD_FRAME_PREVIOUS , CSAGA_Frame::On_Frame_Previous_UI)
EVT_MENU (ID_CMD_FRAME_CLOSE , CSAGA_Frame::On_Frame_Close)
EVT_UPDATE_UI (ID_CMD_FRAME_CLOSE , CSAGA_Frame::On_Frame_Close_UI)
EVT_MENU (ID_CMD_FRAME_CLOSE_ALL , CSAGA_Frame::On_Frame_Close_All)
EVT_UPDATE_UI (ID_CMD_FRAME_CLOSE_ALL , CSAGA_Frame::On_Frame_Close_All_UI)
EVT_MENU (ID_CMD_FRAME_WKSP_SHOW , CSAGA_Frame::On_WKSP_Show)
EVT_UPDATE_UI (ID_CMD_FRAME_WKSP_SHOW , CSAGA_Frame::On_WKSP_Show_UI)
EVT_MENU (ID_CMD_FRAME_ACTIVE_SHOW , CSAGA_Frame::On_Active_Show)
EVT_UPDATE_UI (ID_CMD_FRAME_ACTIVE_SHOW , CSAGA_Frame::On_Active_Show_UI)
EVT_MENU (ID_CMD_FRAME_INFO_SHOW , CSAGA_Frame::On_INFO_Show)
EVT_UPDATE_UI (ID_CMD_FRAME_INFO_SHOW , CSAGA_Frame::On_INFO_Show_UI)
EVT_MENU_RANGE (ID_CMD_WKSP_FIRST , ID_CMD_WKSP_LAST , CSAGA_Frame::On_Command_Workspace)
EVT_UPDATE_UI_RANGE (ID_CMD_WKSP_FIRST , ID_CMD_WKSP_LAST , CSAGA_Frame::On_Command_Workspace_UI)
EVT_MENU_RANGE (ID_CMD_MODULE_FIRST , ID_CMD_MODULE_LAST , CSAGA_Frame::On_Command_Module)
EVT_UPDATE_UI_RANGE (ID_CMD_MODULE_FIRST , ID_CMD_MODULE_LAST , CSAGA_Frame::On_Command_Module_UI)
EVT_MENU_RANGE (ID_CMD_CHILD_FIRST , ID_CMD_CHILD_LAST , CSAGA_Frame::On_Command_Child)
EVT_UPDATE_UI_RANGE (ID_CMD_MAP_FIRST , ID_CMD_MAP_LAST , CSAGA_Frame::On_Command_Child_UI)
EVT_UPDATE_UI_RANGE (ID_CMD_HISTOGRAM_FIRST , ID_CMD_HISTOGRAM_LAST , CSAGA_Frame::On_Command_Child_UI)
END_EVENT_TABLE()
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CSAGA_Frame::CSAGA_Frame(void)
: wxMDIParentFrame(NULL, ID_WND_MAIN, SAGA_CAPTION, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE|wxHSCROLL|wxVSCROLL|wxFRAME_NO_WINDOW_MENU)
{
//-----------------------------------------------------
g_pSAGA_Frame = this;
m_nTopWindows = 0;
m_pTopWindows = NULL;
m_pINFO = NULL;
m_pActive = NULL;
m_pWKSP = NULL;
SG_Set_UI_Callback (Get_Callback());
SetIcon (IMG_Get_Icon(ID_IMG_SAGA_ICON_32));
SetDropTarget (new CSAGA_Frame_DropTarget);
//-----------------------------------------------------
int STATUSBAR_Sizes[STATUSBAR_COUNT] = { -1, -1, 90, 90, 90, -1 };
CreateStatusBar (STATUSBAR_COUNT);
SetStatusWidths (STATUSBAR_COUNT, STATUSBAR_Sizes);
SetStatusBarPane (STATUSBAR_DEFAULT);
StatusBar_Set_Text (LNG("[VAL] ready"));
m_pProgressBar = ((CSAGA_Frame_StatusBar *)GetStatusBar())->m_pProgressBar;
//-----------------------------------------------------
m_pLayout = new wxAuiManager(this);
m_pLayout->GetArtProvider()->SetColor (wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)
);
m_pLayout->GetArtProvider()->SetColor (wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR,
wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)
);
m_pLayout->GetArtProvider()->SetMetric (wxAUI_DOCKART_GRADIENT_TYPE , wxAUI_GRADIENT_NONE);
m_pLayout->GetArtProvider()->SetMetric (wxAUI_DOCKART_CAPTION_SIZE , 14);
m_pLayout->SetFlags(m_pLayout->GetFlags() ^ wxAUI_MGR_TRANSPARENT_DRAG);
// m_pLayout->SetFlags(m_pLayout->GetFlags() ^ wxAUI_MGR_ALLOW_ACTIVE_PANE);
//-----------------------------------------------------
_Bar_Add(m_pINFO = new CINFO (this), 0);
_Bar_Add(m_pActive = new CACTIVE(this), 1);
_Bar_Add(m_pWKSP = new CWKSP (this), 2);
m_pINFO ->Add_Pages();
m_pActive ->Add_Pages();
m_pWKSP ->Add_Pages();
//-----------------------------------------------------
SetMenuBar(MB_Create(NULL));
//-----------------------------------------------------
m_pTB_Main = _Create_ToolBar();
m_pTB_Map = CVIEW_Map ::_Create_ToolBar();
m_pTB_Map_3D = CVIEW_Map_3D ::_Create_ToolBar();
m_pTB_Layout = CVIEW_Layout ::_Create_ToolBar();
m_pTB_Table = CVIEW_Table ::_Create_ToolBar();
m_pTB_Diagram = CVIEW_Table_Diagram ::_Create_ToolBar();
m_pTB_Histogram = CVIEW_Histogram ::_Create_ToolBar();
m_pTB_ScatterPlot = CVIEW_ScatterPlot ::_Create_ToolBar();
//-----------------------------------------------------
m_pLayout->GetPane(GetClientWindow()).Show().Center();
wxString s;
if( CONFIG_Read(wxT("/FL"), wxT("MANAGER"), s) )
{
m_pLayout->LoadPerspective(s);
}
else
{
s = wxT("layout2|")
wxT("name=mdiclient;caption=;state=256;dir=5;layer=0;row=0;pos=0;prop=100000;bestw=0;besth=0;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("name=Messages;caption=Messages;state=16779260;dir=3;layer=0;row=0;pos=0;prop=100000;bestw=200;besth=100;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=400;floath=200|")
wxT("name=Object Properties;caption=Object Properties;state=16779260;dir=2;layer=1;row=0;pos=0;prop=100000;bestw=200;besth=100;minw=100;minh=100;maxw=-1;maxh=-1;floatx=917;floaty=69;floatw=200;floath=400|")
wxT("name=Workspace;caption=Workspace;state=16779260;dir=4;layer=0;row=0;pos=0;prop=100000;bestw=200;besth=100;minw=100;minh=100;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=200;floath=400|")
wxT("name=Standard;caption=Standard;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=131;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("name=Map;caption=Map;state=16788210;dir=1;layer=10;row=0;pos=142;prop=100000;bestw=269;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("name=3D-View;caption=3D-View;state=16788210;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=423;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("name=Map-Layout;caption=Map-Layout;state=16788210;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=69;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("name=Table;caption=Table;state=16788210;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=146;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("name=Diagram;caption=Diagram;state=16788210;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=23;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("name=Histogram;caption=Histogram;state=16788210;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=46;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("name=Scatterplot;caption=Scatterplot;state=16788210;dir=1;layer=10;row=0;pos=0;prop=100000;bes")
wxT("tw=46;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
wxT("dock_size(5,0,0)=10|dock_size(3,0,0)=116|dock_size(4,0,0)=195|dock_size(1,10,0)=10|dock_size(2,1,0)=245|");
m_pLayout->LoadPerspective(s);
}
_Bar_Show(m_pTB_Main, true);
m_pLayout->Update();
Show(true);
//-----------------------------------------------------
int x, y, dx, dy;
long l;
x = CONFIG_Read(wxT("/FL"), wxT("X" ), l) ? l : -1;
y = CONFIG_Read(wxT("/FL"), wxT("Y" ), l) ? l : -1;
dx = CONFIG_Read(wxT("/FL"), wxT("DX"), l) ? l : 800;
dy = CONFIG_Read(wxT("/FL"), wxT("DY"), l) ? l : 600;
SetSize(x, y, dx, dy);
if( !(CONFIG_Read(wxT("/FL"), wxT("STATE"), l) && l == 0) )
{
Maximize();
}
Update();
//-----------------------------------------------------
if( g_pSAGA->argc <= 1 && g_pData->Initialise() )
{
Refresh(false);
}
}
//---------------------------------------------------------
CSAGA_Frame::~CSAGA_Frame(void)
{
//-----------------------------------------------------
if( IsIconized() )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -