Path Tracer
Macros | Typedefs | Functions | Variables
InterfaceGestion.h File Reference

Defines functions that are used when drawing the interface. More...

#include <chrono>
#include <fstream>
#include <random>
#include <iostream>
#include <math.h>
#include "nlohmann/json.hpp"
#include <fbxsdk.h>
#include <windows.h>
Include dependency graph for InterfaceGestion.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _USE_MATH_DEFINES
 
#define NOMINMAX
 

Typedefs

using json = nlohmann::json
 

Functions

void clearScreenPrintHeader ()
 Clears the console and prints the header. More...
 
void availableCommandsHeader ()
 Prints a header before printing which commands are available. More...
 
void showCMDCursor (bool show)
 Shows or hide the cursor in the interface. More...
 
std::string bool2string (bool b)
 Converts a boolean to a string. More...
 
double getCurrentTimeSeconds ()
 Gives the number of seconds since 1st January 1970. More...
 
double randomDouble ()
 Computes a random double between 0 and 1. More...
 
bool fileExists (std::string fileName)
 Verifies if the file exists. More...
 
std::string formatFileName (std::string fileName, std::string extension)
 Formats the name of the file the user gave and the extension we want. More...
 

Variables

constexpr unsigned int MAX_LENGTH_STRING_FROM_USER = 256
 Maximum length for a string the user can give. More...
 
const std::string PROMPT = "> "
 String that signals the user can write a command. More...
 
const std::string STAR_SPLITTER = std::string(26, '*')
 A line of stars. More...
 
const std::string DASH_SPLITTER = std::string(26, '-')
 A line of dashs. More...
 
const std::string INVALID_COMMAND = "Invalid command."
 String used to show that the command was invalid. More...
 
const std::string PICTURE_EXTENSION = "bmp"
 File extension for pictures. More...
 
const std::string FBX_EXTENSION = "fbx"
 File extension for fbx files. More...
 
const std::string PICTURE_SAVE_EXTENSION_JSON = "ptpict"
 Custom file extension to save pictures. More...
 
const std::string OBJECTS_SAVE_EXTENSION = "ptobj"
 Custom file extension to save object groups. More...
 
const std::string PARAMETERS_SAVE_EXTENSION = "ptparam"
 Custom file extension to save parameters. More...
 
static std::uniform_real_distribution< double > unif = std::uniform_real_distribution<double>(0, 1)
 Uniform distribution used by the randomDouble() function. More...
 
static std::default_random_engine re = std::default_random_engine(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count())
 Random engine used by the randomDouble() function. More...
 

Detailed Description

Defines functions that are used when drawing the interface.

Macro Definition Documentation

◆ _USE_MATH_DEFINES

#define _USE_MATH_DEFINES

◆ NOMINMAX

#define NOMINMAX

Typedef Documentation

◆ json

using json = nlohmann::json

Function Documentation

◆ availableCommandsHeader()

void availableCommandsHeader ( )

Prints a header before printing which commands are available.

◆ bool2string()

std::string bool2string ( bool  b)

Converts a boolean to a string.

Parameters
bThe boolean that will be converted.
Returns
The boolean converted into a string.

◆ clearScreenPrintHeader()

void clearScreenPrintHeader ( )

Clears the console and prints the header.

See also
printAll()

◆ fileExists()

bool fileExists ( std::string  fileName)

Verifies if the file exists.

Parameters
fileNameThe path to the file.
Returns
True if the file exists, false else.

◆ formatFileName()

std::string formatFileName ( std::string  fileName,
std::string  extension 
)

Formats the name of the file the user gave and the extension we want.

For example, it will format "test.txt" into "test.txt" and "test" into "test.txt".

Parameters
fileNameThe path to the file we want to format.
extensionThe file extension with which we want to format the file.
Returns
The formated file name.

◆ getCurrentTimeSeconds()

double getCurrentTimeSeconds ( )

Gives the number of seconds since 1st January 1970.

Returns
The time since 1st January 1970 in seconds.

◆ randomDouble()

double randomDouble ( )

Computes a random double between 0 and 1.

Simply calls unif(re).

Returns
A random double between 0 and 1 generated following a uniform distrbution.
See also
unif, re

◆ showCMDCursor()

void showCMDCursor ( bool  show)

Shows or hide the cursor in the interface.

Used code from Captain Obvlious. Remove blinking underscore on console / cmd prompt. [Accessed 28th December 2020]. Stackoverflow. 3rd August 2013. Available from: https://stackoverflow.com/a/18028927/12637970.

Parameters
showWhether the cursor will be shown or hidden.

Variable Documentation

◆ DASH_SPLITTER

const std::string DASH_SPLITTER = std::string(26, '-')

A line of dashs.

◆ FBX_EXTENSION

const std::string FBX_EXTENSION = "fbx"

◆ INVALID_COMMAND

const std::string INVALID_COMMAND = "Invalid command."

String used to show that the command was invalid.

See also
commandWasInvalid

◆ MAX_LENGTH_STRING_FROM_USER

constexpr unsigned int MAX_LENGTH_STRING_FROM_USER = 256
constexpr

Maximum length for a string the user can give.

◆ OBJECTS_SAVE_EXTENSION

const std::string OBJECTS_SAVE_EXTENSION = "ptobj"

Custom file extension to save object groups.

See also
PICTURE_EXTENSION, FBX_EXTENSION, PICTURE_SAVE_EXTENSION_JSON, PARAMETERS_SAVE_EXTENSION

◆ PARAMETERS_SAVE_EXTENSION

const std::string PARAMETERS_SAVE_EXTENSION = "ptparam"

Custom file extension to save parameters.

See also
PICTURE_EXTENSION, FBX_EXTENSION, PICTURE_SAVE_EXTENSION_JSON, OBJECTS_SAVE_EXTENSION

◆ PICTURE_EXTENSION

const std::string PICTURE_EXTENSION = "bmp"

◆ PICTURE_SAVE_EXTENSION_JSON

const std::string PICTURE_SAVE_EXTENSION_JSON = "ptpict"

Custom file extension to save pictures.

See also
PICTURE_EXTENSION, FBX_EXTENSION, OBJECTS_SAVE_EXTENSION, PARAMETERS_SAVE_EXTENSION

◆ PROMPT

const std::string PROMPT = "> "

String that signals the user can write a command.

◆ re

static std::default_random_engine re = std::default_random_engine(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count())
static

Random engine used by the randomDouble() function.

Its seed is given by the number of seconds between the 1st January 1970 and the moment at which the user starts the program.

See also
unif, randomDouble(), getCurrentTimeSeconds()

◆ STAR_SPLITTER

const std::string STAR_SPLITTER = std::string(26, '*')

A line of stars.

◆ unif

static std::uniform_real_distribution< double > unif = std::uniform_real_distribution<double>(0, 1)
static

Uniform distribution used by the randomDouble() function.

This distribution gives a random double between 0 and 1.

See also
re, randomDouble()