📄 wksp_layer.cpp
字号:
///////////////////////////////////////////////////////////
// //
// SAGA //
// //
// System for Automated Geoscientific Analyses //
// //
// User Interface //
// //
// Program: SAGA //
// //
//-------------------------------------------------------//
// //
// WKSP_Layer.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 "res_commands.h"
#include "res_dialogs.h"
#include "helper.h"
#include "active.h"
#include "active_parameters.h"
#include "wksp_base_control.h"
#include "wksp_data_manager.h"
#include "wksp_map_manager.h"
#include "wksp_map.h"
#include "wksp_map_layer.h"
#include "wksp_data_layers.h"
#include "wksp_layer.h"
#include "wksp_layer_classify.h"
#include "wksp_layer_legend.h"
#include "view_histogram.h"
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CWKSP_Layer * Get_Active_Layer(void)
{
return( g_pACTIVE ? g_pACTIVE->Get_Layer() : NULL );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
CWKSP_Layer::CWKSP_Layer(CSG_Data_Object *pObject)
{
m_pObject = pObject;
m_pClassify = new CWKSP_Layer_Classify;
m_pLegend = new CWKSP_Layer_Legend(this);
m_pHistogram = NULL;
}
//---------------------------------------------------------
CWKSP_Layer::~CWKSP_Layer(void)
{
Histogram_Show(false);
if( g_pMaps )
{
g_pMaps->Del(this);
}
if( m_pClassify )
{
delete(m_pClassify);
}
if( m_pLegend )
{
delete(m_pLegend);
}
//-----------------------------------------------------
if( g_pData->Exists(m_pObject) )
{
if( m_pObject->is_Valid() == true )
{
MSG_General_Add(
wxString::Format(wxT("%s %s: %s..."),
LNG("[MSG] Close"),
SG_Get_DataObject_Name(m_pObject->Get_ObjectType()),
m_pObject->Get_Name()
),
true, true
);
delete(m_pObject);
MSG_General_Add(LNG("[MSG] okay"), false);
}
else
{
delete(m_pObject);
}
}
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
bool CWKSP_Layer::On_Command(int Cmd_ID)
{
switch( Cmd_ID )
{
default:
return( CWKSP_Base_Item::On_Command(Cmd_ID) );
case ID_CMD_SHAPES_SAVE:
case ID_CMD_GRIDS_SAVE:
case ID_CMD_TIN_SAVE:
Save(m_pObject->Get_File_Name());
break;
case ID_CMD_SHAPES_SAVEAS:
case ID_CMD_GRIDS_SAVEAS:
case ID_CMD_TIN_SAVEAS:
Save();
break;
case ID_CMD_WKSP_ITEM_RETURN:
case ID_CMD_SHAPES_SHOW:
case ID_CMD_GRIDS_SHOW:
case ID_CMD_TIN_SHOW:
g_pMaps->Add(this);
break;
}
return( true );
}
//---------------------------------------------------------
bool CWKSP_Layer::On_Command_UI(wxUpdateUIEvent &event)
{
switch( event.GetId() )
{
default:
return( CWKSP_Base_Item::On_Command_UI(event) );
case ID_CMD_TIN_SAVE:
case ID_CMD_GRIDS_SAVE:
case ID_CMD_SHAPES_SAVE:
event.Enable(m_pObject->is_Modified() && m_pObject->Get_File_Name() && *(m_pObject->Get_File_Name()));
break;
}
return( true );
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
void CWKSP_Layer::Create_Parameters(void)
{
m_Parameters.Create(this, LNG(""), LNG(""));
m_Parameters.Set_Callback_On_Parameter_Changed(&_On_Parameter_Changed);
//-----------------------------------------------------
m_Parameters.Add_Node(
NULL , "NODE_GENERAL" , LNG("[CAP] General"),
LNG("")
);
m_Parameters.Add_String(
m_Parameters("NODE_GENERAL") , "OBJECT_NAME" , LNG("[CAP] Name"),
LNG(""),
m_pObject->Get_Name()
);
m_Parameters.Add_Value(
m_Parameters("NODE_GENERAL") , "SHOW_LEGEND" , LNG("[CAP] Show Legend"),
LNG(""),
PARAMETER_TYPE_Bool, true
);
//-----------------------------------------------------
m_Parameters.Add_Node(
NULL , "NODE_DISPLAY" , LNG("[CAP] Display"),
LNG("")
);
//-----------------------------------------------------
// Visibility...
m_Parameters.Add_Node(
NULL , "NODE_VISIBILITY" , LNG("[CAP] Display: Visibility"),
LNG("")
);
m_Parameters.Add_Value(
m_Parameters("NODE_VISIBILITY") , "SHOW_ALWAYS" , LNG("[CAP] Show Always"),
LNG(""),
PARAMETER_TYPE_Bool, true
);
m_Parameters.Add_Range(
m_Parameters("NODE_VISIBILITY") , "SHOW_RANGE" , LNG("[CAP] Scale Dependent"),
LNG(""),
0.0, 1000.0, 0.0, true
);
//-----------------------------------------------------
// Classification...
m_Parameters.Add_Node(
NULL , "NODE_COLORS" , LNG("[CAP] Display: Color Classification"),
LNG("")
);
m_Parameters.Add_Choice(
m_Parameters("NODE_COLORS") , "COLORS_TYPE" , LNG("[CAP] Type"),
LNG(""),
wxString::Format(wxT("%s|%s|%s|"),
LNG("[VAL] Unique Symbol"),
LNG("[VAL] Lookup Table"),
LNG("[VAL] Graduated Color")
), 0
);
//-----------------------------------------------------
// Classification: Unique Value...
m_Parameters.Add_Node(
m_Parameters("NODE_COLORS") , "NODE_UNISYMBOL" , LNG("[CAP] Unique Symbol"),
LNG("")
);
m_Parameters.Add_Value(
m_Parameters("NODE_UNISYMBOL") , "UNISYMBOL_COLOR" , LNG("[CAP] Color"),
LNG(""),
PARAMETER_TYPE_Color, SG_GET_RGB(0, 255, 0)
);
//-----------------------------------------------------
// Classification: Lookup Table...
m_Parameters.Add_Node(
m_Parameters("NODE_COLORS") , "NODE_LUT" , LNG("[CAP] Lookup Table"),
LNG("")
);
CSG_Table LUT;
LUT.Add_Field(LNG("COLOR") , TABLE_FIELDTYPE_Color);
LUT.Add_Field(LNG("NAME") , TABLE_FIELDTYPE_String);
LUT.Add_Field(LNG("DESCRIPTION") , TABLE_FIELDTYPE_String);
LUT.Add_Field(LNG("MINIMUM") , TABLE_FIELDTYPE_Double);
LUT.Add_Field(LNG("MAXIMUM") , TABLE_FIELDTYPE_Double);
m_Parameters.Add_FixedTable(
m_Parameters("NODE_LUT") , "LUT" , LNG("[CAP] Table"),
LNG(""),
&LUT
);
//-----------------------------------------------------
// Classification: Metric...
m_Parameters.Add_Node(
m_Parameters("NODE_COLORS") , "NODE_METRIC" , LNG("[CAP] Graduated Color"),
LNG("")
);
m_Parameters.Add_Colors(
m_Parameters("NODE_METRIC") , "METRIC_COLORS" , LNG("[CAP] Colors"),
LNG("")
);
m_Parameters.Add_Range(
m_Parameters("NODE_METRIC") , "METRIC_ZRANGE" , LNG("[CAP] Value Range"),
LNG("")
);
m_Parameters.Add_Choice(
m_Parameters("NODE_METRIC") , "METRIC_SCALE_MODE" , LNG("[CAP] Mode"),
LNG(""),
wxString::Format(wxT("%s|%s|%s|"),
LNG("[VAL] Linear"),
LNG("[VAL] Logarithmic (up)"),
LNG("[VAL] Logarithmic (down)")
), 0
);
m_Parameters.Add_Value(
m_Parameters("NODE_METRIC") , "METRIC_SCALE_LOG" , LNG("[CAP] Logarithmic Stretch Factor"),
LNG(""),
PARAMETER_TYPE_Double, 1.0
);
//-----------------------------------------------------
m_pClassify->Initialise(this, m_Parameters("LUT")->asTable(), m_Parameters("METRIC_COLORS")->asColors());
On_Create_Parameters();
DataObject_Changed();
}
///////////////////////////////////////////////////////////
// //
// //
// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
bool CWKSP_Layer::Save(void)
{
bool bResult;
wxString File_Path;
switch( Get_Type() )
{
default:
bResult = false;
break;
case WKSP_ITEM_TIN:
case WKSP_ITEM_Shapes:
bResult = DLG_Save(File_Path, ID_DLG_SHAPES_SAVE);
break;
case WKSP_ITEM_Grid:
bResult = DLG_Save(File_Path, ID_DLG_GRIDS_SAVE);
break;
}
if( bResult )
{
bResult = m_pObject->Save(File_Path);
PROCESS_Set_Okay();
}
return( bResult );
}
//---------------------------------------------------------
bool CWKSP_Layer::Save(const wxChar *File_Path)
{
bool bResult;
if( File_Path && *File_Path )
{
bResult = m_pObject->Save(File_Path);
PROCESS_Set_Okay();
return( bResult );
}
return( Save() );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -