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

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() {
connect( coreWidget_->examiner_widgets_[i], SIGNAL( viewUpdated() ),
this, SLOT( viewUpdated()) ,Qt::DirectConnection);
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)
QVector< OpenFlipper::Options::RecentFile > recentFiles = OpenFlipper::Options::recentFiles();
for (int i = 0 ; i < recentFiles.size() ; ++i )
if ( recentFiles[i].filename == _action->text() ){
if (recentFiles[i].type == DATA_NONE)
if (recentFiles[i].type == DATA_UNKNOWN)
loadSettings( recentFiles[i].filename );
else{
OpenFlipper::Options::loadingRecentFile(true);
......@@ -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)"),
QString(tr("Name,Toolbox List")).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)"),
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"),
QString(tr("Selection type,Object types")).split(","),
......
......@@ -163,7 +163,7 @@ void Core::preprocessObjFile(QString _filename)
// find out data type
DataType dataType = DATA_NONE;
DataType dataType = DATA_UNKNOWN;
std::string fname = _filename.toStdString();
std::fstream in(fname.c_str(), std::ios_base::in);
......
......@@ -167,7 +167,7 @@ int Core::loadObject ( QString _filename ) {
openIniFile(_filename,true,true,true);
if ( OpenFlipper::Options::gui() )
coreWidget_->addRecent(_filename, DATA_NONE);
coreWidget_->addRecent(_filename, DATA_UNKNOWN);
return -2;
} else
......@@ -183,7 +183,7 @@ int Core::loadObject ( QString _filename ) {
/// Function for loading a given file
int Core::loadObject( DataType _type, QString _filename) {
if (_type == DATA_NONE)
if (_type == DATA_UNKNOWN)
return loadObject(_filename);
for (int i=0; i < (int)supportedTypes_.size(); i++)
......@@ -278,48 +278,48 @@ void Core::slotCopyObject( int _oldId , int& _newId ) {
/// Slot for loading a given file
void Core::slotLoad(QString _filename, DataType _type, int& _id) {
_id = loadObject(_type,_filename);
// Check if it is a polymesh
if ( _type == DATA_POLY_MESH ) {
PolyMeshObject* poly = 0;
PluginFunctions::getObject(_id,poly);
if ( poly != 0 ) {
PolyMesh& mesh = *poly->mesh();
bool isTriangleMesh = true;
for ( PolyMesh::FaceIter f_it = mesh.faces_begin(); f_it != mesh.faces_end() ; ++f_it) {
// Count number of vertices for the current face
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;
// Check if it is a triangle. If not, this is really a poly mesh
if ( count != 3 ) {
isTriangleMesh = false;
break;
}
}
// 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 ) {
QMessageBox::StandardButton result = QMessageBox::question ( 0,
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?"),
(QMessageBox::Yes | QMessageBox::No ),
QMessageBox::StandardButton result = QMessageBox::question ( 0,
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?"),
(QMessageBox::Yes | QMessageBox::No ),
QMessageBox::Yes );
// User decided to reload as triangle mesh
// User decided to reload as triangle mesh
if ( result == QMessageBox::Yes ) {
slotDeleteObject(_id);
_id = loadObject(DATA_TRIANGLE_MESH ,_filename);
_type = DATA_TRIANGLE_MESH;
}
}
}
}
if ( _id < 0 )
......@@ -596,7 +596,7 @@ void Core::loadSettings(){
applyOptions();
}
coreWidget_->addRecent(complete_name, DATA_NONE);
coreWidget_->addRecent(complete_name, DATA_UNKNOWN);
}
}
......
......@@ -251,6 +251,6 @@ void Core::saveSettings(){
//add to recent files
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) {
BaseObject::BaseObject(BaseObject* _parent) :
id_(-1),
persistentId_(-1),
objectType_(DATA_NONE),
objectType_(DATA_UNKNOWN),
flags_(),
visible_(true),
parentItem_(_parent),
......@@ -123,7 +123,7 @@ void BaseObject::persistentId( int _id ) {
void BaseObject::cleanup() {
persistentId_ = -1;
objectType_ = DATA_NONE;
objectType_ = DATA_UNKNOWN;
flags_.clear();
......@@ -148,7 +148,7 @@ DataType BaseObject::dataType() {
}
void BaseObject::setDataType(DataType _type) {
if ( objectType_ != DATA_NONE )
if ( objectType_ != DATA_UNKNOWN )
std::cerr << "BaseObect : overwriting data type" << std::endl;
objectType_ = _type;
}
......
......@@ -105,9 +105,9 @@ class TypeInfo {
/// The icon of the datatype
QString iconName;
/// Human readable name
QString readableName;
QString readableName;
};
static std::vector< TypeInfo > types;
......@@ -117,8 +117,8 @@ static std::vector< TypeInfo > types;
void initialize() {
if ( !initialized_ ) {
stringToTypeInfo["Unknown"] = types.size();
typeToTypeInfo[DATA_NONE] = types.size();
types.push_back( TypeInfo(DATA_NONE ,"Unknown" ,"Unknown.png", QCoreApplication::translate("Types","Unknown")) );
typeToTypeInfo[DATA_UNKNOWN] = types.size();
types.push_back( TypeInfo(DATA_UNKNOWN ,"Unknown" ,"Unknown.png", QCoreApplication::translate("Types","Unknown")) );
stringToTypeInfo["Group"] = types.size();
typeToTypeInfo[DATA_GROUP] = types.size();
......@@ -136,7 +136,7 @@ void initialize() {
typeToTypeInfo[DATA_ALL] = types.size();
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_TRIANGLE_MESH_CONST_ID] = "TriangleMesh";
typeToString[DATA_POLY_MESH_CONST_ID] = "PolyMesh";
......@@ -174,7 +174,7 @@ DataType typeId(QString _name) {
#ifdef DEBUG
std::cerr << "Unknown Data type with name " << _name.toStdString() << std::endl;
#endif
return -1;
return DATA_UNKNOWN;
}
}
......@@ -252,8 +252,8 @@ QString dataTypeName( DataType _id ) {
if ( index != typeToTypeInfo.end() )
return types[ index->second ].readableName ;
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"));
}
......@@ -266,8 +266,8 @@ QString dataTypeName( QString _typeName ) {
if ( index != stringToTypeInfo.end() )
return types[ index->second ].readableName ;
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"));
}
......@@ -282,8 +282,7 @@ void setDataTypeName( DataType _id , QString _name ) {
if ( index != typeToTypeInfo.end() )
types[ index->second ].readableName = _name;
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
......@@ -295,9 +294,7 @@ void setDataTypeName( QString _typeName , QString _name ) {
if ( index != stringToTypeInfo.end() )
types[ index->second ].readableName = _name;
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 @@
/** \brief Predefined datatypes
*
* 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
#define DATA_NONE 0
#define DATA_UNKNOWN 0
/// Items used for Grouping
#define DATA_GROUP 1
......@@ -121,7 +121,7 @@ typedef std::vector<BaseObjectData*> DataContainer;
//================================================================================================
/** Adds a datatype and returns the id for the new type
*
*
* @param _name Internal name for the new DataType
* @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
typeNames_(_typeNames)
{
setupUi(this);
typeBox->setDuplicatesEnabled(false);
for (int i=0; i < (int)types_.size(); i++)
typeBox->addItem(typeNames_[i],QVariant(types_[i]));
//set last used DataType as currentItem
for (int i=0; i < typeBox->count(); i++)
if (typeBox->itemText(i) == OpenFlipper::Options::lastDataType())
typeBox->setCurrentIndex(i);
connect(cancelButton,SIGNAL(clicked()),this,SLOT(close()));
connect(addButton,SIGNAL(clicked()),this,SLOT(slotAddEmpty()));
}
......@@ -70,7 +70,7 @@ addEmptyWidget::addEmptyWidget(std::vector< DataType > _types , QStringList _typ
void addEmptyWidget::slotAddEmpty(){
int index = typeBox->currentIndex();
int unused;
DataType type = (DataType) typeBox->itemData(index).toInt();
for (int i=0; i < (int)types_.size(); i++)
if (types_[i] == type){
......@@ -79,6 +79,6 @@ void addEmptyWidget::slotAddEmpty(){
this->close();
return;
}
emit chosen(DATA_NONE,unused);
emit chosen(DATA_UNKNOWN,unused);
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