⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 view_table_diagram.cpp

📁 这是一个GPS相关的程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:

///////////////////////////////////////////////////////////
//                                                       //
//                         SAGA                          //
//                                                       //
//      System for Automated Geoscientific Analyses      //
//                                                       //
//                    User Interface                     //
//                                                       //
//                    Program: SAGA                      //
//                                                       //
//-------------------------------------------------------//
//                                                       //
//                VIEW_Table_Diagram.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/window.h>

#include "res_commands.h"
#include "res_controls.h"
#include "res_images.h"
#include "res_dialogs.h"

#include "helper.h"
#include "dc_helper.h"

#include "wksp_table.h"

#include "view_table_diagram.h"


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
IMPLEMENT_CLASS(CVIEW_Table_Diagram, CVIEW_Base);

//---------------------------------------------------------
BEGIN_EVENT_TABLE(CVIEW_Table_Diagram, CVIEW_Base)
	EVT_PAINT			(CVIEW_Table_Diagram::On_Paint)
	EVT_SIZE			(CVIEW_Table_Diagram::On_Size)

	EVT_MENU			(ID_CMD_DIAGRAM_PARAMETERS	, CVIEW_Table_Diagram::On_Parameters)
END_EVENT_TABLE()


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
CVIEW_Table_Diagram::CVIEW_Table_Diagram(CWKSP_Table *pTable)
	: CVIEW_Base(ID_VIEW_TABLE_DIAGRAM, wxString::Format(wxT("%s [%s]"), LNG("[CAP] Diagram"), pTable->Get_Name().c_str()), ID_IMG_WND_DIAGRAM, CVIEW_Table_Diagram::_Create_Menu(), LNG("[CAP] Diagram"))
{
	SYS_Set_Color_BG_Window(this);

	m_pOwner	= pTable;
	m_pTable	= pTable->Get_Table();

	m_nFields	= 0;
	m_Fields	= NULL;

	m_pFont		= NULL;

	_Initialize();
	_DLG_Parameters();
}

//---------------------------------------------------------
CVIEW_Table_Diagram::~CVIEW_Table_Diagram(void)
{
	m_pOwner->View_Closes(this);

	_Destroy_Fields();
}


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
wxMenu * CVIEW_Table_Diagram::_Create_Menu(void)
{
	wxMenu	*pMenu	= new wxMenu();

	CMD_Menu_Add_Item(pMenu, false, ID_CMD_DIAGRAM_PARAMETERS);

	return( pMenu );
}

//---------------------------------------------------------
wxToolBarBase * CVIEW_Table_Diagram::_Create_ToolBar(void)
{
	wxToolBarBase	*pToolBar	= CMD_ToolBar_Create(ID_TB_VIEW_TABLE_DIAGRAM);

	CMD_ToolBar_Add_Item(pToolBar, false, ID_CMD_DIAGRAM_PARAMETERS);

	CMD_ToolBar_Add(pToolBar, LNG("[CAP] Diagram"));

	return( pToolBar );
}


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
void CVIEW_Table_Diagram::On_Size(wxSizeEvent &WXUNUSED(event))
{
	Refresh();
}


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
void CVIEW_Table_Diagram::On_Paint(wxPaintEvent &event)
{
	wxRect		r(wxPoint(0, 0), GetClientSize());
	wxPaintDC	dc(this);

	Draw_Edge(dc, EDGE_STYLE_SUNKEN, r);

	Draw(dc, r);
}


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
bool CVIEW_Table_Diagram::Update_Diagram(void)
{
	if( m_Structure.is_Compatible(m_pTable, true) )
	{
		_Set_Fields();
	}
	else
	{
		_Initialize();
	}

	return( true );
}


///////////////////////////////////////////////////////////
//														 //
//														 //
//														 //
///////////////////////////////////////////////////////////

//---------------------------------------------------------
void CVIEW_Table_Diagram::_Destroy_Fields(void)
{
	if( m_nFields > 0 )
	{
		SG_Free(m_Fields);
		m_Fields	= NULL;
		m_nFields	= 0;
	}
}

//---------------------------------------------------------
bool CVIEW_Table_Diagram::_Set_Fields(void)
{
	_Destroy_Fields();

	if( m_pTable && m_pTable->Get_Field_Count() > 0 )
	{
		const wxChar	*sField;
		int			iField;

		iField		= m_Parameters("_DIAGRAM_XFIELD")->asInt();
		sField		= m_Parameters("_DIAGRAM_XFIELD")->asChoice()->Get_Item(iField);
		m_xField	= -1;

		for(iField=0; iField<m_pTable->Get_Field_Count(); iField++)
		{
			if( SG_STR_CMP(sField, m_pTable->Get_Field_Name(iField)) == 0 )
			{
				m_xMin	= m_pTable->Get_MinValue(iField);
				m_xMax	= m_pTable->Get_MaxValue(iField);

				if( m_xMin < m_xMax )
				{
					m_xField	= iField;
				}
				break;
			}
		}

		if( m_xField < 0 )
		{
			m_xMin	= 1;
			m_xMax	= 1 + m_pTable->Get_Record_Count();
		}

		//-------------------------------------------------
		for(iField=0; iField<m_pTable->Get_Field_Count(); iField++)
		{
			if(	m_pTable->Get_Field_Type(iField) != TABLE_FIELDTYPE_String
			&&	m_Parameters(wxString::Format(wxT("FIELD_%d"), iField))->asBool() )
			{
				m_Fields			= (int *)SG_Realloc(m_Fields, (m_nFields + 1) * sizeof(int));
				m_Fields[m_nFields]	= iField;

				m_Colors.Set_Color(iField, m_Parameters(wxString::Format(wxT("COLOR_%d"), iField))->asColor());

				m_nFields++;

				if( m_nFields == 1 )
				{
					m_zMin	= m_pTable->Get_MinValue(iField);
					m_zMax	= m_pTable->Get_MaxValue(iField);
				}
				else
				{
					if( m_zMin	> m_pTable->Get_MinValue(iField) )
						m_zMin	= m_pTable->Get_MinValue(iField);

					if( m_zMax	< m_pTable->Get_MaxValue(iField) )
						m_zMax	= m_pTable->Get_MaxValue(iField);
				}
			}
		}
	}

	Refresh();

	return( m_nFields > 0 );
}

//---------------------------------------------------------
void CVIEW_Table_Diagram::_Initialize(void)
{
	int			iField;
	CSG_String	sFields_All, sFields_Num;
	CSG_Parameter	*pNode, *pFields, *pColors;

	//-----------------------------------------------------
	_Destroy_Fields();

	if( m_pTable && m_pTable->Get_Field_Count() > 0 && m_pTable->Get_Record_Count() > 0 )
	{
		m_Structure.Create(m_pTable);

		m_Colors.Set_Count(m_pTable->Get_Field_Count());

		m_Parameters.Create(NULL, LNG("[CAP] Properties"), LNG(""));

		pFields	= m_Parameters.Add_Node(NULL, "NODE_FIELDS", LNG("[CAP] Attributes")	, LNG(""));
		pColors	= m_Parameters.Add_Node(NULL, "NODE_COLORS", LNG("[CAP] Colors")		, LNG(""));

		for(iField=0; iField<m_pTable->Get_Field_Count(); iField++)
		{
			if( m_pTable->Get_Field_Type(iField) != TABLE_FIELDTYPE_String )
			{
				m_Parameters.Add_Value(
					pFields, wxString::Format(wxT("FIELD_%d"), iField), m_pTable->Get_Field_Name(iField),
					LNG("[CAP] Show"),
					PARAMETER_TYPE_Bool, false
				);

				m_Parameters.Add_Value(
					pColors, wxString::Format(wxT("COLOR_%d"), iField), m_pTable->Get_Field_Name(iField),
					LNG("[CAP] Color"),
					PARAMETER_TYPE_Color, m_Colors.Get_Color(iField)
				);

				sFields_Num.Append(m_pTable->Get_Field_Name(iField));
				sFields_Num.Append(wxT("|"));
			}

			sFields_All.Append(m_pTable->Get_Field_Name(iField));
			sFields_All.Append(wxT("|"));
		}

		pNode	= m_Parameters.Add_Node(
			NULL, "GENERAL", LNG("[CAP] General"),
			LNG("")
		);

		m_Parameters.Add_Choice(
			pNode, "_DIAGRAM_TYPE"		, LNG("[CAP] Display Type"),
			LNG(""),
			wxString::Format(wxT("%s|%s|%s|%s|"),

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -