DrawModeConverter.cc 13.6 KB
Newer Older
Jan Möbius's avatar
 
Jan Möbius committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
//=============================================================================
//
//                               OpenFlipper
//        Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
//                           www.openflipper.org
//
//-----------------------------------------------------------------------------
//
//                                License
//
//  OpenFlipper is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
// 
//  OpenFlipper is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
// 
//  You should have received a copy of the GNU Lesser General Public License
//  along with OpenFlipper.  If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
//   $Revision$
//   $Author$
//   $Date$
//
//=============================================================================




//=============================================================================
//
//
//=============================================================================


//== INCLUDES =================================================================

#include "DrawModeConverter.hh"

//== TYPEDEFS =================================================================

//== CLASS DEFINITION =========================================================

/// Convert a drawmode to a vector of QStrings
std::vector< QString > drawModeToList(unsigned int _drawMode) {
  std::vector< QString > draw_modes;
  
  if ( _drawMode & ACG::SceneGraph::DrawModes::DEFAULT )
    draw_modes.push_back("DEFAULT");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED)
    draw_modes.push_back("SOLID_SMOOTH_SHADED");
  if ( _drawMode & ACG::SceneGraph::DrawModes::HIDDENLINE)
    draw_modes.push_back("HIDDENLINE");
  if ( _drawMode & ACG::SceneGraph::DrawModes::WIREFRAME)
    draw_modes.push_back("WIREFRAME");
  if ( _drawMode & ACG::SceneGraph::DrawModes::POINTS)
    draw_modes.push_back("POINTS");
  if ( _drawMode & ACG::SceneGraph::DrawModes::POINTS_COLORED)
    draw_modes.push_back("POINTS_COLORED");
  if ( _drawMode & ACG::SceneGraph::DrawModes::POINTS_SHADED)
    draw_modes.push_back("POINTS_SHADED");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED) 
    draw_modes.push_back("SOLID_FLAT_SHADED");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_PHONG_SHADED)
    draw_modes.push_back("SOLID_PHONG_SHADED");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED)
    draw_modes.push_back("SOLID_POINTS_COLORED");
73 74 75 76
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED)
    draw_modes.push_back("SOLID_FACES_COLORED");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED)
    draw_modes.push_back("SOLID_POINTS_COLORED");
Jan Möbius's avatar
 
Jan Möbius committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_ENV_MAPPED)
    draw_modes.push_back("SOLID_ENV_MAPPED");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_TEXTURED)
    draw_modes.push_back("SOLID_TEXTURED");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_TEXTURED_SHADED)
    draw_modes.push_back("SOLID_TEXTURED_SHADED");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_1DTEXTURED)
    draw_modes.push_back("SOLID_1DTEXTURED");        
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_1DTEXTURED_SHADED)
    draw_modes.push_back("SOLID_1DTEXTURED_SHADED");     
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_3DTEXTURED)
    draw_modes.push_back("SOLID_3DTEXTURED");             
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_3DTEXTURED_SHADED)
    draw_modes.push_back("SOLID_3DTEXTURED_SHADED");    
91 92 93 94 95 96 97 98 99
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_FLAT_SHADED)
    draw_modes.push_back("SOLID_FACES_COLORED_FLAT_SHADED");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE)
    draw_modes.push_back("SOLID_2DTEXTURED_FACE");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE_SHADED)
    draw_modes.push_back("SOLID_2DTEXTURED_FACE_SHADED");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_SHADER)
    draw_modes.push_back("SOLID_SHADER");    

Jan Möbius's avatar
 
Jan Möbius committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
  return draw_modes;
}

/// Convert a vector of QStrings to a draw mode
unsigned int ListToDrawMode ( std::vector< QString > _draw_modes ) {
    
  unsigned int drawMode = 0 ;
  
  for ( uint i = 0 ; i < _draw_modes.size() ; ++i ) {
    if( _draw_modes[i] == "DEFAULT" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::DEFAULT;
    } else  if( _draw_modes[i] == "SOLID_SMOOTH_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED;
    } else if( _draw_modes[i] == "HIDDENLINE" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::HIDDENLINE;
    } else if( _draw_modes[i] == "WIREFRAME" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::WIREFRAME;
    } else if( _draw_modes[i] == "POINTS" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::POINTS;
    } else if( _draw_modes[i] == "POINTS_COLORED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::POINTS_COLORED;
    } else if( _draw_modes[i] == "POINTS_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::POINTS_SHADED;
    } else if( _draw_modes[i] == "SOLID_FLAT_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED;
    } else if( _draw_modes[i] == "SOLID_PHONG_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_PHONG_SHADED;
    } else if( _draw_modes[i] == "SOLID_POINTS_COLORED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED;
129 130
    } else if( _draw_modes[i] == "SOLID_FACES_COLORED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED;
Jan Möbius's avatar
 
Jan Möbius committed
131 132 133 134 135 136 137 138 139 140 141 142 143 144
    } else if( _draw_modes[i] == "SOLID_ENV_MAPPED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_ENV_MAPPED;
    } else if( _draw_modes[i] == "SOLID_TEXTURED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_TEXTURED;
    } else if( _draw_modes[i] == "SOLID_TEXTURED_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_TEXTURED_SHADED;
    } else if( _draw_modes[i] == "SOLID_1DTEXTURED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_1DTEXTURED;
    } else if( _draw_modes[i] == "SOLID_1DTEXTURED_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_1DTEXTURED_SHADED;
    } else if( _draw_modes[i] == "SOLID_3DTEXTURED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_3DTEXTURED;
    } else if( _draw_modes[i] == "SOLID_3DTEXTURED_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_3DTEXTURED_SHADED;
145 146 147 148 149 150 151 152
    } else if( _draw_modes[i] == "SOLID_FACES_COLORED_FLAT_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_FLAT_SHADED;
    } else if( _draw_modes[i] == "SOLID_2DTEXTURED_FACE" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE;
    } else if( _draw_modes[i] == "SOLID_2DTEXTURED_FACE_SHADED" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE_SHADED;
    } else if( _draw_modes[i] == "SOLID_SHADER" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_SHADER;
Jan Möbius's avatar
 
Jan Möbius committed
153 154 155 156 157 158 159
    }
  }
  
  return drawMode; 
 
}

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
/// Convert a vector of DrawMode-Descriptions to a draw mode
unsigned int descriptionsToDrawMode ( std::vector< QString > _draw_modes ) {
    
  unsigned int drawMode = 0 ;
  
  for ( uint i = 0 ; i < _draw_modes.size() ; ++i ) {
    if( _draw_modes[i] == "Default" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::DEFAULT;
    } else  if( _draw_modes[i] == "Solid (smooth shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED;
    } else if( _draw_modes[i] == "Hiddenline" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::HIDDENLINE;
    } else if( _draw_modes[i] == "Wireframe" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::WIREFRAME;
    } else if( _draw_modes[i] == "Points" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::POINTS;
    } else if( _draw_modes[i] == "Points (colored)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::POINTS_COLORED;
    } else if( _draw_modes[i] == "Points (shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::POINTS_SHADED;
    } else if( _draw_modes[i] == "Solid (flat shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED;
    } else if( _draw_modes[i] == "Solid (Phong shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_PHONG_SHADED;
    } else if( _draw_modes[i] == "Solid (colored per-face)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED;
    } else if( _draw_modes[i] == "Solid (colored per-vertex)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED;
    } else if( _draw_modes[i] == "Solid (environment mapped)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_ENV_MAPPED;
    } else if( _draw_modes[i] == "Solid (textured)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_TEXTURED;
    } else if( _draw_modes[i] == "Solid (textured, shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_TEXTURED_SHADED;
    } else if( _draw_modes[i] == "Solid (scalar field)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_1DTEXTURED;
    } else if( _draw_modes[i] == "Solid (scalar field, shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_1DTEXTURED_SHADED;
    } else if( _draw_modes[i] == "Solid (3D textured)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_3DTEXTURED;
    } else if( _draw_modes[i] == "Solid (3D textured, shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_3DTEXTURED_SHADED;
    } else if( _draw_modes[i] == "Solid (colored per-face, flat shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_FLAT_SHADED;
    } else if( _draw_modes[i] == "Solid (face textured)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE;
    } else if( _draw_modes[i] == "Solid (face textured, shaded)" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE_SHADED;
    } else if( _draw_modes[i] == "Shader controlled" ) {
      drawMode = drawMode | ACG::SceneGraph::DrawModes::SOLID_SHADER;

    }
  }
  
  return drawMode; 
}

/// Convert a drawmode to a vector of QStrings
std::vector< QString > drawModeToDescriptions(unsigned int _drawMode) {
  std::vector< QString > draw_modes;
  
  if ( _drawMode & ACG::SceneGraph::DrawModes::DEFAULT )
    draw_modes.push_back("Default");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_SMOOTH_SHADED)
    draw_modes.push_back("Solid (smooth shaded)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::HIDDENLINE)
    draw_modes.push_back("Hiddenline");
  if ( _drawMode & ACG::SceneGraph::DrawModes::WIREFRAME)
    draw_modes.push_back("Wireframe");
  if ( _drawMode & ACG::SceneGraph::DrawModes::POINTS)
    draw_modes.push_back("Points");
  if ( _drawMode & ACG::SceneGraph::DrawModes::POINTS_COLORED)
    draw_modes.push_back("Points (colored)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::POINTS_SHADED)
    draw_modes.push_back("Points (shaded)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED) 
    draw_modes.push_back("Solid (flat shaded)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_PHONG_SHADED)
    draw_modes.push_back("Solid (Phong shaded)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED)
    draw_modes.push_back("Solid (colored per-vertex)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED)
    draw_modes.push_back("Solid (colored per-face)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED)
    draw_modes.push_back("Solid (colored per-vertex)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_ENV_MAPPED)
    draw_modes.push_back("Solid (environment mapped)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_TEXTURED)
    draw_modes.push_back("Solid (textured)");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_TEXTURED_SHADED)
    draw_modes.push_back("Solid (textured, shaded)");
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_1DTEXTURED)
    draw_modes.push_back("Solid (scalar field)");        
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_1DTEXTURED_SHADED)
    draw_modes.push_back("Solid (scalar field, shaded)");     
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_3DTEXTURED)
    draw_modes.push_back("Solid (3D textured)");             
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_3DTEXTURED_SHADED)
    draw_modes.push_back("Solid (3D textured, shaded)");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED_FLAT_SHADED)
    draw_modes.push_back("Solid (colored per-face, flat shaded)");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE)
    draw_modes.push_back("Solid (face textured)");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_2DTEXTURED_FACE_SHADED)
    draw_modes.push_back("Solid (face textured, shaded)");    
  if ( _drawMode & ACG::SceneGraph::DrawModes::SOLID_SHADER)
    draw_modes.push_back("Shader controlled");    

  return draw_modes;
}
Jan Möbius's avatar
 
Jan Möbius committed
270 271
//=============================================================================