Types.cc 4.56 KB
Newer Older
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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
//=============================================================================
//
//                               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: 3957 $
//   $Author: moebius $
//   $Date: 2008-12-12 15:45:50 +0100 (Fr, 12. Dez 2008) $
//
//=============================================================================




//=============================================================================
//
//  Types
//
//=============================================================================

/**
 * \file Types.cc
 * This File contains the basic functions to handle datatypes
 */


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

#include "Types.hh"
#include <map>


/** This field defines the start id for custom datatypes. It starts high to avoid conflicts with previously
 * hardcoded versions.
 */
static int nextTypeId_ = 2048;

/// Variable used to automatically initialize the maps
static bool initialized_ = false;

/** This map maps an dataType id to an typeName
 */
static std::map< unsigned int, QString > typesToString;

/** This map maps an dataType name to its id
 */
static std::map< QString , unsigned int > StringToType;

class TypeInfo {

  public:

  TypeInfo(DataType _type, QString _name, QString _iconName) :
    type(_type),
    name(_name),
    iconName(_iconName)
  {}

  /// The id of the datatype
  DataType type;

  /// The name of the datatype
  QString  name;

  /// The icon of the datatype
  QString  iconName;
};

static std::vector< TypeInfo > types;

//== Functions =========================================================

void initialize() {
  if ( !initialized_ ) {
    types.push_back( TypeInfo(DATA_NONE            ,"Unknown"        ,"Unknown.png") );
    types.push_back( TypeInfo(DATA_GROUP           ,"Group"          ,"Unknown.png") );
    types.push_back( TypeInfo(DATA_POINTS          ,"Points"         ,"Unknown.png") );

    types.push_back( TypeInfo(DATA_POLY_LINE       ,"PolyLine"       ,"PolyLineType.png") );
    types.push_back( TypeInfo(DATA_TRIANGLE_MESH   ,"TriangleMesh"   ,"TriangleType.png") );
    types.push_back( TypeInfo(DATA_POLY_MESH       ,"PolyMesh"       ,"PolyType.png") );

    types.push_back( TypeInfo(DATA_BSPLINE_CURVE   ,"BSplineCurve"   ,"BSplineCurveType.png") );
    types.push_back( TypeInfo(DATA_VOLUME          ,"Volume"         ,"Unknown.png") );
    types.push_back( TypeInfo(DATA_BSPLINE_SURFACE ,"BSplineSurface" ,"Unknown.png") );

    types.push_back( TypeInfo(DATA_SKELETON        ,"Skeleton"       ,"Unknown.png") );
    types.push_back( TypeInfo(DATA_GIS             ,"GIS"            ,"Unknown.png") );
    types.push_back( TypeInfo(DATA_ALL             ,"All"            ,"Unknown.png") );

    std::cerr << "Todo : Initialize DataType system" << std::endl;
    initialized_ = true;
  }
}

// Adds a datatype and returns the id for the new type
DataType addDataType(QString _name) {
  initialize();
  std::cerr << "addDataType in Types.cc not implemented yet" << std::endl;
  nextTypeId_ *= 2;
  return( nextTypeId_ /2 );
}

DataType typeId(QString _name) {
  initialize();
  std::cerr << "typeId in Types.cc not implemented yet" << std::endl;
  return (DATA_NONE);
}

QString typeIcon(QString  _name) {
  initialize();
  return QString("");
}

QString typeIcon(DataType _id) {
  initialize();
  return QString("");
}

void setTypeIcon( DataType _id   , QString _icon ) {
  initialize();

}

void setTypeIcon( QString  _name , QString _icon ) {
  initialize();

}

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