Nano v1.0.0
Simulating Natural Selection
ss::pl::graph::Graph Class Reference

#include <graph.h>

Inheritance diagram for ss::pl::graph::Graph:
Scene

Public Member Functions

 Graph (std::string sceneName, SceneManager &sceneManager)
 Constructor for the Graph class. More...
 
virtual void Start ()
 Method which is called in the start of the Graph page. More...
 
virtual void Update ()
 Method which is called every frame. More...
 
virtual void onExit ()
 Method which is called when we exit the program or the Graph page. More...
 
virtual void loadAssets ()
 Method for loading all the needed assets in the graph page. More...
 
virtual void deleteAssets ()
 Method for deallocating the dynamically created assets. More...
 
- Public Member Functions inherited from Scene
 Scene (std::string sceneName)
 
virtual void Start ()=0
 
virtual void Update ()=0
 
virtual void onExit ()=0
 
virtual void loadAssets ()=0
 
virtual void deleteAssets ()=0
 

Static Public Member Functions

static float getHighestSense (const std::vector< ss::types::Cycle > &cycle)
 Getter highest sense function. More...
 
static float getHighestSpeed (const std::vector< ss::types::Cycle > &cycle)
 Getter highest speed function. More...
 
static float getGrowthPercentage (int lastedBef, int lastedCur)
 Method for getting the Growth percentage. More...
 
static float getDecreasedPercentage (int lastedBef, int lastedCur)
 Method for getting the Decreased percentage. More...
 

Public Attributes

SceneManagerm_sceneManager
 
- Public Attributes inherited from Scene
bool isSetUp = false
 
std::string m_sceneName
 

Static Public Attributes

static std::string fileName
 
- Static Public Attributes inherited from Scene
static ThemeTypes currentTheme = ThemeTypes::LightTheme
 
static const std::array< std::string, 2 > themePaths = {"lightTheme", "darkTheme"}
 
static const std::array< Color, 2 > backgroundColors {{{239, 239, 239, 255}, {5, 11, 30, 255}}}
 

Private Types

enum class  AutoState { AutoOn , AutoOff }
 

Private Member Functions

std::pair< float, float > getHighestSenseAndSpeed (const std::vector< ss::types::Cycle > &cycle)
 Function returning the highest sense and speed. More...
 
void drawGraph ()
 Method for drawing the Graph body. More...
 
void drawMenu ()
 Method for drawing the menu in the graph page. More...
 
void checkCollision ()
 Method for checking the collision on click. More...
 
void automateCycle ()
 Method for automating the cycle change. More...
 
void getTraitData (size_t cycle)
 Method for loading trait data. More...
 
void drawTrait ()
 Method for drawing trait data into the graph. More...
 
Vector2 calculateTraitPosition (float sence, float speed)
 Method for calculating trait data position. More...
 

Private Attributes

Texture2D backArrow_Texture
 
Texture2D graph_Container
 
Texture2D cycle_Next
 
Texture2D cycle_Prev
 
Texture2D slider_Box
 
Texture2D auto_Button
 
Texture2D data_Container
 
Vector2 mousePos
 
Vector2 graphLine
 
Vector2 graphText
 
Font fontInter
 
size_t currentCycle
 
unsigned int totalAlive
 
float currentSense
 
float currentSpeed
 
bool autoCycle
 
int cycleSpeed
 
float fElapsedTime
 
std::string populationChange
 
std::vector< ss::types::CyclecycleInfo
 
std::pair< float, float > maxSenseAndSpeed
 
enum ss::pl::graph::Graph::AutoState currentAutoState = AutoState::AutoOff
 
const std::array< std::string, 2 > autoPaths = {"Auto_Button_Checked", "Auto_Button_Unchecked"}
 
std::vector< ss::types::TraittraitData
 
const std::array< Color, 2 > graphColors {{{246, 245, 250, 255}, {108, 108, 108, 255}}}
 

Additional Inherited Members

- Public Types inherited from Scene
enum class  ThemeTypes { LightTheme , DarkTheme }
 

Member Enumeration Documentation

◆ AutoState

enum class ss::pl::graph::Graph::AutoState
strongprivate
Enumerator
AutoOn 
AutoOff 

Constructor & Destructor Documentation

◆ Graph()

ss::pl::graph::Graph::Graph ( std::string  sceneName,
SceneManager sceneManager 
)

Constructor for the Graph class.

Parameters
sceneNameThe name of the current scene. Which here is "Graph".
sceneManagerA reference to already existing SceneManager object to control the program flow.

Member Function Documentation

◆ automateCycle()

void ss::pl::graph::Graph::automateCycle ( )
private

Method for automating the cycle change.

◆ calculateTraitPosition()

Vector2 ss::pl::graph::Graph::calculateTraitPosition ( float  sence,
float  speed 
)
private

Method for calculating trait data position.

It returns the position in coordinates (x, y) for each trait according the the graph.

Parameters
senceIt holds the current trait's sence.
speedIt holds the current trait's speed.
Returns
Vector2 of X and Y positions.

◆ checkCollision()

void ss::pl::graph::Graph::checkCollision ( )
private

Method for checking the collision on click.

◆ deleteAssets()

void ss::pl::graph::Graph::deleteAssets ( )
virtual

Method for deallocating the dynamically created assets.

Implements Scene.

◆ drawGraph()

void ss::pl::graph::Graph::drawGraph ( )
private

Method for drawing the Graph body.

◆ drawMenu()

void ss::pl::graph::Graph::drawMenu ( )
private

Method for drawing the menu in the graph page.

◆ drawTrait()

void ss::pl::graph::Graph::drawTrait ( )
private

Method for drawing trait data into the graph.

It uses DrawCircleV function to draw each trait's sense and speed into the graph.

◆ getDecreasedPercentage()

float ss::pl::graph::Graph::getDecreasedPercentage ( int  lastedBef,
int  lastedCur 
)
inlinestatic

Method for getting the Decreased percentage.

It returns the absolute value of the percentage when the current cycle' lasted entities had growth.

Parameters
lastedBefIt holds the lasted entities in the previous cycle.
lastedCurit holds the lasted entities in the current cycle.
Returns
The percentage when it's decreasing.

◆ getGrowthPercentage()

float ss::pl::graph::Graph::getGrowthPercentage ( int  lastedBef,
int  lastedCur 
)
inlinestatic

Method for getting the Growth percentage.

It returns the absolute value of the percentage when the current cycle' lasted entities had growth.

Parameters
lastedBefIt holds the lasted entities in the previous cycle.
lastedCurit holds the lasted entities in the current cycle.
Returns
The percentage when it's growing.

◆ getHighestSense()

float ss::pl::graph::Graph::getHighestSense ( const std::vector< ss::types::Cycle > &  cycles)
static

Getter highest sense function.

Function which gets the highest sense of a generation holding in a .json file.

Parameters
cyclesGeneration data.
Returns
Highest sense as a float.

◆ getHighestSenseAndSpeed()

std::pair< float, float > ss::pl::graph::Graph::getHighestSenseAndSpeed ( const std::vector< ss::types::Cycle > &  cycle)
private

Function returning the highest sense and speed.

Function returning the highest sense and speed as a pair of floats.

Parameters
cyclesGeneration data.
Returns
A pair of floats holding sense and speed.

◆ getHighestSpeed()

float ss::pl::graph::Graph::getHighestSpeed ( const std::vector< ss::types::Cycle > &  cycles)
static

Getter highest speed function.

Function which gets the highest speed of a generation holding in a .json file.

Parameters
cyclesGeneration data.
Returns
Highest speed as a float.

◆ getTraitData()

void ss::pl::graph::Graph::getTraitData ( size_t  cycle)
private

Method for loading trait data.

It fills traitData vector with data from cycleInfo.traitsInfo.

Parameters
cycleit holds a iterator to the current cycle.

◆ loadAssets()

void ss::pl::graph::Graph::loadAssets ( )
virtual

Method for loading all the needed assets in the graph page.

Implements Scene.

◆ onExit()

void ss::pl::graph::Graph::onExit ( )
virtual

Method which is called when we exit the program or the Graph page.

It deallocates every dynamically created object in the class' instance.

Implements Scene.

◆ Start()

void ss::pl::graph::Graph::Start ( )
virtual

Method which is called in the start of the Graph page.

Implements Scene.

◆ Update()

void ss::pl::graph::Graph::Update ( )
virtual

Method which is called every frame.

It updates the current scene every frame.

Implements Scene.

Member Data Documentation

◆ auto_Button

Texture2D ss::pl::graph::Graph::auto_Button
private

◆ autoCycle

bool ss::pl::graph::Graph::autoCycle
private

◆ autoPaths

const std::array<std::string, 2> ss::pl::graph::Graph::autoPaths = {"Auto_Button_Checked", "Auto_Button_Unchecked"}
private

◆ backArrow_Texture

Texture2D ss::pl::graph::Graph::backArrow_Texture
private

◆ currentAutoState

enum ss::pl::graph::Graph::AutoState ss::pl::graph::Graph::currentAutoState = AutoState::AutoOff
private

◆ currentCycle

size_t ss::pl::graph::Graph::currentCycle
private

◆ currentSense

float ss::pl::graph::Graph::currentSense
private

◆ currentSpeed

float ss::pl::graph::Graph::currentSpeed
private

◆ cycle_Next

Texture2D ss::pl::graph::Graph::cycle_Next
private

◆ cycle_Prev

Texture2D ss::pl::graph::Graph::cycle_Prev
private

◆ cycleInfo

std::vector<ss::types::Cycle> ss::pl::graph::Graph::cycleInfo
private

◆ cycleSpeed

int ss::pl::graph::Graph::cycleSpeed
private

◆ data_Container

Texture2D ss::pl::graph::Graph::data_Container
private

◆ fElapsedTime

float ss::pl::graph::Graph::fElapsedTime
private

◆ fileName

std::string ss::pl::graph::Graph::fileName
inlinestatic

◆ fontInter

Font ss::pl::graph::Graph::fontInter
private

◆ graph_Container

Texture2D ss::pl::graph::Graph::graph_Container
private

◆ graphColors

const std::array<Color, 2> ss::pl::graph::Graph::graphColors {{{246, 245, 250, 255}, {108, 108, 108, 255}}}
private

◆ graphLine

Vector2 ss::pl::graph::Graph::graphLine
private

◆ graphText

Vector2 ss::pl::graph::Graph::graphText
private

◆ m_sceneManager

SceneManager& ss::pl::graph::Graph::m_sceneManager

◆ maxSenseAndSpeed

std::pair<float, float> ss::pl::graph::Graph::maxSenseAndSpeed
private

◆ mousePos

Vector2 ss::pl::graph::Graph::mousePos
private

◆ populationChange

std::string ss::pl::graph::Graph::populationChange
private

◆ slider_Box

Texture2D ss::pl::graph::Graph::slider_Box
private

◆ totalAlive

unsigned int ss::pl::graph::Graph::totalAlive
private

◆ traitData

std::vector<ss::types::Trait> ss::pl::graph::Graph::traitData
private

The documentation for this class was generated from the following files: