modernize C++: use nullptr
This commit is contained in:
@@ -122,7 +122,7 @@ public:
|
||||
std::ostringstream& ss,
|
||||
ElementIDRefs* sids,
|
||||
long masterTag,
|
||||
const char* postfix = 0,
|
||||
const char* postfix = nullptr,
|
||||
long tag = 0,
|
||||
bool forceTag = false) const;
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
|
||||
long getElementHistory(const MappedName & name,
|
||||
long masterTag,
|
||||
MappedName *original=0, std::vector<MappedName> *history=0) const;
|
||||
MappedName *original=nullptr, std::vector<MappedName> *history=nullptr) const;
|
||||
|
||||
private:
|
||||
/** Serialize this map
|
||||
|
||||
@@ -63,12 +63,12 @@ PyObject* StringHasherPy::getID(PyObject *args)
|
||||
{
|
||||
long id = -1;
|
||||
int index = 0;
|
||||
PyObject *value = 0;
|
||||
PyObject *value = nullptr;
|
||||
PyObject *base64 = Py_False;
|
||||
if (!PyArg_ParseTuple(args, "l|i",&id,&index)) {
|
||||
PyErr_Clear();
|
||||
if (!PyArg_ParseTuple(args, "O|O",&value,&base64))
|
||||
return NULL; // NULL triggers exception
|
||||
return nullptr;
|
||||
}
|
||||
if(id>0) {
|
||||
PY_TRY {
|
||||
@@ -139,7 +139,7 @@ Py::Dict StringHasherPy::getTable() const {
|
||||
|
||||
PyObject *StringHasherPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int StringHasherPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
|
||||
@@ -480,7 +480,7 @@ bool ParameterGrp::HasGroup(const char* Name) const
|
||||
if (_GroupMap.find(Name) != _GroupMap.end())
|
||||
return true;
|
||||
|
||||
if (_pGroupNode && FindElement(_pGroupNode,"FCParamGroup",Name) != 0)
|
||||
if (_pGroupNode && FindElement(_pGroupNode,"FCParamGroup",Name) != nullptr)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -1246,7 +1246,7 @@ void ParameterGrp::Clear(bool notify)
|
||||
|
||||
// Remove the rest of non-group nodes;
|
||||
std::vector<std::pair<ParamType, std::string>> params;
|
||||
for (DOMNode *child = _pGroupNode->getFirstChild(), *next = child; child != 0; child = next) {
|
||||
for (DOMNode *child = _pGroupNode->getFirstChild(), *next = child; child != nullptr; child = next) {
|
||||
next = next->getNextSibling();
|
||||
ParamType type = TypeValue(StrX(child->getNodeName()).c_str());
|
||||
if (type != ParamType::FCInvalid && type != ParamType::FCGroup)
|
||||
@@ -1354,7 +1354,7 @@ ParameterGrp::GetParameterNames(const char * sFilter) const
|
||||
std::string Name;
|
||||
|
||||
for (DOMNode *clChild = _pGroupNode->getFirstChild();
|
||||
clChild != 0; clChild = clChild->getNextSibling()) {
|
||||
clChild != nullptr; clChild = clChild->getNextSibling()) {
|
||||
if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) {
|
||||
StrX type(clChild->getNodeName());
|
||||
ParamType Type = TypeValue(type.c_str());
|
||||
|
||||
@@ -153,13 +153,13 @@ public:
|
||||
std::string &Value,
|
||||
const char *Default) const;
|
||||
std::vector<std::pair<std::string, std::string>>
|
||||
GetAttributeMap(ParamType Type, const char * sFilter = NULL) const;
|
||||
GetAttributeMap(ParamType Type, const char * sFilter = nullptr) const;
|
||||
/** Return the type and name of all parameters with optional filter
|
||||
* @param sFilter only strings which name includes sFilter are put in the vector
|
||||
* @return std::vector of pair(type, name)
|
||||
*/
|
||||
std::vector<std::pair<ParamType,std::string>>
|
||||
GetParameterNames(const char * sFilter = NULL) const;
|
||||
GetParameterNames(const char * sFilter = nullptr) const;
|
||||
//@}
|
||||
|
||||
/** @name methods for bool handling */
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
explicit TreeWidget(const char *name, QWidget* parent=nullptr);
|
||||
~TreeWidget() override;
|
||||
|
||||
static void setupResizableColumn(TreeWidget *tree=0);
|
||||
static void setupResizableColumn(TreeWidget *tree=nullptr);
|
||||
static void scrollItemToTop();
|
||||
void selectAllInstances(const ViewProviderDocumentObject &vpd);
|
||||
void selectLinkedObject(App::DocumentObject *linked);
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
*
|
||||
* @see https://github.com/FreeCAD/FreeCAD/issues/8708
|
||||
*/
|
||||
static std::unique_ptr<UiLoader> newInstance(QObject *parent=0);
|
||||
static std::unique_ptr<UiLoader> newInstance(QObject *parent=nullptr);
|
||||
|
||||
~UiLoader() override;
|
||||
|
||||
|
||||
@@ -3165,7 +3165,7 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
|
||||
}
|
||||
std::map<std::string, App::Color> ret;
|
||||
for(const auto &v : colors) {
|
||||
const char *pos = 0;
|
||||
const char *pos = nullptr;
|
||||
auto sobj = getObject()->resolve(v.first.c_str(),nullptr,nullptr,&pos);
|
||||
if(!sobj || !pos)
|
||||
continue;
|
||||
|
||||
@@ -1767,8 +1767,8 @@ CDxfRead::CDxfRead(const char* filepath)
|
||||
m_ifs->imbue(std::locale("C"));
|
||||
|
||||
m_version = RUnknown;
|
||||
m_CodePage = NULL;
|
||||
m_encoding = NULL;
|
||||
m_CodePage = nullptr;
|
||||
m_encoding = nullptr;
|
||||
stringToUTF8 = &CDxfRead::UTF8ToUTF8;
|
||||
}
|
||||
|
||||
@@ -3323,7 +3323,7 @@ bool CDxfRead::ReadDWGCodePage()
|
||||
{
|
||||
get_line();
|
||||
get_line();
|
||||
assert(m_CodePage == NULL); // If not, we have found two DWGCODEPAGE variables or DoRead was called twice on the same CDxfRead object.
|
||||
assert(m_CodePage == nullptr); // If not, we have found two DWGCODEPAGE variables or DoRead was called twice on the same CDxfRead object.
|
||||
m_CodePage = new std::string(m_str);
|
||||
|
||||
return ResolveEncoding();
|
||||
@@ -3331,15 +3331,15 @@ bool CDxfRead::ReadDWGCodePage()
|
||||
|
||||
bool CDxfRead::ResolveEncoding()
|
||||
{
|
||||
if (m_encoding != NULL) {
|
||||
if (m_encoding != nullptr) {
|
||||
delete m_encoding;
|
||||
m_encoding = NULL;
|
||||
m_encoding = nullptr;
|
||||
}
|
||||
if (m_version >= R2007) { // Note this does not include RUnknown, but does include RLater
|
||||
m_encoding = new std::string("utf_8");
|
||||
stringToUTF8 = &CDxfRead::UTF8ToUTF8;
|
||||
}
|
||||
else if (m_CodePage == NULL) {
|
||||
else if (m_CodePage == nullptr) {
|
||||
// cp1252
|
||||
m_encoding = new std::string("cp1252");
|
||||
stringToUTF8 = &CDxfRead::GeneralToUTF8;
|
||||
@@ -3362,10 +3362,10 @@ bool CDxfRead::ResolveEncoding()
|
||||
// and is just a direct c++ callable.
|
||||
Base::PyGILStateLocker lock;
|
||||
PyObject* pyDecoder = PyCodec_Decoder(m_encoding->c_str());
|
||||
if (pyDecoder == NULL)
|
||||
if (pyDecoder == nullptr)
|
||||
return false; // A key error exception will have been placed.
|
||||
PyObject* pyUTF8Decoder = PyCodec_Decoder("utf_8");
|
||||
assert(pyUTF8Decoder != NULL);
|
||||
assert(pyUTF8Decoder != nullptr);
|
||||
if (pyDecoder == pyUTF8Decoder)
|
||||
stringToUTF8 = &CDxfRead::UTF8ToUTF8;
|
||||
else
|
||||
@@ -3373,7 +3373,7 @@ bool CDxfRead::ResolveEncoding()
|
||||
Py_DECREF(pyDecoder);
|
||||
Py_DECREF(pyUTF8Decoder);
|
||||
}
|
||||
return m_encoding != NULL;
|
||||
return m_encoding != nullptr;
|
||||
}
|
||||
|
||||
const char* CDxfRead::UTF8ToUTF8(const char* encoded) const
|
||||
@@ -3385,15 +3385,15 @@ const char* CDxfRead::GeneralToUTF8(const char* encoded) const
|
||||
{
|
||||
Base::PyGILStateLocker lock;
|
||||
PyObject* decoded = PyUnicode_Decode(encoded, strlen(encoded), m_encoding->c_str(), "strict");
|
||||
if (decoded == NULL)
|
||||
return NULL;
|
||||
if (decoded == nullptr)
|
||||
return nullptr;
|
||||
Py_ssize_t len;
|
||||
const char* converted = PyUnicode_AsUTF8AndSize(decoded, &len);
|
||||
char* result = NULL;
|
||||
if (converted != NULL) {
|
||||
char* result = nullptr;
|
||||
if (converted != nullptr) {
|
||||
// converted only has lifetime of decoded so we must save a copy.
|
||||
result = (char *)malloc(len + 1);
|
||||
if (result == NULL)
|
||||
if (result == nullptr)
|
||||
PyErr_SetString(PyExc_MemoryError, "Out of memory");
|
||||
else
|
||||
memcpy(result, converted, len + 1);
|
||||
|
||||
@@ -58,8 +58,9 @@ std::string SketchObjectPy::representation() const
|
||||
|
||||
PyObject* SketchObjectPy::solve(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
int ret = this->getSketchObjectPtr()->solve();
|
||||
return Py_BuildValue("i", ret);
|
||||
}
|
||||
@@ -71,10 +72,12 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args)
|
||||
bool isConstruction;
|
||||
if (!PyArg_ParseTuple(args, "OO!", &pcObj, &PyBool_Type, &construction)) {
|
||||
PyErr_Clear();
|
||||
if (!PyArg_ParseTuple(args, "O", &pcObj))
|
||||
if (!PyArg_ParseTuple(args, "O", &pcObj)) {
|
||||
return nullptr;
|
||||
else
|
||||
}
|
||||
else {
|
||||
isConstruction = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
isConstruction = Base::asBoolean(construction);
|
||||
@@ -202,8 +205,9 @@ PyObject* SketchObjectPy::addGeometry(PyObject* args)
|
||||
PyObject* SketchObjectPy::delGeometry(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
if (!PyArg_ParseTuple(args, "i", &Index))
|
||||
if (!PyArg_ParseTuple(args, "i", &Index)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->delGeometry(Index)) {
|
||||
std::stringstream str;
|
||||
@@ -219,16 +223,18 @@ PyObject* SketchObjectPy::delGeometries(PyObject* args)
|
||||
{
|
||||
PyObject* pcObj;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &pcObj))
|
||||
if (!PyArg_ParseTuple(args, "O", &pcObj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PyObject_TypeCheck(pcObj, &(PyList_Type)) || PyObject_TypeCheck(pcObj, &(PyTuple_Type))) {
|
||||
|
||||
std::vector<int> geoIdList;
|
||||
Py::Sequence list(pcObj);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyLong_Check((*it).ptr()))
|
||||
if (PyLong_Check((*it).ptr())) {
|
||||
geoIdList.push_back(PyLong_AsLong((*it).ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->delGeometries(geoIdList)) {
|
||||
@@ -248,8 +254,9 @@ PyObject* SketchObjectPy::delGeometries(PyObject* args)
|
||||
|
||||
PyObject* SketchObjectPy::deleteAllGeometry(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->deleteAllGeometry()) {
|
||||
std::stringstream str;
|
||||
@@ -263,8 +270,9 @@ PyObject* SketchObjectPy::deleteAllGeometry(PyObject* args)
|
||||
|
||||
PyObject* SketchObjectPy::deleteAllConstraints(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->deleteAllConstraints()) {
|
||||
std::stringstream str;
|
||||
@@ -280,8 +288,9 @@ PyObject* SketchObjectPy::deleteAllConstraints(PyObject* args)
|
||||
PyObject* SketchObjectPy::toggleConstruction(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
if (!PyArg_ParseTuple(args, "i", &Index))
|
||||
if (!PyArg_ParseTuple(args, "i", &Index)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->toggleConstruction(Index)) {
|
||||
std::stringstream str;
|
||||
@@ -297,8 +306,9 @@ PyObject* SketchObjectPy::setConstruction(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
PyObject* Mode;
|
||||
if (!PyArg_ParseTuple(args, "iO!", &Index, &PyBool_Type, &Mode))
|
||||
if (!PyArg_ParseTuple(args, "iO!", &Index, &PyBool_Type, &Mode)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->setConstruction(Index, Base::asBoolean(Mode))) {
|
||||
std::stringstream str;
|
||||
@@ -313,13 +323,15 @@ PyObject* SketchObjectPy::setConstruction(PyObject* args)
|
||||
PyObject* SketchObjectPy::getConstruction(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
if (!PyArg_ParseTuple(args, "i", &Index))
|
||||
if (!PyArg_ParseTuple(args, "i", &Index)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto gf = this->getSketchObjectPtr()->getGeometryFacade(Index);
|
||||
|
||||
if (gf)
|
||||
if (gf) {
|
||||
return Py::new_reference_to(Py::Boolean(gf->getConstruction()));
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
str << "Not able to retrieve construction mode of a geometry with the given index: " << Index;
|
||||
@@ -330,8 +342,9 @@ PyObject* SketchObjectPy::getConstruction(PyObject* args)
|
||||
PyObject* SketchObjectPy::addConstraint(PyObject* args)
|
||||
{
|
||||
PyObject* pcObj;
|
||||
if (!PyArg_ParseTuple(args, "O", &pcObj))
|
||||
if (!PyArg_ParseTuple(args, "O", &pcObj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PyObject_TypeCheck(pcObj, &(Sketcher::ConstraintPy::Type))) {
|
||||
Sketcher::Constraint* constr =
|
||||
@@ -405,8 +418,9 @@ PyObject* SketchObjectPy::addConstraint(PyObject* args)
|
||||
PyObject* SketchObjectPy::delConstraint(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
if (!PyArg_ParseTuple(args, "i", &Index))
|
||||
if (!PyArg_ParseTuple(args, "i", &Index)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->delConstraint(Index)) {
|
||||
std::stringstream str;
|
||||
@@ -422,8 +436,9 @@ PyObject* SketchObjectPy::renameConstraint(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
char* utf8Name;
|
||||
if (!PyArg_ParseTuple(args, "iet", &Index, "utf-8", &utf8Name))
|
||||
if (!PyArg_ParseTuple(args, "iet", &Index, "utf-8", &utf8Name)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string Name = utf8Name;
|
||||
PyMem_Free(utf8Name);
|
||||
@@ -462,8 +477,9 @@ PyObject* SketchObjectPy::renameConstraint(PyObject* args)
|
||||
PyObject* SketchObjectPy::getIndexByName(PyObject* args)
|
||||
{
|
||||
char* utf8Name;
|
||||
if (!PyArg_ParseTuple(args, "et", "utf-8", &utf8Name))
|
||||
if (!PyArg_ParseTuple(args, "et", "utf-8", &utf8Name)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string Name = utf8Name;
|
||||
PyMem_Free(utf8Name);
|
||||
@@ -488,8 +504,9 @@ PyObject* SketchObjectPy::carbonCopy(PyObject* args)
|
||||
{
|
||||
char* ObjectName;
|
||||
PyObject* construction = Py_True;
|
||||
if (!PyArg_ParseTuple(args, "s|O!:Give an object", &ObjectName, &PyBool_Type, &construction))
|
||||
if (!PyArg_ParseTuple(args, "s|O!:Give an object", &ObjectName, &PyBool_Type, &construction)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Sketcher::SketchObject* skObj = this->getSketchObjectPtr();
|
||||
App::DocumentObject* Obj = skObj->getDocument()->getObject(ObjectName);
|
||||
@@ -524,8 +541,9 @@ PyObject* SketchObjectPy::addExternal(PyObject* args)
|
||||
{
|
||||
char* ObjectName;
|
||||
char* SubName;
|
||||
if (!PyArg_ParseTuple(args, "ss:Give an object and subelement name", &ObjectName, &SubName))
|
||||
if (!PyArg_ParseTuple(args, "ss:Give an object and subelement name", &ObjectName, &SubName)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// get the target object for the external link
|
||||
Sketcher::SketchObject* skObj = this->getSketchObjectPtr();
|
||||
@@ -558,8 +576,9 @@ PyObject* SketchObjectPy::addExternal(PyObject* args)
|
||||
PyObject* SketchObjectPy::delExternal(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
if (!PyArg_ParseTuple(args, "i", &Index))
|
||||
if (!PyArg_ParseTuple(args, "i", &Index)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->delExternal(Index)) {
|
||||
std::stringstream str;
|
||||
@@ -574,8 +593,9 @@ PyObject* SketchObjectPy::delExternal(PyObject* args)
|
||||
PyObject* SketchObjectPy::delConstraintOnPoint(PyObject* args)
|
||||
{
|
||||
int Index, pos = -1;
|
||||
if (!PyArg_ParseTuple(args, "i|i", &Index, &pos))
|
||||
if (!PyArg_ParseTuple(args, "i|i", &Index, &pos)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (pos >= static_cast<int>(Sketcher::PointPos::none)
|
||||
&& pos <= static_cast<int>(Sketcher::PointPos::mid)) {
|
||||
@@ -703,23 +723,30 @@ PyObject* SketchObjectPy::setDatum(PyObject* args)
|
||||
int err = this->getSketchObjectPtr()->setDatum(Index, Datum);
|
||||
if (err) {
|
||||
std::stringstream str;
|
||||
if (err == -1)
|
||||
if (err == -1) {
|
||||
str << "Invalid constraint index: " << Index;
|
||||
else if (err == -3)
|
||||
}
|
||||
else if (err == -3) {
|
||||
str << "Cannot set the datum because the sketch contains conflicting constraints";
|
||||
else if (err == -2)
|
||||
}
|
||||
else if (err == -2) {
|
||||
str << "Datum " << (const char*)Quantity.getUserString().toUtf8()
|
||||
<< " for the constraint with index " << Index << " is invalid";
|
||||
else if (err == -4)
|
||||
}
|
||||
else if (err == -4) {
|
||||
str << "Negative datum values are not valid for the constraint with index " << Index;
|
||||
else if (err == -5)
|
||||
}
|
||||
else if (err == -5) {
|
||||
str << "Zero is not a valid datum for the constraint with index " << Index;
|
||||
else if (err == -6)
|
||||
}
|
||||
else if (err == -6) {
|
||||
str << "Cannot set the datum because of invalid geometry";
|
||||
else
|
||||
}
|
||||
else {
|
||||
str << "Unexpected problem at setting datum "
|
||||
<< (const char*)Quantity.getUserString().toUtf8()
|
||||
<< " for the constraint with index " << Index;
|
||||
}
|
||||
PyErr_SetString(PyExc_ValueError, str.str().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
@@ -797,8 +824,9 @@ PyObject* SketchObjectPy::setDriving(PyObject* args)
|
||||
PyObject* driving;
|
||||
int constrid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iO!", &constrid, &PyBool_Type, &driving))
|
||||
if (!PyArg_ParseTuple(args, "iO!", &constrid, &PyBool_Type, &driving)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->setDriving(constrid, Base::asBoolean(driving))) {
|
||||
std::stringstream str;
|
||||
@@ -814,8 +842,9 @@ PyObject* SketchObjectPy::setDatumsDriving(PyObject* args)
|
||||
{
|
||||
PyObject* driving;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &driving))
|
||||
if (!PyArg_ParseTuple(args, "O!", &PyBool_Type, &driving)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->setDatumsDriving(Base::asBoolean(driving))) {
|
||||
std::stringstream str;
|
||||
@@ -829,8 +858,9 @@ PyObject* SketchObjectPy::setDatumsDriving(PyObject* args)
|
||||
|
||||
PyObject* SketchObjectPy::moveDatumsToEnd(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->moveDatumsToEnd()) {
|
||||
std::stringstream str;
|
||||
@@ -848,8 +878,9 @@ PyObject* SketchObjectPy::getDriving(PyObject* args)
|
||||
int constrid;
|
||||
bool driving;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid))
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->getDriving(constrid, driving)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Invalid constraint id");
|
||||
@@ -863,8 +894,9 @@ PyObject* SketchObjectPy::toggleDriving(PyObject* args)
|
||||
{
|
||||
int constrid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid))
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->toggleDriving(constrid)) {
|
||||
std::stringstream str;
|
||||
@@ -890,16 +922,18 @@ PyObject* SketchObjectPy::setVirtualSpace(PyObject* args)
|
||||
std::vector<int> constrIds;
|
||||
Py::Sequence list(id_or_ids);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyLong_Check((*it).ptr()))
|
||||
if (PyLong_Check((*it).ptr())) {
|
||||
constrIds.push_back(PyLong_AsLong((*it).ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
int ret = this->getSketchObjectPtr()->setVirtualSpace(constrIds,
|
||||
Base::asBoolean(invirtualspace));
|
||||
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
throw Py::TypeError("Impossible to set virtual space!");
|
||||
}
|
||||
}
|
||||
catch (const Base::ValueError& e) {
|
||||
throw Py::ValueError(e.getMessage());
|
||||
@@ -930,8 +964,9 @@ PyObject* SketchObjectPy::getVirtualSpace(PyObject* args)
|
||||
int constrid;
|
||||
bool invirtualspace;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid))
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->getVirtualSpace(constrid, invirtualspace)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Invalid constraint id");
|
||||
@@ -945,8 +980,9 @@ PyObject* SketchObjectPy::toggleVirtualSpace(PyObject* args)
|
||||
{
|
||||
int constrid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid))
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->toggleVirtualSpace(constrid)) {
|
||||
std::stringstream str;
|
||||
@@ -963,8 +999,9 @@ PyObject* SketchObjectPy::setActive(PyObject* args)
|
||||
PyObject* isactive;
|
||||
int constrid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iO!", &constrid, &PyBool_Type, &isactive))
|
||||
if (!PyArg_ParseTuple(args, "iO!", &constrid, &PyBool_Type, &isactive)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->setActive(constrid, Base::asBoolean(isactive))) {
|
||||
std::stringstream str;
|
||||
@@ -982,8 +1019,9 @@ PyObject* SketchObjectPy::getActive(PyObject* args)
|
||||
int constrid;
|
||||
bool isactive;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid))
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->getActive(constrid, isactive)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Invalid constraint id");
|
||||
@@ -997,8 +1035,9 @@ PyObject* SketchObjectPy::toggleActive(PyObject* args)
|
||||
{
|
||||
int constrid;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid))
|
||||
if (!PyArg_ParseTuple(args, "i", &constrid)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->toggleActive(constrid)) {
|
||||
std::stringstream str;
|
||||
@@ -1017,8 +1056,9 @@ PyObject* SketchObjectPy::movePoint(PyObject* args)
|
||||
int relative = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "iiO!|i", &GeoId, &PointType, &(Base::VectorPy::Type), &pcObj, &relative))
|
||||
args, "iiO!|i", &GeoId, &PointType, &(Base::VectorPy::Type), &pcObj, &relative)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pcObj)->value();
|
||||
|
||||
@@ -1037,8 +1077,9 @@ PyObject* SketchObjectPy::movePoint(PyObject* args)
|
||||
PyObject* SketchObjectPy::getGeoVertexIndex(PyObject* args)
|
||||
{
|
||||
int index;
|
||||
if (!PyArg_ParseTuple(args, "i", &index))
|
||||
if (!PyArg_ParseTuple(args, "i", &index)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SketchObject* obj = this->getSketchObjectPtr();
|
||||
int geoId;
|
||||
@@ -1053,8 +1094,9 @@ PyObject* SketchObjectPy::getGeoVertexIndex(PyObject* args)
|
||||
PyObject* SketchObjectPy::getPoint(PyObject* args)
|
||||
{
|
||||
int GeoId, PointType;
|
||||
if (!PyArg_ParseTuple(args, "ii", &GeoId, &PointType))
|
||||
if (!PyArg_ParseTuple(args, "ii", &GeoId, &PointType)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PointType < 0 || PointType > 3) {
|
||||
PyErr_SetString(PyExc_ValueError, "Invalid point type");
|
||||
@@ -1074,8 +1116,9 @@ PyObject* SketchObjectPy::getPoint(PyObject* args)
|
||||
PyObject* SketchObjectPy::getAxis(PyObject* args)
|
||||
{
|
||||
int AxId;
|
||||
if (!PyArg_ParseTuple(args, "i", &AxId))
|
||||
if (!PyArg_ParseTuple(args, "i", &AxId)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new Base::AxisPy(new Base::Axis(this->getSketchObjectPtr()->getAxis(AxId)));
|
||||
}
|
||||
@@ -1149,8 +1192,9 @@ PyObject* SketchObjectPy::trim(PyObject* args)
|
||||
PyObject* pcObj;
|
||||
int GeoId;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iO!", &GeoId, &(Base::VectorPy::Type), &pcObj))
|
||||
if (!PyArg_ParseTuple(args, "iO!", &GeoId, &(Base::VectorPy::Type), &pcObj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pcObj)->value();
|
||||
|
||||
@@ -1193,8 +1237,9 @@ PyObject* SketchObjectPy::split(PyObject* args)
|
||||
PyObject* pcObj;
|
||||
int GeoId;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iO!", &GeoId, &(Base::VectorPy::Type), &pcObj))
|
||||
if (!PyArg_ParseTuple(args, "iO!", &GeoId, &(Base::VectorPy::Type), &pcObj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Vector3d v1 = static_cast<Base::VectorPy*>(pcObj)->value();
|
||||
try {
|
||||
@@ -1218,8 +1263,9 @@ PyObject* SketchObjectPy::join(PyObject* args)
|
||||
int PosId1 = static_cast<int>(Sketcher::PointPos::none),
|
||||
PosId2 = static_cast<int>(Sketcher::PointPos::none);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "iiii", &GeoId1, &PosId1, &GeoId2, &PosId2))
|
||||
return 0;
|
||||
if (!PyArg_ParseTuple(args, "iiii", &GeoId1, &PosId1, &GeoId2, &PosId2)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->join(
|
||||
GeoId1, (Sketcher::PointPos)PosId1, GeoId2, (Sketcher::PointPos)PosId2)) {
|
||||
@@ -1227,7 +1273,7 @@ PyObject* SketchObjectPy::join(PyObject* args)
|
||||
str << "Not able to join the curves with end points: (" << GeoId1 << ", " << PosId1
|
||||
<< "), (" << GeoId2 << ", " << PosId2 << ")";
|
||||
PyErr_SetString(PyExc_ValueError, str.str().c_str());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
@@ -1239,23 +1285,26 @@ PyObject* SketchObjectPy::addSymmetric(PyObject* args)
|
||||
int refGeoId;
|
||||
int refPosId = static_cast<int>(Sketcher::PointPos::none);
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Oi|i", &pcObj, &refGeoId, &refPosId))
|
||||
if (!PyArg_ParseTuple(args, "Oi|i", &pcObj, &refGeoId, &refPosId)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PyObject_TypeCheck(pcObj, &(PyList_Type)) || PyObject_TypeCheck(pcObj, &(PyTuple_Type))) {
|
||||
std::vector<int> geoIdList;
|
||||
Py::Sequence list(pcObj);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyLong_Check((*it).ptr()))
|
||||
if (PyLong_Check((*it).ptr())) {
|
||||
geoIdList.push_back(PyLong_AsLong((*it).ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
int ret = this->getSketchObjectPtr()->addSymmetric(
|
||||
geoIdList, refGeoId, static_cast<Sketcher::PointPos>(refPosId))
|
||||
+ 1;
|
||||
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
throw Py::TypeError("Symmetric operation unsuccessful!");
|
||||
}
|
||||
|
||||
std::size_t numGeo = geoIdList.size();
|
||||
Py::Tuple tuple(numGeo);
|
||||
@@ -1278,8 +1327,9 @@ PyObject* SketchObjectPy::addCopy(PyObject* args)
|
||||
PyObject* clone = Py_False;
|
||||
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "OO!|O!", &pcObj, &(Base::VectorPy::Type), &pcVect, &PyBool_Type, &clone))
|
||||
args, "OO!|O!", &pcObj, &(Base::VectorPy::Type), &pcVect, &PyBool_Type, &clone)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Vector3d vect = static_cast<Base::VectorPy*>(pcVect)->value();
|
||||
|
||||
@@ -1287,8 +1337,9 @@ PyObject* SketchObjectPy::addCopy(PyObject* args)
|
||||
std::vector<int> geoIdList;
|
||||
Py::Sequence list(pcObj);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyLong_Check((*it).ptr()))
|
||||
if (PyLong_Check((*it).ptr())) {
|
||||
geoIdList.push_back(PyLong_AsLong((*it).ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -1296,8 +1347,9 @@ PyObject* SketchObjectPy::addCopy(PyObject* args)
|
||||
this->getSketchObjectPtr()->addCopy(geoIdList, vect, false, Base::asBoolean(clone))
|
||||
+ 1;
|
||||
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
throw Py::TypeError("Copy operation unsuccessful!");
|
||||
}
|
||||
|
||||
std::size_t numGeo = geoIdList.size();
|
||||
Py::Tuple tuple(numGeo);
|
||||
@@ -1322,8 +1374,9 @@ PyObject* SketchObjectPy::addMove(PyObject* args)
|
||||
{
|
||||
PyObject *pcObj, *pcVect;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OO!", &pcObj, &(Base::VectorPy::Type), &pcVect))
|
||||
if (!PyArg_ParseTuple(args, "OO!", &pcObj, &(Base::VectorPy::Type), &pcVect)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Vector3d vect = static_cast<Base::VectorPy*>(pcVect)->value();
|
||||
|
||||
@@ -1331,8 +1384,9 @@ PyObject* SketchObjectPy::addMove(PyObject* args)
|
||||
std::vector<int> geoIdList;
|
||||
Py::Sequence list(pcObj);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyLong_Check((*it).ptr()))
|
||||
if (PyLong_Check((*it).ptr())) {
|
||||
geoIdList.push_back(PyLong_AsLong((*it).ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
this->getSketchObjectPtr()->addCopy(geoIdList, vect, true);
|
||||
@@ -1364,8 +1418,9 @@ PyObject* SketchObjectPy::addRectangularArray(PyObject* args)
|
||||
&cols,
|
||||
&PyBool_Type,
|
||||
&constraindisplacement,
|
||||
&perpscale))
|
||||
&perpscale)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Base::Vector3d vect = static_cast<Base::VectorPy*>(pcVect)->value();
|
||||
|
||||
@@ -1373,8 +1428,9 @@ PyObject* SketchObjectPy::addRectangularArray(PyObject* args)
|
||||
std::vector<int> geoIdList;
|
||||
Py::Sequence list(pcObj);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyLong_Check((*it).ptr()))
|
||||
if (PyLong_Check((*it).ptr())) {
|
||||
geoIdList.push_back(PyLong_AsLong((*it).ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -1388,8 +1444,9 @@ PyObject* SketchObjectPy::addRectangularArray(PyObject* args)
|
||||
perpscale)
|
||||
+ 1;
|
||||
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
throw Py::TypeError("Copy operation unsuccessful!");
|
||||
}
|
||||
}
|
||||
catch (const Base::ValueError& e) {
|
||||
throw Py::ValueError(e.getMessage());
|
||||
@@ -1407,21 +1464,24 @@ PyObject* SketchObjectPy::removeAxesAlignment(PyObject* args)
|
||||
{
|
||||
PyObject* pcObj;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O", &pcObj))
|
||||
if (!PyArg_ParseTuple(args, "O", &pcObj)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PyObject_TypeCheck(pcObj, &(PyList_Type)) || PyObject_TypeCheck(pcObj, &(PyTuple_Type))) {
|
||||
std::vector<int> geoIdList;
|
||||
Py::Sequence list(pcObj);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyLong_Check((*it).ptr()))
|
||||
if (PyLong_Check((*it).ptr())) {
|
||||
geoIdList.push_back(PyLong_AsLong((*it).ptr()));
|
||||
}
|
||||
}
|
||||
|
||||
int ret = this->getSketchObjectPtr()->removeAxesAlignment(geoIdList) + 1;
|
||||
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
throw Py::TypeError("Operation unsuccessful!");
|
||||
}
|
||||
|
||||
Py_Return;
|
||||
}
|
||||
@@ -1435,8 +1495,9 @@ PyObject* SketchObjectPy::calculateAngleViaPoint(PyObject* args)
|
||||
{
|
||||
int GeoId1 = 0, GeoId2 = 0;
|
||||
double px = 0, py = 0;
|
||||
if (!PyArg_ParseTuple(args, "iidd", &GeoId1, &GeoId2, &px, &py))
|
||||
if (!PyArg_ParseTuple(args, "iidd", &GeoId1, &GeoId2, &px, &py)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SketchObject* obj = this->getSketchObjectPtr();
|
||||
if (GeoId1 > obj->getHighestCurveIndex() || -GeoId1 > obj->getExternalGeometryCount()
|
||||
@@ -1453,8 +1514,9 @@ PyObject* SketchObjectPy::isPointOnCurve(PyObject* args)
|
||||
{
|
||||
int GeoId = GeoEnum::GeoUndef;
|
||||
double px = 0, py = 0;
|
||||
if (!PyArg_ParseTuple(args, "idd", &GeoId, &px, &py))
|
||||
if (!PyArg_ParseTuple(args, "idd", &GeoId, &px, &py)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SketchObject* obj = this->getSketchObjectPtr();
|
||||
if (GeoId > obj->getHighestCurveIndex() || -GeoId > obj->getExternalGeometryCount()) {
|
||||
@@ -1468,8 +1530,9 @@ PyObject* SketchObjectPy::isPointOnCurve(PyObject* args)
|
||||
PyObject* SketchObjectPy::calculateConstraintError(PyObject* args)
|
||||
{
|
||||
int ic = -1;
|
||||
if (!PyArg_ParseTuple(args, "i", &ic))
|
||||
if (!PyArg_ParseTuple(args, "i", &ic)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SketchObject* obj = this->getSketchObjectPtr();
|
||||
if (ic >= obj->Constraints.getSize() || ic < 0) {
|
||||
@@ -1484,8 +1547,9 @@ PyObject* SketchObjectPy::calculateConstraintError(PyObject* args)
|
||||
PyObject* SketchObjectPy::changeConstraintsLocking(PyObject* args)
|
||||
{
|
||||
int bLock = 0;
|
||||
if (!PyArg_ParseTuple(args, "i", &bLock))
|
||||
if (!PyArg_ParseTuple(args, "i", &bLock)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SketchObject* obj = this->getSketchObjectPtr();
|
||||
|
||||
@@ -1499,8 +1563,9 @@ PyObject* SketchObjectPy::ExposeInternalGeometry(PyObject* args)
|
||||
{
|
||||
int GeoId;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId))
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->exposeInternalGeometry(GeoId) == -1) {
|
||||
std::stringstream str;
|
||||
@@ -1517,8 +1582,9 @@ PyObject* SketchObjectPy::DeleteUnusedInternalGeometry(PyObject* args)
|
||||
{
|
||||
int GeoId;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId))
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->deleteUnusedInternalGeometry(GeoId) == -1) {
|
||||
std::stringstream str;
|
||||
@@ -1534,8 +1600,9 @@ PyObject* SketchObjectPy::exposeInternalGeometry(PyObject* args)
|
||||
{
|
||||
int GeoId;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId))
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->exposeInternalGeometry(GeoId) == -1) {
|
||||
std::stringstream str;
|
||||
@@ -1551,8 +1618,9 @@ PyObject* SketchObjectPy::deleteUnusedInternalGeometry(PyObject* args)
|
||||
{
|
||||
int GeoId;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId))
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->deleteUnusedInternalGeometry(GeoId) == -1) {
|
||||
std::stringstream str;
|
||||
@@ -1568,8 +1636,9 @@ PyObject* SketchObjectPy::convertToNURBS(PyObject* args)
|
||||
{
|
||||
int GeoId;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId))
|
||||
if (!PyArg_ParseTuple(args, "i", &GeoId)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!this->getSketchObjectPtr()->convertToNURBS(GeoId)) {
|
||||
std::stringstream str;
|
||||
@@ -1586,8 +1655,9 @@ PyObject* SketchObjectPy::increaseBSplineDegree(PyObject* args)
|
||||
int GeoId;
|
||||
int incr = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i|i", &GeoId, &incr))
|
||||
if (!PyArg_ParseTuple(args, "i|i", &GeoId, &incr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!this->getSketchObjectPtr()->increaseBSplineDegree(GeoId, incr)) {
|
||||
std::stringstream str;
|
||||
@@ -1604,8 +1674,9 @@ PyObject* SketchObjectPy::decreaseBSplineDegree(PyObject* args)
|
||||
int GeoId;
|
||||
int decr = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "i|i", &GeoId, &decr))
|
||||
if (!PyArg_ParseTuple(args, "i|i", &GeoId, &decr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ok = this->getSketchObjectPtr()->decreaseBSplineDegree(GeoId, decr);
|
||||
return Py_BuildValue("O", (ok ? Py_True : Py_False));
|
||||
@@ -1617,8 +1688,9 @@ PyObject* SketchObjectPy::modifyBSplineKnotMultiplicity(PyObject* args)
|
||||
int knotIndex;
|
||||
int multiplicity = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "ii|i", &GeoId, &knotIndex, &multiplicity))
|
||||
if (!PyArg_ParseTuple(args, "ii|i", &GeoId, &knotIndex, &multiplicity)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!this->getSketchObjectPtr()->modifyBSplineKnotMultiplicity(
|
||||
GeoId, knotIndex, multiplicity)) {
|
||||
@@ -1637,8 +1709,9 @@ PyObject* SketchObjectPy::insertBSplineKnot(PyObject* args)
|
||||
double knotParam;
|
||||
int multiplicity = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "id|i", &GeoId, &knotParam, &multiplicity))
|
||||
if (!PyArg_ParseTuple(args, "id|i", &GeoId, &knotParam, &multiplicity)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!this->getSketchObjectPtr()->insertBSplineKnot(GeoId, knotParam, multiplicity)) {
|
||||
std::stringstream str;
|
||||
@@ -1658,8 +1731,9 @@ PyObject* SketchObjectPy::autoconstraint(PyObject* args)
|
||||
|
||||
|
||||
if (!PyArg_ParseTuple(
|
||||
args, "|ddO!", &precision, &angleprecision, &PyBool_Type, &includeconstruction))
|
||||
args, "|ddO!", &precision, &angleprecision, &PyBool_Type, &includeconstruction)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->autoConstraint(
|
||||
precision, angleprecision, Base::asBoolean(includeconstruction))) {
|
||||
@@ -1677,8 +1751,9 @@ PyObject* SketchObjectPy::detectMissingPointOnPointConstraints(PyObject* args)
|
||||
double precision = Precision::Confusion() * 1000;
|
||||
PyObject* includeconstruction = Py_True;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|dO!", &precision, &PyBool_Type, &includeconstruction))
|
||||
if (!PyArg_ParseTuple(args, "|dO!", &precision, &PyBool_Type, &includeconstruction)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return Py::new_reference_to(
|
||||
Py::Long(this->getSketchObjectPtr()->detectMissingPointOnPointConstraints(
|
||||
@@ -1689,8 +1764,9 @@ PyObject* SketchObjectPy::detectMissingVerticalHorizontalConstraints(PyObject* a
|
||||
{
|
||||
double angleprecision = M_PI / 8;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|d", &angleprecision))
|
||||
if (!PyArg_ParseTuple(args, "|d", &angleprecision)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return Py::new_reference_to(Py::Long(
|
||||
this->getSketchObjectPtr()->detectMissingVerticalHorizontalConstraints(angleprecision)));
|
||||
@@ -1700,8 +1776,9 @@ PyObject* SketchObjectPy::detectMissingEqualityConstraints(PyObject* args)
|
||||
{
|
||||
double precision = Precision::Confusion() * 1000;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|d", &precision))
|
||||
if (!PyArg_ParseTuple(args, "|d", &precision)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return Py::new_reference_to(
|
||||
Py::Long(this->getSketchObjectPtr()->detectMissingEqualityConstraints(precision)));
|
||||
@@ -1711,8 +1788,9 @@ PyObject* SketchObjectPy::analyseMissingPointOnPointCoincident(PyObject* args)
|
||||
{
|
||||
double angleprecision = M_PI / 8;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|d", &angleprecision))
|
||||
if (!PyArg_ParseTuple(args, "|d", &angleprecision)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
this->getSketchObjectPtr()->analyseMissingPointOnPointCoincident(angleprecision);
|
||||
|
||||
@@ -1724,8 +1802,9 @@ PyObject* SketchObjectPy::makeMissingPointOnPointCoincident(PyObject* args)
|
||||
|
||||
PyObject* onebyone = Py_False;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &onebyone))
|
||||
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &onebyone)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
this->getSketchObjectPtr()->makeMissingPointOnPointCoincident(Base::asBoolean(onebyone));
|
||||
|
||||
@@ -1736,8 +1815,9 @@ PyObject* SketchObjectPy::makeMissingVerticalHorizontal(PyObject* args)
|
||||
{
|
||||
PyObject* onebyone = Py_False;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &onebyone))
|
||||
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &onebyone)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
this->getSketchObjectPtr()->makeMissingVerticalHorizontal(Base::asBoolean(onebyone));
|
||||
|
||||
@@ -1748,8 +1828,9 @@ PyObject* SketchObjectPy::makeMissingEquality(PyObject* args)
|
||||
{
|
||||
PyObject* onebyone = Py_True;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &onebyone))
|
||||
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &onebyone)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
this->getSketchObjectPtr()->makeMissingEquality(Base::asBoolean(onebyone));
|
||||
|
||||
@@ -1760,8 +1841,9 @@ PyObject* SketchObjectPy::autoRemoveRedundants(PyObject* args)
|
||||
{
|
||||
PyObject* updategeo = Py_True;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &updategeo))
|
||||
if (!PyArg_ParseTuple(args, "|O!", &PyBool_Type, &updategeo)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
this->getSketchObjectPtr()->autoRemoveRedundants(Base::asBoolean(updategeo));
|
||||
|
||||
@@ -1770,8 +1852,9 @@ PyObject* SketchObjectPy::autoRemoveRedundants(PyObject* args)
|
||||
|
||||
PyObject* SketchObjectPy::toPythonCommands(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto sketch = this->getSketchObjectPtr();
|
||||
|
||||
@@ -2026,8 +2109,9 @@ void SketchObjectPy::setMissingRadiusConstraints(Py::List arg)
|
||||
|
||||
PyObject* SketchObjectPy::getGeometryWithDependentParameters(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<std::pair<int, PointPos>> geometrymap;
|
||||
|
||||
@@ -2120,8 +2204,9 @@ void SketchObjectPy::setGeometryFacadeList(Py::List value)
|
||||
PyObject* SketchObjectPy::getGeometryId(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
if (!PyArg_ParseTuple(args, "i", &Index))
|
||||
if (!PyArg_ParseTuple(args, "i", &Index)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
long Id;
|
||||
|
||||
@@ -2139,8 +2224,9 @@ PyObject* SketchObjectPy::setGeometryId(PyObject* args)
|
||||
{
|
||||
int Index;
|
||||
long Id;
|
||||
if (!PyArg_ParseTuple(args, "il", &Index, &Id))
|
||||
if (!PyArg_ParseTuple(args, "il", &Index, &Id)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (this->getSketchObjectPtr()->setGeometryId(Index, Id)) {
|
||||
std::stringstream str;
|
||||
@@ -2231,8 +2317,9 @@ int SketchObjectPy::setCustomAttributes(const char* attr, PyObject* obj)
|
||||
|
||||
prop->setPyObject(obj);
|
||||
|
||||
if (strcmp(attr, "Geometry") == 0)
|
||||
if (strcmp(attr, "Geometry") == 0) {
|
||||
getSketchObjectPtr()->rebuildVertexIndex();
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -57,12 +57,14 @@ bool isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection)
|
||||
&& doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
|
||||
if (static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchMode()
|
||||
== ViewProviderSketch::STATUS_NONE) {
|
||||
if (!actsOnSelection)
|
||||
if (!actsOnSelection) {
|
||||
return true;
|
||||
}
|
||||
else if (Gui::Selection().countObjectsOfType(
|
||||
Sketcher::SketchObject::getClassTypeId())
|
||||
> 0)
|
||||
> 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,18 +301,24 @@ void CmdSketcherCompBSplineShowHideGeometryInformation::activated(int iMsg)
|
||||
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
Gui::Command* cmd;
|
||||
|
||||
if (iMsg == 0)
|
||||
if (iMsg == 0) {
|
||||
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineDegree");
|
||||
else if (iMsg == 1)
|
||||
}
|
||||
else if (iMsg == 1) {
|
||||
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePolygon");
|
||||
else if (iMsg == 2)
|
||||
}
|
||||
else if (iMsg == 2) {
|
||||
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineComb");
|
||||
else if (iMsg == 3)
|
||||
}
|
||||
else if (iMsg == 3) {
|
||||
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineKnotMultiplicity");
|
||||
else if (iMsg == 4)
|
||||
}
|
||||
else if (iMsg == 4) {
|
||||
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePoleWeight");
|
||||
else
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
cmd->invoke(0);
|
||||
|
||||
@@ -356,8 +364,9 @@ void CmdSketcherCompBSplineShowHideGeometryInformation::languageChange()
|
||||
{
|
||||
Command::languageChange();
|
||||
|
||||
if (!_pcAction)
|
||||
if (!_pcAction) {
|
||||
return;
|
||||
}
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
@@ -950,12 +959,15 @@ void CmdSketcherCompModifyKnotMultiplicity::activated(int iMsg)
|
||||
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
Gui::Command* cmd;
|
||||
|
||||
if (iMsg == 0)
|
||||
if (iMsg == 0) {
|
||||
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineIncreaseKnotMultiplicity");
|
||||
else if (iMsg == 1)
|
||||
}
|
||||
else if (iMsg == 1) {
|
||||
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineDecreaseKnotMultiplicity");
|
||||
else
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
|
||||
cmd->invoke(0);
|
||||
|
||||
@@ -993,8 +1005,9 @@ void CmdSketcherCompModifyKnotMultiplicity::languageChange()
|
||||
{
|
||||
Command::languageChange();
|
||||
|
||||
if (!_pcAction)
|
||||
if (!_pcAction) {
|
||||
return;
|
||||
}
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
@@ -1132,10 +1145,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (applied)
|
||||
if (applied) {
|
||||
Gui::Command::commitCommand();
|
||||
else
|
||||
}
|
||||
else {
|
||||
Gui::Command::abortCommand();
|
||||
}
|
||||
|
||||
tryAutoRecomputeIfNotSolve(Obj);
|
||||
|
||||
@@ -1223,9 +1238,10 @@ void CmdSketcherInsertKnot::activated(int iMsg)
|
||||
int GeoId = std::atoi(SubNames[0].substr(4, 4000).c_str()) - 1;
|
||||
const Part::Geometry* geo = Obj->getGeometry(GeoId);
|
||||
|
||||
if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId())
|
||||
if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) {
|
||||
ActivateBSplineHandler(getActiveGuiDocument(),
|
||||
new DrawSketchHandlerBSplineInsertKnot(Obj, GeoId));
|
||||
}
|
||||
else {
|
||||
Gui::TranslatedUserWarning(
|
||||
Obj,
|
||||
@@ -1264,7 +1280,7 @@ void CmdSketcherJoinCurves::activated(int iMsg)
|
||||
|
||||
// get the selection
|
||||
std::vector<Gui::SelectionObject> selection;
|
||||
selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId());
|
||||
selection = getSelection().getSelectionEx(nullptr, Sketcher::SketchObject::getClassTypeId());
|
||||
|
||||
// only one sketch with its subelements are allowed to be selected
|
||||
if (selection.size() != 1) {
|
||||
@@ -1367,10 +1383,12 @@ void CmdSketcherJoinCurves::activated(int iMsg)
|
||||
getSelection().clearSelection();
|
||||
}
|
||||
|
||||
if (applied)
|
||||
if (applied) {
|
||||
Gui::Command::commitCommand();
|
||||
else
|
||||
}
|
||||
else {
|
||||
Gui::Command::abortCommand();
|
||||
}
|
||||
|
||||
tryAutoRecomputeIfNotSolve(Obj);
|
||||
getSelection().clearSelection();
|
||||
|
||||
@@ -231,7 +231,7 @@ void CmdBlendCurve::activated(int)
|
||||
std::string objName[2];
|
||||
std::string edge[2];
|
||||
std::string featName = getUniqueObjectName("BlendCurve");
|
||||
std::vector<Gui::SelectionObject> sel = getSelection().getSelectionEx(0, Part::Feature::getClassTypeId());
|
||||
std::vector<Gui::SelectionObject> sel = getSelection().getSelectionEx(nullptr, Part::Feature::getClassTypeId());
|
||||
|
||||
objName[0] = sel[0].getFeatName();
|
||||
edge[0] = sel[0].getSubNames()[0];
|
||||
|
||||
@@ -571,7 +571,7 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject
|
||||
-
|
||||
+ if not i.Static and not i.Class:
|
||||
+ if (not i.Const):
|
||||
if (ret != 0)
|
||||
if (ret != nullptr)
|
||||
static_cast<@self.export.Name@*>(self)->startNotify();
|
||||
-
|
||||
-
|
||||
|
||||
Reference in New Issue
Block a user