Commit 0ea3cdf0 authored by Mike Kremer's avatar Mike Kremer
Browse files

Changed DATA_NONE to DATA_UNKNOWN. Replaced all occurrences of it. If a data...

Changed DATA_NONE to DATA_UNKNOWN. Replaced all occurrences of it. If a data type is not found, typeId() now returns DATA_UNKNOWN instead of -1 which formerly returned UINT max since it was casted to an unsigned int.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7306 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b748b9bd
...@@ -474,9 +474,9 @@ Core::init() { ...@@ -474,9 +474,9 @@ Core::init() {
connect( coreWidget_->examiner_widgets_[i], SIGNAL( viewUpdated() ), connect( coreWidget_->examiner_widgets_[i], SIGNAL( viewUpdated() ),
this, SLOT( viewUpdated()) ,Qt::DirectConnection); this, SLOT( viewUpdated()) ,Qt::DirectConnection);
connect( coreWidget_->examiner_widgets_[i], SIGNAL( viewChanged() ), connect( coreWidget_->examiner_widgets_[i], SIGNAL( viewChanged() ),
this, SIGNAL( pluginViewChanged() ) ,Qt::DirectConnection); this, SIGNAL( pluginViewChanged() ) ,Qt::DirectConnection);
} }
} }
...@@ -865,7 +865,7 @@ Core::slotRecentOpen(QAction* _action) ...@@ -865,7 +865,7 @@ Core::slotRecentOpen(QAction* _action)
QVector< OpenFlipper::Options::RecentFile > recentFiles = OpenFlipper::Options::recentFiles(); QVector< OpenFlipper::Options::RecentFile > recentFiles = OpenFlipper::Options::recentFiles();
for (int i = 0 ; i < recentFiles.size() ; ++i ) for (int i = 0 ; i < recentFiles.size() ; ++i )
if ( recentFiles[i].filename == _action->text() ){ if ( recentFiles[i].filename == _action->text() ){
if (recentFiles[i].type == DATA_NONE) if (recentFiles[i].type == DATA_UNKNOWN)
loadSettings( recentFiles[i].filename ); loadSettings( recentFiles[i].filename );
else{ else{
OpenFlipper::Options::loadingRecentFile(true); OpenFlipper::Options::loadingRecentFile(true);
...@@ -1243,10 +1243,10 @@ void Core::setDescriptions(){ ...@@ -1243,10 +1243,10 @@ void Core::setDescriptions(){
emit setSlotDescription("addViewModeToolboxes(QString,QString)", tr("Set toolboxes for a viewmode (This automatically adds the view mode if it does not exist)"), emit setSlotDescription("addViewModeToolboxes(QString,QString)", tr("Set toolboxes for a viewmode (This automatically adds the view mode if it does not exist)"),
QString(tr("Name,Toolbox List")).split(","), QString(tr("Name,Toolbox List")).split(","),
QString(tr("Name of the Viewmode, ; seperated list of toolboxes visible in this viewmode")).split(",")); QString(tr("Name of the Viewmode, ; seperated list of toolboxes visible in this viewmode")).split(","));
emit setSlotDescription("addViewModeToolbars(QString,QString)", tr("Set toolbars for a viewmode (This automatically adds the view mode if it does not exist)"), emit setSlotDescription("addViewModeToolbars(QString,QString)", tr("Set toolbars for a viewmode (This automatically adds the view mode if it does not exist)"),
QString(tr("Name,Toolbar List")).split(","), QString(tr("Name,Toolbar List")).split(","),
QString(tr("Name of the Viewmode, ; seperated list of toolbars visible in this viewmode")).split(",")); QString(tr("Name of the Viewmode, ; seperated list of toolbars visible in this viewmode")).split(","));
emit setSlotDescription("objectList(QString,QStringList)", tr("Returns object list"), emit setSlotDescription("objectList(QString,QStringList)", tr("Returns object list"),
QString(tr("Selection type,Object types")).split(","), QString(tr("Selection type,Object types")).split(","),
......
...@@ -163,7 +163,7 @@ void Core::preprocessObjFile(QString _filename) ...@@ -163,7 +163,7 @@ void Core::preprocessObjFile(QString _filename)
// find out data type // find out data type
DataType dataType = DATA_NONE; DataType dataType = DATA_UNKNOWN;
std::string fname = _filename.toStdString(); std::string fname = _filename.toStdString();
std::fstream in(fname.c_str(), std::ios_base::in); std::fstream in(fname.c_str(), std::ios_base::in);
......
...@@ -167,7 +167,7 @@ int Core::loadObject ( QString _filename ) { ...@@ -167,7 +167,7 @@ int Core::loadObject ( QString _filename ) {
openIniFile(_filename,true,true,true); openIniFile(_filename,true,true,true);
if ( OpenFlipper::Options::gui() ) if ( OpenFlipper::Options::gui() )
coreWidget_->addRecent(_filename, DATA_NONE); coreWidget_->addRecent(_filename, DATA_UNKNOWN);
return -2; return -2;
} else } else
...@@ -183,7 +183,7 @@ int Core::loadObject ( QString _filename ) { ...@@ -183,7 +183,7 @@ int Core::loadObject ( QString _filename ) {
/// Function for loading a given file /// Function for loading a given file
int Core::loadObject( DataType _type, QString _filename) { int Core::loadObject( DataType _type, QString _filename) {
if (_type == DATA_NONE) if (_type == DATA_UNKNOWN)
return loadObject(_filename); return loadObject(_filename);
for (int i=0; i < (int)supportedTypes_.size(); i++) for (int i=0; i < (int)supportedTypes_.size(); i++)
...@@ -278,48 +278,48 @@ void Core::slotCopyObject( int _oldId , int& _newId ) { ...@@ -278,48 +278,48 @@ void Core::slotCopyObject( int _oldId , int& _newId ) {
/// Slot for loading a given file /// Slot for loading a given file
void Core::slotLoad(QString _filename, DataType _type, int& _id) { void Core::slotLoad(QString _filename, DataType _type, int& _id) {
_id = loadObject(_type,_filename); _id = loadObject(_type,_filename);
// Check if it is a polymesh // Check if it is a polymesh
if ( _type == DATA_POLY_MESH ) { if ( _type == DATA_POLY_MESH ) {
PolyMeshObject* poly = 0; PolyMeshObject* poly = 0;
PluginFunctions::getObject(_id,poly); PluginFunctions::getObject(_id,poly);
if ( poly != 0 ) { if ( poly != 0 ) {
PolyMesh& mesh = *poly->mesh(); PolyMesh& mesh = *poly->mesh();
bool isTriangleMesh = true; bool isTriangleMesh = true;
for ( PolyMesh::FaceIter f_it = mesh.faces_begin(); f_it != mesh.faces_end() ; ++f_it) { for ( PolyMesh::FaceIter f_it = mesh.faces_begin(); f_it != mesh.faces_end() ; ++f_it) {
// Count number of vertices for the current face // Count number of vertices for the current face
uint count = 0; uint count = 0;
for ( PolyMesh::FaceVertexIter fv_it( mesh,f_it); fv_it; ++fv_it ) for ( PolyMesh::FaceVertexIter fv_it( mesh,f_it); fv_it; ++fv_it )
++count; ++count;
// Check if it is a triangle. If not, this is really a poly mesh // Check if it is a triangle. If not, this is really a poly mesh
if ( count != 3 ) { if ( count != 3 ) {
isTriangleMesh = false; isTriangleMesh = false;
break; break;
} }
} }
// Mesh loaded as polymesh is actually a triangle mesh. Ask the user to reload as triangle mesh or keep it as poly mesh. // Mesh loaded as polymesh is actually a triangle mesh. Ask the user to reload as triangle mesh or keep it as poly mesh.
if ( isTriangleMesh ) { if ( isTriangleMesh ) {
QMessageBox::StandardButton result = QMessageBox::question ( 0, QMessageBox::StandardButton result = QMessageBox::question ( 0,
tr("TriMesh loaded as PolyMesh"), tr("TriMesh loaded as PolyMesh"),
tr("You opened the mesh as a poly mesh but actually its a triangle mesh. \nShould it be opened as a triangle mesh?"), tr("You opened the mesh as a poly mesh but actually its a triangle mesh. \nShould it be opened as a triangle mesh?"),
(QMessageBox::Yes | QMessageBox::No ), (QMessageBox::Yes | QMessageBox::No ),
QMessageBox::Yes ); QMessageBox::Yes );
// User decided to reload as triangle mesh // User decided to reload as triangle mesh
if ( result == QMessageBox::Yes ) { if ( result == QMessageBox::Yes ) {
slotDeleteObject(_id); slotDeleteObject(_id);
_id = loadObject(DATA_TRIANGLE_MESH ,_filename); _id = loadObject(DATA_TRIANGLE_MESH ,_filename);
_type = DATA_TRIANGLE_MESH; _type = DATA_TRIANGLE_MESH;
} }
} }
} }
} }
if ( _id < 0 ) if ( _id < 0 )
...@@ -596,7 +596,7 @@ void Core::loadSettings(){ ...@@ -596,7 +596,7 @@ void Core::loadSettings(){
applyOptions(); applyOptions();
} }
coreWidget_->addRecent(complete_name, DATA_NONE); coreWidget_->addRecent(complete_name, DATA_UNKNOWN);
} }
} }
......
...@@ -251,6 +251,6 @@ void Core::saveSettings(){ ...@@ -251,6 +251,6 @@ void Core::saveSettings(){
//add to recent files //add to recent files
if ( OpenFlipper::Options::gui() ) if ( OpenFlipper::Options::gui() )
coreWidget_->addRecent( complete_name, DATA_NONE ); coreWidget_->addRecent( complete_name, DATA_UNKNOWN );
} }
...@@ -83,7 +83,7 @@ BaseObject::BaseObject(const BaseObject& _object) { ...@@ -83,7 +83,7 @@ BaseObject::BaseObject(const BaseObject& _object) {
BaseObject::BaseObject(BaseObject* _parent) : BaseObject::BaseObject(BaseObject* _parent) :
id_(-1), id_(-1),
persistentId_(-1), persistentId_(-1),
objectType_(DATA_NONE), objectType_(DATA_UNKNOWN),
flags_(), flags_(),
visible_(true), visible_(true),
parentItem_(_parent), parentItem_(_parent),
...@@ -123,7 +123,7 @@ void BaseObject::persistentId( int _id ) { ...@@ -123,7 +123,7 @@ void BaseObject::persistentId( int _id ) {
void BaseObject::cleanup() { void BaseObject::cleanup() {
persistentId_ = -1; persistentId_ = -1;
objectType_ = DATA_NONE; objectType_ = DATA_UNKNOWN;
flags_.clear(); flags_.clear();
...@@ -148,7 +148,7 @@ DataType BaseObject::dataType() { ...@@ -148,7 +148,7 @@ DataType BaseObject::dataType() {
} }
void BaseObject::setDataType(DataType _type) { void BaseObject::setDataType(DataType _type) {
if ( objectType_ != DATA_NONE ) if ( objectType_ != DATA_UNKNOWN )
std::cerr << "BaseObect : overwriting data type" << std::endl; std::cerr << "BaseObect : overwriting data type" << std::endl;
objectType_ = _type; objectType_ = _type;
} }
......
...@@ -105,9 +105,9 @@ class TypeInfo { ...@@ -105,9 +105,9 @@ class TypeInfo {
/// The icon of the datatype /// The icon of the datatype
QString iconName; QString iconName;
/// Human readable name /// Human readable name
QString readableName; QString readableName;
}; };
static std::vector< TypeInfo > types; static std::vector< TypeInfo > types;
...@@ -117,8 +117,8 @@ static std::vector< TypeInfo > types; ...@@ -117,8 +117,8 @@ static std::vector< TypeInfo > types;
void initialize() { void initialize() {
if ( !initialized_ ) { if ( !initialized_ ) {
stringToTypeInfo["Unknown"] = types.size(); stringToTypeInfo["Unknown"] = types.size();
typeToTypeInfo[DATA_NONE] = types.size(); typeToTypeInfo[DATA_UNKNOWN] = types.size();
types.push_back( TypeInfo(DATA_NONE ,"Unknown" ,"Unknown.png", QCoreApplication::translate("Types","Unknown")) ); types.push_back( TypeInfo(DATA_UNKNOWN ,"Unknown" ,"Unknown.png", QCoreApplication::translate("Types","Unknown")) );
stringToTypeInfo["Group"] = types.size(); stringToTypeInfo["Group"] = types.size();
typeToTypeInfo[DATA_GROUP] = types.size(); typeToTypeInfo[DATA_GROUP] = types.size();
...@@ -136,7 +136,7 @@ void initialize() { ...@@ -136,7 +136,7 @@ void initialize() {
typeToTypeInfo[DATA_ALL] = types.size(); typeToTypeInfo[DATA_ALL] = types.size();
types.push_back( TypeInfo(DATA_ALL ,"All" ,"Unknown.png", QCoreApplication::translate("Types","All")) ); types.push_back( TypeInfo(DATA_ALL ,"All" ,"Unknown.png", QCoreApplication::translate("Types","All")) );
typeToString[DATA_NONE] = "Unknown"; typeToString[DATA_UNKNOWN] = "Unknown";
typeToString[DATA_GROUP] = "Group"; typeToString[DATA_GROUP] = "Group";
typeToString[DATA_TRIANGLE_MESH_CONST_ID] = "TriangleMesh"; typeToString[DATA_TRIANGLE_MESH_CONST_ID] = "TriangleMesh";
typeToString[DATA_POLY_MESH_CONST_ID] = "PolyMesh"; typeToString[DATA_POLY_MESH_CONST_ID] = "PolyMesh";
...@@ -174,7 +174,7 @@ DataType typeId(QString _name) { ...@@ -174,7 +174,7 @@ DataType typeId(QString _name) {
#ifdef DEBUG #ifdef DEBUG
std::cerr << "Unknown Data type with name " << _name.toStdString() << std::endl; std::cerr << "Unknown Data type with name " << _name.toStdString() << std::endl;
#endif #endif
return -1; return DATA_UNKNOWN;
} }
} }
...@@ -252,8 +252,8 @@ QString dataTypeName( DataType _id ) { ...@@ -252,8 +252,8 @@ QString dataTypeName( DataType _id ) {
if ( index != typeToTypeInfo.end() ) if ( index != typeToTypeInfo.end() )
return types[ index->second ].readableName ; return types[ index->second ].readableName ;
else else
std::cerr << "Could not get human name for DataType. Type not found!" << std::endl; std::cerr << "Could not get human name for DataType. Type not found!" << std::endl;
return QString(QCoreApplication::translate("Types","Unknown Type")); return QString(QCoreApplication::translate("Types","Unknown Type"));
} }
...@@ -266,8 +266,8 @@ QString dataTypeName( QString _typeName ) { ...@@ -266,8 +266,8 @@ QString dataTypeName( QString _typeName ) {
if ( index != stringToTypeInfo.end() ) if ( index != stringToTypeInfo.end() )
return types[ index->second ].readableName ; return types[ index->second ].readableName ;
else else
std::cerr << "Could not get human name for DataType. Type not found!" << std::endl; std::cerr << "Could not get human name for DataType. Type not found!" << std::endl;
return QString(QCoreApplication::translate("Types","Unknown Type")); return QString(QCoreApplication::translate("Types","Unknown Type"));
} }
...@@ -282,8 +282,7 @@ void setDataTypeName( DataType _id , QString _name ) { ...@@ -282,8 +282,7 @@ void setDataTypeName( DataType _id , QString _name ) {
if ( index != typeToTypeInfo.end() ) if ( index != typeToTypeInfo.end() )
types[ index->second ].readableName = _name; types[ index->second ].readableName = _name;
else else
std::cerr << "Could not set human name for DataType. Type not found!" << std::endl; std::cerr << "Could not set human name for DataType. Type not found!" << std::endl;
} }
/// Set the icon for a given dataType /// Set the icon for a given dataType
...@@ -295,9 +294,7 @@ void setDataTypeName( QString _typeName , QString _name ) { ...@@ -295,9 +294,7 @@ void setDataTypeName( QString _typeName , QString _name ) {
if ( index != stringToTypeInfo.end() ) if ( index != stringToTypeInfo.end() )
types[ index->second ].readableName = _name; types[ index->second ].readableName = _name;
else else
std::cerr << "Could not set human name for DataType. Type not found!" << std::endl; std::cerr << "Could not set human name for DataType. Type not found!" << std::endl;
} }
//============================================================================= //=============================================================================
......
...@@ -68,11 +68,11 @@ ...@@ -68,11 +68,11 @@
/** \brief Predefined datatypes /** \brief Predefined datatypes
* *
* Here are several datatypes which have predefined ids. This might be changed to runtime added * Here are several datatypes which have predefined ids. This might be changed to runtime added
* datatypes in the futere. * datatypes in the future.
*/ */
/// None of the other Objects /// None of the other Objects
#define DATA_NONE 0 #define DATA_UNKNOWN 0
/// Items used for Grouping /// Items used for Grouping
#define DATA_GROUP 1 #define DATA_GROUP 1
...@@ -121,7 +121,7 @@ typedef std::vector<BaseObjectData*> DataContainer; ...@@ -121,7 +121,7 @@ typedef std::vector<BaseObjectData*> DataContainer;
//================================================================================================ //================================================================================================
/** Adds a datatype and returns the id for the new type /** Adds a datatype and returns the id for the new type
* *
* @param _name Internal name for the new DataType * @param _name Internal name for the new DataType
* @param _readableName Human readable Name for this type ( Use tr to make it translatable ) * @param _readableName Human readable Name for this type ( Use tr to make it translatable )
*/ */
......
...@@ -52,17 +52,17 @@ addEmptyWidget::addEmptyWidget(std::vector< DataType > _types , QStringList _typ ...@@ -52,17 +52,17 @@ addEmptyWidget::addEmptyWidget(std::vector< DataType > _types , QStringList _typ
typeNames_(_typeNames) typeNames_(_typeNames)
{ {
setupUi(this); setupUi(this);
typeBox->setDuplicatesEnabled(false); typeBox->setDuplicatesEnabled(false);
for (int i=0; i < (int)types_.size(); i++) for (int i=0; i < (int)types_.size(); i++)
typeBox->addItem(typeNames_[i],QVariant(types_[i])); typeBox->addItem(typeNames_[i],QVariant(types_[i]));
//set last used DataType as currentItem //set last used DataType as currentItem
for (int i=0; i < typeBox->count(); i++) for (int i=0; i < typeBox->count(); i++)
if (typeBox->itemText(i) == OpenFlipper::Options::lastDataType()) if (typeBox->itemText(i) == OpenFlipper::Options::lastDataType())
typeBox->setCurrentIndex(i); typeBox->setCurrentIndex(i);
connect(cancelButton,SIGNAL(clicked()),this,SLOT(close())); connect(cancelButton,SIGNAL(clicked()),this,SLOT(close()));
connect(addButton,SIGNAL(clicked()),this,SLOT(slotAddEmpty())); connect(addButton,SIGNAL(clicked()),this,SLOT(slotAddEmpty()));
} }
...@@ -70,7 +70,7 @@ addEmptyWidget::addEmptyWidget(std::vector< DataType > _types , QStringList _typ ...@@ -70,7 +70,7 @@ addEmptyWidget::addEmptyWidget(std::vector< DataType > _types , QStringList _typ
void addEmptyWidget::slotAddEmpty(){ void addEmptyWidget::slotAddEmpty(){
int index = typeBox->currentIndex(); int index = typeBox->currentIndex();
int unused; int unused;
DataType type = (DataType) typeBox->itemData(index).toInt(); DataType type = (DataType) typeBox->itemData(index).toInt();
for (int i=0; i < (int)types_.size(); i++) for (int i=0; i < (int)types_.size(); i++)
if (types_[i] == type){ if (types_[i] == type){
...@@ -79,6 +79,6 @@ void addEmptyWidget::slotAddEmpty(){ ...@@ -79,6 +79,6 @@ void addEmptyWidget::slotAddEmpty(){
this->close(); this->close();
return; return;
} }
emit chosen(DATA_NONE,unused); emit chosen(DATA_UNKNOWN,unused);
this->close(); this->close();
} }
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