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

Added function to get drawmode from its description

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17721 383ad7c9-94d9-4d36-a494-682f7c89f535
parent ac3c0f39
......@@ -207,6 +207,26 @@ DrawMode::DrawMode(ModeFlagSet _flags) :
layers_[0] = DrawModeProperties();
}
DrawMode DrawMode::getFromDescription(std::string _description)
{
DrawMode val;
bool found = false;
std::istringstream f(_description);
std::string s;
while (std::getline(f, s, '+')) {
VecDrawModes::const_iterator modeIter, modeEnd( registeredDrawModes_.end() );
for( modeIter = registeredDrawModes_.begin(); modeIter != modeEnd; ++modeIter ) {
if(modeIter->name() == s) {
val |= modeIter->id();
found = true;
}
}
}
if(!found)
return DEFAULT;
else return val;
}
DrawMode::operator bool() const {
return( modeFlags_ != NONE.modeFlags_ );
}
......
......@@ -310,6 +310,12 @@ namespace DrawModes {
*/
DrawMode( ModeFlagSet _flags );
/* \brief Returns a registered draw mode based on the description passed or if none could be found the default one.
*
* @param _description A description created by description().
*/
static DrawMode getFromDescription(std::string _description);
//===========================================================================
/** @name Operators
......
Markdown is supported
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