diff --git a/.gitignore b/.gitignore index d995046f..73131621 100644 --- a/.gitignore +++ b/.gitignore @@ -74,4 +74,6 @@ builds/build_* builds/*.zip builds/deps_* +doc/ + CMakeLists.txt.user diff --git a/AirCoupler.cpp b/AirCoupler.cpp index 5c6c0b09..32f814fd 100644 --- a/AirCoupler.cpp +++ b/AirCoupler.cpp @@ -10,69 +10,77 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "AirCoupler.h" -TAirCoupler::TAirCoupler() +AirCoupler::AirCoupler() { Clear(); } -TAirCoupler::~TAirCoupler() +AirCoupler::~AirCoupler() { } -int TAirCoupler::GetStatus() -{ // zwraca 1, jeśli istnieje model prosty, 2 gdy skośny - int x = 0; - if (pModelOn) - x = 1; - if (pModelxOn) - x = 2; - return x; +/** + * \return 1 when \(straight\) TModel3d \c ModelOn exists + * \return 2 when \(slanted\) TModel3d \c ModelxOn exists + * \return 0 when neither of them exist + */ +int AirCoupler::GetStatus() +{ + if (ModelOn) return 1; + if (ModelxOn) return 2; + return 0; } -void TAirCoupler::Clear() -{ // zerowanie wskaźników - pModelOn = NULL; - pModelOff = NULL; - pModelxOn = NULL; - bOn = false; - bxOn = false; +/** + * Reset pointers and variables. + */ +void AirCoupler::Clear() +{ + ModelOn = NULL; + ModelOff = NULL; + ModelxOn = NULL; + On = false; + xOn = false; } -void TAirCoupler::Init(std::string const &asName, TModel3d *pModel) -{ // wyszukanie submodeli - if (!pModel) - return; // nie ma w czym szukać - pModelOn = pModel->GetFromName( asName + "_on" ); // połączony na wprost - pModelOff = pModel->GetFromName( asName + "_off" ); // odwieszony - pModelxOn = pModel->GetFromName( asName + "_xon" ); // połączony na skos +/** + * Looks for submodels in the model and updates pointers. + */ +void AirCoupler::Init(std::string const &asName, TModel3d *Model) +{ + if (!Model) + return; + ModelOn = Model->GetFromName(asName + "_on"); // Straight connect. + ModelOff = Model->GetFromName(asName + "_off"); // Not connected. Hung up. + ModelxOn = Model->GetFromName(asName + "_xon"); // Slanted connect. } - -void TAirCoupler::Load(cParser *Parser, TModel3d *pModel) +/** + * Gets name of submodel \(from cParser \b *Parser\), + * looks for it in the TModel3d \b *Model and update pointers. + * If submodel is not found, reset pointers. +*/ +void AirCoupler::Load(cParser *Parser, TModel3d *Model) { std::string name = Parser->getToken(); - if( pModel ) { - - Init( name, pModel ); + if(Model) + { + Init(name, Model); } else { - pModelOn = NULL; - pModelxOn = NULL; - pModelOff = NULL; + ModelOn = NULL; + ModelxOn = NULL; + ModelOff = NULL; } } -void TAirCoupler::Update() +// Update submodels visibility. +void AirCoupler::Update() { - // if ((pModelOn!=NULL) && (pModelOn!=NULL)) - { - if (pModelOn) - pModelOn->iVisible = bOn; - if (pModelOff) - pModelOff->iVisible = !(bOn || bxOn); - if (pModelxOn) - pModelxOn->iVisible = bxOn; - } + if (ModelOn) + ModelOn->iVisible = On; + if (ModelOff) + ModelOff->iVisible = !(On || xOn); + if (ModelxOn) + ModelxOn->iVisible = xOn; } - -//--------------------------------------------------------------------------- diff --git a/AirCoupler.h b/AirCoupler.h index 8cdebaea..fbb2bd1c 100644 --- a/AirCoupler.h +++ b/AirCoupler.h @@ -12,42 +12,40 @@ http://mozilla.org/MPL/2.0/. #include "Model3d.h" #include "parser.h" -class TAirCoupler +class AirCoupler { - private: - // TButtonType eType; - TSubModel *pModelOn, *pModelOff, *pModelxOn; - bool bOn; - bool bxOn; +private: + TSubModel *ModelOn, *ModelOff, *ModelxOn; + bool On; + bool xOn; void Update(); - public: - TAirCoupler(); - ~TAirCoupler(); +public: + AirCoupler(); + ~AirCoupler(); + ///Reset members. void Clear(); - inline void TurnOn() - { - bOn = true; - bxOn = false; - Update(); - }; - inline void TurnOff() - { - bOn = false; - bxOn = false; - Update(); - }; - inline void TurnxOn() - { - bOn = false; - bxOn = true; - Update(); - }; - // inline bool Active() { if ((pModelOn)||(pModelOff)) return true; return false;}; + ///Looks for submodels. + void Init(std::string const &asName, TModel3d *Model); + ///Loads info about coupler. + void Load(cParser *Parser, TModel3d *Model); int GetStatus(); - void Init(std::string const &asName, TModel3d *pModel); - void Load(cParser *Parser, TModel3d *pModel); - // bool Render(); + inline void TurnOn() ///Turns on straight coupler. + { + On = true; + xOn = false; + Update(); + }; + inline void TurnOff() ///Turns on disconnected coupler. + { + On = false; + xOn = false; + Update(); + }; + inline void TurnxOn() ///Turns on slanted coupler. + { + On = false; + xOn = true; + Update(); + }; }; - -//--------------------------------------------------------------------------- diff --git a/DynObj.h b/DynObj.h index c8369855..ef706724 100644 --- a/DynObj.h +++ b/DynObj.h @@ -266,15 +266,15 @@ public: // modele składowe pojazdu TButton btCoupler1; // sprzegi TButton btCoupler2; - TAirCoupler + AirCoupler btCPneumatic1; // sprzegi powietrzne //yB - zmienione z Button na AirCoupler - krzyzyki - TAirCoupler btCPneumatic2; - TAirCoupler btCPneumatic1r; // ABu: to zeby nie bylo problemow przy laczeniu wagonow, - TAirCoupler btCPneumatic2r; // jesli beda polaczone sprzegami 1<->1 lub 0<->0 - TAirCoupler btPneumatic1; // ABu: sprzegi powietrzne zolte - TAirCoupler btPneumatic2; - TAirCoupler btPneumatic1r; // ABu: analogicznie jak 4 linijki wyzej - TAirCoupler btPneumatic2r; + AirCoupler btCPneumatic2; + AirCoupler btCPneumatic1r; // ABu: to zeby nie bylo problemow przy laczeniu wagonow, + AirCoupler btCPneumatic2r; // jesli beda polaczone sprzegami 1<->1 lub 0<->0 + AirCoupler btPneumatic1; // ABu: sprzegi powietrzne zolte + AirCoupler btPneumatic2; + AirCoupler btPneumatic1r; // ABu: analogicznie jak 4 linijki wyzej + AirCoupler btPneumatic2r; TButton btCCtrl1; // sprzegi sterowania TButton btCCtrl2;