Path Tracer
InterfaceGestion.h
Go to the documentation of this file.
1 #ifndef DEF_INTERFACEGESTION
2 #define DEF_INTERFACEGESTION
3 
4 #include <chrono>
5 #include <fstream>
6 #include <random>
7 #include <iostream>
8 
9 #define _USE_MATH_DEFINES // to be able to use M_PI from math.h
10 #include <math.h>
11 
12 // Needs to be included before fbxsdk, else creates conflict.
13 #include "nlohmann/json.hpp"
15 
16 #include <fbxsdk.h>
17 
18 #define NOMINMAX // So that window.h does not interfere with std::min and std::max
19 #include <windows.h> // To hide CMD cursor
20 
111 // Constants
112 constexpr unsigned int MAX_LENGTH_STRING_FROM_USER = 256;
113 const std::string PROMPT = "> ";
114 const std::string STAR_SPLITTER = std::string(26, '*');
115 const std::string DASH_SPLITTER = std::string(26, '-');
116 const std::string INVALID_COMMAND = "Invalid command.";
117 
118 const std::string PICTURE_EXTENSION = "bmp"; // list of available extensions: http://cimg.eu/reference/group__cimg__files__io.html
119 const std::string FBX_EXTENSION = "fbx";
120 const std::string PICTURE_SAVE_EXTENSION_JSON = "ptpict";
121 const std::string OBJECTS_SAVE_EXTENSION = "ptobj";
122 const std::string PARAMETERS_SAVE_EXTENSION = "ptparam";
123 
124 static std::uniform_real_distribution<double> unif = std::uniform_real_distribution<double>(0, 1);
125 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());
126 
127 
128 // Functions
131 void showCMDCursor(bool show);
132 
133 std::string bool2string(bool b);
134 double getCurrentTimeSeconds();
135 double randomDouble();
136 
137 bool fileExists(std::string fileName);
138 std::string formatFileName(std::string fileName, std::string extension);
139 
140 #endif
const std::string FBX_EXTENSION
File extension for fbx files.
Definition: InterfaceGestion.h:119
constexpr unsigned int MAX_LENGTH_STRING_FROM_USER
Maximum length for a string the user can give.
Definition: InterfaceGestion.h:112
static std::uniform_real_distribution< double > unif
Uniform distribution used by the randomDouble() function.
Definition: InterfaceGestion.h:124
std::string formatFileName(std::string fileName, std::string extension)
Formats the name of the file the user gave and the extension we want.
Definition: InterfaceCreation.cpp:236
const std::string PROMPT
String that signals the user can write a command.
Definition: InterfaceGestion.h:113
const std::string PARAMETERS_SAVE_EXTENSION
Custom file extension to save parameters.
Definition: InterfaceGestion.h:122
double randomDouble()
Computes a random double between 0 and 1.
Definition: InterfaceGestion.cpp:43
const std::string PICTURE_EXTENSION
File extension for pictures.
Definition: InterfaceGestion.h:118
const std::string INVALID_COMMAND
String used to show that the command was invalid.
Definition: InterfaceGestion.h:116
std::string bool2string(bool b)
Converts a boolean to a string.
Definition: InterfaceGestion.cpp:31
void showCMDCursor(bool show)
Shows or hide the cursor in the interface.
Definition: InterfaceGestion.cpp:20
void availableCommandsHeader()
Prints a header before printing which commands are available.
Definition: InterfaceGestion.cpp:13
const std::string STAR_SPLITTER
A line of stars.
Definition: InterfaceGestion.h:114
const std::string PICTURE_SAVE_EXTENSION_JSON
Custom file extension to save pictures.
Definition: InterfaceGestion.h:120
bool fileExists(std::string fileName)
Verifies if the file exists.
Definition: InterfaceCreation.cpp:231
static std::default_random_engine re
Random engine used by the randomDouble() function.
Definition: InterfaceGestion.h:125
nlohmann::json json
Definition: InterfaceGestion.h:14
double getCurrentTimeSeconds()
Gives the number of seconds since 1st January 1970.
Definition: InterfaceGestion.cpp:37
const std::string DASH_SPLITTER
A line of dashs.
Definition: InterfaceGestion.h:115
const std::string OBJECTS_SAVE_EXTENSION
Custom file extension to save object groups.
Definition: InterfaceGestion.h:121
void clearScreenPrintHeader()
Clears the console and prints the header.
Definition: InterfaceGestion.cpp:4