Sketcher: Reformat to current clang-format standard
This commit is contained in:
committed by
Chris Hennes
parent
41a1a7a8e6
commit
791fe02934
@@ -82,13 +82,15 @@ ViewProviderSketchDrawSketchHandlerAttorney::drawEdit(ViewProviderSketch& vp,
|
||||
}
|
||||
|
||||
inline void ViewProviderSketchDrawSketchHandlerAttorney::drawEdit(
|
||||
ViewProviderSketch& vp, const std::list<std::vector<Base::Vector2d>>& list)
|
||||
ViewProviderSketch& vp,
|
||||
const std::list<std::vector<Base::Vector2d>>& list)
|
||||
{
|
||||
vp.drawEdit(list);
|
||||
}
|
||||
|
||||
inline void ViewProviderSketchDrawSketchHandlerAttorney::drawEditMarkers(
|
||||
ViewProviderSketch& vp, const std::vector<Base::Vector2d>& EditMarkers,
|
||||
ViewProviderSketch& vp,
|
||||
const std::vector<Base::Vector2d>& EditMarkers,
|
||||
unsigned int augmentationlevel)
|
||||
{
|
||||
vp.drawEditMarkers(EditMarkers, augmentationlevel);
|
||||
@@ -132,15 +134,16 @@ ViewProviderSketchDrawSketchHandlerAttorney::getPreselectCross(const ViewProvide
|
||||
}
|
||||
|
||||
inline void
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::setAngleSnapping(ViewProviderSketch& vp, bool enable,
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::setAngleSnapping(ViewProviderSketch& vp,
|
||||
bool enable,
|
||||
Base::Vector2d referencePoint)
|
||||
{
|
||||
vp.setAngleSnapping(enable, referencePoint);
|
||||
}
|
||||
|
||||
inline void
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::moveConstraint(ViewProviderSketch& vp, int constNum,
|
||||
const Base::Vector2d& toPos)
|
||||
inline void ViewProviderSketchDrawSketchHandlerAttorney::moveConstraint(ViewProviderSketch& vp,
|
||||
int constNum,
|
||||
const Base::Vector2d& toPos)
|
||||
{
|
||||
vp.moveConstraint(constNum, toPos);
|
||||
}
|
||||
@@ -157,8 +160,9 @@ CurveConverter::CurveConverter()
|
||||
}
|
||||
catch (const Base::ValueError& e) {// ensure that if parameter strings are not well-formed, the
|
||||
// exception is not propagated
|
||||
Base::Console().DeveloperError(
|
||||
"CurveConverter", "Malformed parameter string: %s\n", e.what());
|
||||
Base::Console().DeveloperError("CurveConverter",
|
||||
"Malformed parameter string: %s\n",
|
||||
e.what());
|
||||
}
|
||||
|
||||
updateCurvedEdgeCountSegmentsParameter();
|
||||
@@ -174,8 +178,9 @@ CurveConverter::~CurveConverter()
|
||||
catch (const Base::ValueError&
|
||||
e) {// ensure that if parameter strings are not well-formed, the program is not
|
||||
// terminated when calling the noexcept destructor.
|
||||
Base::Console().DeveloperError(
|
||||
"CurveConverter", "Malformed parameter string: %s\n", e.what());
|
||||
Base::Console().DeveloperError("CurveConverter",
|
||||
"Malformed parameter string: %s\n",
|
||||
e.what());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,8 +210,9 @@ std::vector<Base::Vector2d> CurveConverter::toVector2D(const Part::Geometry* geo
|
||||
double segment =
|
||||
(geo->getLastParameter() - geo->getFirstParameter()) / curvedEdgeCountSegments;
|
||||
|
||||
for (int i = 0; i < curvedEdgeCountSegments; i++)
|
||||
for (int i = 0; i < curvedEdgeCountSegments; i++) {
|
||||
emplaceasvector2d(geo->value(geo->getFirstParameter() + i * segment));
|
||||
}
|
||||
|
||||
// either close the curve for untrimmed conic or set the last point for bounded curves
|
||||
emplaceasvector2d(isconic ? geo->value(0) : geo->value(geo->getLastParameter()));
|
||||
@@ -220,8 +226,9 @@ CurveConverter::toVector2DList(const std::vector<Part::Geometry*>& geometries)
|
||||
{
|
||||
std::list<std::vector<Base::Vector2d>> list;
|
||||
|
||||
for (const auto& geo : geometries)
|
||||
for (const auto& geo : geometries) {
|
||||
list.push_back(toVector2D(geo));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -233,8 +240,9 @@ void CurveConverter::updateCurvedEdgeCountSegmentsParameter()
|
||||
int stdcountsegments = hGrp->GetInt("SegmentsPerGeometry", 50);
|
||||
|
||||
// value cannot be smaller than 6
|
||||
if (stdcountsegments < 6)
|
||||
if (stdcountsegments < 6) {
|
||||
stdcountsegments = 6;
|
||||
}
|
||||
|
||||
curvedEdgeCountSegments = stdcountsegments;
|
||||
};
|
||||
@@ -353,7 +361,9 @@ void DrawSketchHandler::setCrosshairCursor(const char* svgName)
|
||||
setCrosshairCursor(cursorName);
|
||||
}
|
||||
|
||||
void DrawSketchHandler::setSvgCursor(const QString& cursorName, int x, int y,
|
||||
void DrawSketchHandler::setSvgCursor(const QString& cursorName,
|
||||
int x,
|
||||
int y,
|
||||
const std::map<unsigned long, unsigned long>& colorMapping)
|
||||
{
|
||||
// The Sketcher_Pointer_*.svg icons have a default size of 64x64. When directly creating
|
||||
@@ -374,10 +384,12 @@ void DrawSketchHandler::setSvgCursor(const QString& cursorName, int x, int y,
|
||||
#endif
|
||||
qreal cursorSize = defaultCursorSize * pRatio;
|
||||
|
||||
QPixmap pointer = Gui::BitmapFactory().pixmapFromSvg(
|
||||
cursorName.toStdString().c_str(), QSizeF(cursorSize, cursorSize), colorMapping);
|
||||
if (isRatioOne)
|
||||
QPixmap pointer = Gui::BitmapFactory().pixmapFromSvg(cursorName.toStdString().c_str(),
|
||||
QSizeF(cursorSize, cursorSize),
|
||||
colorMapping);
|
||||
if (isRatioOne) {
|
||||
pointer = pointer.scaled(32, 32);
|
||||
}
|
||||
pointer.setDevicePixelRatio(pRatio);
|
||||
setCursor(pointer, hotX, hotY, false);
|
||||
}
|
||||
@@ -478,8 +490,9 @@ void DrawSketchHandler::updateCursor()
|
||||
{
|
||||
auto cursorstring = getCrosshairCursorSVGName();
|
||||
|
||||
if (cursorstring != QString::fromLatin1("None"))
|
||||
if (cursorstring != QString::fromLatin1("None")) {
|
||||
setCrosshairCursor(cursorstring);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSketchHandler::applyCursor()
|
||||
@@ -562,16 +575,20 @@ DrawSketchHandler::suggestedConstraintsPixmaps(std::vector<AutoConstraint>& sugg
|
||||
}
|
||||
|
||||
int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggestedConstraints,
|
||||
const Base::Vector2d& Pos, const Base::Vector2d& Dir,
|
||||
const Base::Vector2d& Pos,
|
||||
const Base::Vector2d& Dir,
|
||||
AutoConstraint::TargetType type)
|
||||
{
|
||||
suggestedConstraints.clear();
|
||||
|
||||
if (!sketchgui->Autoconstraints.getValue())
|
||||
if (!sketchgui->Autoconstraints.getValue()) {
|
||||
return 0;// If Autoconstraints property is not set quit
|
||||
}
|
||||
|
||||
Base::Vector3d hitShapeDir = Base::Vector3d(
|
||||
0, 0, 0);// direction of hit shape (if it is a line, the direction of the line)
|
||||
Base::Vector3d hitShapeDir =
|
||||
Base::Vector3d(0,
|
||||
0,
|
||||
0);// direction of hit shape (if it is a line, the direction of the line)
|
||||
|
||||
// Get Preselection
|
||||
int preSelPnt = getPreselectPoint();
|
||||
@@ -581,8 +598,9 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
|
||||
Sketcher::PointPos PosId = Sketcher::PointPos::none;
|
||||
|
||||
if (preSelPnt != -1)
|
||||
if (preSelPnt != -1) {
|
||||
sketchgui->getSketchObject()->getGeoVertexIndex(preSelPnt, GeoId, PosId);
|
||||
}
|
||||
else if (preSelCrv != -1) {
|
||||
const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(preSelCrv);
|
||||
|
||||
@@ -615,15 +633,19 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
constr.GeoId = GeoId;
|
||||
constr.PosId = PosId;
|
||||
if ((type == AutoConstraint::VERTEX || type == AutoConstraint::VERTEX_NO_TANGENCY)
|
||||
&& PosId != Sketcher::PointPos::none)
|
||||
&& PosId != Sketcher::PointPos::none) {
|
||||
constr.Type = Sketcher::Coincident;
|
||||
else if (type == AutoConstraint::CURVE && PosId != Sketcher::PointPos::none)
|
||||
}
|
||||
else if (type == AutoConstraint::CURVE && PosId != Sketcher::PointPos::none) {
|
||||
constr.Type = Sketcher::PointOnObject;
|
||||
}
|
||||
else if ((type == AutoConstraint::VERTEX || type == AutoConstraint::VERTEX_NO_TANGENCY)
|
||||
&& PosId == Sketcher::PointPos::none)
|
||||
&& PosId == Sketcher::PointPos::none) {
|
||||
constr.Type = Sketcher::PointOnObject;
|
||||
else if (type == AutoConstraint::CURVE && PosId == Sketcher::PointPos::none)
|
||||
}
|
||||
else if (type == AutoConstraint::CURVE && PosId == Sketcher::PointPos::none) {
|
||||
constr.Type = Sketcher::Tangent;
|
||||
}
|
||||
|
||||
if (constr.Type == Sketcher::Tangent && Dir.Length() > 1e-8
|
||||
&& hitShapeDir.Length()
|
||||
@@ -637,20 +659,23 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
// degrees)
|
||||
if (fabs(cosangle) < 0.995f
|
||||
|| ((GeoId == Sketcher::GeoEnum::HAxis || GeoId == Sketcher::GeoEnum::VAxis)
|
||||
&& fabs(cosangle) < 0.1))
|
||||
&& fabs(cosangle) < 0.1)) {
|
||||
suggestedConstraints.push_back(constr);
|
||||
}
|
||||
|
||||
|
||||
return suggestedConstraints.size();
|
||||
}
|
||||
|
||||
if (constr.Type != Sketcher::None)
|
||||
if (constr.Type != Sketcher::None) {
|
||||
suggestedConstraints.push_back(constr);
|
||||
}
|
||||
}
|
||||
|
||||
if (Dir.Length() < 1e-8 || type == AutoConstraint::CURVE)
|
||||
if (Dir.Length() < 1e-8 || type == AutoConstraint::CURVE) {
|
||||
// Direction not set so return;
|
||||
return suggestedConstraints.size();
|
||||
}
|
||||
|
||||
// Suggest vertical and horizontal constraints
|
||||
|
||||
@@ -663,19 +688,23 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
constr.GeoId = GeoEnum::GeoUndef;
|
||||
constr.PosId = Sketcher::PointPos::none;
|
||||
double angle = std::abs(atan2(Dir.y, Dir.x));
|
||||
if (angle < angleDevRad || (M_PI - angle) < angleDevRad)
|
||||
if (angle < angleDevRad || (M_PI - angle) < angleDevRad) {
|
||||
// Suggest horizontal constraint
|
||||
constr.Type = Sketcher::Horizontal;
|
||||
else if (std::abs(angle - M_PI_2) < angleDevRad)
|
||||
}
|
||||
else if (std::abs(angle - M_PI_2) < angleDevRad) {
|
||||
// Suggest vertical constraint
|
||||
constr.Type = Sketcher::Vertical;
|
||||
}
|
||||
|
||||
if (constr.Type != Sketcher::None)
|
||||
if (constr.Type != Sketcher::None) {
|
||||
suggestedConstraints.push_back(constr);
|
||||
}
|
||||
|
||||
// Do not seek for tangent if we are actually building a primitive
|
||||
if (type == AutoConstraint::VERTEX_NO_TANGENCY)
|
||||
if (type == AutoConstraint::VERTEX_NO_TANGENCY) {
|
||||
return suggestedConstraints.size();
|
||||
}
|
||||
|
||||
// Find if there are tangent constraints (currently arcs and circles)
|
||||
|
||||
@@ -706,8 +735,9 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
double radius = circle->getRadius();
|
||||
|
||||
// ignore if no touch (use dot product)
|
||||
if (tmpDir * (center - tmpPos) > 0 || tmpDir * (center - tmpStart) < 0)
|
||||
if (tmpDir * (center - tmpPos) > 0 || tmpDir * (center - tmpStart) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Base::Vector3d projPnt(0.f, 0.f, 0.f);
|
||||
projPnt = projPnt.ProjectToLine(center - tmpPos, tmpDir);
|
||||
@@ -755,8 +785,9 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
double radius = arc->getRadius();
|
||||
|
||||
// ignore if no touch (use dot product)
|
||||
if (tmpDir * (center - tmpPos) > 0 || tmpDir * (center - tmpStart) < 0)
|
||||
if (tmpDir * (center - tmpPos) > 0 || tmpDir * (center - tmpStart) < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Base::Vector3d projPnt(0.f, 0.f, 0.f);
|
||||
projPnt = projPnt.ProjectToLine(center - tmpPos, tmpDir);
|
||||
@@ -767,8 +798,9 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
arc->getRange(startAngle, endAngle, /*emulateCCW=*/true);
|
||||
|
||||
double angle = atan2(projPnt.y, projPnt.x);
|
||||
while (angle < startAngle)
|
||||
while (angle < startAngle) {
|
||||
angle += 2 * D_PI;// Bring it to range of arc
|
||||
}
|
||||
|
||||
// if the point is on correct side of arc
|
||||
if (angle <= endAngle) {// Now need to check only one side
|
||||
@@ -818,8 +850,9 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
- startAngle,
|
||||
2.f * M_PI);
|
||||
|
||||
while (angle < startAngle)
|
||||
while (angle < startAngle) {
|
||||
angle += 2 * D_PI;// Bring it to range of arc
|
||||
}
|
||||
|
||||
// if the point is on correct side of arc
|
||||
if (angle <= endAngle) {// Now need to check only one side
|
||||
@@ -831,8 +864,9 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
}
|
||||
|
||||
if (tangId != GeoEnum::GeoUndef) {
|
||||
if (tangId > getHighestCurveIndex())// external Geometry
|
||||
if (tangId > getHighestCurveIndex()) {// external Geometry
|
||||
tangId = getHighestCurveIndex() - tangId;
|
||||
}
|
||||
// Suggest vertical constraint
|
||||
constr.Type = Tangent;
|
||||
constr.GeoId = tangId;
|
||||
@@ -844,11 +878,13 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint>& suggested
|
||||
}
|
||||
|
||||
void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>& autoConstrs,
|
||||
int geoId1, Sketcher::PointPos posId1,
|
||||
int geoId1,
|
||||
Sketcher::PointPos posId1,
|
||||
bool createowncommand /*= true*/)
|
||||
{
|
||||
if (!sketchgui->Autoconstraints.getValue())
|
||||
if (!sketchgui->Autoconstraints.getValue()) {
|
||||
return;// If Autoconstraints property is not set quit
|
||||
}
|
||||
|
||||
if (!autoConstrs.empty()) {
|
||||
|
||||
@@ -864,8 +900,9 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>&
|
||||
|
||||
switch (it->Type) {
|
||||
case Sketcher::Coincident: {
|
||||
if (posId1 == Sketcher::PointPos::none)
|
||||
if (posId1 == Sketcher::PointPos::none) {
|
||||
continue;
|
||||
}
|
||||
// If the auto constraint has a point create a coincident otherwise it is an
|
||||
// edge on a point
|
||||
Gui::cmdAppObjectArgs(
|
||||
@@ -918,8 +955,9 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>&
|
||||
&& (geom1->getTypeId() == Part::GeomEllipse::getClassTypeId()
|
||||
|| geom2->getTypeId() == Part::GeomEllipse::getClassTypeId())) {
|
||||
|
||||
if (geom1->getTypeId() != Part::GeomEllipse::getClassTypeId())
|
||||
if (geom1->getTypeId() != Part::GeomEllipse::getClassTypeId()) {
|
||||
std::swap(geoId1, geoId2);
|
||||
}
|
||||
|
||||
// geoId1 is the ellipse
|
||||
geom1 = Obj->getGeometry(geoId1);
|
||||
@@ -945,8 +983,9 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>&
|
||||
&& (geom1->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()
|
||||
|| geom2->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId())) {
|
||||
|
||||
if (geom1->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId())
|
||||
if (geom1->getTypeId() != Part::GeomArcOfEllipse::getClassTypeId()) {
|
||||
std::swap(geoId1, geoId2);
|
||||
}
|
||||
|
||||
// geoId1 is the arc of ellipse
|
||||
geom1 = Obj->getGeometry(geoId1);
|
||||
@@ -1049,8 +1088,9 @@ void DrawSketchHandler::drawDirectionAtCursor(const Base::Vector2d& position,
|
||||
void DrawSketchHandler::drawEditMarkers(const std::vector<Base::Vector2d>& EditMarkers,
|
||||
unsigned int augmentationlevel)
|
||||
{
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::drawEditMarkers(
|
||||
*sketchgui, EditMarkers, augmentationlevel);
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::drawEditMarkers(*sketchgui,
|
||||
EditMarkers,
|
||||
augmentationlevel);
|
||||
}
|
||||
|
||||
void DrawSketchHandler::setAxisPickStyle(bool on)
|
||||
@@ -1090,12 +1130,12 @@ Sketcher::SketchObject* DrawSketchHandler::getSketchObject()
|
||||
|
||||
void DrawSketchHandler::setAngleSnapping(bool enable, Base::Vector2d referencePoint)
|
||||
{
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::setAngleSnapping(
|
||||
*sketchgui, enable, referencePoint);
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::setAngleSnapping(*sketchgui,
|
||||
enable,
|
||||
referencePoint);
|
||||
}
|
||||
|
||||
void DrawSketchHandler::moveConstraint(int constNum, const Base::Vector2d& toPos)
|
||||
{
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::moveConstraint(
|
||||
*sketchgui, constNum, toPos);
|
||||
}
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::moveConstraint(*sketchgui, constNum, toPos);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user