TechDraw: changed CosmeticVertex point picker dashed circle to filled dot. (#20095)

* techdraw: changed the cosmetic vertex shape

* add back the call to prepareGeometryChange

* add getVertexSize and getLineWidth methods to QGIViewPart

* use doubles for sizes

* update setRadius in QGMarker to use double instead of float
This commit is contained in:
Captain
2025-03-17 22:35:29 +05:30
committed by GitHub
parent 3d03bb45f8
commit 384fcdf006
8 changed files with 35 additions and 19 deletions

2
.gitignore vendored
View File

@@ -56,6 +56,8 @@ tags
/CMakeUserPresets.json
Testing
compile_commands.json
*.sublime-project
*.sublime-workspace
# crowdin file
src/Tools/freecad.zip

View File

@@ -118,7 +118,7 @@ void QGMarker::keyPressEvent(QKeyEvent * event)
}
//! adjust the size of this marker
void QGMarker::setRadius(float radius)
void QGMarker::setRadius(double radius)
{
//TODO:: implement different marker shapes. circle, square, triangle, ???
//if (m_markerShape == Circle) { ...

View File

@@ -55,7 +55,7 @@ public:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
void keyPressEvent(QKeyEvent * event) override;
void setRadius(float radius) override;
void setRadius(double radius) override;
Q_SIGNALS:
void dragging(QPointF pos, int idx);

View File

@@ -49,7 +49,7 @@ QGIVertex::QGIVertex(int index) :
setRadius(m_radius);
}
void QGIVertex::setRadius(float r)
void QGIVertex::setRadius(double r)
{
m_radius = r;
QPainterPath p;

View File

@@ -46,8 +46,8 @@ public:
int getProjIndex() const { return projIndex; }
float getRadius() { return m_radius; }
virtual void setRadius(float r);
double getRadius() const { return m_radius; }
virtual void setRadius(double r);
Base::Vector2d toVector2d() const;
Base::Vector2d vector2dBetweenPoints(const QGIVertex* p2) const;
@@ -56,9 +56,7 @@ protected:
bool multiselectEligible() override { return true; }
int projIndex;
float m_radius;
private:
double m_radius;
};
}

View File

@@ -433,8 +433,6 @@ void QGIViewPart::drawAllVertexes()
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
auto vp(static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject())));
float lineWidth = vp->LineWidth.getValue() * lineScaleFactor; //thick
double vertexScaleFactor = Preferences::getPreferenceGroup("General")->GetFloat("VertexScale", 3.0);
QColor vertexColor = PreferencesGui::getAccessibleQColor(PreferencesGui::vertexQColor());
const std::vector<TechDraw::VertexPtr>& verts = dvp->getVertexGeometry();
@@ -445,8 +443,8 @@ void QGIViewPart::drawAllVertexes()
QGICMark* cmItem = new QGICMark(i);
addToGroup(cmItem);
cmItem->setPos(Rez::guiX((*vert)->x()), Rez::guiX((*vert)->y()));
cmItem->setThick(0.5 * lineWidth);//need minimum?
cmItem->setSize(lineWidth * vertexScaleFactor * vp->CenterScale.getValue());
cmItem->setThick(0.5F * getLineWidth());//need minimum?
cmItem->setSize(getVertexSize() * vp->CenterScale.getValue());
cmItem->setPrettyNormal();
cmItem->setZValue(ZVALUE::VERTEX);
}
@@ -458,7 +456,7 @@ void QGIViewPart::drawAllVertexes()
item->setPos(Rez::guiX((*vert)->x()), Rez::guiX((*vert)->y()));
item->setNormalColor(vertexColor);
item->setFillColor(vertexColor);
item->setRadius(lineWidth * vertexScaleFactor);
item->setRadius(getVertexSize());
item->setPrettyNormal();
item->setZValue(ZVALUE::VERTEX);
}
@@ -1292,3 +1290,13 @@ void QGIViewPart::setGroupSelection(bool isSelected, const std::vector<std::stri
}
}
}
double QGIViewPart::getLineWidth() {
auto vp{static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()))};
return vp->LineWidth.getValue() * lineScaleFactor; // Thick
}
double QGIViewPart::getVertexSize() {
return getLineWidth() * Preferences::vertexScale();
}

View File

@@ -124,6 +124,9 @@ public:
virtual bool removeSelectedCosmetic() const;
virtual double getLineWidth();
virtual double getVertexSize();
protected:
QPainterPath drawPainterPath(TechDraw::BaseGeomPtr baseGeom) const;
void drawViewPart();

View File

@@ -41,7 +41,9 @@
#include "PreferencesGui.h"
#include "QGTracker.h"
#include "QGIVertex.h"
#include "QGIView.h"
#include "QGIViewPart.h"
#include "QGSPage.h"
#include "Rez.h"
#include "ZVALUE.h"
@@ -438,12 +440,15 @@ void QGTracker::setPoint(std::vector<QPointF> pts)
return;
}
prepareGeometryChange();
QPainterPath newPath;
QPointF center = pts.front();
double radius = 50.0;
newPath.addEllipse(center, radius, radius);
setPath(newPath);
setPrettyNormal();
auto point = new QGIVertex(-1);
point->setParentItem(this);
point->setPos(pts.front());
point->setRadius(static_cast<QGIViewPart *>(m_qgParent)->getVertexSize());
point->setNormalColor(Qt::blue);
point->setFillColor(Qt::blue);
point->setPrettyNormal();
point->setZValue(ZVALUE::VERTEX);
}
std::vector<Base::Vector3d> QGTracker::convertPoints()