<commit_before>//
// EnviroGUI.cpp
// GUI-specific functionality of the Enviro class
//
// Copyright (c) 2003-2006 Virtual Terrain Project
// Free for all uses, see license.txt for details.
//

// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "vtlib/vtlib.h"
#include "vtlib/core/Terrain.h"
#include "vtdata/vtLog.h"
#include "vtui/Helper.h"
#include "vtui/InstanceDlg.h"
#include "vtui/ProfileDlg.h"

#include "EnviroGUI.h"
#include "EnviroApp.h"
#include "EnviroFrame.h"
#include "canvas.h"
#include "DistanceDlg3d.h"
#include "LayerDlg.h"
#include "StyleDlg.h"

#if WIN32 || !wxUSE_JOYSTICK
  #include "vtui/Joystick.h"
#else
  #include "wx/joystick.h"
#endif

DECLARE_APP(EnviroApp);

//
// This is a 'singleton', the only instance of the global application object
//
EnviroGUI g_App;

// helper
EnviroFrame *GetFrame()
{
	return dynamic_cast<EnviroFrame *>(wxGetApp().GetTopWindow());
}

EnviroGUI::EnviroGUI()
{
	m_pJFlyer = NULL;
}

EnviroGUI::~EnviroGUI()
{
}

void EnviroGUI::ShowPopupMenu(const IPoint2 &pos)
{
	GetFrame()->ShowPopupMenu(pos);
}

void EnviroGUI::SetTerrainToGUI(vtTerrain *pTerrain)
{
	GetFrame()->SetTerrainToGUI(pTerrain);

	if (pTerrain && m_pJFlyer)
	{
		float speed = pTerrain->GetParams().GetValueFloat(STR_NAVSPEED);
		m_pJFlyer->SetSpeed(speed);
	}
}

void EnviroGUI::SetFlightSpeed(float speed)
{
	if (m_pJFlyer)
		m_pJFlyer->SetSpeed(speed);
	Enviro::SetFlightSpeed(speed);
}

void EnviroGUI::SetState(AppState s)
{
	// if entering or leaving terrain or orbit state
	AppState previous = m_state;
	m_state = s;

	if ((previous == AS_Terrain && m_state != AS_Terrain) ||
		(previous == AS_Orbit && m_state != AS_Orbit) ||
		(previous != AS_Terrain && m_state == AS_Terrain) ||
		(previous != AS_Orbit && m_state == AS_Orbit))<commit_msg>added logging for app state changes<commit_after>//
// EnviroGUI.cpp
// GUI-specific functionality of the Enviro class
//
// Copyright (c) 2003-2007 Virtual Terrain Project
// Free for all uses, see license.txt for details.
//

// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "vtlib/vtlib.h"
#include "vtlib/core/Terrain.h"
#include "vtdata/vtLog.h"
#include "vtui/Helper.h"
#include "vtui/InstanceDlg.h"
#include "vtui/ProfileDlg.h"

#include "EnviroGUI.h"
#include "EnviroApp.h"
#include "EnviroFrame.h"
#include "canvas.h"
#include "DistanceDlg3d.h"
#include "LayerDlg.h"
#include "StyleDlg.h"

#if WIN32 || !wxUSE_JOYSTICK
  #include "vtui/Joystick.h"
#else
  #include "wx/joystick.h"
#endif

DECLARE_APP(EnviroApp);

//
// This is a 'singleton', the only instance of the global application object
//
EnviroGUI g_App;

// helper
EnviroFrame *GetFrame()
{
	return dynamic_cast<EnviroFrame *>(wxGetApp().GetTopWindow());
}

EnviroGUI::EnviroGUI()
{
	m_pJFlyer = NULL;
}

EnviroGUI::~EnviroGUI()
{
}

void EnviroGUI::ShowPopupMenu(const IPoint2 &pos)
{
	GetFrame()->ShowPopupMenu(pos);
}

void EnviroGUI::SetTerrainToGUI(vtTerrain *pTerrain)
{
	GetFrame()->SetTerrainToGUI(pTerrain);

	if (pTerrain && m_pJFlyer)
	{
		float speed = pTerrain->GetParams().GetValueFloat(STR_NAVSPEED);
		m_pJFlyer->SetSpeed(speed);
	}
}

void EnviroGUI::SetFlightSpeed(float speed)
{
	if (m_pJFlyer)
		m_pJFlyer->SetSpeed(speed);
	Enviro::SetFlightSpeed(speed);
}

const char *AppStateNames[] = 
{
	"AS_Initializing",
	"AS_Neutral",
	"AS_Orbit",
	"AS_MovingIn",
	"AS_Terrain",
	"AS_MovingOut",
	"AS_Error"
};

void EnviroGUI::SetState(AppState s)
{
	// if entering or leaving terrain or orbit state
	AppState previous = m_state;
	m_state = s;

	if (m_state != previous)
	{
		VTLOG("Changing app state from %s to %s\n", AppStateNames[previous],
			AppStateNames[m_state]);
	}

	if ((previous == AS_Terrain && m_state != AS_Terrain) ||
		(previous == AS_Orbit && m_state != AS_Orbit) ||
		(previous != AS_Terrain && m_state == AS_Terrain) ||
		(previous != AS_Orbit && m_state == AS_Orbit))
{'fraction_non_alphanumeric': 0.15165053363117398, 'fraction_numerical': 0.005956813104988831, 'mean_word_length': 4.9527326440177255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2745382', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1625, 'n_words': 330}