App: Prepare for clang-format
This commit is contained in:
@@ -37,6 +37,10 @@ exclude: |
|
||||
(?x)^(
|
||||
.*vcproj.*|
|
||||
.*vcxproj.*|
|
||||
src/App/ExpressionParser.tab.c|
|
||||
src/App/ExpressionParser.tab.h|
|
||||
src/App/ExpressionParser.y|
|
||||
src/App/lex.ExpressionParser.c|
|
||||
src/Mod/Import/App/SCL|
|
||||
src/Mod/Import/App/SCL_output|
|
||||
src/Mod/Mesh/App/TestData|
|
||||
|
||||
@@ -175,6 +175,7 @@ AppExport std::map<std::string, std::string> Application::mConfig;
|
||||
//**************************************************************************
|
||||
// Construction and destruction
|
||||
|
||||
// clang-format off
|
||||
PyDoc_STRVAR(FreeCAD_doc,
|
||||
"The functions in the FreeCAD module allow working with documents.\n"
|
||||
"The FreeCAD instance provides a list of references of documents which\n"
|
||||
@@ -237,6 +238,7 @@ init_image_module()
|
||||
};
|
||||
return PyModule_Create(&ImageModuleDef);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
Application::Application(std::map<std::string,std::string> &mConfig)
|
||||
: _mConfig(mConfig)
|
||||
@@ -264,6 +266,7 @@ void Application::setupPythonTypes()
|
||||
}
|
||||
Py::Module(pAppModule).setAttr(std::string("ActiveDocument"),Py::None());
|
||||
|
||||
// clang-format off
|
||||
static struct PyModuleDef ConsoleModuleDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"__FreeCADConsole__", Console_doc, -1,
|
||||
@@ -371,8 +374,10 @@ void Application::setupPythonTypes()
|
||||
Base::Vector2dPy::init_type();
|
||||
Base::Interpreter().addType(Base::Vector2dPy::type_object(),
|
||||
pBaseModule,"Vector2d");
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
void Application::setupPythonException(PyObject* module)
|
||||
{
|
||||
// Define custom Python exception types
|
||||
@@ -421,6 +426,7 @@ void Application::setupPythonException(PyObject* module)
|
||||
Py_INCREF(Base::PyExc_FC_CADKernelError);
|
||||
PyModule_AddObject(module, "CADKernelError", Base::PyExc_FC_CADKernelError);
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
//**************************************************************************
|
||||
// Interface
|
||||
@@ -488,6 +494,7 @@ Document* Application::newDocument(const char * Name, const char * UserName, boo
|
||||
_pActiveDoc = doc;
|
||||
|
||||
//NOLINTBEGIN
|
||||
// clang-format off
|
||||
// connect the signals to the application for the new document
|
||||
_pActiveDoc->signalBeforeChange.connect(std::bind(&App::Application::slotBeforeChangeDocument, this, sp::_1, sp::_2));
|
||||
_pActiveDoc->signalChanged.connect(std::bind(&App::Application::slotChangedDocument, this, sp::_1, sp::_2));
|
||||
@@ -508,6 +515,7 @@ Document* Application::newDocument(const char * Name, const char * UserName, boo
|
||||
_pActiveDoc->signalStartSave.connect(std::bind(&App::Application::slotStartSaveDocument, this, sp::_1, sp::_2));
|
||||
_pActiveDoc->signalFinishSave.connect(std::bind(&App::Application::slotFinishSaveDocument, this, sp::_1, sp::_2));
|
||||
_pActiveDoc->signalChangePropertyEditor.connect(std::bind(&App::Application::slotChangePropertyEditor, this, sp::_1, sp::_2));
|
||||
// clang-format on
|
||||
//NOLINTEND
|
||||
|
||||
// make sure that the active document is set in case no GUI is up
|
||||
@@ -1921,6 +1929,7 @@ void Application::init(int argc, char ** argv)
|
||||
}
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
void Application::initTypes()
|
||||
{
|
||||
// Base types
|
||||
@@ -2484,6 +2493,7 @@ void processProgramOptions(const variables_map& vm, std::map<std::string,std::st
|
||||
}
|
||||
}
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
void Application::initConfig(int argc, char ** argv)
|
||||
{
|
||||
|
||||
@@ -513,6 +513,7 @@ private:
|
||||
static void setupPythonTypes();
|
||||
static void setupPythonException(PyObject*);
|
||||
|
||||
// clang-format off
|
||||
// static python wrapper of the exported functions
|
||||
static PyObject* sGetParam (PyObject *self, PyObject *args);
|
||||
static PyObject* sSaveParameter (PyObject *self, PyObject *args);
|
||||
@@ -563,6 +564,7 @@ private:
|
||||
static PyObject *sCloseActiveTransaction(PyObject *self,PyObject *args);
|
||||
static PyObject *sCheckAbort(PyObject *self,PyObject *args);
|
||||
static PyMethodDef Methods[];
|
||||
// clang-format on
|
||||
|
||||
friend class ApplicationObserver;
|
||||
|
||||
|
||||
@@ -129,12 +129,14 @@ void Color::setPackedARGB(uint32_t argb)
|
||||
|
||||
std::string Color::asHexString() const
|
||||
{
|
||||
// clang-format off
|
||||
std::stringstream ss;
|
||||
ss << "#" << std::hex << std::uppercase << std::setfill('0')
|
||||
<< std::setw(2) << int(std::lround(r * 255.0F))
|
||||
<< std::setw(2) << int(std::lround(g * 255.0F))
|
||||
<< std::setw(2) << int(std::lround(b * 255.0F));
|
||||
return ss.str();
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
bool Color::fromHexString(const std::string& hex)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "FCGlobal.h"
|
||||
|
||||
|
||||
// clang-format off
|
||||
namespace Data
|
||||
{
|
||||
|
||||
@@ -64,6 +65,7 @@ AppExport const char *findElementName(const char *subname);
|
||||
AppExport const char *hasMappedElementName(const char *subname);
|
||||
|
||||
|
||||
}// namespace Data
|
||||
} // namespace Data
|
||||
// clang-format on
|
||||
|
||||
#endif // ELEMENT_NAMING_UTILS_H
|
||||
|
||||
@@ -384,7 +384,7 @@ void ExtensionContainer::restoreExtensions(Base::XMLReader& reader) {
|
||||
if (!ext->isPythonExtension()) {
|
||||
delete ext;
|
||||
std::stringstream str;
|
||||
str << "Extension is not a python addable version: '" << Type << "'" << std::ends;
|
||||
str << "Extension is not a python addable version: '" << Type << "'";
|
||||
throw Base::TypeError(str.str());
|
||||
}
|
||||
|
||||
|
||||
@@ -120,11 +120,14 @@ public:
|
||||
~ExtensionContainer() override;
|
||||
|
||||
void registerExtension(Base::Type extension, App::Extension* ext);
|
||||
bool hasExtension(Base::Type, bool derived=true) const; //returns first of type (or derived from if set to true) and throws otherwise
|
||||
bool hasExtension(const std::string& name) const; //this version does not check derived classes
|
||||
//returns first of type (or derived from if set to true) and throws otherwise
|
||||
bool hasExtension(Base::Type, bool derived=true) const;
|
||||
//this version does not check derived classes
|
||||
bool hasExtension(const std::string& name) const;
|
||||
bool hasExtensions() const;
|
||||
App::Extension* getExtension(Base::Type, bool derived = true, bool no_except=false) const;
|
||||
App::Extension* getExtension(const std::string& name) const; //this version does not check derived classes
|
||||
//this version does not check derived classes
|
||||
App::Extension* getExtension(const std::string& name) const;
|
||||
// this version checks for derived types and doesn't throw
|
||||
template<typename ExtensionT>
|
||||
ExtensionT* getExtension() const {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
// clang-format off
|
||||
#ifndef APP_FEATUREPYTHONPYIMP_H
|
||||
#define APP_FEATUREPYTHONPYIMP_H
|
||||
|
||||
@@ -117,3 +118,4 @@ private:
|
||||
#endif
|
||||
|
||||
#endif // APP_FEATUREPYTHONPYIMP_H
|
||||
// clang-format on
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
// clang-format off
|
||||
namespace App
|
||||
{
|
||||
|
||||
@@ -200,3 +201,4 @@ PyObject *FeaturePythonPyT<FeaturePyT>::_getattr(const char *attr)
|
||||
}
|
||||
|
||||
} //namespace App
|
||||
// clang-format on
|
||||
|
||||
@@ -695,6 +695,7 @@ FreeCAD.addImportType("FreeCAD document (*.FCStd)","FreeCAD")
|
||||
# set to no gui, is overwritten by InitGui
|
||||
App.GuiUp = 0
|
||||
|
||||
# fmt: off
|
||||
# fill up unit definitions
|
||||
|
||||
App.Units.NanoMetre = App.Units.Quantity('nm')
|
||||
@@ -898,7 +899,7 @@ App.Units.VolumetricThermalExpansionCoefficient = App.Units.Unit(0,0,0,0,-1)
|
||||
App.Units.Work = App.Units.Unit(2,1,-2)
|
||||
App.Units.YieldStrength = App.Units.Unit(-1,1,-2)
|
||||
App.Units.YoungsModulus = App.Units.Unit(-1,1,-2)
|
||||
|
||||
# fmt: on
|
||||
|
||||
# Add an enum for the different unit schemes
|
||||
from enum import IntEnum
|
||||
|
||||
@@ -32,11 +32,12 @@ PROPERTY_SOURCE(App::MeasureDistance, App::DocumentObject)
|
||||
|
||||
MeasureDistance::MeasureDistance()
|
||||
{
|
||||
// clang-format off
|
||||
ADD_PROPERTY_TYPE(P1,(Base::Vector3d()),"Measurement",Prop_None,"First point of measurement");
|
||||
ADD_PROPERTY_TYPE(P2,(Base::Vector3d()),"Measurement",Prop_None,"Second point of measurement");
|
||||
ADD_PROPERTY_TYPE(Distance,(0.0) ,"Measurement",App::PropertyType(Prop_ReadOnly|Prop_Output),
|
||||
"Distance between the points");
|
||||
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
MeasureDistance::~MeasureDistance() = default;
|
||||
|
||||
@@ -136,13 +136,16 @@ void Origin::setupObject () {
|
||||
const char *role;
|
||||
const QString label;
|
||||
Base::Rotation rot;
|
||||
} setupData [] = {
|
||||
}
|
||||
setupData [] = {
|
||||
// clang-format off
|
||||
{App::Line::getClassTypeId(), AxisRoles[0], tr("X-axis"), Base::Rotation()},
|
||||
{App::Line::getClassTypeId(), AxisRoles[1], tr("Y-axis"), Base::Rotation(Base::Vector3d(1,1,1), M_PI*2/3)},
|
||||
{App::Line::getClassTypeId(), AxisRoles[2], tr("Z-axis"), Base::Rotation(Base::Vector3d(1,-1,1), M_PI*2/3)},
|
||||
{App::Plane::getClassTypeId(), PlaneRoles[0], tr("XY-plane"), Base::Rotation()},
|
||||
{App::Plane::getClassTypeId(), PlaneRoles[1], tr("XZ-plane"), Base::Rotation(1.0, 0.0, 0.0, 1.0 )},
|
||||
{App::Plane::getClassTypeId(), PlaneRoles[2], tr("YZ-plane"), Base::Rotation(Base::Vector3d(1,1,1), M_PI*2/3)}
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
App::Document *doc = getDocument ();
|
||||
|
||||
@@ -261,8 +261,9 @@ void Property::Paste(const Property& /*from*/)
|
||||
}
|
||||
|
||||
void Property::setStatusValue(unsigned long status) {
|
||||
// clang-format off
|
||||
static const unsigned long mask =
|
||||
(1<<PropDynamic)
|
||||
(1<<PropDynamic)
|
||||
|(1<<PropNoRecompute)
|
||||
|(1<<PropReadOnly)
|
||||
|(1<<PropTransient)
|
||||
@@ -270,6 +271,7 @@ void Property::setStatusValue(unsigned long status) {
|
||||
|(1<<PropHidden)
|
||||
|(1<<PropNoPersist)
|
||||
|(1<<Busy);
|
||||
// clang-format on
|
||||
|
||||
status &= ~mask;
|
||||
status |= StatusBits.to_ulong() & mask;
|
||||
|
||||
@@ -42,6 +42,7 @@ class PropertyContainer;
|
||||
class DocumentObject;
|
||||
class Extension;
|
||||
|
||||
// clang-format off
|
||||
enum PropertyType
|
||||
{
|
||||
Prop_None = 0, /*!< No special property type */
|
||||
@@ -52,6 +53,7 @@ enum PropertyType
|
||||
Prop_NoRecompute = 16,/*!< Modified property doesn't touch its container for recompute */
|
||||
Prop_NoPersist = 32,/*!< Property won't be saved to file at all */
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
struct AppExport PropertyData
|
||||
{
|
||||
|
||||
@@ -139,7 +139,13 @@ void PropertyVector::setPyObject(PyObject *value)
|
||||
|
||||
void PropertyVector::Save (Base::Writer &writer) const
|
||||
{
|
||||
writer.Stream() << writer.ind() << "<PropertyVector valueX=\"" << _cVec.x << "\" valueY=\"" << _cVec.y << "\" valueZ=\"" << _cVec.z <<"\"/>" << endl;
|
||||
// clang-format off
|
||||
writer.Stream() << writer.ind()
|
||||
<< "<PropertyVector valueX=\"" << _cVec.x
|
||||
<< "\" valueY=\"" << _cVec.y
|
||||
<< "\" valueZ=\"" << _cVec.z
|
||||
<<"\"/>" << endl;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void PropertyVector::Restore(Base::XMLReader &reader)
|
||||
@@ -437,12 +443,14 @@ void PropertyMatrix::setPyObject(PyObject *value)
|
||||
|
||||
void PropertyMatrix::Save (Base::Writer &writer) const
|
||||
{
|
||||
// clang-format off
|
||||
writer.Stream() << writer.ind() << "<PropertyMatrix";
|
||||
writer.Stream() << " a11=\"" << _cMat[0][0] << "\" a12=\"" << _cMat[0][1] << "\" a13=\"" << _cMat[0][2] << "\" a14=\"" << _cMat[0][3] << "\"";
|
||||
writer.Stream() << " a21=\"" << _cMat[1][0] << "\" a22=\"" << _cMat[1][1] << "\" a23=\"" << _cMat[1][2] << "\" a24=\"" << _cMat[1][3] << "\"";
|
||||
writer.Stream() << " a31=\"" << _cMat[2][0] << "\" a32=\"" << _cMat[2][1] << "\" a33=\"" << _cMat[2][2] << "\" a34=\"" << _cMat[2][3] << "\"";
|
||||
writer.Stream() << " a41=\"" << _cMat[3][0] << "\" a42=\"" << _cMat[3][1] << "\" a43=\"" << _cMat[3][2] << "\" a44=\"" << _cMat[3][3] << "\"";
|
||||
writer.Stream() <<"/>" << endl;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void PropertyMatrix::Restore(Base::XMLReader &reader)
|
||||
@@ -1291,4 +1299,4 @@ void PropertyComplexGeoData::afterRestore()
|
||||
}
|
||||
}
|
||||
PropertyGeometry::afterRestore();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user