All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent eafd18dac0
commit 25c3ba7338
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -110,78 +110,104 @@ PyMOD_INIT_FUNC(Measure)
// Add fundamental umf Measure Types
App::MeasureManager::addMeasureType("DISTANCE",
"Distance",
"Measure::MeasureDistance",
MeasureDistance::isValidSelection,
MeasureDistance::isPrioritizedSelection);
App::MeasureManager::addMeasureType(
"DISTANCE",
"Distance",
"Measure::MeasureDistance",
MeasureDistance::isValidSelection,
MeasureDistance::isPrioritizedSelection
);
App::MeasureManager::addMeasureType("DISTANCEFREE",
"Distance Free",
"Measure::MeasureDistanceDetached",
MeasureDistanceDetached::isValidSelection,
nullptr);
App::MeasureManager::addMeasureType(
"DISTANCEFREE",
"Distance Free",
"Measure::MeasureDistanceDetached",
MeasureDistanceDetached::isValidSelection,
nullptr
);
App::MeasureManager::addMeasureType("ANGLE",
"Angle",
"Measure::MeasureAngle",
MeasureAngle::isValidSelection,
MeasureAngle::isPrioritizedSelection);
App::MeasureManager::addMeasureType(
"ANGLE",
"Angle",
"Measure::MeasureAngle",
MeasureAngle::isValidSelection,
MeasureAngle::isPrioritizedSelection
);
App::MeasureManager::addMeasureType("LENGTH",
"Length",
"Measure::MeasureLength",
MeasureLength::isValidSelection,
nullptr);
App::MeasureManager::addMeasureType(
"LENGTH",
"Length",
"Measure::MeasureLength",
MeasureLength::isValidSelection,
nullptr
);
App::MeasureManager::addMeasureType("POSITION",
"Position",
"Measure::MeasurePosition",
MeasurePosition::isValidSelection,
nullptr);
App::MeasureManager::addMeasureType(
"POSITION",
"Position",
"Measure::MeasurePosition",
MeasurePosition::isValidSelection,
nullptr
);
App::MeasureManager::addMeasureType("AREA",
"Area",
"Measure::MeasureArea",
MeasureArea::isValidSelection,
nullptr);
App::MeasureManager::addMeasureType(
"AREA",
"Area",
"Measure::MeasureArea",
MeasureArea::isValidSelection,
nullptr
);
App::MeasureManager::addMeasureType("RADIUS",
"Radius",
"Measure::MeasureRadius",
MeasureRadius::isValidSelection,
MeasureRadius::isPrioritizedSelection);
App::MeasureManager::addMeasureType(
"RADIUS",
"Radius",
"Measure::MeasureRadius",
MeasureRadius::isValidSelection,
MeasureRadius::isPrioritizedSelection
);
// load measure callbacks from Part module
auto lengthList = Part::MeasureClient::reportLengthCB();
for (auto& entry : lengthList) {
MeasureBaseExtendable<Part::MeasureLengthInfo>::addGeometryHandler(entry.m_module,
entry.m_callback);
MeasureBaseExtendable<Part::MeasureLengthInfo>::addGeometryHandler(
entry.m_module,
entry.m_callback
);
}
auto angleList = Part::MeasureClient::reportAngleCB();
for (auto& entry : angleList) {
MeasureBaseExtendable<Part::MeasureAngleInfo>::addGeometryHandler(entry.m_module,
entry.m_callback);
MeasureBaseExtendable<Part::MeasureAngleInfo>::addGeometryHandler(
entry.m_module,
entry.m_callback
);
}
auto areaList = Part::MeasureClient::reportAreaCB();
for (auto& entry : areaList) {
MeasureBaseExtendable<Part::MeasureAreaInfo>::addGeometryHandler(entry.m_module,
entry.m_callback);
MeasureBaseExtendable<Part::MeasureAreaInfo>::addGeometryHandler(
entry.m_module,
entry.m_callback
);
}
auto distanceList = Part::MeasureClient::reportDistanceCB();
for (auto& entry : distanceList) {
MeasureBaseExtendable<Part::MeasureDistanceInfo>::addGeometryHandler(entry.m_module,
entry.m_callback);
MeasureBaseExtendable<Part::MeasureDistanceInfo>::addGeometryHandler(
entry.m_module,
entry.m_callback
);
}
auto positionList = Part::MeasureClient::reportPositionCB();
for (auto& entry : positionList) {
MeasureBaseExtendable<Part::MeasurePositionInfo>::addGeometryHandler(entry.m_module,
entry.m_callback);
MeasureBaseExtendable<Part::MeasurePositionInfo>::addGeometryHandler(
entry.m_module,
entry.m_callback
);
}
auto radiusList = Part::MeasureClient::reportRadiusCB();
for (auto& entry : radiusList) {
MeasureBaseExtendable<Part::MeasureRadiusInfo>::addGeometryHandler(entry.m_module,
entry.m_callback);
MeasureBaseExtendable<Part::MeasureRadiusInfo>::addGeometryHandler(
entry.m_module,
entry.m_callback
);
}

View File

@@ -88,7 +88,8 @@ public:
&Module::getLocatedTopoShape,
"Part.TopoShape = Measure.getLocatedTopoShape(DocumentObject, longSubElement) Resolves "
"the net placement of DocumentObject and returns the object's shape/subshape with the "
"net placement applied. Link scaling operations along the path are also applied.");
"net placement applied. Link scaling operations along the path are also applied."
);
initialize("This is a module for measuring"); // register with Python
}
~Module() override

View File

@@ -38,27 +38,27 @@ PROPERTY_SOURCE(Measure::MeasureAngle, Measure::MeasureBase)
MeasureAngle::MeasureAngle()
{
ADD_PROPERTY_TYPE(Element1,
(nullptr),
"Measurement",
App::Prop_None,
"First element of the measurement");
ADD_PROPERTY_TYPE(Element1, (nullptr), "Measurement", App::Prop_None, "First element of the measurement");
Element1.setScope(App::LinkScope::Global);
Element1.setAllowExternal(true);
ADD_PROPERTY_TYPE(Element2,
(nullptr),
"Measurement",
App::Prop_None,
"Second element of the measurement");
ADD_PROPERTY_TYPE(
Element2,
(nullptr),
"Measurement",
App::Prop_None,
"Second element of the measurement"
);
Element2.setScope(App::LinkScope::Global);
Element2.setAllowExternal(true);
ADD_PROPERTY_TYPE(Angle,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Angle between the two elements");
ADD_PROPERTY_TYPE(
Angle,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Angle between the two elements"
);
Angle.setUnit(Base::Unit::Angle);
}

View File

@@ -36,19 +36,17 @@ PROPERTY_SOURCE(Measure::MeasureArea, Measure::MeasureBase)
MeasureArea::MeasureArea()
{
ADD_PROPERTY_TYPE(Elements,
(nullptr),
"Measurement",
App::Prop_None,
"Element to get the area from");
ADD_PROPERTY_TYPE(Elements, (nullptr), "Measurement", App::Prop_None, "Element to get the area from");
Elements.setScope(App::LinkScope::Global);
Elements.setAllowExternal(true);
ADD_PROPERTY_TYPE(Area,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Area of element");
ADD_PROPERTY_TYPE(
Area,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Area of element"
);
}
MeasureArea::~MeasureArea() = default;

View File

@@ -44,7 +44,8 @@ MeasureBase::MeasureBase()
(Base::Placement()),
nullptr,
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output | App::Prop_NoRecompute),
"Visual placement of the measurement");
"Visual placement of the measurement"
);
}
@@ -183,7 +184,8 @@ QString MeasureBase::getResultString()
if (prop->isDerivedFrom<App::PropertyQuantity>()) {
return QString::fromStdString(
static_cast<App::PropertyQuantity*>(prop)->getQuantityValue().getUserString());
static_cast<App::PropertyQuantity*>(prop)->getQuantityValue().getUserString()
);
}

View File

@@ -133,16 +133,17 @@ public:
auto handler = getGeometryHandler(mod);
if (!handler) {
Base::Console().log("MeasureBaseExtendable::getMeasureInfo: No geometry handler "
"available for submitted element type");
Base::Console().log(
"MeasureBaseExtendable::getMeasureInfo: No geometry handler "
"available for submitted element type"
);
return nullptr;
}
return handler(subObjT);
}
static void addGeometryHandlers(const std::vector<std::string>& modules,
GeometryHandler callback)
static void addGeometryHandlers(const std::vector<std::string>& modules, GeometryHandler callback)
{
// TODO: this will replace a callback with a later one. Should we check that there isn't
// already a handler defined for this module?

View File

@@ -45,58 +45,68 @@ PROPERTY_SOURCE(Measure::MeasureDistance, Measure::MeasureBase)
MeasureDistance::MeasureDistance()
{
ADD_PROPERTY_TYPE(Element1,
(nullptr),
"Measurement",
App::Prop_None,
"First element of the measurement");
ADD_PROPERTY_TYPE(Element1, (nullptr), "Measurement", App::Prop_None, "First element of the measurement");
Element1.setScope(App::LinkScope::Global);
Element1.setAllowExternal(true);
ADD_PROPERTY_TYPE(Element2,
(nullptr),
"Measurement",
App::Prop_None,
"Second element of the measurement");
ADD_PROPERTY_TYPE(
Element2,
(nullptr),
"Measurement",
App::Prop_None,
"Second element of the measurement"
);
Element2.setScope(App::LinkScope::Global);
Element2.setAllowExternal(true);
ADD_PROPERTY_TYPE(Distance,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance between the two elements");
ADD_PROPERTY_TYPE(
Distance,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance between the two elements"
);
Distance.setUnit(Base::Unit::Length);
ADD_PROPERTY_TYPE(DistanceX,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in X-direction");
ADD_PROPERTY_TYPE(
DistanceX,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in X-direction"
);
DistanceX.setUnit(Base::Unit::Length);
ADD_PROPERTY_TYPE(DistanceY,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in Y-direction");
ADD_PROPERTY_TYPE(
DistanceY,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in Y-direction"
);
DistanceY.setUnit(Base::Unit::Length);
ADD_PROPERTY_TYPE(DistanceZ,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in Z-direction");
ADD_PROPERTY_TYPE(
DistanceZ,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in Z-direction"
);
DistanceZ.setUnit(Base::Unit::Length);
ADD_PROPERTY_TYPE(Position1,
(Base::Vector3d(0.0, 0.0, 0.0)),
"Measurement",
App::Prop_Hidden,
"Position1");
ADD_PROPERTY_TYPE(Position2,
(Base::Vector3d(0.0, 1.0, 0.0)),
"Measurement",
App::Prop_Hidden,
"Position2");
ADD_PROPERTY_TYPE(
Position1,
(Base::Vector3d(0.0, 0.0, 0.0)),
"Measurement",
App::Prop_Hidden,
"Position1"
);
ADD_PROPERTY_TYPE(
Position2,
(Base::Vector3d(0.0, 1.0, 0.0)),
"Measurement",
App::Prop_Hidden,
"Position2"
);
}
MeasureDistance::~MeasureDistance() = default;
@@ -117,10 +127,9 @@ bool MeasureDistance::isValidSelection(const App::MeasureSelection& selection)
}
if (type != App::MeasureElementType::POINT && type != App::MeasureElementType::LINE
&& type != App::MeasureElementType::LINESEGMENT
&& type != App::MeasureElementType::CIRCLE && type != App::MeasureElementType::ARC
&& type != App::MeasureElementType::CURVE && type != App::MeasureElementType::PLANE
&& type != App::MeasureElementType::CYLINDER) {
&& type != App::MeasureElementType::LINESEGMENT && type != App::MeasureElementType::CIRCLE
&& type != App::MeasureElementType::ARC && type != App::MeasureElementType::CURVE
&& type != App::MeasureElementType::PLANE && type != App::MeasureElementType::CYLINDER) {
return false;
}
}
@@ -322,42 +331,42 @@ PROPERTY_SOURCE(Measure::MeasureDistanceDetached, Measure::MeasureBase)
MeasureDistanceDetached::MeasureDistanceDetached()
{
ADD_PROPERTY_TYPE(Distance,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance between the two elements");
ADD_PROPERTY_TYPE(
Distance,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance between the two elements"
);
Distance.setUnit(Base::Unit::Length);
ADD_PROPERTY_TYPE(DistanceX,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in X-direction");
ADD_PROPERTY_TYPE(
DistanceX,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in X-direction"
);
DistanceX.setUnit(Base::Unit::Length);
ADD_PROPERTY_TYPE(DistanceY,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in Y-direction");
ADD_PROPERTY_TYPE(
DistanceY,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in Y-direction"
);
DistanceY.setUnit(Base::Unit::Length);
ADD_PROPERTY_TYPE(DistanceZ,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in Z-direction");
ADD_PROPERTY_TYPE(
DistanceZ,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Distance in Z-direction"
);
DistanceZ.setUnit(Base::Unit::Length);
ADD_PROPERTY_TYPE(Position1,
(Base::Vector3d(0.0, 0.0, 0.0)),
"Measurement",
App::Prop_None,
"Position1");
ADD_PROPERTY_TYPE(Position2,
(Base::Vector3d(0.0, 1.0, 0.0)),
"Measurement",
App::Prop_None,
"Position2");
ADD_PROPERTY_TYPE(Position1, (Base::Vector3d(0.0, 0.0, 0.0)), "Measurement", App::Prop_None, "Position1");
ADD_PROPERTY_TYPE(Position2, (Base::Vector3d(0.0, 1.0, 0.0)), "Measurement", App::Prop_None, "Position2");
}
MeasureDistanceDetached::~MeasureDistanceDetached() = default;
@@ -425,10 +434,12 @@ Base::Type MeasureDistanceType::getTypeId() const
void MeasureDistanceType::init()
{
initSubclass(MeasureDistanceType::classTypeId,
"App::MeasureDistance",
"App::DocumentObject",
&(MeasureDistanceType::create));
initSubclass(
MeasureDistanceType::classTypeId,
"App::MeasureDistance",
"App::DocumentObject",
&(MeasureDistanceType::create)
);
}
void* MeasureDistanceType::create()
@@ -440,9 +451,11 @@ Base::Type MeasureDistanceType::classTypeId = Base::Type::BadType;
// Migrate old MeasureDistance Type
void MeasureDistanceDetached::handleChangedPropertyName(Base::XMLReader& reader,
const char* TypeName,
const char* PropName)
void MeasureDistanceDetached::handleChangedPropertyName(
Base::XMLReader& reader,
const char* TypeName,
const char* PropName
)
{
if (strcmp(PropName, "P1") == 0 && strcmp(TypeName, "App::PropertyVector") == 0) {
Position1.Restore(reader);

View File

@@ -57,8 +57,7 @@ private:
};
class MeasureExport MeasureDistance
: public Measure::MeasureBaseExtendable<Part::MeasureDistanceInfo>
class MeasureExport MeasureDistance: public Measure::MeasureBaseExtendable<Part::MeasureDistanceInfo>
{
PROPERTY_HEADER_WITH_OVERRIDE(Measure::MeasureDistance);
@@ -155,9 +154,11 @@ public:
// Return the object we are measuring
std::vector<App::DocumentObject*> getSubject() const override;
void handleChangedPropertyName(Base::XMLReader& reader,
const char* TypeName,
const char* PropName) override;
void handleChangedPropertyName(
Base::XMLReader& reader,
const char* TypeName,
const char* PropName
) override;
private:
void onChanged(const App::Property* prop) override;

View File

@@ -38,19 +38,17 @@ PROPERTY_SOURCE(Measure::MeasureLength, Measure::MeasureBase)
MeasureLength::MeasureLength()
{
ADD_PROPERTY_TYPE(Elements,
(nullptr),
"Measurement",
App::Prop_None,
"Elements to get the length from");
ADD_PROPERTY_TYPE(Elements, (nullptr), "Measurement", App::Prop_None, "Elements to get the length from");
Elements.setScope(App::LinkScope::Global);
Elements.setAllowExternal(true);
ADD_PROPERTY_TYPE(Length,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Length of selection");
ADD_PROPERTY_TYPE(
Length,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Length of selection"
);
}
MeasureLength::~MeasureLength() = default;

View File

@@ -37,20 +37,18 @@ PROPERTY_SOURCE(Measure::MeasurePosition, Measure::MeasureBase)
MeasurePosition::MeasurePosition()
{
ADD_PROPERTY_TYPE(Element,
(nullptr),
"Measurement",
App::Prop_None,
"Element to get the position from");
ADD_PROPERTY_TYPE(Element, (nullptr), "Measurement", App::Prop_None, "Element to get the position from");
Element.setScope(App::LinkScope::Global);
Element.setAllowExternal(true);
ADD_PROPERTY_TYPE(Position,
(0.0, 0.0, 0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"The absolute position");
ADD_PROPERTY_TYPE(
Position,
(0.0, 0.0, 0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"The absolute position"
);
}
MeasurePosition::~MeasurePosition() = default;
@@ -137,10 +135,8 @@ QString MeasurePosition::getResultString()
int precision = 2;
QString text;
QTextStream(&text) << "X: " << QString::number(value.x, 'f', precision) << " " << unit
<< Qt::endl
<< "Y: " << QString::number(value.y, 'f', precision) << " " << unit
<< Qt::endl
QTextStream(&text) << "X: " << QString::number(value.x, 'f', precision) << " " << unit << Qt::endl
<< "Y: " << QString::number(value.y, 'f', precision) << " " << unit << Qt::endl
<< "Z: " << QString::number(value.z, 'f', precision) << " " << unit;
return text;
}

View File

@@ -42,8 +42,7 @@ namespace Measure
{
class MeasureExport MeasurePosition
: public Measure::MeasureBaseExtendable<Part::MeasurePositionInfo>
class MeasureExport MeasurePosition: public Measure::MeasureBaseExtendable<Part::MeasurePositionInfo>
{
PROPERTY_HEADER_WITH_OVERRIDE(Measure::MeasurePosition);

View File

@@ -45,19 +45,17 @@ PROPERTY_SOURCE(Measure::MeasureRadius, Measure::MeasureBase)
MeasureRadius::MeasureRadius()
{
ADD_PROPERTY_TYPE(Element,
(nullptr),
"Measurement",
App::Prop_None,
"Element to get the radius from");
ADD_PROPERTY_TYPE(Element, (nullptr), "Measurement", App::Prop_None, "Element to get the radius from");
Element.setScope(App::LinkScope::Global);
Element.setAllowExternal(true);
ADD_PROPERTY_TYPE(Radius,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Radius of selection");
ADD_PROPERTY_TYPE(
Radius,
(0.0),
"Measurement",
App::PropertyType(App::Prop_ReadOnly | App::Prop_Output),
"Radius of selection"
);
}
MeasureRadius::~MeasureRadius() = default;

View File

@@ -127,11 +127,12 @@ MeasureType Measurement::findType()
for (; obj != objects.end(); ++obj, ++subEl) {
TopoDS_Shape refSubShape;
try {
refSubShape = Part::Feature::getShape(*obj,
Part::ShapeOption::NeedSubElement
| Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
(*subEl).c_str());
refSubShape = Part::Feature::getShape(
*obj,
Part::ShapeOption::NeedSubElement | Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
(*subEl).c_str()
);
if (refSubShape.IsNull()) {
return MeasureType::Invalid;
@@ -324,14 +325,14 @@ MeasureType Measurement::getType()
return measureType;
}
TopoDS_Shape
Measurement::getShape(App::DocumentObject* obj, const char* subName, TopAbs_ShapeEnum hint) const
TopoDS_Shape Measurement::getShape(App::DocumentObject* obj, const char* subName, TopAbs_ShapeEnum hint) const
{
return Part::Feature::getShape(obj,
Part::ShapeOption::NeedSubElement
| Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
subName);
return Part::Feature::getShape(
obj,
Part::ShapeOption::NeedSubElement | Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
subName
);
}
@@ -408,7 +409,8 @@ double Measurement::length() const
}
default: {
throw Base::RuntimeError(
"Measurement - length - Curve type not currently handled");
"Measurement - length - Curve type not currently handled"
);
}
}
}
@@ -618,8 +620,7 @@ double Measurement::cylinderAxisDistance() const
BRepAdaptor_Surface surface2(face2);
if (surface1.GetType() == GeomAbs_Cylinder && surface2.GetType() == GeomAbs_Cylinder) {
distance =
gp_Lin(surface1.Cylinder().Axis()).Distance(gp_Lin(surface2.Cylinder().Axis()));
distance = gp_Lin(surface1.Cylinder().Axis()).Distance(gp_Lin(surface2.Cylinder().Axis()));
}
}
else if (measureType == MeasureType::CircleToCylinder) {
@@ -740,7 +741,8 @@ double Measurement::angle(const Base::Vector3d& /*param*/) const
}
double aRad = axis1.Angle(axis2);
return Base::toDegrees<double>(
std::min(aRad, std::fmod(aRad + std::numbers::pi, 2.0 * std::numbers::pi)));
std::min(aRad, std::fmod(aRad + std::numbers::pi, 2.0 * std::numbers::pi))
);
}
}
throw Base::RuntimeError("Unexpected error for angle measurement");
@@ -831,10 +833,8 @@ Base::Vector3d Measurement::delta() const
if (measureType == MeasureType::PointToPoint) {
if (numRefs == 2) {
// Keep separate case for two points to reduce need for complex algorithm
TopoDS_Shape shape1 =
getShape(objects.at(0), subElements.at(0).c_str(), TopAbs_VERTEX);
TopoDS_Shape shape2 =
getShape(objects.at(1), subElements.at(1).c_str(), TopAbs_VERTEX);
TopoDS_Shape shape1 = getShape(objects.at(0), subElements.at(0).c_str(), TopAbs_VERTEX);
TopoDS_Shape shape2 = getShape(objects.at(1), subElements.at(1).c_str(), TopAbs_VERTEX);
const TopoDS_Vertex& vert1 = TopoDS::Vertex(shape1);
const TopoDS_Vertex& vert2 = TopoDS::Vertex(shape2);
@@ -845,8 +845,7 @@ Base::Vector3d Measurement::delta() const
return Base::Vector3d(diff.X(), diff.Y(), diff.Z());
}
}
else if (measureType == MeasureType::PointToEdge
|| measureType == MeasureType::PointToSurface
else if (measureType == MeasureType::PointToEdge || measureType == MeasureType::PointToSurface
|| measureType == MeasureType::PointToCircle
|| measureType == MeasureType::PointToCylinder) {
// BrepExtema can calculate minimum distance between any set of topology sets.
@@ -870,8 +869,7 @@ Base::Vector3d Measurement::delta() const
else if (measureType == MeasureType::Edges) {
// Only case that is supported is straight line edge
if (numRefs == 1) {
TopoDS_Shape shape =
getShape(objects.at(0), subElements.at(0).c_str(), TopAbs_EDGE);
TopoDS_Shape shape = getShape(objects.at(0), subElements.at(0).c_str(), TopAbs_EDGE);
const TopoDS_Edge& edge = TopoDS::Edge(shape);
BRepAdaptor_Curve curve(edge);
@@ -883,10 +881,8 @@ Base::Vector3d Measurement::delta() const
}
}
else if (numRefs == 2) {
TopoDS_Shape shape1 =
getShape(objects.at(0), subElements.at(0).c_str(), TopAbs_EDGE);
TopoDS_Shape shape2 =
getShape(objects.at(1), subElements.at(1).c_str(), TopAbs_EDGE);
TopoDS_Shape shape1 = getShape(objects.at(0), subElements.at(0).c_str(), TopAbs_EDGE);
TopoDS_Shape shape2 = getShape(objects.at(1), subElements.at(1).c_str(), TopAbs_EDGE);
BRepAdaptor_Curve curve1(TopoDS::Edge(shape1));
BRepAdaptor_Curve curve2(TopoDS::Edge(shape2));
@@ -1026,11 +1022,12 @@ bool Measurement::planesAreParallel() const
for (size_t i = 0; i < objects.size(); ++i) {
TopoDS_Shape refSubShape;
try {
refSubShape = Part::Feature::getShape(objects[i],
Part::ShapeOption::NeedSubElement
| Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
subElements[i].c_str());
refSubShape = Part::Feature::getShape(
objects[i],
Part::ShapeOption::NeedSubElement | Part::ShapeOption::ResolveLink
| Part::ShapeOption::Transform,
subElements[i].c_str()
);
if (refSubShape.IsNull()) {
return false;

View File

@@ -111,8 +111,7 @@ public:
double diameter() const;
// Calculates the angle between two edges
double
angle(const Base::Vector3d& param = Base::Vector3d(0, 0, 0)) const; // param is never used???
double angle(const Base::Vector3d& param = Base::Vector3d(0, 0, 0)) const; // param is never used???
// Calculate the center of mass
Base::Vector3d massCenter() const;
@@ -134,9 +133,11 @@ public:
protected:
// Hint parameter helps sort out compound shapes by specifying a subelement type
// use hint = TopAbs_COMPOUND to give no hint
TopoDS_Shape getShape(App::DocumentObject* obj,
const char* subName,
TopAbs_ShapeEnum hint = TopAbs_COMPOUND) const;
TopoDS_Shape getShape(
App::DocumentObject* obj,
const char* subName,
TopAbs_ShapeEnum hint = TopAbs_COMPOUND
) const;
private:
MeasureType measureType;

View File

@@ -50,7 +50,8 @@ Base::Color Preferences::defaultLineColor()
{
Base::Color fcColor;
fcColor.setPackedValue(
getPreferenceGroup("Appearance")->GetUnsigned("DefaultLineColor", 0x3CF00000));
getPreferenceGroup("Appearance")->GetUnsigned("DefaultLineColor", 0x3CF00000)
);
return fcColor;
}
@@ -58,7 +59,8 @@ Base::Color Preferences::defaultTextColor()
{
Base::Color fcColor;
fcColor.setPackedValue(
getPreferenceGroup("Appearance")->GetUnsigned("DefaultTextColor", 0x00000000));
getPreferenceGroup("Appearance")->GetUnsigned("DefaultTextColor", 0x00000000)
);
return fcColor;
}
@@ -66,7 +68,8 @@ Base::Color Preferences::defaultTextBackgroundColor()
{
Base::Color fcColor;
fcColor.setPackedValue(
getPreferenceGroup("Appearance")->GetUnsigned("DefaultTextBackgroundColor", 0x3CF00000));
getPreferenceGroup("Appearance")->GetUnsigned("DefaultTextBackgroundColor", 0x3CF00000)
);
return fcColor;
}

View File

@@ -55,9 +55,11 @@ using namespace Measure;
//! ResolveResult is a class to hold the result of resolving a selection into the actual target
//! object and traditional subElement name (Vertex1).
ResolveResult::ResolveResult(const App::DocumentObject* realTarget,
const std::string& shortSubName,
const App::DocumentObject* targetParent)
ResolveResult::ResolveResult(
const App::DocumentObject* realTarget,
const std::string& shortSubName,
const App::DocumentObject* targetParent
)
: m_target(App::SubObjectT(realTarget, shortSubName.c_str()))
, m_targetParent(App::DocumentObjectT(targetParent))
{}
@@ -80,14 +82,16 @@ App::DocumentObject& ResolveResult::getTargetParent() const
//! returns the actual target object and subname pointed to by selectObj and selectLongSub (which
//! is likely a result from getSelection or getSelectionEx)
ResolveResult ShapeFinder::resolveSelection(const App::DocumentObject& selectObj,
const std::string& selectLongSub)
ResolveResult ShapeFinder::resolveSelection(
const App::DocumentObject& selectObj,
const std::string& selectLongSub
)
{
App::DocumentObject* targetParent {nullptr};
std::string childName {};
const char* subElement {nullptr};
App::DocumentObject* realTarget =
selectObj.resolve(selectLongSub.c_str(), &targetParent, &childName, &subElement);
App::DocumentObject* realTarget
= selectObj.resolve(selectLongSub.c_str(), &targetParent, &childName, &subElement);
auto shortSub = getLastTerm(selectLongSub);
return {realTarget, shortSub, targetParent};
}
@@ -100,8 +104,7 @@ ResolveResult ShapeFinder::resolveSelection(const App::DocumentObject& selectObj
// TODO: to truly locate the shape, we need to consider attachments - see
// ShapeExtractor::getShapesFromXRoot()
// and ShapeFinder::getLinkAttachParent()
TopoDS_Shape ShapeFinder::getLocatedShape(const App::DocumentObject& rootObject,
const std::string& leafSub)
TopoDS_Shape ShapeFinder::getLocatedShape(const App::DocumentObject& rootObject, const std::string& leafSub)
{
auto resolved = resolveSelection(rootObject, leafSub);
auto target = &resolved.getTarget();
@@ -110,9 +113,10 @@ TopoDS_Shape ShapeFinder::getLocatedShape(const App::DocumentObject& rootObject,
return {};
}
TopoDS_Shape shape =
Part::Feature::getShape(target,
Part::ShapeOption::ResolveLink | Part::ShapeOption::Transform);
TopoDS_Shape shape = Part::Feature::getShape(
target,
Part::ShapeOption::ResolveLink | Part::ShapeOption::Transform
);
if (isShapeReallyNull(shape)) {
return {};
}
@@ -131,8 +135,10 @@ TopoDS_Shape ShapeFinder::getLocatedShape(const App::DocumentObject& rootObject,
//! convenient version of previous method
Part::TopoShape ShapeFinder::getLocatedTopoShape(const App::DocumentObject& rootObject,
const std::string& leafSub)
Part::TopoShape ShapeFinder::getLocatedTopoShape(
const App::DocumentObject& rootObject,
const std::string& leafSub
)
{
return {getLocatedShape(rootObject, leafSub)};
}
@@ -142,10 +148,12 @@ Part::TopoShape ShapeFinder::getLocatedTopoShape(const App::DocumentObject& root
//! the placements will need to be applied in the reverse order (ie top down) of what is delivered
//! in plm stack. leafSub is a dot separated longSubName which DOES NOT include rootObject. the
//! result does not include rootObject's transform.
void ShapeFinder::crawlPlacementChain(std::vector<Base::Placement>& plmStack,
std::vector<Base::Matrix4D>& scaleStack,
const App::DocumentObject& rootObject,
const std::string& leafSub)
void ShapeFinder::crawlPlacementChain(
std::vector<Base::Placement>& plmStack,
std::vector<Base::Matrix4D>& scaleStack,
const App::DocumentObject& rootObject,
const std::string& leafSub
)
{
auto currentSub = leafSub;
std::string previousSub {};
@@ -169,9 +177,11 @@ void ShapeFinder::crawlPlacementChain(std::vector<Base::Placement>& plmStack,
//! return inShape with placement and scaler applied. If inShape contains any infinite subshapes
//! (such as Datum planes), the infinite shapes will not be included in the result.
TopoDS_Shape ShapeFinder::transformShape(TopoDS_Shape& inShape,
const Base::Placement& placement,
const Base::Matrix4D& scaler)
TopoDS_Shape ShapeFinder::transformShape(
TopoDS_Shape& inShape,
const Base::Placement& placement,
const Base::Matrix4D& scaler
)
{
if (isShapeReallyNull(inShape)) {
return {};
@@ -294,8 +304,10 @@ bool ShapeFinder::isShapeReallyNull(const TopoDS_Shape& shape)
//! Returns the net transformation of a path from rootObject to leafSub. rootObject's transform
//! is included in the result.
std::pair<Base::Placement, Base::Matrix4D>
ShapeFinder::getGlobalTransform(const App::DocumentObject& rootObject, const std::string& leafSub)
std::pair<Base::Placement, Base::Matrix4D> ShapeFinder::getGlobalTransform(
const App::DocumentObject& rootObject,
const std::string& leafSub
)
{
// we prune the last term if it is a vertex, edge or face
std::string newSub = removeGeometryTerm(leafSub);
@@ -321,8 +333,9 @@ ShapeFinder::getGlobalTransform(const App::DocumentObject& rootObject, const std
//! tries to get the global position and scale for a object with no information about the
//! path through the tree from a root to cursor object.
std::pair<Base::Placement, Base::Matrix4D>
ShapeFinder::getGlobalTransform(const App::DocumentObject* cursorObject)
std::pair<Base::Placement, Base::Matrix4D> ShapeFinder::getGlobalTransform(
const App::DocumentObject* cursorObject
)
{
if (!cursorObject) {
return {};
@@ -346,9 +359,10 @@ ShapeFinder::getGlobalTransform(const App::DocumentObject* cursorObject)
//! combine a series of placement & scale transforms. The input stacks are expected in leaf to root
//! order, but the result is in the expected root to leaf order.
std::pair<Base::Placement, Base::Matrix4D>
ShapeFinder::sumTransforms(const std::vector<Base::Placement>& plmStack,
const std::vector<Base::Matrix4D>& scaleStack)
std::pair<Base::Placement, Base::Matrix4D> ShapeFinder::sumTransforms(
const std::vector<Base::Placement>& plmStack,
const std::vector<Base::Matrix4D>& scaleStack
)
{
Base::Placement netPlm;
Base::Matrix4D netScale;
@@ -398,9 +412,11 @@ std::string ShapeFinder::PlacementAsString(const Base::Placement& inPlacement)
//! debug routine. return readable form of TopLoc_Location from OCC
std::string ShapeFinder::LocationAsString(const TopLoc_Location& location)
{
auto position = Base::Vector3d {location.Transformation().TranslationPart().X(),
location.Transformation().TranslationPart().Y(),
location.Transformation().TranslationPart().Z()};
auto position = Base::Vector3d {
location.Transformation().TranslationPart().X(),
location.Transformation().TranslationPart().Y(),
location.Transformation().TranslationPart().Z()
};
gp_XYZ axisDir;
double angle {0};
auto isRotation = location.Transformation().GetRotation(axisDir, angle);

View File

@@ -47,9 +47,11 @@ class MeasureExport ResolveResult
{
public:
ResolveResult();
ResolveResult(const App::DocumentObject* realTarget,
const std::string& shortSubName,
const App::DocumentObject* targetParent);
ResolveResult(
const App::DocumentObject* realTarget,
const std::string& shortSubName,
const App::DocumentObject* targetParent
);
App::DocumentObject& getTarget() const;
std::string getShortSub() const;
@@ -65,24 +67,35 @@ private:
class MeasureExport ShapeFinder: public SubnameHelper
{
public:
static TopoDS_Shape getLocatedShape(const App::DocumentObject& rootObject,
const std::string& leafSub);
static Part::TopoShape getLocatedTopoShape(const App::DocumentObject& rootObject,
const std::string& leafSub);
static TopoDS_Shape getLocatedShape(
const App::DocumentObject& rootObject,
const std::string& leafSub
);
static Part::TopoShape getLocatedTopoShape(
const App::DocumentObject& rootObject,
const std::string& leafSub
);
static std::pair<Base::Placement, Base::Matrix4D>
getGlobalTransform(const App::DocumentObject& rootObject, const std::string& leafSub);
static std::pair<Base::Placement, Base::Matrix4D>
getGlobalTransform(const App::DocumentObject* cursorObject);
static std::pair<Base::Placement, Base::Matrix4D> getGlobalTransform(
const App::DocumentObject& rootObject,
const std::string& leafSub
);
static std::pair<Base::Placement, Base::Matrix4D> getGlobalTransform(
const App::DocumentObject* cursorObject
);
static void crawlPlacementChain(std::vector<Base::Placement>& plmStack,
std::vector<Base::Matrix4D>& scaleStack,
const App::DocumentObject& rootObj,
const std::string& leafSub);
static void crawlPlacementChain(
std::vector<Base::Placement>& plmStack,
std::vector<Base::Matrix4D>& scaleStack,
const App::DocumentObject& rootObj,
const std::string& leafSub
);
static ResolveResult resolveSelection(const App::DocumentObject& selectObj,
const std::string& selectLongSub);
static ResolveResult resolveSelection(
const App::DocumentObject& selectObj,
const std::string& selectLongSub
);
static Base::Placement getPlacement(const App::DocumentObject* root);
static Base::Matrix4D getScale(const App::DocumentObject* root);
@@ -91,34 +104,42 @@ public:
static std::string PlacementAsString(const Base::Placement& inPlacement);
static std::string LocationAsString(const TopLoc_Location& location);
static TopoDS_Shape transformShape(TopoDS_Shape& inShape,
const Base::Placement& placement,
const Base::Matrix4D& scaler);
static TopoDS_Shape transformShape(
TopoDS_Shape& inShape,
const Base::Placement& placement,
const Base::Matrix4D& scaler
);
static TopoDS_Shape stripInfiniteShapes(const TopoDS_Shape& inShape);
static bool isShapeReallyNull(const TopoDS_Shape& shape);
static std::pair<Base::Placement, Base::Matrix4D>
sumTransforms(const std::vector<Base::Placement>& plmStack,
const std::vector<Base::Matrix4D>& scaleStack);
static std::pair<Base::Placement, Base::Matrix4D> sumTransforms(
const std::vector<Base::Placement>& plmStack,
const std::vector<Base::Matrix4D>& scaleStack
);
static App::DocumentObject* getLinkAttachParent(const App::DocumentObject* attachedObject);
static Base::Placement getAttachedPlacement(const App::DocumentObject* cursorObject);
static std::string getFullPath(const App::DocumentObject* object);
static std::vector<App::DocumentObject*> getGeometryRootObjects(const App::Document* doc);
static std::vector<std::list<App::DocumentObject*>>
getGeometryPathsFromOutList(const App::DocumentObject* object);
static std::vector<std::list<App::DocumentObject*>> getGeometryPathsFromOutList(
const App::DocumentObject* object
);
private:
static bool ignoreModule(const std::string& moduleName);
static bool ignoreObject(const App::DocumentObject* object);
static bool ignoreLinkAttachedObject(const App::DocumentObject* object,
const App::DocumentObject* inlistObject);
static std::vector<App::DocumentObject*>
tidyInList(const std::vector<App::DocumentObject*>& inlist);
static std::vector<App::DocumentObject*>
tidyInListAttachment(const App::DocumentObject* owner,
const std::vector<App::DocumentObject*>& inlist);
static bool ignoreLinkAttachedObject(
const App::DocumentObject* object,
const App::DocumentObject* inlistObject
);
static std::vector<App::DocumentObject*> tidyInList(
const std::vector<App::DocumentObject*>& inlist
);
static std::vector<App::DocumentObject*> tidyInListAttachment(
const App::DocumentObject* owner,
const std::vector<App::DocumentObject*>& inlist
);
};
} // namespace Measure

View File

@@ -106,7 +106,8 @@ PyMOD_INIT_FUNC(MeasureGui)
// register preferences pages
new Gui::PrefPageProducer<MeasureGui::DlgPrefsMeasureAppearanceImp>(
QT_TRANSLATE_NOOP("QObject", "Measure"));
QT_TRANSLATE_NOOP("QObject", "Measure")
);
// Q_INIT_RESOURCE(Measure);

View File

@@ -29,7 +29,7 @@
#include <Mod/Measure/MeasureGlobal.h>
#ifdef FC_OS_WIN32
#include <windows.h>
# include <windows.h>
#endif
// standard
@@ -52,20 +52,20 @@
// GL
// Include glext before QtAll/InventorAll
#ifdef FC_OS_WIN32
#include <GL/gl.h>
#include <GL/glext.h>
# include <GL/gl.h>
# include <GL/glext.h>
#else
#ifdef FC_OS_MACOSX
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#else
#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES 1
#endif
#include <GL/gl.h>
#include <GL/glext.h>
#endif // FC_OS_MACOSX
#endif // FC_OS_WIN32
# ifdef FC_OS_MACOSX
# include <OpenGL/gl.h>
# include <OpenGL/glext.h>
# else
# ifndef GL_GLEXT_PROTOTYPES
# define GL_GLEXT_PROTOTYPES 1
# endif
# include <GL/gl.h>
# include <GL/glext.h>
# endif // FC_OS_MACOSX
#endif // FC_OS_WIN32
// Should come after glext.h to avoid warnings
#include <Inventor/C/glue/gl.h>

View File

@@ -152,9 +152,11 @@ void QuickMeasure::addSelectionToMeasurement()
int count = 0;
int limit = 100;
auto selObjs = Gui::Selection().getSelectionEx(nullptr,
App::DocumentObject::getClassTypeId(),
Gui::ResolveMode::NoResolve);
auto selObjs = Gui::Selection().getSelectionEx(
nullptr,
App::DocumentObject::getClassTypeId(),
Gui::ResolveMode::NoResolve
);
for (auto& selObj : selObjs) {
App::DocumentObject* rootObj = selObj.getObject();
@@ -237,15 +239,18 @@ void QuickMeasure::printResult()
double angle = measurement->angle();
if (angle <= Precision::Confusion()) {
print(tr("Total area: %1, Axis distance: %2")
.arg(areaStr(measurement->area()),
lengthStr(measurement->cylinderAxisDistance())));
print(
tr("Total area: %1, Axis distance: %2")
.arg(areaStr(measurement->area()), lengthStr(measurement->cylinderAxisDistance()))
);
}
else {
print(tr("Total area: %1, Axis distance: %2, Axis angle: %3")
.arg(areaStr(measurement->area()),
lengthStr(measurement->cylinderAxisDistance()),
angleStr(angle)));
.arg(
areaStr(measurement->area()),
lengthStr(measurement->cylinderAxisDistance()),
angleStr(angle)
));
}
}
else if (mtype == MeasureType::Edges) {
@@ -274,43 +279,48 @@ void QuickMeasure::printResult()
print(tr("Minimum distance: %1").arg(lengthStr(measurement->length())));
}
else if (mtype == MeasureType::PointToCylinder) {
print(tr("Minimum distance: %1, Axis distance: %2")
.arg(lengthStr(measurement->length()),
lengthStr(measurement->cylinderAxisDistance())));
print(
tr("Minimum distance: %1, Axis distance: %2")
.arg(lengthStr(measurement->length()), lengthStr(measurement->cylinderAxisDistance()))
);
}
else if (mtype == MeasureType::PointToCircle) {
print(tr("Minimum distance: %1, Center distance: %2")
.arg(lengthStr(measurement->length()),
lengthStr(measurement->circleCenterDistance())));
print(
tr("Minimum distance: %1, Center distance: %2")
.arg(lengthStr(measurement->length()), lengthStr(measurement->circleCenterDistance()))
);
}
else if (mtype == MeasureType::TwoCircles) {
double angle = measurement->angle();
if (angle <= Precision::Confusion()) {
print(tr("Total length: %1, Center distance: %2")
.arg(lengthStr(measurement->length()),
lengthStr(measurement->circleCenterDistance())));
.arg(
lengthStr(measurement->length()),
lengthStr(measurement->circleCenterDistance())
));
}
else {
print(tr("Total length: %1, Center distance: %2, Axis angle: %3")
.arg(lengthStr(measurement->length()),
lengthStr(measurement->circleCenterDistance()),
angleStr(angle)));
.arg(
lengthStr(measurement->length()),
lengthStr(measurement->circleCenterDistance()),
angleStr(angle)
));
}
}
else if (mtype == MeasureType::CircleToEdge) {
print(tr("Total length: %1, Center distance: %2")
.arg(lengthStr(measurement->length()),
lengthStr(measurement->circleCenterDistance())));
print(
tr("Total length: %1, Center distance: %2")
.arg(lengthStr(measurement->length()), lengthStr(measurement->circleCenterDistance()))
);
}
else if (mtype == MeasureType::CircleToSurface) {
print(
tr("Center surface distance: %1").arg(lengthStr(measurement->circleCenterDistance())));
print(tr("Center surface distance: %1").arg(lengthStr(measurement->circleCenterDistance())));
}
else if (mtype == MeasureType::CircleToCylinder) {
double angle = measurement->angle();
if (angle <= Precision::Confusion()) {
print(
tr("Center axis distance: %1").arg(lengthStr(measurement->cylinderAxisDistance())));
print(tr("Center axis distance: %1").arg(lengthStr(measurement->cylinderAxisDistance())));
}
else {
print(tr("Center axis distance: %1, Axis angle: %2")

View File

@@ -62,10 +62,12 @@ using SelectionStyle = Gui::SelectionSingleton::SelectionStyle;
TaskMeasure::TaskMeasure()
{
this->setButtonPosition(TaskMeasure::South);
auto taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("umf-measurement"),
tr("Measurement"),
true,
nullptr);
auto taskbox = new Gui::TaskView::TaskBox(
Gui::BitmapFactory().pixmap("umf-measurement"),
tr("Measurement"),
true,
nullptr
);
setupShortcuts(taskbox);
@@ -94,22 +96,27 @@ TaskMeasure::TaskMeasure()
autoSaveAction->setChecked(mAutoSave);
autoSaveAction->setToolTip(
tr("Auto saving of the last measurement when starting a new "
"measurement. Use the Shift key to temporarily invert the behaviour."));
"measurement. Use the Shift key to temporarily invert the behaviour.")
);
connect(autoSaveAction, &QAction::triggered, this, &TaskMeasure::autoSaveChanged);
newMeasurementBehaviourAction = new QAction(tr("Additive Selection"));
newMeasurementBehaviourAction->setCheckable(true);
newMeasurementBehaviourAction->setChecked(Gui::Selection().getSelectionStyle()
== SelectionStyle::GreedySelection);
newMeasurementBehaviourAction->setChecked(
Gui::Selection().getSelectionStyle() == SelectionStyle::GreedySelection
);
newMeasurementBehaviourAction->setToolTip(
tr("If checked, new selection will be added to the measurement. If unchecked, the Ctrl key "
"must be "
"pressed to add a "
"selection to the current measurement otherwise a new measurement will be started"));
connect(newMeasurementBehaviourAction,
&QAction::triggered,
this,
&TaskMeasure::newMeasurementBehaviourChanged);
"selection to the current measurement otherwise a new measurement will be started")
);
connect(
newMeasurementBehaviourAction,
&QAction::triggered,
this,
&TaskMeasure::newMeasurementBehaviourChanged
);
mSettings = new QToolButton();
mSettings->setToolTip(tr("Settings"));
@@ -131,10 +138,7 @@ TaskMeasure::TaskMeasure()
}
// Connect dropdown's change signal to our onModeChange slot
connect(modeSwitch,
qOverload<int>(&QComboBox::currentIndexChanged),
this,
&TaskMeasure::onModeChanged);
connect(modeSwitch, qOverload<int>(&QComboBox::currentIndexChanged), this, &TaskMeasure::onModeChanged);
// Result widget
valueResult = new QLineEdit();
@@ -245,7 +249,8 @@ void TaskMeasure::createObject(const App::MeasureType* measureType)
else {
// Create measure object
_mMeasureObject = dynamic_cast<Measure::MeasureBase*>(
doc->addObject(measureType->measureObject.c_str(), measureType->label.c_str()));
doc->addObject(measureType->measureObject.c_str(), measureType->label.c_str())
);
}
}
@@ -275,8 +280,7 @@ void TaskMeasure::tryUpdate()
std::string mod = Base::Type::getModuleName(sub->getTypeId().getName());
if (!App::MeasureManager::hasMeasureHandler(mod.c_str())) {
Base::Console().message("No measure handler available for geometry of module: %s\n",
mod);
Base::Console().message("No measure handler available for geometry of module: %s\n", mod);
clearSelection();
return;
}
@@ -390,9 +394,11 @@ void TaskMeasure::ensureGroup(Measure::MeasureBase* measurement)
App::Document* doc = measurement->getDocument();
auto group = dynamic_cast<App::DocumentObjectGroup*>(doc->getObject(measurementGroupName));
if (!group || !group->isValid()) {
group = doc->addObject<App::DocumentObjectGroup>(measurementGroupName,
true,
"MeasureGui::ViewProviderMeasureGroup");
group = doc->addObject<App::DocumentObjectGroup>(
measurementGroupName,
true,
"MeasureGui::ViewProviderMeasureGroup"
);
}
group->addObject(measurement);

View File

@@ -168,22 +168,24 @@ SbMatrix ViewProviderMeasureAngle::getMatrix()
gp_Vec yAxis = zAxis.Crossed(xAxis).Normalized();
zAxis = xAxis.Crossed(yAxis).Normalized();
dimSys = SbMatrix(xAxis.X(),
yAxis.X(),
zAxis.X(),
origin.X(),
xAxis.Y(),
yAxis.Y(),
zAxis.Y(),
origin.Y(),
xAxis.Z(),
yAxis.Z(),
zAxis.Z(),
origin.Z(),
0.0,
0.0,
0.0,
1.0);
dimSys = SbMatrix(
xAxis.X(),
yAxis.X(),
zAxis.X(),
origin.X(),
xAxis.Y(),
yAxis.Y(),
zAxis.Y(),
origin.Y(),
xAxis.Z(),
yAxis.Z(),
zAxis.Z(),
origin.Z(),
0.0,
0.0,
0.0,
1.0
);
dimSys = dimSys.transpose();
radius = midPointProjection.Magnitude();
@@ -236,22 +238,24 @@ SbMatrix ViewProviderMeasureAngle::getMatrix()
gp_Vec zAxis = (xAxis.Crossed(fakeYAxis)).Normalized();
gp_Vec yAxis = zAxis.Crossed(xAxis).Normalized();
dimSys = SbMatrix(xAxis.X(),
yAxis.X(),
zAxis.X(),
dimensionOriginPoint.X(),
xAxis.Y(),
yAxis.Y(),
zAxis.Y(),
dimensionOriginPoint.Y(),
xAxis.Z(),
yAxis.Z(),
zAxis.Z(),
dimensionOriginPoint.Z(),
0.0,
0.0,
0.0,
1.0);
dimSys = SbMatrix(
xAxis.X(),
yAxis.X(),
zAxis.X(),
dimensionOriginPoint.X(),
xAxis.Y(),
yAxis.Y(),
zAxis.Y(),
dimensionOriginPoint.Y(),
xAxis.Z(),
yAxis.Z(),
zAxis.Z(),
dimensionOriginPoint.Z(),
0.0,
0.0,
0.0,
1.0
);
dimSys = dimSys.transpose();
}
@@ -292,7 +296,8 @@ ViewProviderMeasureAngle::ViewProviderMeasureAngle()
engineAngle->A.connectFrom(&arcEngine->midpoint);
engineAngle->B.connectFrom(&pLabelTranslation->translation);
engineAngle->expression.setValue(
"tA=normalize(A); tB=normalize(B); oa=atan2(tB[1], tB[0])-atan2(tA[1], tA[0])");
"tA=normalize(A); tB=normalize(B); oa=atan2(tB[1], tB[0])-atan2(tA[1], tA[0])"
);
Gui::ArcEngine* arcEngineSecondary = new Gui::ArcEngine();
arcEngineSecondary->radius.connectFrom(&calculatorRadius->oa);
@@ -334,8 +339,7 @@ void ViewProviderMeasureAngle::redrawAnnotation()
pcTransform->setMatrix(matrix);
}
catch (const Base::Exception& e) {
Base::Console().error("Error in ViewProviderMeasureAngle::redrawAnnotation: %s\n",
e.what());
Base::Console().error("Error in ViewProviderMeasureAngle::redrawAnnotation: %s\n", e.what());
return;
}

View File

@@ -77,26 +77,34 @@ ViewProviderMeasureBase::ViewProviderMeasureBase()
{
static const char* agroup = "Appearance";
// NOLINTBEGIN
ADD_PROPERTY_TYPE(TextColor,
(Preferences::defaultTextColor()),
agroup,
App::Prop_None,
"Color for the measurement text");
ADD_PROPERTY_TYPE(TextBackgroundColor,
(Preferences::defaultTextBackgroundColor()),
agroup,
App::Prop_None,
"Color for the measurement text background");
ADD_PROPERTY_TYPE(LineColor,
(Preferences::defaultLineColor()),
agroup,
App::Prop_None,
"Color for the measurement lines");
ADD_PROPERTY_TYPE(FontSize,
(Preferences::defaultFontSize()),
agroup,
App::Prop_None,
"Size of measurement text");
ADD_PROPERTY_TYPE(
TextColor,
(Preferences::defaultTextColor()),
agroup,
App::Prop_None,
"Color for the measurement text"
);
ADD_PROPERTY_TYPE(
TextBackgroundColor,
(Preferences::defaultTextBackgroundColor()),
agroup,
App::Prop_None,
"Color for the measurement text background"
);
ADD_PROPERTY_TYPE(
LineColor,
(Preferences::defaultLineColor()),
agroup,
App::Prop_None,
"Color for the measurement lines"
);
ADD_PROPERTY_TYPE(
FontSize,
(Preferences::defaultFontSize()),
agroup,
App::Prop_None,
"Size of measurement text"
);
// NOLINTEND
pGlobalSeparator = new SoSeparator();
@@ -401,10 +409,12 @@ void ViewProviderMeasureBase::connectToSubject(App::DocumentObject* subject)
}
// NOLINTBEGIN
auto bndVisibility = std::bind(&ViewProviderMeasureBase::onSubjectVisibilityChanged,
this,
std::placeholders::_1,
std::placeholders::_2);
auto bndVisibility = std::bind(
&ViewProviderMeasureBase::onSubjectVisibilityChanged,
this,
std::placeholders::_1,
std::placeholders::_2
);
// NOLINTEND
_mVisibilityChangedConnection = subject->signalChanged.connect(bndVisibility);
}
@@ -439,8 +449,7 @@ Measure::MeasureBase* ViewProviderMeasureBase::getMeasureObject()
//! layout of the elements and relationship with the cardinal axes and the view direction.
//! elementDirection is expected to be a normalized vector. an example of an elementDirection would
//! be the vector from the start of a line to the end.
Base::Vector3d ViewProviderMeasureBase::getTextDirection(Base::Vector3d elementDirection,
double tolerance)
Base::Vector3d ViewProviderMeasureBase::getTextDirection(Base::Vector3d elementDirection, double tolerance)
{
// TODO: this can fail if the active view is not a 3d view (spreadsheet, techdraw page) and
// something causes a measure to try to update we need to search through the mdi views for a 3d
@@ -454,8 +463,7 @@ Base::Vector3d ViewProviderMeasureBase::getTextDirection(Base::Vector3d elementD
view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
}
catch (const Base::RuntimeError&) {
Base::Console().log(
"ViewProviderMeasureBase::getTextDirection: Could not get active view\n");
Base::Console().log("ViewProviderMeasureBase::getTextDirection: Could not get active view\n");
}
if (view) {
@@ -518,8 +526,10 @@ bool ViewProviderMeasureBase::isSubjectVisible()
//! gets called when the subject object issues a signalChanged (ie a property change). We are only
//! interested in the subject's Visibility property
void ViewProviderMeasureBase::onSubjectVisibilityChanged(const App::DocumentObject& docObj,
const App::Property& prop)
void ViewProviderMeasureBase::onSubjectVisibilityChanged(
const App::DocumentObject& docObj,
const App::Property& prop
)
{
if (docObj.isRemoving()) {
return;
@@ -603,9 +613,10 @@ ViewProviderMeasure::ViewProviderMeasure()
lineSep->addChild(pCoords);
lineSep->addChild(pLines);
auto points = new SoMarkerSet();
points->markerIndex =
Gui::Inventor::MarkerBitmaps::getMarkerIndex("CROSS",
Gui::ViewParams::instance()->getMarkerSize());
points->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"CROSS",
Gui::ViewParams::instance()->getMarkerSize()
);
points->numPoints = 1;
lineSep->addChild(points);
@@ -615,8 +626,7 @@ ViewProviderMeasure::ViewProviderMeasure()
view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
}
catch (const Base::RuntimeError&) {
Base::Console().log(
"ViewProviderMeasure::ViewProviderMeasure: Could not get active view\n");
Base::Console().log("ViewProviderMeasure::ViewProviderMeasure: Could not get active view\n");
}
if (view) {
@@ -703,8 +713,7 @@ Base::Vector3d ViewProviderMeasure::getTextPosition()
Gui::View3DInventor* view = dynamic_cast<Gui::View3DInventor*>(this->getActiveView());
if (!view) {
Base::Console().log(
"ViewProviderMeasureBase::getTextPosition: Could not get active view\n");
Base::Console().log("ViewProviderMeasureBase::getTextPosition: Could not get active view\n");
return Base::Vector3d();
}

View File

@@ -147,8 +147,10 @@ protected:
SoSeparator* getSoSeparatorText();
static constexpr double defaultTolerance = 10e-6;
virtual Base::Vector3d getTextDirection(Base::Vector3d elementDirection,
double tolerance = defaultTolerance);
virtual Base::Vector3d getTextDirection(
Base::Vector3d elementDirection,
double tolerance = defaultTolerance
);
float getViewScale();
// TODO: getters & setters and move variables to private?

View File

@@ -253,23 +253,25 @@ SbMatrix ViewProviderMeasureDistance::getMatrix()
assert(fabs(localYAxis.Dot(localXAxis)) < tolerance);
Base::Vector3d localZAxis = localYAxis.Cross(localXAxis).Normalize();
SbMatrix matrix = SbMatrix(localXAxis.x,
localXAxis.y,
localXAxis.z,
0,
localYAxis.x,
localYAxis.y,
localYAxis.z,
0,
localZAxis.x,
localZAxis.y,
localZAxis.z,
0,
// 0,0,0,1
origin[0],
origin[1],
origin[2],
1);
SbMatrix matrix = SbMatrix(
localXAxis.x,
localXAxis.y,
localXAxis.z,
0,
localYAxis.x,
localYAxis.y,
localYAxis.z,
0,
localZAxis.x,
localZAxis.y,
localZAxis.z,
0,
// 0,0,0,1
origin[0],
origin[1],
origin[2],
1
);
return matrix;
}
@@ -279,8 +281,10 @@ SbMatrix ViewProviderMeasureDistance::getMatrix()
//! layout of the elements and its relationship with the cardinal axes and the view direction.
//! elementDirection is expected to be a normalized vector. an example of an elementDirection would
//! be the vector from the start of a line to the end.
Base::Vector3d ViewProviderMeasureDistance::getTextDirection(Base::Vector3d elementDirection,
double tolerance)
Base::Vector3d ViewProviderMeasureDistance::getTextDirection(
Base::Vector3d elementDirection,
double tolerance
)
{
const Base::Vector3d stdX(1.0, 0.0, 0.0);
const Base::Vector3d stdY(0.0, 1.0, 0.0);
@@ -306,11 +310,13 @@ ViewProviderMeasureDistance::ViewProviderMeasureDistance()
{
sPixmap = "Measurement-Distance";
ADD_PROPERTY_TYPE(ShowDelta,
(false),
"Appearance",
App::Prop_None,
"Display the X, Y and Z components of the distance");
ADD_PROPERTY_TYPE(
ShowDelta,
(false),
"Appearance",
App::Prop_None,
"Display the X, Y and Z components of the distance"
);
// vert indexes used to create the annotation lines
const size_t lineCount(3);
@@ -343,8 +349,10 @@ ViewProviderMeasureDistance::ViewProviderMeasureDistance()
auto engineCoords = new SoCalculator();
engineCoords->a.connectFrom(&fieldDistance);
engineCoords->A.connectFrom(&pLabelTranslation->translation);
engineCoords->expression.setValue("ta=a/2; tb=A[1]; oA=vec3f(ta, 0, 0); oB=vec3f(-ta, 0, 0); "
"oC=vec3f(ta, tb, 0); oD=vec3f(-ta, tb, 0)");
engineCoords->expression.setValue(
"ta=a/2; tb=A[1]; oA=vec3f(ta, 0, 0); oB=vec3f(-ta, 0, 0); "
"oC=vec3f(ta, tb, 0); oD=vec3f(-ta, tb, 0)"
);
auto engineCat = new SoConcatenate(SoMFVec3f::getClassTypeId());
engineCat->input[0]->connectFrom(&engineCoords->oA);
@@ -374,9 +382,10 @@ ViewProviderMeasureDistance::ViewProviderMeasureDistance()
pLineSeparatorSecondary->addChild(lineSetSecondary);
auto points = new SoMarkerSet();
points->markerIndex =
Gui::Inventor::MarkerBitmaps::getMarkerIndex("CROSS",
ViewParams::instance()->getMarkerSize());
points->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex(
"CROSS",
ViewParams::instance()->getMarkerSize()
);
points->numPoints = 2;
pLineSeparator->addChild(points);
@@ -472,23 +481,25 @@ void ViewProviderMeasureDistance::redrawAnnotation()
// Set the distance
fieldDistance = (vec2 - vec1).Length();
auto propDistance =
dynamic_cast<App::PropertyDistance*>(pcObject->getPropertyByName("Distance"));
auto propDistance = dynamic_cast<App::PropertyDistance*>(pcObject->getPropertyByName("Distance"));
setLabelValue(QString::fromStdString(propDistance->getQuantityValue().getUserString()));
// Set delta distance
auto propDistanceX =
static_cast<App::PropertyDistance*>(getMeasureObject()->getPropertyByName("DistanceX"));
auto propDistanceX = static_cast<App::PropertyDistance*>(
getMeasureObject()->getPropertyByName("DistanceX")
);
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(0))
->text.setValue(("Δx: " + propDistanceX->getQuantityValue().getUserString()).c_str());
auto propDistanceY =
static_cast<App::PropertyDistance*>(getMeasureObject()->getPropertyByName("DistanceY"));
auto propDistanceY = static_cast<App::PropertyDistance*>(
getMeasureObject()->getPropertyByName("DistanceY")
);
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(1))
->text.setValue(("Δy: " + propDistanceY->getQuantityValue().getUserString()).c_str());
auto propDistanceZ =
static_cast<App::PropertyDistance*>(getMeasureObject()->getPropertyByName("DistanceZ"));
auto propDistanceZ = static_cast<App::PropertyDistance*>(
getMeasureObject()->getPropertyByName("DistanceZ")
);
static_cast<DimensionLinear*>(pDeltaDimensionSwitch->getChild(2))
->text.setValue(("Δz: " + propDistanceZ->getQuantityValue().getUserString()).c_str());
@@ -504,8 +515,9 @@ void ViewProviderMeasureDistance::onChanged(const App::Property* prop)
{
if (prop == &ShowDelta) {
pDeltaDimensionSwitch->whichChild.setValue(ShowDelta.getValue() ? SO_SWITCH_ALL
: SO_SWITCH_NONE);
pDeltaDimensionSwitch->whichChild.setValue(
ShowDelta.getValue() ? SO_SWITCH_ALL : SO_SWITCH_NONE
);
}
else if (prop == &TextBackgroundColor) {
auto bColor = TextBackgroundColor.getValue();

View File

@@ -99,8 +99,10 @@ public:
void positionAnno(const Measure::MeasureBase* measureObject) override;
protected:
Base::Vector3d getTextDirection(Base::Vector3d elementDirection,
double tolerance = defaultTolerance) override;
Base::Vector3d getTextDirection(
Base::Vector3d elementDirection,
double tolerance = defaultTolerance
) override;
void onChanged(const App::Property* prop) override;
private:

View File

@@ -25,25 +25,25 @@
#include <FCGlobal.h>
#ifndef MEASURE_GLOBAL_H
#define MEASURE_GLOBAL_H
# define MEASURE_GLOBAL_H
// Measure
#ifndef MeasureExport
#ifdef Measure_EXPORTS
#define MeasureExport FREECAD_DECL_EXPORT
#else
#define MeasureExport FREECAD_DECL_IMPORT
#endif
#endif
# ifndef MeasureExport
# ifdef Measure_EXPORTS
# define MeasureExport FREECAD_DECL_EXPORT
# else
# define MeasureExport FREECAD_DECL_IMPORT
# endif
# endif
// MeasureGui
#ifndef MeasureGuiExport
#ifdef MeasureGui_EXPORTS
#define MeasureGuiExport FREECAD_DECL_EXPORT
#else
#define MeasureGuiExport FREECAD_DECL_IMPORT
#endif
#endif
# ifndef MeasureGuiExport
# ifdef MeasureGui_EXPORTS
# define MeasureGuiExport FREECAD_DECL_EXPORT
# else
# define MeasureGuiExport FREECAD_DECL_IMPORT
# endif
# endif
#endif // MEASURE_GLOBAL_H