power grid debug panel

This commit is contained in:
tmj-fstate
2019-06-06 16:01:41 +02:00
parent b1d9c9db46
commit 4ca55d7b2b
6 changed files with 54 additions and 1 deletions

View File

@@ -528,7 +528,7 @@ glm::vec3
TTraction::wire_color() const {
glm::vec3 color;
if( false == DebugModeFlag ) {
if( false == DebugTractionFlag ) {
switch( Material ) { // Ra: kolory podzieliłem przez 2, bo po zmianie ambient za jasne były
// trzeba uwzględnić kierunek świecenia Słońca - tylko ze Słońcem widać kolor
case 1: {

View File

@@ -15,6 +15,8 @@ http://mozilla.org/MPL/2.0/.
class TTractionPowerSource : public scene::basic_node {
friend class debug_panel;
public:
// constructor
TTractionPowerSource( scene::node_data const &Nodedata );

View File

@@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/.
#include "simulationtime.h"
#include "Timer.h"
#include "Event.h"
#include "TractionPower.h"
#include "Camera.h"
#include "mtable.h"
#include "Train.h"
@@ -476,6 +477,7 @@ debug_panel::update() {
m_scantablelines.clear();
m_scenariolines.clear();
m_eventqueuelines.clear();
m_powergridlines.clear();
m_cameralines.clear();
m_rendererlines.clear();
@@ -485,6 +487,7 @@ debug_panel::update() {
update_section_scantable( m_scantablelines );
update_section_scenario( m_scenariolines );
update_section_eventqueue( m_eventqueuelines );
update_section_powergrid( m_powergridlines );
update_section_camera( m_cameralines );
update_section_renderer( m_rendererlines );
}
@@ -526,6 +529,10 @@ debug_panel::render() {
// event queue filter
ImGui::Checkbox( "By This Vehicle Only", &m_eventqueueactivevehicleonly );
}
if( true == render_section( "Power Grid", m_powergridlines ) ) {
// traction state debug
ImGui::Checkbox( "Debug Traction", &DebugTractionFlag );
}
render_section( "Camera", m_cameralines );
render_section( "Gfx Renderer", m_rendererlines );
// toggles
@@ -984,6 +991,46 @@ debug_panel::update_section_eventqueue( std::vector<text_line> &Output ) {
}
}
void
debug_panel::update_section_powergrid( std::vector<text_line> &Output ) {
auto const lowpowercolor { glm::vec4( 164.0f / 255.0f, 132.0f / 255.0f, 84.0f / 255.0f, 1.f ) };
auto const nopowercolor { glm::vec4( 164.0f / 255.0f, 84.0f / 255.0f, 84.0f / 255.0f, 1.f ) };
Output.emplace_back( "Name: Output: Timeout:", Global.UITextColor );
std::string textline;
for( auto const *powerstation : simulation::Powergrid.sequence() ) {
if( true == powerstation->bSection ) { continue; }
auto const name { (
powerstation->m_name.empty() ?
"(unnamed)" :
powerstation->m_name )
+ " " };
textline =
name.substr( 0, 20 )
+ " " + to_string( powerstation->OutputVoltage, 0, 5 )
+ " " + to_string( powerstation->FuseTimer, 1, 12 )
+ ( powerstation->FuseCounter == 0 ?
"" :
" (x" + to_string( powerstation->FuseCounter ) + ")" );
Output.emplace_back(
textline,
( ( powerstation->FastFuse || powerstation->SlowFuse ) ? nopowercolor :
powerstation->OutputVoltage < ( 0.8 * powerstation->NominalVoltage ) ? lowpowercolor :
Global.UITextColor ) );
}
if( Output.size() == 1 ) {
Output.front().data = "(no power stations)";
}
}
void
debug_panel::update_section_camera( std::vector<text_line> &Output ) {

View File

@@ -87,6 +87,7 @@ private:
void update_section_scantable( std::vector<text_line> &Output );
void update_section_scenario( std::vector<text_line> &Output );
void update_section_eventqueue( std::vector<text_line> &Output );
void update_section_powergrid( std::vector<text_line> &Output );
void update_section_camera( std::vector<text_line> &Output );
void update_section_renderer( std::vector<text_line> &Output );
// section update helpers
@@ -105,6 +106,7 @@ private:
m_cameralines,
m_scenariolines,
m_eventqueuelines,
m_powergridlines,
m_rendererlines;
int tprev { 0 }; // poprzedni czas
double VelPrev { 0.0 }; // poprzednia prędkość

View File

@@ -31,6 +31,7 @@ bool DebugModeFlag = false;
bool FreeFlyModeFlag = false;
bool EditorModeFlag = false;
bool DebugCameraFlag = false;
bool DebugTractionFlag = false;
double Max0R(double x1, double x2)
{

View File

@@ -38,6 +38,7 @@ extern bool DebugModeFlag;
extern bool FreeFlyModeFlag;
extern bool EditorModeFlag;
extern bool DebugCameraFlag;
extern bool DebugTractionFlag;
/*funkcje matematyczne*/
double Max0R(double x1, double x2);