SketcherGui: apply clang-format

This commit is contained in:
Abdullah Tahiri
2023-05-25 15:09:30 +02:00
committed by abdullahtahiriyo
parent dc2d861bf0
commit 78ae9c1d7d
98 changed files with 17648 additions and 13572 deletions

View File

@@ -28,30 +28,33 @@
#include "GeometryCreationMode.h"
namespace SketcherGui {
namespace SketcherGui
{
extern GeometryCreationMode geometryCreationMode; // defined in CommandCreateGeo.cpp
extern GeometryCreationMode geometryCreationMode;// defined in CommandCreateGeo.cpp
class SplittingSelection : public Gui::SelectionFilterGate
class SplittingSelection: public Gui::SelectionFilterGate
{
App::DocumentObject* object;
public:
explicit SplittingSelection(App::DocumentObject* obj)
: Gui::SelectionFilterGate(nullPointer()), object(obj)
: Gui::SelectionFilterGate(nullPointer())
, object(obj)
{}
bool allow(App::Document * /*pDoc*/, App::DocumentObject *pObj, const char *sSubName)
bool allow(App::Document* /*pDoc*/, App::DocumentObject* pObj, const char* sSubName)
{
if (pObj != this->object)
return false;
if (!sSubName || sSubName[0] == '\0')
return false;
std::string element(sSubName);
if (element.substr(0,4) == "Edge") {
int GeoId = std::atoi(element.substr(4,4000).c_str()) - 1;
Sketcher::SketchObject *Sketch = static_cast<Sketcher::SketchObject*>(object);
const Part::Geometry *geom = Sketch->getGeometry(GeoId);
if (element.substr(0, 4) == "Edge") {
int GeoId = std::atoi(element.substr(4, 4000).c_str()) - 1;
Sketcher::SketchObject* Sketch = static_cast<Sketcher::SketchObject*>(object);
const Part::Geometry* geom = Sketch->getGeometry(GeoId);
if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()
|| geom->getTypeId() == Part::GeomCircle::getClassTypeId()
|| geom->getTypeId() == Part::GeomEllipse::getClassTypeId()
@@ -60,16 +63,16 @@ public:
return true;
}
}
else if (element.substr(0,6) == "Vertex") {
int VertId = std::atoi(element.substr(6,4000).c_str()) - 1;
else if (element.substr(0, 6) == "Vertex") {
int VertId = std::atoi(element.substr(6, 4000).c_str()) - 1;
int GeoId = Sketcher::GeoEnum::GeoUndef;
Sketcher::PointPos PosId = Sketcher::PointPos::none;
Sketcher::SketchObject *Sketch = static_cast<Sketcher::SketchObject*>(object);
Sketcher::SketchObject* Sketch = static_cast<Sketcher::SketchObject*>(object);
Sketch->getGeoVertexIndex(VertId, GeoId, PosId);
if (isBsplineKnot(Sketch, GeoId))
return true;
}
return false;
return false;
}
};
@@ -100,7 +103,7 @@ public:
int curveGeoId = getPreselectCurve();
if (curveGeoId >= 0) {
const Part::Geometry *geom = sketchgui->getSketchObject()->getGeometry(curveGeoId);
const Part::Geometry* geom = sketchgui->getSketchObject()->getGeometry(curveGeoId);
if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId()
|| geom->getTypeId() == Part::GeomCircle::getClassTypeId()
|| geom->getTypeId() == Part::GeomEllipse::getClassTypeId()
@@ -113,16 +116,15 @@ public:
// No curve of interest is pre-selected. Try pre-selected point.
int pointGeoId = getPreselectPoint();
if (pointGeoId >=0) {
if (pointGeoId >= 0) {
// TODO: This has to be a knot. Find the spline.
const auto& constraints = getSketchObject()->Constraints.getValues();
const auto& conIt = std::find_if(
constraints.begin(), constraints.end(),
[pointGeoId](auto constr) {
return (constr->Type == Sketcher::InternalAlignment &&
constr->AlignmentType == Sketcher::BSplineKnotPoint &&
constr->First == pointGeoId);
const auto& conIt =
std::find_if(constraints.begin(), constraints.end(), [pointGeoId](auto constr) {
return (constr->Type == Sketcher::InternalAlignment
&& constr->AlignmentType == Sketcher::BSplineKnotPoint
&& constr->First == pointGeoId);
});
if (conIt != constraints.end())
@@ -133,15 +135,18 @@ public:
if (GeoId >= 0) {
try {
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Split edge"));
Gui::cmdAppObjectArgs(sketchgui->getObject(), "split(%d,App.Vector(%f,%f,0))",
GeoId, onSketchPos.x, onSketchPos.y);
Gui::cmdAppObjectArgs(sketchgui->getObject(),
"split(%d,App.Vector(%f,%f,0))",
GeoId,
onSketchPos.x,
onSketchPos.y);
Gui::Command::commitCommand();
tryAutoRecompute(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
tryAutoRecompute(static_cast<Sketcher::SketchObject*>(sketchgui->getObject()));
}
catch (const Base::Exception& e) {
Gui::NotifyError(sketchgui,
QT_TRANSLATE_NOOP("Notifications", "Error"),
QT_TRANSLATE_NOOP("Notifications", "Failed to add edge"));
QT_TRANSLATE_NOOP("Notifications", "Error"),
QT_TRANSLATE_NOOP("Notifications", "Failed to add edge"));
Gui::Command::abortCommand();
}
@@ -161,13 +166,13 @@ private:
Gui::Selection().addSelectionGate(new SplittingSelection(sketchgui->getObject()));
}
QString getCrosshairCursorSVGName() const override {
QString getCrosshairCursorSVGName() const override
{
return QString::fromLatin1("Sketcher_Pointer_Splitting");
}
};
} // namespace SketcherGui
}// namespace SketcherGui
#endif // SKETCHERGUI_DrawSketchHandlerSplitting_H
#endif// SKETCHERGUI_DrawSketchHandlerSplitting_H