BlankMat 0.1.0
Free open-source 3D texture creation application
Loading...
Searching...
No Matches
MaterialContainer Class Reference
Inheritance diagram for MaterialContainer:
Collaboration diagram for MaterialContainer:

Public Member Functions

MaterialAddMaterial (Material *item, bool replace=false)
 Adds the material to the container.
 
MaterialGetDefault ()
 Returns the default material.
 
virtual bool IsDeleteable (Material *item)
 Returns whether the given item is deletable (ie. not a default element or internal)
 
void LoadTextures (TextureContainer *textures)
 Loads the textures of materials in this container.
 
 MaterialContainer (TextureContainer *textures)
 Initializes a default material container with the default material.
 
- Public Member Functions inherited from IContainer< Material >
void Read (const std::string &scope, std::ifstream &file, bool clear) override
 Reads this container from the file.
 
void Write (std::ofstream &file) override
 Writes this container to the file.
 
void Clear () override
 Clears the container of all items, deleting them.
 
void ClearData ()
 Clears the data of the container without deleting it. Only use this if pointers to the data exist elsewhere.
 
unsigned int WriteCount () override
 Returns the number of items that will be written from the container.
 
unsigned int Count ()
 Returns the number of elements in the container.
 
bool Empty ()
 Returns whether the container is empty or not.
 
virtual std::string GetUniqueName (const std::string &name)
 Returns a unique name, incrementing the existing name until it is unique.
 
virtual bool Select (const std::string &name)
 Selects the given item. Does nothing if the item is not part of the container.
 
virtual bool Select (Material *item)
 Selects the given item. Does nothing if the item is not part of the container.
 
virtual void Deselect ()
 Deselects the currently selected item.
 
virtual const std::string GetSelectedName ()
 Returns the currently selected item.
 
virtual MaterialGetSelectedItem ()
 Returns the currently selected item.
 
virtual MaterialAdd (const std::string &name, Material *item, bool replace, bool select=false)
 Adds the given item to the container, or if it already exists, updates the item to the given one.
 
virtual bool TryDelete (Material *item)
 Attempts to delete the given item. Does nothing if the item is not deleteable or is null.
 
virtual bool Remove (const std::string &name)
 Removes the given item from the container.
 
virtual bool Remove (Material *item)
 Removes the given item from the container.
 
virtual MaterialGetItem (const std::string &name)
 Returns the item with the given key, or nullptr if not found.
 
virtual const std::string GetKey (Material *item)
 Returns the key of the item given, or an empty string if not found.
 
virtual bool Contains (const std::string &name)
 Returns whether the container contains an item with the given name.
 
virtual bool Rename (const std::string &name, const std::string &newName)
 Renames the given item to the new name, or the new name with appended numbers.
 
virtual const std::unordered_map< std::string, Material * > & Data ()
 Returns a reference to the data stored in the container.
 
 ~IContainer ()
 Clears all of the container, deleting its elements.
 

Protected Member Functions

void RenameItem (Material *item, const std::string &name) override
 Renames the given item to the given name.
 
bool SkipItem (Material *item) override
 Returns whether the item should be skipped or not.
 
const std::pair< std::string, Material * > ReadItem (const std::string &scope, std::ifstream &file) override
 Reads the next item from the input file stream.
 
void WriteItem (const std::string &key, Material *item, std::ofstream &file) override
 Writes the given item into the output file stream.
 

Additional Inherited Members

- Protected Attributes inherited from IContainer< Material >
std::unordered_map< std::string, Material * > mData
 Data of the container.
 
std::string mCurSelectedName
 Currently selected item's name.
 
MaterialmCurSelectedItem
 Currently selected item.
 

Constructor & Destructor Documentation

◆ MaterialContainer()

MaterialContainer::MaterialContainer ( TextureContainer textures)
inlineexplicit

Initializes a default material container with the default material.

Parameters
texturesTexture container with default textures

Member Function Documentation

◆ AddMaterial()

Material * MaterialContainer::AddMaterial ( Material item,
bool  replace = false 
)
inline

Adds the material to the container.

Parameters
itemThe item to store
replaceWhether to replace the existing item if this is a duplicate
Returns
The element stored in the container

◆ GetDefault()

Material * MaterialContainer::GetDefault ( )
inline

Returns the default material.

Returns
Default material

◆ IsDeleteable()

virtual bool MaterialContainer::IsDeleteable ( Material item)
inlinevirtual

Returns whether the given item is deletable (ie. not a default element or internal)

Parameters
itemItem to consider
Returns
Whether the item can be deleted safely

Reimplemented from IContainer< Material >.

◆ LoadTextures()

void MaterialContainer::LoadTextures ( TextureContainer textures)
inline

Loads the textures of materials in this container.

Parameters
texturesTexture list of the scene

◆ ReadItem()

const std::pair< std::string, Material * > MaterialContainer::ReadItem ( const std::string &  scope,
std::ifstream &  file 
)
inlineoverrideprotectedvirtual

Reads the next item from the input file stream.

Parameters
scopeScope to read item in
fileFile to read
Returns
Newly constructed item from file

Implements IContainer< Material >.

◆ RenameItem()

void MaterialContainer::RenameItem ( Material item,
const std::string &  name 
)
inlineoverrideprotectedvirtual

Renames the given item to the given name.

Parameters
itemItem to rename

Implements IContainer< Material >.

◆ SkipItem()

bool MaterialContainer::SkipItem ( Material item)
inlineoverrideprotectedvirtual

Returns whether the item should be skipped or not.

Parameters
itemItem to consider
Returns
Whether the item should be skipped

Reimplemented from IContainer< Material >.

◆ WriteItem()

void MaterialContainer::WriteItem ( const std::string &  key,
Material item,
std::ofstream &  file 
)
inlineoverrideprotectedvirtual

Writes the given item into the output file stream.

Parameters
keyKey of item
itemItem to write
fileFile to write to

Implements IContainer< Material >.