use specialized exception classes
This commit is contained in:
+23
-23
@@ -300,7 +300,7 @@ void Application::renameDocument(const char *OldName, const char *NewName)
|
||||
signalRenameDocument(*temp);
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("Application::renameDocument(): no document with this name to rename!");
|
||||
throw Base::RuntimeError("Application::renameDocument(): no document with this name to rename!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ Document* Application::openDocument(const char * FileName)
|
||||
if (!File.exists()) {
|
||||
std::stringstream str;
|
||||
str << "File '" << FileName << "' does not exist!";
|
||||
throw Base::Exception(str.str().c_str());
|
||||
throw Base::FileSystemError(str.str().c_str());
|
||||
}
|
||||
|
||||
// Before creating a new document we check whether the document is already open
|
||||
@@ -460,7 +460,7 @@ Document* Application::openDocument(const char * FileName)
|
||||
if (filepath == fi) {
|
||||
std::stringstream str;
|
||||
str << "The project '" << FileName << "' is already open!";
|
||||
throw Base::Exception(str.str().c_str());
|
||||
throw Base::FileSystemError(str.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ void Application::setActiveDocument(const char *Name)
|
||||
else {
|
||||
std::stringstream s;
|
||||
s << "Try to activate unknown document '" << Name << "'";
|
||||
throw Base::Exception(s.str());
|
||||
throw Base::RuntimeError(s.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,7 +649,7 @@ Base::Reference<ParameterGrp> Application::GetParameterGroupByPath(const char*
|
||||
|
||||
// is there a path seperator ?
|
||||
if (pos == std::string::npos) {
|
||||
throw Base::Exception("Application::GetParameterGroupByPath() no parameter set name specified");
|
||||
throw Base::ValueError("Application::GetParameterGroupByPath() no parameter set name specified");
|
||||
}
|
||||
// assigning the parameter set name
|
||||
cTemp.assign(cName,0,pos);
|
||||
@@ -658,7 +658,7 @@ Base::Reference<ParameterGrp> Application::GetParameterGroupByPath(const char*
|
||||
// test if name is valid
|
||||
std::map<std::string,ParameterManager *>::iterator It = mpcPramManager.find(cTemp.c_str());
|
||||
if (It == mpcPramManager.end())
|
||||
throw Base::Exception("Application::GetParameterGroupByPath() unknown parameter set name specified");
|
||||
throw Base::ValueError("Application::GetParameterGroupByPath() unknown parameter set name specified");
|
||||
|
||||
return It->second->GetGroup(cName.c_str());
|
||||
}
|
||||
@@ -1070,13 +1070,13 @@ void segmentation_fault_handler(int sig)
|
||||
case SIGSEGV:
|
||||
std::cerr << "Illegal storage access..." << std::endl;
|
||||
#if !defined(_DEBUG)
|
||||
throw Base::Exception("Illegal storage access! Please save your work under a new file name and restart the application!");
|
||||
throw Base::AccessViolation("Illegal storage access! Please save your work under a new file name and restart the application!");
|
||||
#endif
|
||||
break;
|
||||
case SIGABRT:
|
||||
std::cerr << "Abnormal program termination..." << std::endl;
|
||||
#if !defined(_DEBUG)
|
||||
throw Base::Exception("Break signal occoured");
|
||||
throw Base::AbnormalProgramTermination("Break signal occoured");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
@@ -1095,7 +1095,7 @@ void unexpection_error_handler()
|
||||
std::cerr << "Unexpected error occurred..." << std::endl;
|
||||
// try to throw an exception and give the user chance to save their work
|
||||
#if !defined(_DEBUG)
|
||||
throw Base::Exception("Unexpected error occurred! Please save your work under a new file name and restart the application!");
|
||||
throw Base::AbnormalProgramTermination("Unexpected error occurred! Please save your work under a new file name and restart the application!");
|
||||
#else
|
||||
terminate();
|
||||
#endif
|
||||
@@ -1110,12 +1110,12 @@ void my_trans_func( unsigned int code, EXCEPTION_POINTERS* pExp )
|
||||
//{
|
||||
// case FLT_DIVIDE_BY_ZERO :
|
||||
// //throw CMyFunkyDivideByZeroException(code, pExp);
|
||||
// throw Base::Exception("Devision by zero!");
|
||||
// throw Base::DivisionByZeroError("Devision by zero!");
|
||||
// break;
|
||||
//}
|
||||
|
||||
// general C++ SEH exception for things we don't need to handle separately....
|
||||
throw Base::Exception("my_trans_func()");
|
||||
throw Base::RuntimeError("my_trans_func()");
|
||||
}
|
||||
#endif
|
||||
void Application::init(int argc, char ** argv)
|
||||
@@ -2022,7 +2022,7 @@ void Application::ExtractUserPath()
|
||||
// Default paths for the user specific stuff
|
||||
struct passwd *pwd = getpwuid(getuid());
|
||||
if (pwd == NULL)
|
||||
throw Base::Exception("Getting HOME path from system failed!");
|
||||
throw Base::RuntimeError("Getting HOME path from system failed!");
|
||||
mConfig["UserHomePath"] = pwd->pw_dir;
|
||||
|
||||
char *path = pwd->pw_dir;
|
||||
@@ -2040,7 +2040,7 @@ void Application::ExtractUserPath()
|
||||
// This should never ever happen
|
||||
std::stringstream str;
|
||||
str << "Application data directory " << appData << " does not exist!";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
|
||||
// In order to write into our data path, we must create some directories, first.
|
||||
@@ -2057,7 +2057,7 @@ void Application::ExtractUserPath()
|
||||
error += appData;
|
||||
// Want more details on console
|
||||
std::cerr << error << std::endl;
|
||||
throw Base::Exception(error);
|
||||
throw Base::FileSystemError(error);
|
||||
}
|
||||
}
|
||||
appData += PATHSEP;
|
||||
@@ -2071,7 +2071,7 @@ void Application::ExtractUserPath()
|
||||
error += appData;
|
||||
// Want more details on console
|
||||
std::cerr << error << std::endl;
|
||||
throw Base::Exception(error);
|
||||
throw Base::FileSystemError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2084,7 +2084,7 @@ void Application::ExtractUserPath()
|
||||
// Default paths for the user specific stuff on the platform
|
||||
struct passwd *pwd = getpwuid(getuid());
|
||||
if (pwd == NULL)
|
||||
throw Base::Exception("Getting HOME path from system failed!");
|
||||
throw Base::RuntimeError("Getting HOME path from system failed!");
|
||||
mConfig["UserHomePath"] = pwd->pw_dir;
|
||||
std::string appData = pwd->pw_dir;
|
||||
appData += PATHSEP;
|
||||
@@ -2096,7 +2096,7 @@ void Application::ExtractUserPath()
|
||||
// This should never ever happen
|
||||
std::stringstream str;
|
||||
str << "Application data directory " << appData << " does not exist!";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
|
||||
// In order to write to our data path, we must create some directories, first.
|
||||
@@ -2112,7 +2112,7 @@ void Application::ExtractUserPath()
|
||||
error += appData;
|
||||
// Want more details on console
|
||||
std::cerr << error << std::endl;
|
||||
throw Base::Exception(error);
|
||||
throw Base::FileSystemError(error);
|
||||
}
|
||||
}
|
||||
appData += PATHSEP;
|
||||
@@ -2126,7 +2126,7 @@ void Application::ExtractUserPath()
|
||||
error += appData;
|
||||
// Want more details on console
|
||||
std::cerr << error << std::endl;
|
||||
throw Base::Exception(error);
|
||||
throw Base::FileSystemError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2161,7 +2161,7 @@ void Application::ExtractUserPath()
|
||||
// This should never ever happen
|
||||
std::stringstream str;
|
||||
str << "Application data directory " << appData << " does not exist!";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
|
||||
// In order to write to our data path we must create some directories first.
|
||||
@@ -2177,7 +2177,7 @@ void Application::ExtractUserPath()
|
||||
error += appData;
|
||||
// Want more details on console
|
||||
std::cerr << error << std::endl;
|
||||
throw Base::Exception(error);
|
||||
throw Base::FileSystemError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2191,7 +2191,7 @@ void Application::ExtractUserPath()
|
||||
error += appData;
|
||||
// Want more details on console
|
||||
std::cerr << error << std::endl;
|
||||
throw Base::Exception(error);
|
||||
throw Base::FileSystemError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2260,7 +2260,7 @@ std::string Application::FindHomePath(const char* sCall)
|
||||
int nchars = readlink("/proc/self/exe", resolved, PATH_MAX);
|
||||
#endif
|
||||
if (nchars < 0 || nchars >= PATH_MAX)
|
||||
throw Base::Exception("Cannot determine the absolute path of the executable");
|
||||
throw Base::FileSystemError("Cannot determine the absolute path of the executable");
|
||||
resolved[nchars] = '\0'; // enfore null termination
|
||||
absPath = resolved;
|
||||
}
|
||||
|
||||
@@ -1747,7 +1747,7 @@ Document::getDependencyList(const std::vector<App::DocumentObject*>& objs) const
|
||||
std::stringstream ss;
|
||||
ss << "Gathering all dependencies failed, probably due to circular dependencies. Error: ";
|
||||
ss << e.what();
|
||||
throw Base::Exception(ss.str().c_str());
|
||||
throw Base::RuntimeError(ss.str().c_str());
|
||||
}
|
||||
|
||||
std::set<Vertex> out;
|
||||
|
||||
@@ -207,7 +207,7 @@ void _getInListRecursive(std::vector<DocumentObject*>& objSet, const DocumentObj
|
||||
// if the check object is in the recursive inList we have a cycle!
|
||||
if (objIt == checkObj || depth <= 0){
|
||||
std::cerr << "DocumentObject::getInListRecursive(): cyclic dependency detected!"<<std::endl;
|
||||
throw Base::Exception("DocumentObject::getInListRecursive(): cyclic dependency detected!");
|
||||
throw Base::RuntimeError("DocumentObject::getInListRecursive(): cyclic dependency detected!");
|
||||
}
|
||||
|
||||
objSet.push_back(objIt);
|
||||
@@ -239,7 +239,7 @@ void _getOutListRecursive(std::vector<DocumentObject*>& objSet, const DocumentOb
|
||||
// if the check object is in the recursive inList we have a cycle!
|
||||
if (objIt == checkObj || depth <= 0){
|
||||
std::cerr << "DocumentObject::getOutListRecursive(): cyclic dependency detected!" << std::endl;
|
||||
throw Base::Exception("DocumentObject::getOutListRecursive(): cyclic dependency detected!");
|
||||
throw Base::RuntimeError("DocumentObject::getOutListRecursive(): cyclic dependency detected!");
|
||||
}
|
||||
objSet.push_back(objIt);
|
||||
_getOutListRecursive(objSet, objIt, checkObj,depth-1);
|
||||
@@ -280,7 +280,7 @@ bool DocumentObject::testIfLinkDAGCompatible(const std::vector<DocumentObject *>
|
||||
{
|
||||
Document* doc = this->getDocument();
|
||||
if (!doc)
|
||||
throw Base::Exception("DocumentObject::testIfLinkIsDAG: object is not in any document.");
|
||||
throw Base::RuntimeError("DocumentObject::testIfLinkIsDAG: object is not in any document.");
|
||||
std::vector<App::DocumentObject*> deplist = doc->getDependencyList(linksTo);
|
||||
if( std::find(deplist.begin(),deplist.end(),this) != deplist.end() )
|
||||
//found this in dependency list
|
||||
@@ -315,7 +315,7 @@ bool DocumentObject::_isInInListRecursive(const DocumentObject* /*act*/,
|
||||
// if the check object is in the recursive inList we have a cycle!
|
||||
if (obj == checkObj || depth <= 0){
|
||||
std::cerr << "DocumentObject::getOutListRecursive(): cyclic dependency detected!" << std::endl;
|
||||
throw Base::Exception("DocumentObject::getOutListRecursive(): cyclic dependency detected!");
|
||||
throw Base::RuntimeError("DocumentObject::getOutListRecursive(): cyclic dependency detected!");
|
||||
}
|
||||
|
||||
if (_isInInListRecursive(obj, test, checkObj, depth - 1))
|
||||
@@ -362,7 +362,7 @@ bool DocumentObject::_isInOutListRecursive(const DocumentObject* act,
|
||||
// if the check object is in the recursive inList we have a cycle!
|
||||
if (obj == checkObj || depth <= 0){
|
||||
std::cerr << "DocumentObject::isInOutListRecursive(): cyclic dependency detected!" << std::endl;
|
||||
throw Base::Exception("DocumentObject::isInOutListRecursive(): cyclic dependency detected!");
|
||||
throw Base::RuntimeError("DocumentObject::isInOutListRecursive(): cyclic dependency detected!");
|
||||
}
|
||||
|
||||
if (_isInOutListRecursive(obj, test, checkObj, depth - 1))
|
||||
|
||||
@@ -611,7 +611,9 @@ PyObject* DocumentPy::getTempFileName(PyObject *args)
|
||||
fileName.deleteFile();
|
||||
|
||||
PyObject *p = PyUnicode_DecodeUTF8(fileName.filePath().c_str(),fileName.filePath().size(),0);
|
||||
if (!p) throw Base::Exception("UTF8 conversion failure at PropertyString::getPyObject()");
|
||||
if (!p) {
|
||||
throw Base::UnicodeError("UTF8 conversion failure at PropertyString::getPyObject()");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ Property* DynamicProperty::addDynamicProperty(const char* type, const char* name
|
||||
delete base;
|
||||
std::stringstream str;
|
||||
str << "'" << type << "' is not a property type";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::ValueError(str.str());
|
||||
}
|
||||
|
||||
// get unique name
|
||||
|
||||
@@ -1715,9 +1715,9 @@ double num_change(char* yytext,char dez_delim,char grp_delim)
|
||||
errno = 0;
|
||||
ret_val = strtod( temp, NULL );
|
||||
if (ret_val == 0 && errno == ERANGE)
|
||||
throw Base::Exception("Number underflow.");
|
||||
throw Base::UnderflowError("Number underflow.");
|
||||
if (ret_val == HUGE_VAL || ret_val == -HUGE_VAL)
|
||||
throw Base::Exception("Number overflow.");
|
||||
throw Base::OverflowError("Number overflow.");
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@@ -251,9 +251,9 @@ EXPO [eE][-+]?[0-9]+
|
||||
{DIGIT}+ { COUNTCHARS;
|
||||
yylval.ivalue = strtoll( yytext, NULL, 0 );
|
||||
if (yylval.ivalue == LLONG_MIN)
|
||||
throw Base::Exception("Integer underflow");
|
||||
throw Base::UnderflowError("Integer underflow");
|
||||
else if (yylval.ivalue == LLONG_MAX)
|
||||
throw Base::Exception("Integer overflow");
|
||||
throw Base::OverflowError("Integer overflow");
|
||||
if (yylval.ivalue == 1) { yylval.fvalue = 1; return ONE; } else return INTEGER;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,13 +75,13 @@ void Extension::initExtensionType(Base::Type type) {
|
||||
|
||||
m_extensionType = type;
|
||||
if(m_extensionType.isBad())
|
||||
throw Base::Exception("Extension: Extension type not set");
|
||||
throw Base::RuntimeError("Extension: Extension type not set");
|
||||
}
|
||||
|
||||
void Extension::initExtension(ExtensionContainer* obj) {
|
||||
|
||||
if(m_extensionType.isBad())
|
||||
throw Base::Exception("Extension: Extension type not set");
|
||||
throw Base::RuntimeError("Extension: Extension type not set");
|
||||
|
||||
//all properties are initialised without PropertyContainer father. Now that we know it we can
|
||||
//finally finish the property initialisation
|
||||
@@ -108,7 +108,7 @@ PyObject* Extension::getExtensionPyObject(void) {
|
||||
std::string Extension::name() const {
|
||||
|
||||
if(m_extensionType.isBad())
|
||||
throw Base::Exception("Extension::name: Extension type not set");
|
||||
throw Base::RuntimeError("Extension::name: Extension type not set");
|
||||
|
||||
std::string temp(m_extensionType.getName());
|
||||
std::string::size_type pos = temp.find_last_of(":");
|
||||
|
||||
@@ -53,7 +53,7 @@ ExtensionContainer::~ExtensionContainer() {
|
||||
void ExtensionContainer::registerExtension(Base::Type extension, Extension* ext) {
|
||||
|
||||
if(ext->getExtendedContainer() != this)
|
||||
throw Base::Exception("ExtensionContainer::registerExtension: Extension has not this as base object");
|
||||
throw Base::ValueError("ExtensionContainer::registerExtension: Extension has not this as base object");
|
||||
|
||||
//no duplicate extensions (including base classes)
|
||||
if(hasExtension(extension)) {
|
||||
@@ -104,7 +104,7 @@ Extension* ExtensionContainer::getExtension(Base::Type t) {
|
||||
return entry.second;
|
||||
}
|
||||
//if we arive hear we don't have anything matching
|
||||
throw Base::Exception("ExtensionContainer::getExtension: No extension of given type available");
|
||||
throw Base::TypeError("ExtensionContainer::getExtension: No extension of given type available");
|
||||
}
|
||||
|
||||
return result->second;
|
||||
@@ -370,7 +370,7 @@ void ExtensionContainer::restoreExtensions(Base::XMLReader& reader) {
|
||||
if (extension.isBad() || !extension.isDerivedFrom(App::Extension::getExtensionClassTypeId())) {
|
||||
std::stringstream str;
|
||||
str << "No extension found of type '" << Type << "'" << std::ends;
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::TypeError(str.str());
|
||||
}
|
||||
|
||||
//register the extension
|
||||
@@ -380,7 +380,7 @@ void ExtensionContainer::restoreExtensions(Base::XMLReader& reader) {
|
||||
delete ext;
|
||||
std::stringstream str;
|
||||
str << "Extension is not a python addable version: '" << Type << "'" << std::ends;
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::TypeError(str.str());
|
||||
}
|
||||
|
||||
ext->initExtension(this);
|
||||
|
||||
@@ -134,7 +134,7 @@ DocumentObjectExecReturn *FeatureTest::execute(void)
|
||||
{
|
||||
case 0: break;
|
||||
case 1: throw "Test Exeption";
|
||||
case 2: throw Base::Exception("FeatureTestException::execute(): Testexception");
|
||||
case 2: throw Base::RuntimeError("FeatureTestException::execute(): Testexception");
|
||||
case 3: *i=0;printf("%i",*i);break; // seg-vault
|
||||
case 4: j=0; printf("%i",1/j); break; // int devision by zero
|
||||
case 5: f=0.0; printf("%f",1/f); break; // float devision by zero
|
||||
@@ -161,7 +161,7 @@ DocumentObjectExecReturn *FeatureTestException::execute(void)
|
||||
{
|
||||
//ExceptionType;
|
||||
|
||||
throw Base::Exception("FeatureTestException::execute(): Testexception ;-)");
|
||||
throw Base::RuntimeError("FeatureTestException::execute(): Testexception ;-)");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ GeoFeatureGroupExtension::~GeoFeatureGroupExtension(void)
|
||||
void GeoFeatureGroupExtension::initExtension(ExtensionContainer* obj) {
|
||||
|
||||
if(!obj->isDerivedFrom(App::GeoFeature::getClassTypeId()))
|
||||
throw Base::Exception("GeoFeatureGroupExtension can only be applied to GeoFeatures");
|
||||
throw Base::RuntimeError("GeoFeatureGroupExtension can only be applied to GeoFeatures");
|
||||
|
||||
App::GroupExtension::initExtension(obj);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ void GeoFeatureGroupExtension::initExtension(ExtensionContainer* obj) {
|
||||
PropertyPlacement& GeoFeatureGroupExtension::placement() {
|
||||
|
||||
if(!getExtendedContainer())
|
||||
throw Base::Exception("GeoFeatureGroupExtension was not applied to GeoFeature");
|
||||
throw Base::RuntimeError("GeoFeatureGroupExtension was not applied to GeoFeature");
|
||||
|
||||
return static_cast<App::GeoFeature*>(getExtendedContainer())->Placement;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer * _owner, const
|
||||
if (owner) {
|
||||
const DocumentObject * docObj = freecad_dynamic_cast<const DocumentObject>(owner);
|
||||
if (!docObj)
|
||||
throw Base::Exception("Property must be owned by a document object.");
|
||||
throw Base::RuntimeError("Property must be owned by a document object.");
|
||||
|
||||
if (property.size() > 0) {
|
||||
const Document * doc = docObj->getDocument();
|
||||
@@ -863,7 +863,7 @@ ObjectIdentifier ObjectIdentifier::parse(const DocumentObject *docObj, const std
|
||||
if (v)
|
||||
return v->getPath();
|
||||
else
|
||||
throw Base::Exception("Invalid property specification.");
|
||||
throw Base::RuntimeError("Invalid property specification.");
|
||||
}
|
||||
|
||||
std::string ObjectIdentifier::resolveErrorString() const
|
||||
@@ -1034,7 +1034,7 @@ boost::any ObjectIdentifier::getValue() const
|
||||
destructor d1(pyvalue);
|
||||
|
||||
if (!pyvalue)
|
||||
throw Base::Exception("Failed to get property value.");
|
||||
throw Base::RuntimeError("Failed to get property value.");
|
||||
|
||||
if (PyInt_Check(pyvalue))
|
||||
return boost::any(PyInt_AsLong(pyvalue));
|
||||
@@ -1055,7 +1055,7 @@ boost::any ObjectIdentifier::getValue() const
|
||||
return boost::any(*q);
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("Invalid property type.");
|
||||
throw Base::TypeError("Invalid property type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -71,7 +71,7 @@ App::OriginFeature *Origin::getOriginFeature( const char *role) const {
|
||||
std::stringstream err;
|
||||
err << "Origin \"" << getNameInDocument () << "\" doesn't contain feature with role \""
|
||||
<< role << '"';
|
||||
throw Base::Exception ( err.str().c_str () );
|
||||
throw Base::RuntimeError ( err.str().c_str () );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ App::Line *Origin::getAxis( const char *role ) const {
|
||||
std::stringstream err;
|
||||
err << "Origin \"" << getNameInDocument () << "\" contains bad Axis object for role \""
|
||||
<< role << '"';
|
||||
throw Base::Exception ( err.str().c_str () );
|
||||
throw Base::RuntimeError ( err.str().c_str () );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ App::Plane *Origin::getPlane( const char *role ) const {
|
||||
std::stringstream err;
|
||||
err << "Origin \"" << getNameInDocument () << "\" comtains bad Plane object for role \""
|
||||
<< role << '"';
|
||||
throw Base::Exception ( err.str().c_str () );
|
||||
throw Base::RuntimeError ( err.str().c_str () );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,13 @@ App::Origin *OriginGroupExtension::getOrigin () const {
|
||||
if ( !originObj ) {
|
||||
std::stringstream err;
|
||||
err << "Can't find Origin for \"" << getExtendedObject()->getNameInDocument () << "\"";
|
||||
throw Base::Exception ( err.str().c_str () );
|
||||
throw Base::RuntimeError ( err.str().c_str () );
|
||||
|
||||
} else if (! originObj->isDerivedFrom ( App::Origin::getClassTypeId() ) ) {
|
||||
std::stringstream err;
|
||||
err << "Bad object \"" << originObj->getNameInDocument () << "\"(" << originObj->getTypeId().getName()
|
||||
<< ") linked to the Origin of \"" << getExtendedObject()->getNameInDocument () << "\"";
|
||||
throw Base::Exception ( err.str().c_str () );
|
||||
throw Base::RuntimeError ( err.str().c_str () );
|
||||
} else {
|
||||
return static_cast<App::Origin *> ( originObj );
|
||||
}
|
||||
|
||||
@@ -135,11 +135,11 @@ void Property::aboutToSetValue(void)
|
||||
void Property::verifyPath(const ObjectIdentifier &p) const
|
||||
{
|
||||
if (p.numSubComponents() != 1)
|
||||
throw Base::Exception("Invalid property path: single component expected");
|
||||
throw Base::ValueError("Invalid property path: single component expected");
|
||||
if (!p.getPropertyComponent(0).isSimple())
|
||||
throw Base::Exception("Invalid property path: simple component expected");
|
||||
throw Base::ValueError("Invalid property path: simple component expected");
|
||||
if (p.getPropertyComponent(0).getName() != getName())
|
||||
throw Base::Exception("Invalid property path: name mismatch");
|
||||
throw Base::ValueError("Invalid property path: name mismatch");
|
||||
}
|
||||
|
||||
Property *Property::Copy(void) const
|
||||
|
||||
@@ -269,17 +269,17 @@ const ObjectIdentifier PropertyExpressionEngine::canonicalPath(const ObjectIdent
|
||||
|
||||
// Am I owned by a DocumentObject?
|
||||
if (!docObj)
|
||||
throw Base::Exception("PropertyExpressionEngine must be owned by a DocumentObject.");
|
||||
throw Base::RuntimeError("PropertyExpressionEngine must be owned by a DocumentObject.");
|
||||
|
||||
Property * prop = p.getProperty();
|
||||
|
||||
// p pointing to a property...?
|
||||
if (!prop)
|
||||
throw Base::Exception("Property not found");
|
||||
throw Base::RuntimeError("Property not found");
|
||||
|
||||
// ... in the same container as I?
|
||||
if (prop->getContainer() != getContainer())
|
||||
throw Base::Exception("Property does not belong to same container as PropertyExpressionEngine");
|
||||
throw Base::RuntimeError("Property does not belong to same container as PropertyExpressionEngine");
|
||||
|
||||
// In case someone calls this with p pointing to a PropertyExpressionEngine for some reason
|
||||
if (prop->isDerivedFrom(PropertyExpressionEngine::classTypeId))
|
||||
@@ -399,7 +399,7 @@ void PropertyExpressionEngine::setValue(const ObjectIdentifier & path, boost::sh
|
||||
std::string error = validateExpression(usePath, expr);
|
||||
|
||||
if (error.size() > 0)
|
||||
throw Base::Exception(error.c_str());
|
||||
throw Base::RuntimeError(error.c_str());
|
||||
|
||||
AtomicPropertyChange signaller(*this);
|
||||
expressions[usePath] = ExpressionInfo(expr, comment);
|
||||
@@ -496,7 +496,7 @@ void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs,
|
||||
if (has_cycle) {
|
||||
std::string s = revNodes[src].toString() + " reference creates a cyclic dependency.";
|
||||
|
||||
throw Base::Exception(s.c_str());
|
||||
throw Base::RuntimeError(s.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ DocumentObjectExecReturn *App::PropertyExpressionEngine::execute()
|
||||
DocumentObject * docObj = freecad_dynamic_cast<DocumentObject>(getContainer());
|
||||
|
||||
if (!docObj)
|
||||
throw Base::Exception("PropertyExpressionEngine must be owned by a DocumentObject.");
|
||||
throw Base::RuntimeError("PropertyExpressionEngine must be owned by a DocumentObject.");
|
||||
|
||||
if (running)
|
||||
return DocumentObject::StdReturn;
|
||||
@@ -571,13 +571,13 @@ DocumentObjectExecReturn *App::PropertyExpressionEngine::execute()
|
||||
Property * prop = it->getProperty();
|
||||
|
||||
if (!prop)
|
||||
throw Base::Exception("Path does not resolve to a property.");
|
||||
throw Base::RuntimeError("Path does not resolve to a property.");
|
||||
|
||||
DocumentObject* parent = freecad_dynamic_cast<DocumentObject>(prop->getContainer());
|
||||
|
||||
/* Make sure property belongs to the same container as this PropertyExpressionEngine */
|
||||
if (parent != docObj)
|
||||
throw Base::Exception("Invalid property owner.");
|
||||
throw Base::RuntimeError("Invalid property owner.");
|
||||
|
||||
// Evaluate expression
|
||||
std::unique_ptr<Expression> e(expressions[*it].expression->eval());
|
||||
|
||||
+13
-11
@@ -122,7 +122,7 @@ void PropertyFileIncluded::setValue(const char* sFile, const char* sName)
|
||||
{
|
||||
if (sFile && sFile[0] != '\0') {
|
||||
if (_cValue == sFile)
|
||||
throw Base::Exception("Not possible to set the same file!");
|
||||
throw Base::FileSystemError("Not possible to set the same file!");
|
||||
|
||||
// keep the path to the original file
|
||||
_OriginalName = sFile;
|
||||
@@ -133,7 +133,7 @@ void PropertyFileIncluded::setValue(const char* sFile, const char* sName)
|
||||
if (!file.exists()) {
|
||||
std::stringstream str;
|
||||
str << "File " << file.filePath() << " does not exist.";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
|
||||
aboutToSetValue(); // undo/redo by moving the file away with temp name
|
||||
@@ -192,7 +192,7 @@ void PropertyFileIncluded::setValue(const char* sFile, const char* sName)
|
||||
if (!done) {
|
||||
std::stringstream str;
|
||||
str << "Cannot rename file " << file.filePath() << " to " << _cValue;
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
|
||||
// make the file read-only
|
||||
@@ -227,7 +227,7 @@ void PropertyFileIncluded::setValue(const char* sFile, const char* sName)
|
||||
if (!done) {
|
||||
std::stringstream str;
|
||||
str << "Cannot copy file from " << file.filePath() << " to " << _cValue;
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
|
||||
// make the file read-only
|
||||
@@ -247,7 +247,9 @@ const char* PropertyFileIncluded::getValue(void) const
|
||||
PyObject *PropertyFileIncluded::getPyObject(void)
|
||||
{
|
||||
PyObject *p = PyUnicode_DecodeUTF8(_cValue.c_str(),_cValue.size(),0);
|
||||
if (!p) throw Base::Exception("PropertyFileIncluded: UTF-8 conversion failure");
|
||||
if (!p) {
|
||||
throw Base::UnicodeError("PropertyFileIncluded: UTF-8 conversion failure");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -398,7 +400,7 @@ void PropertyFileIncluded::SaveDocFile (Base::Writer &writer) const
|
||||
std::stringstream str;
|
||||
str << "PropertyFileIncluded::SaveDocFile(): "
|
||||
<< "File '" << _cValue << "' in transient directory doesn't exist.";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
|
||||
// copy plain data
|
||||
@@ -422,7 +424,7 @@ void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader)
|
||||
std::stringstream str;
|
||||
str << "PropertyFileIncluded::RestoreDocFile(): "
|
||||
<< "File '" << _cValue << "' in transient directory cannot be created.";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
|
||||
// copy plain data
|
||||
@@ -457,7 +459,7 @@ Property *PropertyFileIncluded::Copy(void) const
|
||||
str << "PropertyFileIncluded::Copy(): "
|
||||
<< "Renaming the file '" << file.filePath() << "' to '"
|
||||
<< newName.filePath() << "' failed.";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -468,7 +470,7 @@ Property *PropertyFileIncluded::Copy(void) const
|
||||
str << "PropertyFileIncluded::Copy(): "
|
||||
<< "Copying the file '" << file.filePath() << "' to '"
|
||||
<< newName.filePath() << "' failed.";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,7 +513,7 @@ void PropertyFileIncluded::Paste(const Property &from)
|
||||
str << "PropertyFileIncluded::Paste(): "
|
||||
<< "Renaming the file '" << fiSrc.filePath() << "' to '"
|
||||
<< fiDst.filePath() << "' failed.";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -520,7 +522,7 @@ void PropertyFileIncluded::Paste(const Property &from)
|
||||
str << "PropertyFileIncluded::Paste(): "
|
||||
<< "Copying the file '" << fiSrc.filePath() << "' to '"
|
||||
<< fiDst.filePath() << "' failed.";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ Property *PropertyLink::Copy(void) const
|
||||
void PropertyLink::Paste(const Property &from)
|
||||
{
|
||||
if(!from.isDerivedFrom(PropertyLink::getClassTypeId()))
|
||||
throw Base::Exception("Incompatible proeprty to paste to");
|
||||
throw Base::TypeError("Incompatible property to paste to");
|
||||
|
||||
setValue(static_cast<const PropertyLink&>(from)._pcLink);
|
||||
}
|
||||
@@ -603,7 +603,7 @@ void PropertyLinkSubList::setValue(DocumentObject* lValue,const char* SubName)
|
||||
void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,const std::vector<const char*>& lSubNames)
|
||||
{
|
||||
if (lValue.size() != lSubNames.size())
|
||||
throw Base::Exception("PropertyLinkSubList::setValues: size of subelements list != size of objects list");
|
||||
throw Base::ValueError("PropertyLinkSubList::setValues: size of subelements list != size of objects list");
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
//maintain backlinks. _lValueList can contain items multiple times, but we trust the document
|
||||
@@ -629,7 +629,7 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,c
|
||||
void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& lValue,const std::vector<std::string>& lSubNames)
|
||||
{
|
||||
if (lValue.size() != lSubNames.size())
|
||||
throw Base::Exception("PropertyLinkSubList::setValues: size of subelements list != size of objects list");
|
||||
throw Base::ValueError("PropertyLinkSubList::setValues: size of subelements list != size of objects list");
|
||||
|
||||
#ifndef USE_OLD_DAG
|
||||
//maintain backlinks. _lValueList can contain items multiple times, but we trust the document
|
||||
@@ -740,7 +740,7 @@ std::vector<PropertyLinkSubList::SubSet> PropertyLinkSubList::getSubListValues()
|
||||
{
|
||||
std::vector<PropertyLinkSubList::SubSet> values;
|
||||
if (_lValueList.size() != _lSubList.size())
|
||||
throw Base::Exception("PropertyLinkSubList::getSubListValues: size of subelements list != size of objects list");
|
||||
throw Base::ValueError("PropertyLinkSubList::getSubListValues: size of subelements list != size of objects list");
|
||||
|
||||
std::map<App::DocumentObject*, std::vector<std::string> > tmp;
|
||||
for (std::size_t i = 0; i < _lValueList.size(); i++) {
|
||||
|
||||
@@ -213,7 +213,7 @@ PyObject *PropertyPath::getPyObject(void)
|
||||
|
||||
// Returns a new reference, don't increment it!
|
||||
PyObject *p = PyUnicode_DecodeUTF8(str.c_str(),str.size(),0);
|
||||
if (!p) throw Base::Exception("UTF8 conversion failure at PropertyPath::getPyObject()");
|
||||
if (!p) throw Base::UnicodeError("UTF8 conversion failure at PropertyPath::getPyObject()");
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1338,7 +1338,7 @@ const char* PropertyString::getValue(void) const
|
||||
PyObject *PropertyString::getPyObject(void)
|
||||
{
|
||||
PyObject *p = PyUnicode_DecodeUTF8(_cValue.c_str(),_cValue.size(),0);
|
||||
if (!p) throw Base::Exception("UTF8 conversion failure at PropertyString::getPyObject()");
|
||||
if (!p) throw Base::UnicodeError("UTF8 conversion failure at PropertyString::getPyObject()");
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1594,7 +1594,7 @@ PyObject *PropertyStringList::getPyObject(void)
|
||||
PyObject* item = PyUnicode_DecodeUTF8(_lValueList[i].c_str(), _lValueList[i].size(), 0);
|
||||
if (!item) {
|
||||
Py_DECREF(list);
|
||||
throw Base::Exception("UTF8 conversion failure at PropertyStringList::getPyObject()");
|
||||
throw Base::UnicodeError("UTF8 conversion failure at PropertyStringList::getPyObject()");
|
||||
}
|
||||
PyList_SetItem(list, i, item);
|
||||
}
|
||||
@@ -1752,7 +1752,7 @@ PyObject *PropertyMap::getPyObject(void)
|
||||
PyObject* item = PyUnicode_DecodeUTF8(it->second.c_str(), it->second.size(), 0);
|
||||
if (!item) {
|
||||
Py_DECREF(dict);
|
||||
throw Base::Exception("UTF8 conversion failure at PropertyMap::getPyObject()");
|
||||
throw Base::UnicodeError("UTF8 conversion failure at PropertyMap::getPyObject()");
|
||||
}
|
||||
PyDict_SetItemString(dict,it->first.c_str(),item);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ void PropertyQuantity::setPyObject(PyObject *value)
|
||||
}
|
||||
|
||||
if (unit != _Unit)
|
||||
throw Base::Exception("Not matching Unit!");
|
||||
throw Base::UnitsMismatchError("Not matching Unit!");
|
||||
|
||||
PropertyFloat::setValue(quant.getValue());
|
||||
}
|
||||
@@ -178,7 +178,7 @@ void PropertyQuantityConstraint::setPyObject(PyObject *value)
|
||||
}
|
||||
|
||||
if (unit != _Unit)
|
||||
throw Base::Exception("Not matching Unit!");
|
||||
throw Base::UnitsMismatchError("Not matching Unit!");
|
||||
|
||||
PropertyFloat::setValue(quant.getValue());
|
||||
}
|
||||
|
||||
+3
-3
@@ -114,7 +114,7 @@ int App::decodeRow(const std::string &rowstr)
|
||||
if (row >= 0)
|
||||
return row;
|
||||
else
|
||||
throw Base::Exception("Invalid row specification.");
|
||||
throw Base::IndexError("Invalid row specification.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +133,7 @@ int App::decodeColumn(const std::string &colstr)
|
||||
if (col >= 0)
|
||||
return col;
|
||||
else
|
||||
throw Base::Exception("Invalid column specification");
|
||||
throw Base::IndexError("Invalid column specification");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +215,7 @@ App::CellAddress App::stringToAddress(const char * strAddress)
|
||||
return CellAddress(decodeRow(rowstr.str()), decodeColumn(colstr.str()));
|
||||
}
|
||||
else
|
||||
throw Base::Exception("Invalid cell specifier.");
|
||||
throw Base::RuntimeError("Invalid cell specifier.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6320,9 +6320,9 @@ YY_RULE_SETUP
|
||||
{ COUNTCHARS;
|
||||
yylval.ivalue = strtoll( ExpressionParsertext, NULL, 0 );
|
||||
if (yylval.ivalue == LLONG_MIN)
|
||||
throw Base::Exception("Integer underflow");
|
||||
throw Base::UnderflowError("Integer underflow");
|
||||
else if (yylval.ivalue == LLONG_MAX)
|
||||
throw Base::Exception("Integer overflow");
|
||||
throw Base::OverflowError("Integer overflow");
|
||||
if (yylval.ivalue == 1) { yylval.fvalue = 1; return ONE; } else return INTEGER;
|
||||
}
|
||||
YY_BREAK
|
||||
|
||||
@@ -322,7 +322,7 @@ void Builder3D::saveToFile(const char* FileName)
|
||||
result << "} ";
|
||||
std::ofstream file(FileName);
|
||||
if(!file)
|
||||
throw Exception("Builder3D::saveToFile(): Can not open file...");
|
||||
throw FileException("Builder3D::saveToFile(): Can not open file...");
|
||||
|
||||
file << "#Inventor V2.1 ascii " << std::endl;
|
||||
file << result.str();
|
||||
|
||||
@@ -43,10 +43,10 @@ CoordinateSystem::~CoordinateSystem()
|
||||
void CoordinateSystem::setAxes(const Axis& v, const Vector3d& xd)
|
||||
{
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon())
|
||||
throw Base::Exception("Direction is null vector");
|
||||
throw Base::ValueError("Direction is null vector");
|
||||
Vector3d yd = v.getDirection() % xd;
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon())
|
||||
throw Base::Exception("Direction is parallel to Z direction");
|
||||
throw Base::ValueError("Direction is parallel to Z direction");
|
||||
ydir = yd;
|
||||
xdir = ydir % v.getDirection();
|
||||
axis = v;
|
||||
@@ -55,10 +55,10 @@ void CoordinateSystem::setAxes(const Axis& v, const Vector3d& xd)
|
||||
void CoordinateSystem::setAxes(const Vector3d& n, const Vector3d& xd)
|
||||
{
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon())
|
||||
throw Base::Exception("Direction is null vector");
|
||||
throw Base::ValueError("Direction is null vector");
|
||||
Vector3d yd = n % xd;
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon())
|
||||
throw Base::Exception("Direction is parallel to Z direction");
|
||||
throw Base::ValueError("Direction is parallel to Z direction");
|
||||
ydir = yd;
|
||||
xdir = ydir % n;
|
||||
axis.setDirection(n);
|
||||
@@ -73,7 +73,7 @@ void CoordinateSystem::setXDirection(const Vector3d& dir)
|
||||
{
|
||||
Vector3d yd = axis.getDirection() % dir;
|
||||
if (yd.Sqr() < Base::Vector3d::epsilon())
|
||||
throw Base::Exception("Direction is parallel to Z direction");
|
||||
throw Base::ValueError("Direction is parallel to Z direction");
|
||||
ydir = yd;
|
||||
xdir = ydir % axis.getDirection();
|
||||
}
|
||||
@@ -82,7 +82,7 @@ void CoordinateSystem::setYDirection(const Vector3d& dir)
|
||||
{
|
||||
Vector3d xd = dir & axis.getDirection();
|
||||
if (xd.Sqr() < Base::Vector3d::epsilon())
|
||||
throw Base::Exception("Direction is parallel to Z direction");
|
||||
throw Base::ValueError("Direction is parallel to Z direction");
|
||||
xdir = xd;
|
||||
ydir = axis.getDirection() % xdir;
|
||||
}
|
||||
|
||||
@@ -96,6 +96,23 @@ const char* AbortException::what() const throw()
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
XMLBaseException::XMLBaseException(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
XMLBaseException::XMLBaseException(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
XMLBaseException::XMLBaseException(const XMLBaseException &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
XMLParseException::XMLParseException(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
@@ -156,6 +173,40 @@ const char* FileException::what() const throw()
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
FileSystemError::FileSystemError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
FileSystemError::FileSystemError(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
FileSystemError::FileSystemError(const FileSystemError &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
BadFormatError::BadFormatError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
BadFormatError::BadFormatError(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
BadFormatError::BadFormatError(const BadFormatError &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
MemoryException::MemoryException()
|
||||
{
|
||||
_sErrMsg = "Not enough memory available";
|
||||
@@ -185,6 +236,16 @@ AccessViolation::AccessViolation()
|
||||
_sErrMsg = "Access violation";
|
||||
}
|
||||
|
||||
AccessViolation::AccessViolation(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
AccessViolation::AccessViolation(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
AccessViolation::AccessViolation(const AccessViolation &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
@@ -197,6 +258,16 @@ AbnormalProgramTermination::AbnormalProgramTermination()
|
||||
_sErrMsg = "Abnormal program termination";
|
||||
}
|
||||
|
||||
AbnormalProgramTermination::AbnormalProgramTermination(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
AbnormalProgramTermination::AbnormalProgramTermination(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
AbnormalProgramTermination::AbnormalProgramTermination(const AbnormalProgramTermination &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
@@ -272,6 +343,23 @@ ValueError::ValueError(const ValueError &inst)
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
IndexError::IndexError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
IndexError::IndexError(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
IndexError::IndexError(const IndexError &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
AttributeError::AttributeError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
@@ -340,6 +428,23 @@ DivisionByZeroError::DivisionByZeroError(const DivisionByZeroError &inst)
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
ReferencesError::ReferencesError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
ReferencesError::ReferencesError(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
ReferencesError::ReferencesError(const ReferencesError &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
ExpressionError::ExpressionError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
@@ -374,6 +479,74 @@ ParserError::ParserError(const ParserError &inst)
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
UnicodeError::UnicodeError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
UnicodeError::UnicodeError(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
UnicodeError::UnicodeError(const UnicodeError &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
OverflowError::OverflowError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
OverflowError::OverflowError(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
OverflowError::OverflowError(const OverflowError &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
UnderflowError::UnderflowError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
UnderflowError::UnderflowError(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
UnderflowError::UnderflowError(const UnderflowError &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
UnitsMismatchError::UnitsMismatchError(const char * sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
UnitsMismatchError::UnitsMismatchError(const std::string& sMessage)
|
||||
: Exception(sMessage)
|
||||
{
|
||||
}
|
||||
|
||||
UnitsMismatchError::UnitsMismatchError(const UnitsMismatchError &inst)
|
||||
: Exception(inst)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
|
||||
#if defined(__GNUC__) && defined (FC_OS_LINUX)
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
+156
-4
@@ -41,10 +41,6 @@ class BaseExport Exception : public BaseClass
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
Exception(const char * sMessage);
|
||||
Exception(const std::string& sMessage);
|
||||
Exception(void);
|
||||
Exception(const Exception &inst);
|
||||
virtual ~Exception() throw() {}
|
||||
|
||||
Exception &operator=(const Exception &inst);
|
||||
@@ -52,6 +48,13 @@ public:
|
||||
virtual void ReportException (void) const;
|
||||
inline void setMessage(const char * sMessage);
|
||||
inline void setMessage(const std::string& sMessage);
|
||||
|
||||
protected:
|
||||
public: // FIXME: Remove the public keyword
|
||||
Exception(const char * sMessage);
|
||||
Exception(const std::string& sMessage);
|
||||
Exception(void);
|
||||
Exception(const Exception &inst);
|
||||
|
||||
protected:
|
||||
std::string _sErrMsg;
|
||||
@@ -77,6 +80,22 @@ public:
|
||||
virtual const char* what() const throw();
|
||||
};
|
||||
|
||||
/**
|
||||
* The XMLBaseException can be used to indicate any kind of XML related errors.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport XMLBaseException : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
XMLBaseException(const char * sMessage);
|
||||
XMLBaseException(const std::string& sMessage);
|
||||
/// Construction
|
||||
XMLBaseException(const XMLBaseException &inst);
|
||||
/// Destruction
|
||||
virtual ~XMLBaseException() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The XMLParseException is thrown if parsing an XML failed.
|
||||
* @author Werner Mayer
|
||||
@@ -121,6 +140,39 @@ protected:
|
||||
FileInfo file;
|
||||
};
|
||||
|
||||
/**
|
||||
* The FileSystemError can be used to indicate errors on file system
|
||||
* e.g. if renaming of a file failed.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport FileSystemError : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
FileSystemError(const char * sMessage);
|
||||
FileSystemError(const std::string& sMessage);
|
||||
/// Construction
|
||||
FileSystemError(const FileSystemError &inst);
|
||||
/// Destruction
|
||||
virtual ~FileSystemError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The BadFormatError can be used to indicate errors in a data structure.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport BadFormatError : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
BadFormatError(const char * sMessage);
|
||||
BadFormatError(const std::string& sMessage);
|
||||
/// Construction
|
||||
BadFormatError(const BadFormatError &inst);
|
||||
/// Destruction
|
||||
virtual ~BadFormatError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The MemoryException is thrown if not enough memory can be allocated.
|
||||
* @author Werner Mayer
|
||||
@@ -154,6 +206,8 @@ class BaseExport AccessViolation : public Exception
|
||||
public:
|
||||
/// Construction
|
||||
AccessViolation();
|
||||
AccessViolation(const char * sMessage);
|
||||
AccessViolation(const std::string& sMessage);
|
||||
/// Construction
|
||||
AccessViolation(const AccessViolation &inst);
|
||||
/// Destruction
|
||||
@@ -170,6 +224,8 @@ public:
|
||||
/// Construction
|
||||
AbnormalProgramTermination();
|
||||
/// Construction
|
||||
AbnormalProgramTermination(const char * sMessage);
|
||||
AbnormalProgramTermination(const std::string& sMessage);
|
||||
AbnormalProgramTermination(const AbnormalProgramTermination &inst);
|
||||
/// Destruction
|
||||
virtual ~AbnormalProgramTermination() throw() {}
|
||||
@@ -239,6 +295,22 @@ public:
|
||||
virtual ~ValueError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The IndexError can be used when a sequence subscript is out of range.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport IndexError : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
IndexError(const char * sMessage);
|
||||
IndexError(const std::string& sMessage);
|
||||
/// Construction
|
||||
IndexError(const IndexError &inst);
|
||||
/// Destruction
|
||||
virtual ~IndexError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The AttributeError can be used to indicate the usage of a wrong value.
|
||||
* @author Werner Mayer
|
||||
@@ -303,6 +375,22 @@ public:
|
||||
virtual ~DivisionByZeroError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The ReferencesError can be used to indicate a reference counter has the wrong value.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport ReferencesError : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
ReferencesError(const char * sMessage);
|
||||
ReferencesError(const std::string& sMessage);
|
||||
/// Construction
|
||||
ReferencesError(const ReferencesError &inst);
|
||||
/// Destruction
|
||||
virtual ~ReferencesError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The ExpressionError can be used to indicate erroneous.input
|
||||
* to the expression engine.
|
||||
@@ -336,6 +424,70 @@ public:
|
||||
virtual ~ParserError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The UnicodeError can be used to indicate unicode encoding/decoding error.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport UnicodeError : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
UnicodeError(const char * sMessage);
|
||||
UnicodeError(const std::string& sMessage);
|
||||
/// Construction
|
||||
UnicodeError(const UnicodeError &inst);
|
||||
/// Destruction
|
||||
virtual ~UnicodeError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The OverflowError can be used to indicate overflows of numbers.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport OverflowError : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
OverflowError(const char * sMessage);
|
||||
OverflowError(const std::string& sMessage);
|
||||
/// Construction
|
||||
OverflowError(const OverflowError &inst);
|
||||
/// Destruction
|
||||
virtual ~OverflowError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The UnderflowError can be used to indicate underflows of numbers.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport UnderflowError : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
UnderflowError(const char * sMessage);
|
||||
UnderflowError(const std::string& sMessage);
|
||||
/// Construction
|
||||
UnderflowError(const UnderflowError &inst);
|
||||
/// Destruction
|
||||
virtual ~UnderflowError() throw() {}
|
||||
};
|
||||
|
||||
/**
|
||||
* The UnitsMismatchError can be used to indicate that quantities with different units are used.
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class BaseExport UnitsMismatchError : public Exception
|
||||
{
|
||||
public:
|
||||
/// Construction
|
||||
UnitsMismatchError(const char * sMessage);
|
||||
UnitsMismatchError(const std::string& sMessage);
|
||||
/// Construction
|
||||
UnitsMismatchError(const UnitsMismatchError &inst);
|
||||
/// Destruction
|
||||
virtual ~UnitsMismatchError() throw() {}
|
||||
};
|
||||
|
||||
|
||||
inline void Exception::setMessage(const char * sMessage)
|
||||
{
|
||||
|
||||
@@ -303,7 +303,7 @@ void InterpreterSingleton::runInteractiveString(const char *sCmd)
|
||||
PyObject *errobj, *errdata, *errtraceback;
|
||||
PyErr_Fetch(&errobj, &errdata, &errtraceback);
|
||||
|
||||
Exception exc; // do not use PyException since this clears the error indicator
|
||||
RuntimeError exc(""); // do not use PyException since this clears the error indicator
|
||||
if (PyString_Check(errdata))
|
||||
exc.setMessage(PyString_AsString(errdata));
|
||||
PyErr_Restore(errobj, errdata, errtraceback);
|
||||
@@ -367,10 +367,7 @@ void InterpreterSingleton::runFile(const char*pxFileName, bool local)
|
||||
Py_DECREF(result);
|
||||
}
|
||||
else {
|
||||
std::string err = "Unknown file: ";
|
||||
err += pxFileName;
|
||||
err += "\n";
|
||||
throw Exception(err);
|
||||
throw FileException("Unknown file", pxFileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +534,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method,
|
||||
pmeth = PyObject_GetAttrString(pobject, method);
|
||||
if (pmeth == NULL) { /* get callable object */
|
||||
va_end(argslist);
|
||||
throw Exception("Error running InterpreterSingleton::RunMethod() method not defined"); /* bound method? has self */
|
||||
throw AttributeError("Error running InterpreterSingleton::RunMethod() method not defined"); /* bound method? has self */
|
||||
}
|
||||
|
||||
pargs = Py_VaBuildValue(argfmt, argslist); /* args: c->python */
|
||||
@@ -545,7 +542,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method,
|
||||
|
||||
if (pargs == NULL) {
|
||||
Py_DECREF(pmeth);
|
||||
throw Exception("InterpreterSingleton::RunMethod() wrong arguments");
|
||||
throw TypeError("InterpreterSingleton::RunMethod() wrong arguments");
|
||||
}
|
||||
|
||||
presult = PyEval_CallObject(pmeth, pargs); /* run interpreter */
|
||||
@@ -555,7 +552,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method,
|
||||
if (PP_Convert_Result(presult, resfmt, cresult)!= 0) {
|
||||
if ( PyErr_Occurred() )
|
||||
PyErr_Print();
|
||||
throw Exception("Error running InterpreterSingleton::RunMethod() exception in called method");
|
||||
throw RuntimeError("Error running InterpreterSingleton::RunMethod() exception in called method");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,7 +720,7 @@ PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module, const c
|
||||
return proxy;
|
||||
|
||||
// none of the SWIG's succeeded
|
||||
throw Base::Exception("No SWIG wrapped library loaded");
|
||||
throw Base::RuntimeError("No SWIG wrapped library loaded");
|
||||
}
|
||||
|
||||
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
|
||||
@@ -769,7 +766,7 @@ bool InterpreterSingleton::convertSWIGPointerObj(const char* Module, const char*
|
||||
return true;
|
||||
|
||||
// none of the SWIG's succeeded
|
||||
throw Base::Exception("No SWIG wrapped library loaded");
|
||||
throw Base::RuntimeError("No SWIG wrapped library loaded");
|
||||
}
|
||||
|
||||
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
|
||||
|
||||
@@ -278,7 +278,7 @@ void ParameterGrp::importFrom(const char* FileName)
|
||||
ParameterManager Mngr;
|
||||
|
||||
if (Mngr.LoadDocument(FileName) != 1)
|
||||
throw Exception("ParameterGrp::import() cannot load document");
|
||||
throw FileException("ParameterGrp::import() cannot load document", FileName);
|
||||
|
||||
Mngr.GetGroup("BaseApp")->copyTo(Base::Reference<ParameterGrp>(this));
|
||||
}
|
||||
@@ -288,7 +288,7 @@ void ParameterGrp::insert(const char* FileName)
|
||||
ParameterManager Mngr;
|
||||
|
||||
if (Mngr.LoadDocument(FileName) != 1)
|
||||
throw Exception("ParameterGrp::import() cannot load document");
|
||||
throw FileException("ParameterGrp::import() cannot load document", FileName);
|
||||
|
||||
Mngr.GetGroup("root")->insertTo(Base::Reference<ParameterGrp>(this));
|
||||
}
|
||||
@@ -1085,7 +1085,7 @@ void ParameterManager::Init(void)
|
||||
<< " Exception message:"
|
||||
<< pMsg;
|
||||
XMLString::release(&pMsg);
|
||||
throw Exception(err.str().c_str());
|
||||
throw XMLBaseException(err.str().c_str());
|
||||
}
|
||||
Init = true;
|
||||
}
|
||||
@@ -1227,16 +1227,16 @@ int ParameterManager::LoadDocument(const XERCES_CPP_NAMESPACE_QUALIFIER InputSou
|
||||
delete errReporter;
|
||||
|
||||
if (!_pDocument)
|
||||
throw Exception("Malformed Parameter document: Invalid document");
|
||||
throw XMLBaseException("Malformed Parameter document: Invalid document");
|
||||
|
||||
DOMElement* rootElem = _pDocument->getDocumentElement();
|
||||
if (!rootElem)
|
||||
throw Exception("Malformed Parameter document: Root group not found");
|
||||
throw XMLBaseException("Malformed Parameter document: Root group not found");
|
||||
|
||||
_pGroupNode = FindElement(rootElem,"FCParamGroup","Root");
|
||||
|
||||
if (!_pGroupNode)
|
||||
throw Exception("Malformed Parameter document: Root group not found");
|
||||
throw XMLBaseException("Malformed Parameter document: Root group not found");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ inline PyObject * PyAsUnicodeObject(const char *str)
|
||||
// Returns a new reference, don't increment it!
|
||||
PyObject *p = PyUnicode_DecodeUTF8(str,strlen(str),0);
|
||||
if(!p)
|
||||
throw Base::Exception("UTF8 conversion failure at PyAsUnicodeString()");
|
||||
throw Base::UnicodeError("UTF8 conversion failure at PyAsUnicodeString()");
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -79,7 +79,7 @@ bool Quantity::operator ==(const Quantity& that) const
|
||||
bool Quantity::operator <(const Quantity& that) const
|
||||
{
|
||||
if (this->_Unit != that._Unit)
|
||||
throw Base::Exception("Quantity::operator <(): quantities need to have same unit to compare");
|
||||
throw Base::UnitsMismatchError("Quantity::operator <(): quantities need to have same unit to compare");
|
||||
|
||||
return (this->_Value < that._Value) ;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ bool Quantity::operator <(const Quantity& that) const
|
||||
bool Quantity::operator >(const Quantity& that) const
|
||||
{
|
||||
if (this->_Unit != that._Unit)
|
||||
throw Base::Exception("Quantity::operator >(): quantities need to have same unit to compare");
|
||||
throw Base::UnitsMismatchError("Quantity::operator >(): quantities need to have same unit to compare");
|
||||
|
||||
return (this->_Value > that._Value) ;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ bool Quantity::operator >(const Quantity& that) const
|
||||
bool Quantity::operator <=(const Quantity& that) const
|
||||
{
|
||||
if (this->_Unit != that._Unit)
|
||||
throw Base::Exception("Quantity::operator <=(): quantities need to have same unit to compare");
|
||||
throw Base::UnitsMismatchError("Quantity::operator <=(): quantities need to have same unit to compare");
|
||||
|
||||
return (this->_Value <= that._Value) ;
|
||||
}
|
||||
@@ -103,7 +103,7 @@ bool Quantity::operator <=(const Quantity& that) const
|
||||
bool Quantity::operator >=(const Quantity& that) const
|
||||
{
|
||||
if (this->_Unit != that._Unit)
|
||||
throw Base::Exception("Quantity::operator >=(): quantities need to have same unit to compare");
|
||||
throw Base::UnitsMismatchError("Quantity::operator >=(): quantities need to have same unit to compare");
|
||||
|
||||
return (this->_Value >= that._Value) ;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ Quantity Quantity::operator /(double p) const
|
||||
Quantity Quantity::pow(const Quantity &p) const
|
||||
{
|
||||
if (!p._Unit.isEmpty())
|
||||
throw Base::Exception("Quantity::pow(): exponent must not have a unit");
|
||||
throw Base::UnitsMismatchError("Quantity::pow(): exponent must not have a unit");
|
||||
return Quantity(
|
||||
std::pow(this->_Value, p._Value),
|
||||
this->_Unit.pow((short)p._Value)
|
||||
@@ -148,14 +148,14 @@ Quantity Quantity::pow(double p) const
|
||||
Quantity Quantity::operator +(const Quantity &p) const
|
||||
{
|
||||
if (this->_Unit != p._Unit)
|
||||
throw Base::Exception("Quantity::operator +(): Unit mismatch in plus operation");
|
||||
throw Base::UnitsMismatchError("Quantity::operator +(): Unit mismatch in plus operation");
|
||||
return Quantity(this->_Value + p._Value,this->_Unit);
|
||||
}
|
||||
|
||||
Quantity& Quantity::operator +=(const Quantity &p)
|
||||
{
|
||||
if (this->_Unit != p._Unit)
|
||||
throw Base::Exception("Quantity::operator +=(): Unit mismatch in plus operation");
|
||||
throw Base::UnitsMismatchError("Quantity::operator +=(): Unit mismatch in plus operation");
|
||||
|
||||
_Value += p._Value;
|
||||
|
||||
@@ -165,14 +165,14 @@ Quantity& Quantity::operator +=(const Quantity &p)
|
||||
Quantity Quantity::operator -(const Quantity &p) const
|
||||
{
|
||||
if (this->_Unit != p._Unit)
|
||||
throw Base::Exception("Quantity::operator +(): Unit mismatch in minus operation");
|
||||
throw Base::UnitsMismatchError("Quantity::operator +(): Unit mismatch in minus operation");
|
||||
return Quantity(this->_Value - p._Value,this->_Unit);
|
||||
}
|
||||
|
||||
Quantity& Quantity::operator -=(const Quantity &p)
|
||||
{
|
||||
if (this->_Unit != p._Unit)
|
||||
throw Base::Exception("Quantity::operator -=(): Unit mismatch in minus operation");
|
||||
throw Base::UnitsMismatchError("Quantity::operator -=(): Unit mismatch in minus operation");
|
||||
|
||||
_Value -= p._Value;
|
||||
|
||||
@@ -333,8 +333,8 @@ double num_change(char* yytext,char dez_delim,char grp_delim)
|
||||
|
||||
// error func
|
||||
void Quantity_yyerror(char *errorinfo)
|
||||
{
|
||||
throw Base::Exception(errorinfo);
|
||||
{
|
||||
throw Base::ParserError(errorinfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -385,6 +385,6 @@ Quantity Quantity::parse(const QString &string)
|
||||
QuantityParser::yy_delete_buffer (my_string_buffer);
|
||||
|
||||
//if (QuantResult == Quantity(DOUBLE_MIN))
|
||||
// throw Base::Exception("Unknown error in Quantity expression");
|
||||
// throw Base::ParserError("Unknown error in Quantity expression");
|
||||
return QuantResult;
|
||||
}
|
||||
|
||||
+3
-3
@@ -201,7 +201,7 @@ bool Base::XMLReader::read(void)
|
||||
char* message = XMLString::transcode(toCatch.getMessage());
|
||||
std::string what = message;
|
||||
XMLString::release(&message);
|
||||
throw Base::Exception(what);
|
||||
throw Base::XMLBaseException(what);
|
||||
#endif
|
||||
}
|
||||
catch (const SAXParseException& toCatch) {
|
||||
@@ -223,7 +223,7 @@ bool Base::XMLReader::read(void)
|
||||
cerr << "Unexpected Exception \n" ;
|
||||
return false;
|
||||
#else
|
||||
throw Base::Exception("Unexpected XML exception");
|
||||
throw Base::XMLBaseException("Unexpected XML exception");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ void Base::XMLReader::readBinFile(const char* filename)
|
||||
Base::FileInfo fi(filename);
|
||||
Base::ofstream to(fi, std::ios::out | std::ios::binary);
|
||||
if (!to)
|
||||
throw Base::Exception("XMLReader::readBinFile() Could not open file!");
|
||||
throw Base::FileException("XMLReader::readBinFile() Could not open file!");
|
||||
|
||||
bool ok;
|
||||
do {
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ static inline void checkRange(const char * op, int length, int mass, int time, i
|
||||
( luminoseIntensity >= (1 << (UnitSignatureLuminoseIntensityBits - 1)) ) ||
|
||||
( angle >= (1 << (UnitSignatureAngleBits - 1)) ) ||
|
||||
( density >= (1 << (UnitSignatureDensityBits - 1)) ) )
|
||||
throw Base::Exception((std::string("Unit overflow in ") + std::string(op)).c_str());
|
||||
throw Base::OverflowError((std::string("Unit overflow in ") + std::string(op)).c_str());
|
||||
if ( ( length < -(1 << (UnitSignatureLengthBits - 1)) ) ||
|
||||
( mass < -(1 << (UnitSignatureMassBits - 1)) ) ||
|
||||
( time < -(1 << (UnitSignatureTimeBits - 1)) ) ||
|
||||
@@ -55,7 +55,7 @@ static inline void checkRange(const char * op, int length, int mass, int time, i
|
||||
( luminoseIntensity < -(1 << (UnitSignatureLuminoseIntensityBits - 1)) ) ||
|
||||
( angle < -(1 << (UnitSignatureAngleBits - 1)) ) ||
|
||||
( density < -(1 << (UnitSignatureDensityBits - 1)) ) )
|
||||
throw Base::Exception((std::string("Unit underflow in ") + std::string(op)).c_str());
|
||||
throw Base::OverflowError((std::string("Unit underflow in ") + std::string(op)).c_str());
|
||||
}
|
||||
|
||||
Unit::Unit(int8_t Length,
|
||||
|
||||
@@ -148,7 +148,7 @@ double UnitsApi::toDbl(PyObject *ArgObj, const Base::Unit &u)
|
||||
Quantity q = Quantity::parse(str);
|
||||
if (q.getUnit() == u)
|
||||
return q.getValue();
|
||||
throw Base::Exception("Wrong unit type!");
|
||||
throw Base::UnitsMismatchError("Wrong unit type!");
|
||||
}
|
||||
else if (PyFloat_Check(ArgObj)) {
|
||||
return PyFloat_AsDouble(ArgObj);
|
||||
@@ -157,7 +157,7 @@ double UnitsApi::toDbl(PyObject *ArgObj, const Base::Unit &u)
|
||||
return static_cast<double>(PyInt_AsLong(ArgObj));
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("Wrong parameter type!");
|
||||
throw Base::UnitsMismatchError("Wrong parameter type!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ Quantity UnitsApi::toQuantity(PyObject *ArgObj, const Base::Unit &u)
|
||||
d = static_cast<double>(PyInt_AsLong(ArgObj));
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("Wrong parameter type!");
|
||||
throw Base::UnitsMismatchError("Wrong parameter type!");
|
||||
}
|
||||
|
||||
return Quantity(d,u);
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ void Writer::insertAsciiFile(const char* FileName)
|
||||
Base::FileInfo fi(FileName);
|
||||
Base::ifstream from(fi);
|
||||
if (!from)
|
||||
throw Base::Exception("Writer::insertAsciiFile() Could not open file!");
|
||||
throw Base::FileException("Writer::insertAsciiFile() Could not open file!");
|
||||
|
||||
Stream() << "<![CDATA[";
|
||||
char ch;
|
||||
@@ -77,7 +77,7 @@ void Writer::insertBinFile(const char* FileName)
|
||||
Base::FileInfo fi(FileName);
|
||||
Base::ifstream from(fi, std::ios::in | std::ios::binary | std::ios::ate);
|
||||
if (!from)
|
||||
throw Base::Exception("Writer::insertAsciiFile() Could not open file!");
|
||||
throw Base::FileException("Writer::insertAsciiFile() Could not open file!");
|
||||
|
||||
Stream() << "<![CDATA[";
|
||||
std::ifstream::pos_type fileSize = from.tellg();
|
||||
|
||||
+2
-2
@@ -134,7 +134,7 @@ inline StrXUTF8::StrXUTF8(const XMLCh* const toTranscode)
|
||||
XMLTransService::Codes res;
|
||||
transcoder.reset(XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgTransService->makeNewTranscoderFor(XERCES_CPP_NAMESPACE_QUALIFIER XMLRecognizer::UTF_8, res, 4096, XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager));
|
||||
if (res != XMLTransService::Ok)
|
||||
throw Base::Exception("Can't create UTF-8 encoder in StrXUTF8::StrXUTF8()");
|
||||
throw Base::UnicodeError("Cant create UTF-8 encoder in StrXUTF8::StrXUTF8()");
|
||||
}
|
||||
|
||||
//char outBuff[128];
|
||||
@@ -250,7 +250,7 @@ inline XUTF8Str::XUTF8Str(const char* const fromTranscode)
|
||||
XMLTransService::Codes res;
|
||||
transcoder.reset(XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgTransService->makeNewTranscoderFor(XERCES_CPP_NAMESPACE_QUALIFIER XMLRecognizer::UTF_8, res, 4096, XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager));
|
||||
if (res != XMLTransService::Ok)
|
||||
throw Base::Exception("Can't create UTF-8 decoder in XUTF8Str::XUTF8Str()");
|
||||
throw Base::UnicodeError("Cant create UTF-8 decoder in XUTF8Str::XUTF8Str()");
|
||||
}
|
||||
|
||||
static XMLCh outBuff[128];
|
||||
|
||||
@@ -30,11 +30,11 @@ int createSWIGPointerObj_T(const char* TypeName, void* obj, PyObject** ptr, int
|
||||
swig_type_info * swig_type = 0;
|
||||
swig_type = SWIG_TypeQuery(TypeName);
|
||||
if (!swig_type)
|
||||
throw Base::Exception("Cannot find type information for requested type");
|
||||
throw Base::RuntimeError("Cannot find type information for requested type");
|
||||
|
||||
*ptr = SWIG_NewPointerObj(obj,swig_type,own);
|
||||
if (*ptr == 0)
|
||||
throw Base::Exception("Cannot convert into requested type");
|
||||
throw Base::RuntimeError("Cannot convert into requested type");
|
||||
|
||||
// success
|
||||
return 0;
|
||||
@@ -49,11 +49,11 @@ int convertSWIGPointerObj_T(const char* TypeName, PyObject* obj, void** ptr, int
|
||||
swig_type_info * swig_type = 0;
|
||||
swig_type = SWIG_TypeQuery(TypeName);
|
||||
if (!swig_type)
|
||||
throw Base::Exception("Cannot find type information for requested type");
|
||||
throw Base::RuntimeError("Cannot find type information for requested type");
|
||||
|
||||
// return value of 0 is on success
|
||||
if (SWIG_ConvertPtr(obj, ptr, swig_type, flags))
|
||||
throw Base::Exception("Cannot convert into requested type");
|
||||
throw Base::RuntimeError("Cannot convert into requested type");
|
||||
|
||||
// success
|
||||
return 0;
|
||||
|
||||
@@ -267,7 +267,7 @@ Application::Application(bool GUIenabled)
|
||||
QLatin1String("Your system uses the same symbol for decimal point and group separator.\n\n"
|
||||
"This causes serious problems and makes the application fail to work properly.\n"
|
||||
"Go to the system configuration panel of the OS and fix this issue, please."));
|
||||
throw Base::Exception("Invalid system settings");
|
||||
throw Base::RuntimeError("Invalid system settings");
|
||||
}
|
||||
#endif
|
||||
#if 0 // QuantitySpinBox and InputField try to handle the group separator now
|
||||
@@ -1561,7 +1561,7 @@ void Application::runApplication(void)
|
||||
#if !defined(HAVE_QT5_OPENGL)
|
||||
if (!QGLFormat::hasOpenGL()) {
|
||||
QMessageBox::critical(0, QObject::tr("No OpenGL"), QObject::tr("This system does not support OpenGL"));
|
||||
throw Base::Exception("This system does not support OpenGL");
|
||||
throw Base::RuntimeError("This system does not support OpenGL");
|
||||
}
|
||||
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
|
||||
Base::Console().Log("This system does not support framebuffer objects\n");
|
||||
|
||||
+9
-9
@@ -884,7 +884,7 @@ PythonCommand::PythonCommand(const char* name, PyObject * pcPyCommand, const cha
|
||||
_pcPyResourceDict = Interpreter().runMethodObject(_pcPyCommand, "GetResources");
|
||||
// check if the "GetResources()" method returns a Dict object
|
||||
if (!PyDict_Check(_pcPyResourceDict)) {
|
||||
throw Base::Exception("PythonCommand::PythonCommand(): Method GetResources() of the Python "
|
||||
throw Base::TypeError("PythonCommand::PythonCommand(): Method GetResources() of the Python "
|
||||
"command object returns the wrong type (has to be dict)");
|
||||
}
|
||||
|
||||
@@ -921,7 +921,7 @@ const char* PythonCommand::getResource(const char* sName) const
|
||||
if (!pcTemp)
|
||||
return "";
|
||||
if (!PyString_Check(pcTemp)) {
|
||||
throw Base::Exception("PythonCommand::getResource(): Method GetResources() of the Python "
|
||||
throw Base::TypeError("PythonCommand::getResource(): Method GetResources() of the Python "
|
||||
"command object returns a dictionary which holds not only strings");
|
||||
}
|
||||
|
||||
@@ -989,7 +989,7 @@ const char* PythonCommand::getHelpUrl(void) const
|
||||
if (! pcTemp )
|
||||
return "";
|
||||
if (! PyString_Check(pcTemp) )
|
||||
throw Base::Exception("PythonCommand::CmdHelpURL(): Method CmdHelpURL() of the Python command object returns no string");
|
||||
throw Base::TypeError("PythonCommand::CmdHelpURL(): Method CmdHelpURL() of the Python command object returns no string");
|
||||
return PyString_AsString(pcTemp);
|
||||
}
|
||||
|
||||
@@ -1064,16 +1064,16 @@ bool PythonCommand::isChecked() const
|
||||
{
|
||||
PyObject* item = PyDict_GetItemString(_pcPyResourceDict,"Checkable");
|
||||
if (!item) {
|
||||
throw Base::Exception("PythonCommand::isChecked(): Method GetResources() of the Python "
|
||||
"command object doesn't contain the key 'Checkable'");
|
||||
throw Base::ValueError("PythonCommand::isChecked(): Method GetResources() of the Python "
|
||||
"command object doesn't contain the key 'Checkable'");
|
||||
}
|
||||
|
||||
if (PyBool_Check(item)) {
|
||||
return PyObject_IsTrue(item) ? true : false;
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("PythonCommand::isChecked(): Method GetResources() of the Python "
|
||||
"command object contains the key 'Checkable' which is not a boolean");
|
||||
throw Base::ValueError("PythonCommand::isChecked(): Method GetResources() of the Python "
|
||||
"command object contains the key 'Checkable' which is not a boolean");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1351,7 +1351,7 @@ bool PythonGroupCommand::isExclusive() const
|
||||
return PyObject_IsTrue(item) ? true : false;
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("PythonGroupCommand::isExclusive(): Method GetResources() of the Python "
|
||||
throw Base::TypeError("PythonGroupCommand::isExclusive(): Method GetResources() of the Python "
|
||||
"command object contains the key 'Exclusive' which is not a boolean");
|
||||
}
|
||||
}
|
||||
@@ -1367,7 +1367,7 @@ bool PythonGroupCommand::hasDropDownMenu() const
|
||||
return PyObject_IsTrue(item) ? true : false;
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("PythonGroupCommand::hasDropDownMenu(): Method GetResources() of the Python "
|
||||
throw Base::TypeError("PythonGroupCommand::hasDropDownMenu(): Method GetResources() of the Python "
|
||||
"command object contains the key 'DropDownMenu' which is not a boolean");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ void DlgExpressionInput::textChanged(const QString &text)
|
||||
std::string error = path.getDocumentObject()->ExpressionEngine.validateExpression(path, expr);
|
||||
|
||||
if (error.size() > 0)
|
||||
throw Base::Exception(error.c_str());
|
||||
throw Base::RuntimeError(error.c_str());
|
||||
|
||||
std::unique_ptr<Expression> result(expr->eval());
|
||||
|
||||
@@ -139,7 +139,7 @@ void DlgExpressionInput::textChanged(const QString &text)
|
||||
Base::Quantity value = n->getQuantity();
|
||||
|
||||
if (!value.getUnit().isEmpty() && value.getUnit() != impliedUnit)
|
||||
throw Base::Exception("Unit mismatch between result and required unit");
|
||||
throw Base::UnitsMismatchError("Unit mismatch between result and required unit");
|
||||
|
||||
value.setUnit(impliedUnit);
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ void Gui::ExpressionBinding::setExpression(boost::shared_ptr<Expression> expr)
|
||||
const std::string error = docObj->ExpressionEngine.validateExpression(path, expr);
|
||||
|
||||
if (error.size())
|
||||
throw Base::Exception(error.c_str());
|
||||
throw Base::RuntimeError(error.c_str());
|
||||
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ boost::shared_ptr<App::Expression> ExpressionBinding::getExpression() const
|
||||
std::string ExpressionBinding::getExpressionString() const
|
||||
{
|
||||
if (!getExpression())
|
||||
throw Base::Exception("No expression found.");
|
||||
throw Base::RuntimeError("No expression found.");
|
||||
|
||||
return getExpression()->toString();
|
||||
}
|
||||
@@ -141,7 +141,7 @@ bool ExpressionBinding::apply(const std::string & propName)
|
||||
DocumentObject * docObj = path.getDocumentObject();
|
||||
|
||||
if (!docObj)
|
||||
throw Base::Exception("Document object not found.");
|
||||
throw Base::RuntimeError("Document object not found.");
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument('%s').%s.setExpression('%s', u'%s')",
|
||||
docObj->getDocument()->getName(),
|
||||
@@ -155,7 +155,7 @@ bool ExpressionBinding::apply(const std::string & propName)
|
||||
DocumentObject * docObj = path.getDocumentObject();
|
||||
|
||||
if (!docObj)
|
||||
throw Base::Exception("Document object not found.");
|
||||
throw Base::RuntimeError("Document object not found.");
|
||||
|
||||
if (lastExpression)
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument('%s').%s.setExpression('%s', None)",
|
||||
@@ -178,7 +178,7 @@ bool ExpressionBinding::apply()
|
||||
DocumentObject * docObj(path.getDocumentObject());
|
||||
|
||||
if (!docObj)
|
||||
throw Base::Exception("Document object not found.");
|
||||
throw Base::RuntimeError("Document object not found.");
|
||||
|
||||
std::string name = docObj->getNameInDocument();
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ MovableGroup& MovableGroupModel::activeGroup()
|
||||
{
|
||||
// Make sure that the array is not empty
|
||||
if (this->_groups.empty())
|
||||
throw Base::Exception("Empty group");
|
||||
throw Base::RuntimeError("Empty group");
|
||||
return *(this->_groups.begin());
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ const MovableGroup& MovableGroupModel::activeGroup() const
|
||||
{
|
||||
// Make sure that the array is not empty
|
||||
if (this->_groups.empty())
|
||||
throw Base::Exception("Empty group");
|
||||
throw Base::RuntimeError("Empty group");
|
||||
return *(this->_groups.begin());
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ PyObject* InteractiveInterpreter::compile(const char* source) const
|
||||
return eval;
|
||||
} else {
|
||||
// do not throw Base::PyException as this clears the error indicator
|
||||
throw Base::Exception();
|
||||
throw Base::RuntimeError("Code evaluation failed");
|
||||
}
|
||||
|
||||
// can never happen
|
||||
|
||||
@@ -153,7 +153,7 @@ void SelectionFilter::setFilter(const char* filter)
|
||||
else {
|
||||
Filter = filter;
|
||||
if (!parse())
|
||||
throw Base::Exception(Errors.c_str());
|
||||
throw Base::ParserError(Errors.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void SoFCOffscreenRenderer::writeToImageFile(const char* filename, const char* c
|
||||
else {
|
||||
std::stringstream str;
|
||||
str << "Cannot open file '" << filename << "' for writing.";
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::FileSystemError(str.str());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -159,7 +159,7 @@ GesturesDevice::GesturesDevice(QWidget* widget)
|
||||
SoGestureSwipeEvent::initClass();
|
||||
}
|
||||
if (! widget)
|
||||
throw Base::Exception("Can't create a gestures quarter input device without widget (null pointer was passed).");
|
||||
throw Base::ValueError("Can't create a gestures quarter input device without widget (null pointer was passed).");
|
||||
this->widget = widget;
|
||||
}
|
||||
|
||||
|
||||
@@ -825,7 +825,7 @@ bool View3DInventor::setCamera(const char* pCamera)
|
||||
{
|
||||
SoCamera * CamViewer = _viewer->getSoRenderManager()->getCamera();
|
||||
if (!CamViewer) {
|
||||
throw Base::Exception("No camera set so far...");
|
||||
throw Base::RuntimeError("No camera set so far...");
|
||||
}
|
||||
|
||||
SoInput in;
|
||||
@@ -835,7 +835,7 @@ bool View3DInventor::setCamera(const char* pCamera)
|
||||
SoDB::read(&in,Cam);
|
||||
|
||||
if (!Cam){
|
||||
throw Base::Exception("Camera settings failed to read");
|
||||
throw Base::RuntimeError("Camera settings failed to read");
|
||||
}
|
||||
|
||||
// toggle between persepective and orthographic camera
|
||||
@@ -862,7 +862,7 @@ bool View3DInventor::setCamera(const char* pCamera)
|
||||
CamViewerP->farDistance = ((SoPerspectiveCamera *)Cam)->farDistance;
|
||||
CamViewerP->focalDistance = ((SoPerspectiveCamera *)Cam)->focalDistance;
|
||||
} else {
|
||||
throw Base::Exception("Camera type mismatch");
|
||||
throw Base::TypeError("Camera type mismatch");
|
||||
}
|
||||
} else if (Cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
|
||||
if (CamViewerO){
|
||||
@@ -875,7 +875,7 @@ bool View3DInventor::setCamera(const char* pCamera)
|
||||
CamViewerO->aspectRatio = ((SoOrthographicCamera *)Cam)->aspectRatio ;
|
||||
CamViewerO->height = ((SoOrthographicCamera *)Cam)->height;
|
||||
} else {
|
||||
throw Base::Exception("Camera type mismatch");
|
||||
throw Base::TypeError("Camera type mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1016,7 +1016,7 @@ void View3DInventorViewer::savePicture(int w, int h, const QColor& bg, QImage& i
|
||||
if (bgColor.isValid())
|
||||
renderer.setBackgroundColor(SbColor4f(bgColor.redF(), bgColor.greenF(), bgColor.blueF(), bgColor.alphaF()));
|
||||
if (!renderer.render(root))
|
||||
throw Base::Exception("Offscreen rendering failed");
|
||||
throw Base::RuntimeError("Offscreen rendering failed");
|
||||
|
||||
renderer.writeToImage(img);
|
||||
root->unref();
|
||||
@@ -1027,7 +1027,7 @@ void View3DInventorViewer::savePicture(int w, int h, const QColor& bg, QImage& i
|
||||
if (bgColor.isValid())
|
||||
renderer.setBackgroundColor(SbColor(bgColor.redF(), bgColor.greenF(), bgColor.blueF()));
|
||||
if (!renderer.render(root))
|
||||
throw Base::Exception("Offscreen rendering failed");
|
||||
throw Base::RuntimeError("Offscreen rendering failed");
|
||||
|
||||
renderer.writeToImage(img);
|
||||
root->unref();
|
||||
@@ -1211,14 +1211,14 @@ bool View3DInventorViewer::dumpToFile(SoNode* node, const char* filename, bool b
|
||||
vo = std::unique_ptr<SoVectorizeAction>(new SoFCVectorizeU3DAction());
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("Not supported vector graphic");
|
||||
throw Base::ValueError("Not supported vector graphic");
|
||||
}
|
||||
|
||||
SoVectorOutput* out = vo->getOutput();
|
||||
if (!out || !out->openFile(filename)) {
|
||||
std::ostringstream a_out;
|
||||
a_out << "Cannot open file '" << filename << "'";
|
||||
throw Base::Exception(a_out.str());
|
||||
throw Base::FileSystemError(a_out.str());
|
||||
}
|
||||
|
||||
saveGraphic(ps,c,vo.get());
|
||||
|
||||
@@ -584,7 +584,7 @@ void ViewProvider::dragObject(App::DocumentObject* obj) {
|
||||
}
|
||||
}
|
||||
|
||||
throw Base::Exception("ViewProvider::dragObject: no extension for dragging given object available.");
|
||||
throw Base::RuntimeError("ViewProvider::dragObject: no extension for dragging given object available.");
|
||||
}
|
||||
|
||||
|
||||
@@ -625,7 +625,7 @@ void ViewProvider::dropObject(App::DocumentObject* obj) {
|
||||
}
|
||||
}
|
||||
|
||||
throw Base::Exception("ViewProvider::dropObject: no extension for dropping given object available.");
|
||||
throw Base::RuntimeError("ViewProvider::dropObject: no extension for dropping given object available.");
|
||||
}
|
||||
|
||||
void ViewProvider::Restore(Base::XMLReader& reader) {
|
||||
|
||||
@@ -88,7 +88,7 @@ void ViewProviderExtern::setModeByFile(const char* name, const char* ivFileName)
|
||||
}
|
||||
|
||||
file.close();
|
||||
in.setBuffer(&(content[0]),content.size());
|
||||
in.setBuffer(&(content[0]),content.size());
|
||||
setModeBySoInput(name,in);
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void ViewProviderExtern::setModeBySoInput(const char* name, SoInput &ivFileInput
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw Base::Exception("No valid Inventor input");
|
||||
throw Base::RuntimeError("No valid Inventor input");
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -148,7 +148,7 @@ void ViewProviderOriginGroupExtension::updateOriginSize () {
|
||||
|
||||
Gui::ViewProvider *vp = Gui::Application::Instance->getViewProvider(origin);
|
||||
if (!vp) {
|
||||
throw Base::Exception ("No view provider linked to the Origin");
|
||||
throw Base::RuntimeError ("No view provider linked to the Origin");
|
||||
}
|
||||
assert ( vp->isDerivedFrom ( Gui::ViewProviderOrigin::getClassTypeId () ) );
|
||||
vpOrigin = static_cast <Gui::ViewProviderOrigin *> ( vp );
|
||||
|
||||
@@ -1149,7 +1149,7 @@ void PyResource::load(const char* name)
|
||||
if (!fi.exists()) {
|
||||
if (cwd == home) {
|
||||
QString what = QObject::tr("Cannot find file %1").arg(fi.absoluteFilePath());
|
||||
throw Base::Exception(what.toUtf8().constData());
|
||||
throw Base::FileSystemError(what.toUtf8().constData());
|
||||
}
|
||||
else {
|
||||
fi.setFile( QDir(home), fn );
|
||||
@@ -1157,7 +1157,7 @@ void PyResource::load(const char* name)
|
||||
if (!fi.exists()) {
|
||||
QString what = QObject::tr("Cannot find file %1 neither in %2 nor in %3")
|
||||
.arg(fn).arg(cwd).arg(home);
|
||||
throw Base::Exception(what.toUtf8().constData());
|
||||
throw Base::FileSystemError(what.toUtf8().constData());
|
||||
}
|
||||
else {
|
||||
fn = fi.absoluteFilePath(); // file resides in FreeCAD's home directory
|
||||
@@ -1168,7 +1168,7 @@ void PyResource::load(const char* name)
|
||||
else {
|
||||
if (!fi.exists()) {
|
||||
QString what = QObject::tr("Cannot find file %1").arg(fn);
|
||||
throw Base::Exception(what.toUtf8().constData());
|
||||
throw Base::FileSystemError(what.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1184,11 +1184,11 @@ void PyResource::load(const char* name)
|
||||
file.close();
|
||||
}
|
||||
catch (...) {
|
||||
throw Base::Exception("Cannot create resource");
|
||||
throw Base::RuntimeError("Cannot create resource");
|
||||
}
|
||||
|
||||
if (!w)
|
||||
throw Base::Exception("Invalid widget.");
|
||||
throw Base::ValueError("Invalid widget.");
|
||||
|
||||
if (w->inherits("QDialog")) {
|
||||
myDlg = (QDialog*)w;
|
||||
|
||||
@@ -240,11 +240,11 @@ void WinNativeGestureRecognizerPinch::TuneWindowsGestures(QWidget* target)
|
||||
//dynamic linking - required to be able to run on windows pre-7
|
||||
HINSTANCE hinstLib = LoadLibraryA("user32.dll");
|
||||
if (hinstLib == 0)
|
||||
throw Base::Exception("LoadLibrary(user32.dll) failed. Could not tune Windows gestures.");
|
||||
throw Base::RuntimeError("LoadLibrary(user32.dll) failed. Could not tune Windows gestures.");
|
||||
|
||||
ptrSetGestureConfig dllSetGestureConfig = reinterpret_cast<ptrSetGestureConfig> (GetProcAddress(hinstLib,"SetGestureConfig"));
|
||||
if (dllSetGestureConfig == 0)
|
||||
throw Base::Exception("DLL entry point for SetGestureConfig not found in user32.dll. Could not tune Windows gestures.");
|
||||
throw Base::RuntimeError("DLL entry point for SetGestureConfig not found in user32.dll. Could not tune Windows gestures.");
|
||||
|
||||
HWND w = target->winId();
|
||||
|
||||
@@ -264,7 +264,7 @@ void WinNativeGestureRecognizerPinch::TuneWindowsGestures(QWidget* target)
|
||||
if(!ret){
|
||||
DWORD err = GetLastError();
|
||||
QString errMsg = QString::fromLatin1("Error in SetGestureConfig. GetLastError = %1").arg(err);
|
||||
throw Base::Exception(errMsg.toLatin1());
|
||||
throw Base::RuntimeError(errMsg.toLatin1());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ Workbench* WorkbenchManager::createWorkbench (const std::string& name, const std
|
||||
delete base;
|
||||
std::stringstream str;
|
||||
str << "'" << className << "' not a workbench type" << std::ends;
|
||||
throw Base::Exception(str.str());
|
||||
throw Base::TypeError(str.str());
|
||||
}
|
||||
|
||||
wb = static_cast<Workbench*>(base);
|
||||
|
||||
@@ -56,7 +56,7 @@ ImageBase::ImageBase(const ImageBase &rhs)
|
||||
_pPixelData = NULL;
|
||||
_owner = false; // avoids a superfluous delete
|
||||
if (createCopy((void *)(rhs._pPixelData), rhs._width, rhs._height, rhs._format, rhs._numSigBitsPerSample) != 0)
|
||||
throw Base::Exception("ImageBase::ImageBase. Error creating copy of image");
|
||||
throw Base::RuntimeError("ImageBase::ImageBase. Error creating copy of image");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -84,7 +84,7 @@ ImageBase & ImageBase::operator=(const ImageBase &rhs)
|
||||
// rhs is the owner - do a deep copy
|
||||
_owner = false; // avoids a superfluous delete
|
||||
if (createCopy((void *)(rhs._pPixelData), rhs._width, rhs._height, rhs._format, rhs._numSigBitsPerSample) != 0)
|
||||
throw Base::Exception("ImageBase::operator=. Error creating copy of image");
|
||||
throw Base::RuntimeError("ImageBase::operator=. Error creating copy of image");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -904,7 +904,7 @@ void MeshKernel::Read (std::istream &rclIn)
|
||||
}
|
||||
catch (std::exception&) {
|
||||
// Special handling of std::length_error
|
||||
throw Base::Exception("Reading from stream failed");
|
||||
throw Base::BadFormatError("Reading from stream failed");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -93,7 +93,7 @@ Base::Matrix4D AbstractPolygonTriangulator::GetTransformToFitPlane() const
|
||||
planeFit.AddPoint(*it);
|
||||
|
||||
if (planeFit.Fit() == FLOAT_MAX)
|
||||
throw Base::Exception("Plane fit failed");
|
||||
throw Base::RuntimeError("Plane fit failed");
|
||||
|
||||
Base::Vector3f bs = planeFit.GetBase();
|
||||
Base::Vector3f ex = planeFit.GetDirU();
|
||||
|
||||
@@ -91,7 +91,7 @@ App::DocumentObjectExecReturn *SetOperations::execute(void)
|
||||
else if (ot == "outer")
|
||||
type = MeshCore::SetOperations::Outer;
|
||||
else
|
||||
throw new Base::Exception("Operation type must either be 'union' or 'intersection'"
|
||||
throw new Base::ValueError("Operation type must either be 'union' or 'intersection'"
|
||||
" or 'difference' or 'inner' or 'outer'");
|
||||
|
||||
MeshCore::SetOperations setOp(meshKernel1.getKernel(), meshKernel2.getKernel(),
|
||||
@@ -102,9 +102,9 @@ App::DocumentObjectExecReturn *SetOperations::execute(void)
|
||||
else {
|
||||
// Error mesh property
|
||||
if (!mesh1)
|
||||
throw new Base::Exception("First input mesh not set");
|
||||
throw new Base::ValueError("First input mesh not set");
|
||||
if (!mesh2)
|
||||
throw new Base::Exception("Second input mesh not set");
|
||||
throw new Base::ValueError("Second input mesh not set");
|
||||
}
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
@@ -1654,7 +1654,7 @@ void MeshObject::addSegment(const std::vector<unsigned long>& inds)
|
||||
unsigned long maxIndex = _kernel.CountFacets();
|
||||
for (std::vector<unsigned long>::const_iterator it = inds.begin(); it != inds.end(); ++it) {
|
||||
if (*it >= maxIndex)
|
||||
throw Base::Exception("Index out of range");
|
||||
throw Base::IndexError("Index out of range");
|
||||
}
|
||||
|
||||
this->_segments.push_back(Segment(this,inds,true));
|
||||
|
||||
+136
-136
@@ -61,7 +61,7 @@ void PointsAlgos::Load(PointKernel &points, const char *FileName)
|
||||
if (File.extension() == "asc" ||File.extension() == "ASC")
|
||||
LoadAscii(points,FileName);
|
||||
else
|
||||
throw Base::Exception("Unknown ending");
|
||||
throw Base::RuntimeError("Unknown ending");
|
||||
}
|
||||
|
||||
void PointsAlgos::LoadAscii(PointKernel &points, const char *FileName)
|
||||
@@ -109,7 +109,7 @@ void PointsAlgos::LoadAscii(PointKernel &points, const char *FileName)
|
||||
}
|
||||
catch (...) {
|
||||
points.clear();
|
||||
throw Base::Exception("Reading in points failed.");
|
||||
throw Base::BadFormatError("Reading in points failed.");
|
||||
}
|
||||
|
||||
// now remove the last points from the kernel
|
||||
@@ -228,36 +228,36 @@ void PlyReader::read(const std::string& filename)
|
||||
Eigen::Vector4f origin;
|
||||
Eigen::Quaternionf orientation;
|
||||
int ply_version;
|
||||
int data_type;
|
||||
unsigned int data_idx;
|
||||
pcl::PLYReader ply;
|
||||
ply.readHeader(filename, cloud2, origin, orientation, ply_version, data_type, data_idx);
|
||||
|
||||
bool hasIntensity = false;
|
||||
bool hasColors = false;
|
||||
bool hasNormals = false;
|
||||
for (size_t i = 0; i < cloud2.fields.size (); ++i) {
|
||||
if (cloud2.fields[i].name == "intensity")
|
||||
hasIntensity = true;
|
||||
if (cloud2.fields[i].name == "normal_x" || cloud2.fields[i].name == "nx")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "normal_y" || cloud2.fields[i].name == "ny")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "normal_z" || cloud2.fields[i].name == "nz")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "red")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "green")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "blue")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "rgb")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "rgba")
|
||||
hasColors = true;
|
||||
}
|
||||
|
||||
if (hasNormals && hasColors) {
|
||||
int data_type;
|
||||
unsigned int data_idx;
|
||||
pcl::PLYReader ply;
|
||||
ply.readHeader(filename, cloud2, origin, orientation, ply_version, data_type, data_idx);
|
||||
|
||||
bool hasIntensity = false;
|
||||
bool hasColors = false;
|
||||
bool hasNormals = false;
|
||||
for (size_t i = 0; i < cloud2.fields.size (); ++i) {
|
||||
if (cloud2.fields[i].name == "intensity")
|
||||
hasIntensity = true;
|
||||
if (cloud2.fields[i].name == "normal_x" || cloud2.fields[i].name == "nx")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "normal_y" || cloud2.fields[i].name == "ny")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "normal_z" || cloud2.fields[i].name == "nz")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "red")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "green")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "blue")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "rgb")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "rgba")
|
||||
hasColors = true;
|
||||
}
|
||||
|
||||
if (hasNormals && hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal> cloud_in;
|
||||
pcl::io::loadPLYFile<pcl::PointXYZRGBNormal>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -268,8 +268,8 @@ void PlyReader::read(const std::string& filename)
|
||||
colors.push_back(App::Color(it->r/255.0f,it->g/255.0f,it->b/255.0f));
|
||||
normals.push_back(Base::Vector3f(it->normal_x,it->normal_y,it->normal_z));
|
||||
}
|
||||
}
|
||||
else if (hasNormals && hasIntensity) {
|
||||
}
|
||||
else if (hasNormals && hasIntensity) {
|
||||
pcl::PointCloud<pcl::PointXYZINormal> cloud_in;
|
||||
pcl::io::loadPLYFile<pcl::PointXYZINormal>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -280,8 +280,8 @@ void PlyReader::read(const std::string& filename)
|
||||
intensity.push_back(it->intensity);
|
||||
normals.push_back(Base::Vector3f(it->normal_x,it->normal_y,it->normal_z));
|
||||
}
|
||||
}
|
||||
else if (hasColors) {
|
||||
}
|
||||
else if (hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBA> cloud_in;
|
||||
pcl::io::loadPLYFile<pcl::PointXYZRGBA>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -290,8 +290,8 @@ void PlyReader::read(const std::string& filename)
|
||||
points.push_back(Base::Vector3d(it->x,it->y,it->z));
|
||||
colors.push_back(App::Color(it->r/255.0f,it->g/255.0f,it->b/255.0f,it->a/255.0f));
|
||||
}
|
||||
}
|
||||
else if (hasIntensity) {
|
||||
}
|
||||
else if (hasIntensity) {
|
||||
pcl::PointCloud<pcl::PointXYZI> cloud_in;
|
||||
pcl::io::loadPLYFile<pcl::PointXYZI>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -300,8 +300,8 @@ void PlyReader::read(const std::string& filename)
|
||||
points.push_back(Base::Vector3d(it->x,it->y,it->z));
|
||||
intensity.push_back(it->intensity);
|
||||
}
|
||||
}
|
||||
else if (hasNormals) {
|
||||
}
|
||||
else if (hasNormals) {
|
||||
pcl::PointCloud<pcl::PointNormal> cloud_in;
|
||||
pcl::io::loadPLYFile<pcl::PointNormal>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -310,15 +310,15 @@ void PlyReader::read(const std::string& filename)
|
||||
points.push_back(Base::Vector3d(it->x,it->y,it->z));
|
||||
normals.push_back(Base::Vector3f(it->normal_x,it->normal_y,it->normal_z));
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
pcl::PointCloud<pcl::PointXYZ> cloud_in;
|
||||
pcl::io::loadPLYFile<pcl::PointXYZ>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
for (pcl::PointCloud<pcl::PointXYZ>::const_iterator it = cloud_in.begin();it!=cloud_in.end();++it) {
|
||||
points.push_back(Base::Vector3d(it->x,it->y,it->z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -340,39 +340,39 @@ void PcdReader::read(const std::string& filename)
|
||||
Eigen::Vector4f origin;
|
||||
Eigen::Quaternionf orientation;
|
||||
int ply_version;
|
||||
int data_type;
|
||||
unsigned int data_idx;
|
||||
pcl::PCDReader pcd;
|
||||
pcd.readHeader(filename, cloud2, origin, orientation, ply_version, data_type, data_idx);
|
||||
|
||||
bool hasIntensity = false;
|
||||
bool hasColors = false;
|
||||
bool hasNormals = false;
|
||||
for (size_t i = 0; i < cloud2.fields.size (); ++i) {
|
||||
if (cloud2.fields[i].name == "intensity")
|
||||
hasIntensity = true;
|
||||
if (cloud2.fields[i].name == "normal_x" || cloud2.fields[i].name == "nx")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "normal_y" || cloud2.fields[i].name == "ny")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "normal_z" || cloud2.fields[i].name == "nz")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "red")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "green")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "blue")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "rgb")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "rgba")
|
||||
hasColors = true;
|
||||
}
|
||||
|
||||
width = cloud2.width;
|
||||
height = cloud2.height;
|
||||
|
||||
if (hasNormals && hasColors) {
|
||||
int data_type;
|
||||
unsigned int data_idx;
|
||||
pcl::PCDReader pcd;
|
||||
pcd.readHeader(filename, cloud2, origin, orientation, ply_version, data_type, data_idx);
|
||||
|
||||
bool hasIntensity = false;
|
||||
bool hasColors = false;
|
||||
bool hasNormals = false;
|
||||
for (size_t i = 0; i < cloud2.fields.size (); ++i) {
|
||||
if (cloud2.fields[i].name == "intensity")
|
||||
hasIntensity = true;
|
||||
if (cloud2.fields[i].name == "normal_x" || cloud2.fields[i].name == "nx")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "normal_y" || cloud2.fields[i].name == "ny")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "normal_z" || cloud2.fields[i].name == "nz")
|
||||
hasNormals = true;
|
||||
if (cloud2.fields[i].name == "red")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "green")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "blue")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "rgb")
|
||||
hasColors = true;
|
||||
if (cloud2.fields[i].name == "rgba")
|
||||
hasColors = true;
|
||||
}
|
||||
|
||||
width = cloud2.width;
|
||||
height = cloud2.height;
|
||||
|
||||
if (hasNormals && hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal> cloud_in;
|
||||
pcl::io::loadPCDFile<pcl::PointXYZRGBNormal>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -383,8 +383,8 @@ void PcdReader::read(const std::string& filename)
|
||||
colors.push_back(App::Color(it->r/255.0f,it->g/255.0f,it->b/255.0f));
|
||||
normals.push_back(Base::Vector3f(it->normal_x,it->normal_y,it->normal_z));
|
||||
}
|
||||
}
|
||||
else if (hasNormals && hasIntensity) {
|
||||
}
|
||||
else if (hasNormals && hasIntensity) {
|
||||
pcl::PointCloud<pcl::PointXYZINormal> cloud_in;
|
||||
pcl::io::loadPCDFile<pcl::PointXYZINormal>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -395,8 +395,8 @@ void PcdReader::read(const std::string& filename)
|
||||
intensity.push_back(it->intensity);
|
||||
normals.push_back(Base::Vector3f(it->normal_x,it->normal_y,it->normal_z));
|
||||
}
|
||||
}
|
||||
else if (hasColors) {
|
||||
}
|
||||
else if (hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBA> cloud_in;
|
||||
pcl::io::loadPCDFile<pcl::PointXYZRGBA>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -405,8 +405,8 @@ void PcdReader::read(const std::string& filename)
|
||||
points.push_back(Base::Vector3d(it->x,it->y,it->z));
|
||||
colors.push_back(App::Color(it->r/255.0f,it->g/255.0f,it->b/255.0f,it->a/255.0f));
|
||||
}
|
||||
}
|
||||
else if (hasIntensity) {
|
||||
}
|
||||
else if (hasIntensity) {
|
||||
pcl::PointCloud<pcl::PointXYZI> cloud_in;
|
||||
pcl::io::loadPCDFile<pcl::PointXYZI>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -415,8 +415,8 @@ void PcdReader::read(const std::string& filename)
|
||||
points.push_back(Base::Vector3d(it->x,it->y,it->z));
|
||||
intensity.push_back(it->intensity);
|
||||
}
|
||||
}
|
||||
else if (hasNormals) {
|
||||
}
|
||||
else if (hasNormals) {
|
||||
pcl::PointCloud<pcl::PointNormal> cloud_in;
|
||||
pcl::io::loadPCDFile<pcl::PointNormal>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
@@ -425,15 +425,15 @@ void PcdReader::read(const std::string& filename)
|
||||
points.push_back(Base::Vector3d(it->x,it->y,it->z));
|
||||
normals.push_back(Base::Vector3f(it->normal_x,it->normal_y,it->normal_z));
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
pcl::PointCloud<pcl::PointXYZ> cloud_in;
|
||||
pcl::io::loadPCDFile<pcl::PointXYZ>(filename, cloud_in);
|
||||
points.reserve(cloud_in.size());
|
||||
for (pcl::PointCloud<pcl::PointXYZ>::const_iterator it = cloud_in.begin();it!=cloud_in.end();++it) {
|
||||
points.push_back(Base::Vector3d(it->x,it->y,it->z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -503,11 +503,11 @@ PlyWriter::~PlyWriter()
|
||||
|
||||
void PlyWriter::write(const std::string& filename)
|
||||
{
|
||||
bool hasIntensity = (intensity.size() == points.size());
|
||||
bool hasColors = (colors.size() == points.size());
|
||||
bool hasNormals = (normals.size() == points.size());
|
||||
bool hasIntensity = (intensity.size() == points.size());
|
||||
bool hasColors = (colors.size() == points.size());
|
||||
bool hasNormals = (normals.size() == points.size());
|
||||
|
||||
if (hasNormals && hasColors) {
|
||||
if (hasNormals && hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -533,8 +533,8 @@ void PlyWriter::write(const std::string& filename)
|
||||
}
|
||||
|
||||
pcl::io::savePLYFile<pcl::PointXYZRGBNormal>(filename, cloud_out);
|
||||
}
|
||||
else if (hasNormals && hasIntensity) {
|
||||
}
|
||||
else if (hasNormals && hasIntensity) {
|
||||
pcl::PointCloud<pcl::PointXYZINormal> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -557,8 +557,8 @@ void PlyWriter::write(const std::string& filename)
|
||||
}
|
||||
|
||||
pcl::io::savePLYFile<pcl::PointXYZINormal>(filename, cloud_out);
|
||||
}
|
||||
else if (hasColors) {
|
||||
}
|
||||
else if (hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBA> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -580,8 +580,8 @@ void PlyWriter::write(const std::string& filename)
|
||||
}
|
||||
|
||||
pcl::io::savePLYFile<pcl::PointXYZRGBA>(filename, cloud_out);
|
||||
}
|
||||
else if (hasIntensity) {
|
||||
}
|
||||
else if (hasIntensity) {
|
||||
pcl::PointCloud<pcl::PointXYZI> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -600,8 +600,8 @@ void PlyWriter::write(const std::string& filename)
|
||||
}
|
||||
|
||||
pcl::io::savePLYFile<pcl::PointXYZI>(filename, cloud_out);
|
||||
}
|
||||
else if (hasNormals) {
|
||||
}
|
||||
else if (hasNormals) {
|
||||
pcl::PointCloud<pcl::PointNormal> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -620,11 +620,11 @@ void PlyWriter::write(const std::string& filename)
|
||||
pn.normal_z = n.z;
|
||||
cloud_out.push_back(pn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pcl::io::savePLYFile<pcl::PointNormal>(filename, cloud_out);
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
pcl::PointCloud<pcl::PointXYZ> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
for (Points::PointKernel::const_iterator it = points.begin(); it != points.end(); ++it) {
|
||||
@@ -634,7 +634,7 @@ void PlyWriter::write(const std::string& filename)
|
||||
}
|
||||
|
||||
pcl::io::savePLYFile<pcl::PointXYZ>(filename, cloud_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -649,11 +649,11 @@ PcdWriter::~PcdWriter()
|
||||
|
||||
void PcdWriter::write(const std::string& filename)
|
||||
{
|
||||
bool hasIntensity = (intensity.size() == points.size());
|
||||
bool hasColors = (colors.size() == points.size());
|
||||
bool hasNormals = (normals.size() == points.size());
|
||||
bool hasIntensity = (intensity.size() == points.size());
|
||||
bool hasColors = (colors.size() == points.size());
|
||||
bool hasNormals = (normals.size() == points.size());
|
||||
|
||||
if (hasNormals && hasColors) {
|
||||
if (hasNormals && hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBNormal> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -675,13 +675,13 @@ void PcdWriter::write(const std::string& filename)
|
||||
pn.b = c.b * 255.0f;
|
||||
cloud_out.push_back(pn);
|
||||
}
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
pcl::io::savePCDFile<pcl::PointXYZRGBNormal>(filename, cloud_out);
|
||||
}
|
||||
else if (hasNormals && hasIntensity) {
|
||||
}
|
||||
else if (hasNormals && hasIntensity) {
|
||||
pcl::PointCloud<pcl::PointXYZINormal> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -700,13 +700,13 @@ void PcdWriter::write(const std::string& filename)
|
||||
pn.intensity = intensity[index];
|
||||
cloud_out.push_back(pn);
|
||||
}
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
pcl::io::savePCDFile<pcl::PointXYZINormal>(filename, cloud_out);
|
||||
}
|
||||
else if (hasColors) {
|
||||
}
|
||||
else if (hasColors) {
|
||||
pcl::PointCloud<pcl::PointXYZRGBA> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -724,13 +724,13 @@ void PcdWriter::write(const std::string& filename)
|
||||
pc.b = c.b * 255.0f;
|
||||
cloud_out.push_back(pc);
|
||||
}
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
pcl::io::savePCDFile<pcl::PointXYZRGBA>(filename, cloud_out);
|
||||
}
|
||||
else if (hasIntensity) {
|
||||
}
|
||||
else if (hasIntensity) {
|
||||
pcl::PointCloud<pcl::PointXYZI> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -745,13 +745,13 @@ void PcdWriter::write(const std::string& filename)
|
||||
pi.intensity = intensity[index];
|
||||
cloud_out.push_back(pi);
|
||||
}
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
pcl::io::savePCDFile<pcl::PointXYZI>(filename, cloud_out);
|
||||
}
|
||||
else if (hasNormals) {
|
||||
}
|
||||
else if (hasNormals) {
|
||||
pcl::PointCloud<pcl::PointNormal> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
|
||||
@@ -769,23 +769,23 @@ void PcdWriter::write(const std::string& filename)
|
||||
pn.normal_z = n.z;
|
||||
cloud_out.push_back(pn);
|
||||
}
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
pcl::io::savePCDFile<pcl::PointNormal>(filename, cloud_out);
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
pcl::PointCloud<pcl::PointXYZ> cloud_out;
|
||||
cloud_out.reserve(points.size());
|
||||
for (Points::PointKernel::const_iterator it = points.begin(); it != points.end(); ++it) {
|
||||
cloud_out.push_back(pcl::PointXYZ(it->x, it->y, it->z));
|
||||
}
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
cloud_out.width = width;
|
||||
cloud_out.height = height;
|
||||
|
||||
pcl::io::savePCDFile<pcl::PointXYZ>(filename, cloud_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# include <QObject>
|
||||
# include <QEvent>
|
||||
# include <QMutex>
|
||||
# include <QMutexLocker>
|
||||
# include <QMutexLocker>
|
||||
# include <QSemaphore>
|
||||
# include <QThread>
|
||||
# include <QWaitCondition>
|
||||
@@ -253,18 +253,18 @@ void DocumentProtector::init()
|
||||
DocumentReceiver::globalInstance()->
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
}
|
||||
|
||||
void DocumentProtector::slotDeletedDocument(const App::Document& Doc)
|
||||
{
|
||||
if (&Doc == getDocument()) {
|
||||
this->detachDocument();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DocumentProtector::slotDeletedDocument(const App::Document& Doc)
|
||||
{
|
||||
if (&Doc == getDocument()) {
|
||||
this->detachDocument();
|
||||
}
|
||||
}
|
||||
|
||||
void DocumentProtector::validate()
|
||||
{
|
||||
if (!this->getDocument())
|
||||
throw Base::Exception("Handled document is null");
|
||||
throw Base::ValueError("Handled document is null");
|
||||
}
|
||||
|
||||
App::DocumentObject *DocumentProtector::addObject(const std::string& type, const std::string& name)
|
||||
@@ -303,7 +303,7 @@ DocumentObjectProtector::~DocumentObjectProtector()
|
||||
void DocumentObjectProtector::validate()
|
||||
{
|
||||
if (!obj)
|
||||
throw Base::Exception("Handled document object is null");
|
||||
throw Base::ValueError("Handled document object is null");
|
||||
}
|
||||
|
||||
App::DocumentObject* DocumentObjectProtector::getObject() const
|
||||
|
||||
Reference in New Issue
Block a user