PumpkinBrush
Public Types | Public Member Functions | Public Attributes | List of all members
App Class Reference

#include <App.hpp>

Collaboration diagram for App:
Collaboration graph
[legend]

Public Types

enum  commandEnum {
  DRAW, CLEAR, ERASE, UNDO,
  REDO
}
 

Public Member Functions

 App ()
 The constructor of the App class that initializes certain crucial values for the application. More...
 
 App (sf::IpAddress ipAddress, int port)
 The second constructor of the App class that initializes certain crucial values for the application but here it takes in two arguments for networking purposes. More...
 
GeneralBrushgetBrush ()
 Return the current brush instance of the App. More...
 
BrushFactory getBrushFactory ()
 Return the brush factory of App. More...
 
void setBrush (GeneralBrush *brush)
 Set the current brush. More...
 
void addCommand (Command *c)
 The addCommand function servers two purpose, first is adding the command to the redo stack and the second is executing the command so it can be reflected on the canvas. More...
 
void executeCommand (Command *c)
 The execute Command function helps execute the command to generate pixel upon input from the user, the method is being called from AddCommand() function. More...
 
void undoCommand (bool sendMessage)
 The undoCommand function unodoes the the pixel in reverse chronological order from a stack recursively. More...
 
void redoCommand (bool sendMessage)
 The redo commands redo an undo command until if there is an input in between. More...
 
void undoCommandNetwork ()
 The undoCommand function unodoes the the pixel in reverse chronological order for the network i.e so the clients connected get the pixels created and erased on canvas. More...
 
void redoCommandNetwork ()
 The redo commands redo an undo command until if there is an input in between for the network i.e so the clients connected get the pixels created and erased on canvas. More...
 
sf::Image & getImage ()
 Return a reference to our m_image, so that we do not have to publicly expose it. More...
 
void setImage (sf::Image *newImage)
 Sets the image passed in from the parameter for the App class. More...
 
sf::Texture & getTexture ()
 Return a reference to our m_Texture so that we do not have to publicly expose it. More...
 
sf::RenderWindow & getWindow ()
 Return a reference to our m_window so that we do not have to publicly expose it. More...
 
std::stack< Command * > getUndoStack ()
 returns the current undo stack where all the commands to be undone are stored More...
 
std::stack< Command * > getRedoStack ()
 returns the current redo stack where all the commands to be redone are stored More...
 
void destroy ()
 destroy we manually call at end of our program. More...
 
void init (void(*initFunction)(void))
 Initializes the App and sets up the main rendering window(i.e. our canvas.) More...
 
void updateCallback (void(*updateFunction)(App &app))
 Set a callback function which will be called each iteration of the main loop before drawing. More...
 
void drawCallback (void(*drawFunction)(App &app))
 Set a callback function which will be called each iteration of the main loop after update. More...
 
void loop (App &app)
 The main loop function which handles initialization and will be executed until the main window is closed. Within the loop function the update and draw callback functions will be called. More...
 
void setBackgroundColor (sf::Color *colorPassed)
 Set a reference to m_backgroundColor. More...
 
sf::Color & getBackgroundColor ()
 Return a reference to our m_backgroundColor so that we do not have to publicly expose it. More...
 

Public Attributes

sf::TcpSocket clientSocketInApp
 
sf::Socket::Status statusInApp
 
sf::Packet packetInApp
 
unsigned int pmouseX
 
unsigned int pmouseY
 
unsigned int mouseX
 
unsigned int mouseY
 
int commandFlag = 1
 
commandEnum m_prevCommand
 
bool onErase = false
 
sf::RenderWindow * m_window
 
Guim_gui
 

Member Enumeration Documentation

◆ commandEnum

Enumerator
DRAW 
CLEAR 
ERASE 
UNDO 
REDO 

Constructor & Destructor Documentation

◆ App() [1/2]

App::App ( )

The constructor of the App class that initializes certain crucial values for the application.

◆ App() [2/2]

App::App ( sf::IpAddress  ipAddress,
int  port 
)

The second constructor of the App class that initializes certain crucial values for the application but here it takes in two arguments for networking purposes.

Parameters
ipAddressthe IP Address of the server to be passed for the client to connect with the server
portnumber of the server running

Member Function Documentation

◆ addCommand()

void App::addCommand ( Command c)

The addCommand function servers two purpose, first is adding the command to the redo stack and the second is executing the command so it can be reflected on the canvas.

Parameters
ca command object that is being passed, it can be draw, erase or clear

◆ destroy()

void App::destroy ( )

destroy we manually call at end of our program.

◆ drawCallback()

void App::drawCallback ( void(*)(App &app)  drawFunction)

Set a callback function which will be called each iteration of the main loop after update.

Parameters
drawFunctionis a function that takes in App object as an argument so it can be executed later in the application

◆ executeCommand()

void App::executeCommand ( Command c)

The execute Command function helps execute the command to generate pixel upon input from the user, the method is being called from AddCommand() function.

Parameters
ca command object that is being passed, it can be draw, erase or clear

◆ getBackgroundColor()

sf::Color & App::getBackgroundColor ( )

Return a reference to our m_backgroundColor so that we do not have to publicly expose it.

◆ getBrush()

GeneralBrush & App::getBrush ( )

Return the current brush instance of the App.

Returns
m_brush a poiner to m_brush of the App class

◆ getBrushFactory()

BrushFactory App::getBrushFactory ( )

Return the brush factory of App.

Returns
m_brushFactory a poiner to m_brushFactory of the App class

◆ getImage()

sf::Image & App::getImage ( )

Return a reference to our m_image, so that we do not have to publicly expose it.

Returns
m_image a poiner to m_image of the App class

◆ getRedoStack()

std::stack< Command * > App::getRedoStack ( )

returns the current redo stack where all the commands to be redone are stored

Returns
m_redo,

◆ getTexture()

sf::Texture & App::getTexture ( )

Return a reference to our m_Texture so that we do not have to publicly expose it.

Returns
m_texture a poiner to m_texture of the App class

◆ getUndoStack()

std::stack< Command * > App::getUndoStack ( )

returns the current undo stack where all the commands to be undone are stored

Returns
m_undo

◆ getWindow()

sf::RenderWindow & App::getWindow ( )

Return a reference to our m_window so that we do not have to publicly expose it.

Returns
m_window a poiner to m_window of the App class

◆ init()

void App::init ( void(*)(void)  initFunction)

Initializes the App and sets up the main rendering window(i.e. our canvas.)

Parameters
initFunctiona pointer to a function that is executed later when the program is initiated

◆ loop()

void App::loop ( App app)

The main loop function which handles initialization and will be executed until the main window is closed. Within the loop function the update and draw callback functions will be called.

Parameters
appthe instance of app class passed so the it can be used to execute various functions

◆ redoCommand()

void App::redoCommand ( bool  sendMessage)

The redo commands redo an undo command until if there is an input in between.

Parameters
sendMessagea bool value to check if the message has been sent over the network for conditional logic

◆ redoCommandNetwork()

void App::redoCommandNetwork ( )

The redo commands redo an undo command until if there is an input in between for the network i.e so the clients connected get the pixels created and erased on canvas.

◆ setBackgroundColor()

void App::setBackgroundColor ( sf::Color *  colorPassed)

Set a reference to m_backgroundColor.

Parameters
colorPassedthe color of the background

◆ setBrush()

void App::setBrush ( GeneralBrush brush)

Set the current brush.

Parameters
brushthe brush to be set is passed as an argument for the App class

◆ setImage()

void App::setImage ( sf::Image *  newImage)

Sets the image passed in from the parameter for the App class.

Parameters
newImagethe image to be set for the App class

◆ undoCommand()

void App::undoCommand ( bool  sendMessage)

The undoCommand function unodoes the the pixel in reverse chronological order from a stack recursively.

Parameters
sendMessagea bool value to check if the message has been sent over the network for conditional logic

◆ undoCommandNetwork()

void App::undoCommandNetwork ( )

The undoCommand function unodoes the the pixel in reverse chronological order for the network i.e so the clients connected get the pixels created and erased on canvas.

◆ updateCallback()

void App::updateCallback ( void(*)(App &app)  updateFunction)

Set a callback function which will be called each iteration of the main loop before drawing.

Parameters
updateFuntionis a function that takes in App object as an argument so it can be executed later in the application

Member Data Documentation

◆ clientSocketInApp

sf::TcpSocket App::clientSocketInApp

◆ commandFlag

int App::commandFlag = 1

◆ m_gui

Gui* App::m_gui

◆ m_prevCommand

commandEnum App::m_prevCommand

◆ m_window

sf::RenderWindow* App::m_window

◆ mouseX

unsigned int App::mouseX

◆ mouseY

unsigned int App::mouseY

◆ onErase

bool App::onErase = false

◆ packetInApp

sf::Packet App::packetInApp

◆ pmouseX

unsigned int App::pmouseX

◆ pmouseY

unsigned int App::pmouseY

◆ statusInApp

sf::Socket::Status App::statusInApp

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