Commit d14e079a authored by Jan Möbius's avatar Jan Möbius
Browse files

Reworked dynamic drawMode interface



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12530 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d2274064
......@@ -278,14 +278,8 @@ unsigned int DrawMode::maxModes() {
......@@ -355,55 +349,50 @@ void initializeDefaultDrawModes( void )
//----------------------------------------------------------------------------
bool addDrawMode( const std::string & _name, DrawMode & _newId )
const DrawMode& addDrawMode( const std::string & _name )
{
/// \todo Create a new DrawMode correctly
// check if mode exists already
VecDrawModes::iterator modeIter, modeEnd( currentDrawModes_.end() );
for( modeIter = currentDrawModes_.begin(); modeIter != modeEnd; ++modeIter ) {
if( _name == modeIter->name_ )
return modeIter->id_;
if( _name == modeIter->name_ ) {
return modeIter->id_;
}
}
// add new mode
_newId = firstFreeID_;
currentDrawModes_.push_back( DrawModeInternal( _name, _newId ) );
currentDrawModes_.push_back( DrawModeInternal( _name, firstFreeID_ ) );
++firstFreeID_;
return true;
return currentDrawModes_[ currentDrawModes_.size() - 1 ].id_;
}
//----------------------------------------------------------------------------
bool getDrawMode( const std::string & _name, DrawMode & _Id )
const DrawMode& getDrawMode( const std::string & _name )
{
// check if mode exists
VecDrawModes::iterator modeIter, modeEnd( currentDrawModes_.end() );
// check if mode exists
VecDrawModes::const_iterator modeIter, modeEnd( currentDrawModes_.end() );
for( modeIter = currentDrawModes_.begin();
modeIter != modeEnd;
++modeIter )
for( modeIter = currentDrawModes_.begin(); modeIter != modeEnd; ++modeIter )
{
if( _name == modeIter->name_ )
{
if( _name == modeIter->name_ )
{
_Id = modeIter->id_;
return true;
}
return modeIter->id_;
}
}
// the DrawMode does not exists
return false;
// the DrawMode does not exists
return DrawModes::NONE;
}
bool drawModeExists(const std::string & _name) {
// check if mode exists
VecDrawModes::iterator modeIter, modeEnd( currentDrawModes_.end() );
VecDrawModes::const_iterator modeIter, modeEnd( currentDrawModes_.end() );
for( modeIter = currentDrawModes_.begin(); modeIter != modeEnd; ++modeIter )
{
......@@ -415,6 +404,7 @@ bool drawModeExists(const std::string & _name) {
return false;
}
DrawMode getDrawModeFromIndex( unsigned int _index ) {
return DrawMode(_index);
}
......
......@@ -278,20 +278,28 @@ namespace DrawModes {
ACGDLLEXPORT
void initializeDefaultDrawModes( void );
/** Add a custom DrawMode.
The new ID is returned in the variable \c _newId. A false return value
indicates that the addition failed because all available IDs
are occupied.
/** \brief Add a custom DrawMode.
*
The id of the new draw mode is returned. If it already exists, the id of the existing one
is returned.
@param _name Name of the drawmode to add
@return Id of the new draw mode
*/
ACGDLLEXPORT
bool addDrawMode( const std::string & _name, DrawMode & _newId );
const DrawMode& addDrawMode( const std::string & _name);
/** \brief Get a DrawMode from its name
The Id of the DrawMode with name \c _name is returned in variable \c _Id.
Returns false if the DrawMode could not been found.
/** \brief Get a custom DrawMode.
*
The id of the draw mode is returned or if it does not exist, DrawMode::NONE is returned.
@param _name Name of the drawmode
@return Id of the draw mode or DrawModes::NONE
*/
ACGDLLEXPORT
bool getDrawMode( const std::string & _name, DrawMode & _Id );
const DrawMode& getDrawMode( const std::string & _name);
/** \brief Check if the given draw mode exists
*
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment