Merge pull request #25044 from WandererFan/CenterMarksNotShown3
TechDraw: Vertex creation, display and selection issues
This commit is contained in:
@@ -709,3 +709,13 @@ double Preferences::detailSnapRadius()
|
||||
return getPreferenceGroup("General")->GetFloat("DetailSnapRadius", 0.6);
|
||||
}
|
||||
|
||||
|
||||
bool Preferences::showCenterMarks()
|
||||
{
|
||||
return getPreferenceGroup("Decorations")->GetBool("ShowCenterMarks", false);
|
||||
}
|
||||
|
||||
bool Preferences::printCenterMarks()
|
||||
{
|
||||
return getPreferenceGroup("Decorations")->GetBool("PrintCenterMarks", false);
|
||||
}
|
||||
|
||||
@@ -166,6 +166,9 @@ public:
|
||||
static bool snapDetailHighlights();
|
||||
static double detailSnapRadius();
|
||||
|
||||
static bool showCenterMarks();
|
||||
static bool printCenterMarks();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -231,7 +231,6 @@ void CmdTechDrawCosmeticVertexGroup::activated(int iMsg)
|
||||
Base::Console().message("CMD::CVGrp - invalid iMsg: %d\n", iMsg);
|
||||
};
|
||||
updateActive();
|
||||
Gui::Selection().clearSelection();
|
||||
}
|
||||
|
||||
Gui::Action * CmdTechDrawCosmeticVertexGroup::createAction()
|
||||
|
||||
@@ -81,7 +81,8 @@ namespace sp = std::placeholders;
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(TechDrawGui::MDIViewPage, Gui::MDIView)
|
||||
|
||||
MDIViewPage::MDIViewPage(ViewProviderPage* pageVp, Gui::Document* doc, QWidget* parent)
|
||||
: Gui::MDIView(doc, parent), m_vpPage(pageVp)
|
||||
: Gui::MDIView(doc, parent), m_vpPage(pageVp),
|
||||
m_previewState(false)
|
||||
{
|
||||
setMouseTracking(true);
|
||||
|
||||
@@ -362,7 +363,9 @@ void MDIViewPage::printPreview()
|
||||
|
||||
QPrintPreviewDialog dlg(&printer, this);
|
||||
connect(&dlg, &QPrintPreviewDialog::paintRequested, this, qOverload<QPrinter*>(&MDIViewPage::print));
|
||||
m_previewState = true;
|
||||
dlg.exec();
|
||||
m_previewState = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -411,7 +414,7 @@ void MDIViewPage::print(QPrinter* printer)
|
||||
}
|
||||
}
|
||||
|
||||
PagePrinter::print(getViewProviderPage(), printer);
|
||||
PagePrinter::print(getViewProviderPage(), printer, m_previewState);
|
||||
}
|
||||
|
||||
// static routine to print all pages in a document. Used by PrintAll command in Command.cpp
|
||||
|
||||
@@ -156,6 +156,8 @@ private:
|
||||
QList<QGraphicsItem*> m_orderedSceneSelection; //items in selection order
|
||||
|
||||
QString defaultFileName();
|
||||
|
||||
bool m_previewState{false};
|
||||
};
|
||||
|
||||
class MDIViewPagePy : public Py::PythonExtension<MDIViewPagePy>
|
||||
|
||||
@@ -240,7 +240,7 @@ void PagePrinter::printAllPdf(QPrinter* printer, App::Document* doc)
|
||||
renderPage(vpp, painter, sourceRect, targetRect);
|
||||
dPage->redrawCommand();
|
||||
|
||||
ourScene->setExportingPdf(true);
|
||||
ourScene->setExportingPdf(false);
|
||||
}
|
||||
|
||||
ourDoc->setModified(docModifiedState);
|
||||
@@ -305,7 +305,7 @@ void PagePrinter::renderPage(ViewProviderPage* vpp, QPainter& painter, QRectF& s
|
||||
|
||||
|
||||
/// print the Page associated with the view provider
|
||||
void PagePrinter::print(ViewProviderPage* vpPage, QPrinter* printer)
|
||||
void PagePrinter::print(ViewProviderPage* vpPage, QPrinter* printer, bool isPreview)
|
||||
{
|
||||
QPageLayout pageLayout = printer->pageLayout();
|
||||
|
||||
@@ -318,7 +318,8 @@ void PagePrinter::print(ViewProviderPage* vpPage, QPrinter* printer)
|
||||
QPainter painter(printer);
|
||||
|
||||
auto ourScene = vpPage->getQGSPage();
|
||||
if (!printer->outputFileName().isEmpty()) {
|
||||
if (!printer->outputFileName().isEmpty() ||
|
||||
isPreview) {
|
||||
ourScene->setExportingPdf(true);
|
||||
}
|
||||
auto ourDoc = Gui::Application::Instance->getDocument(dPage->getDocument());
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
static PaperAttributes getPaperAttributes(TechDraw::DrawPage* pageObject);
|
||||
static PaperAttributes getPaperAttributes(ViewProviderPage* vpPage);
|
||||
|
||||
static void print(ViewProviderPage* vpPage, QPrinter* printer);
|
||||
static void print(ViewProviderPage* vpPage, QPrinter* printer, bool isPreview = false);
|
||||
static void printPdf(ViewProviderPage* vpPage, const std::string& file);
|
||||
static void printAll(QPrinter* printer, App::Document* doc);
|
||||
static void printAllPdf(QPrinter* printer, App::Document* doc);
|
||||
|
||||
@@ -32,10 +32,13 @@
|
||||
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
|
||||
|
||||
#include "QGIProjGroup.h"
|
||||
#include "QGIViewDimension.h"
|
||||
#include "QGIViewPart.h"
|
||||
#include "Rez.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
QGIProjGroup::QGIProjGroup()
|
||||
{
|
||||
@@ -45,7 +48,6 @@ QGIProjGroup::QGIProjGroup()
|
||||
setFlag(ItemIsSelectable, false);
|
||||
setFlag(ItemIsMovable, true);
|
||||
setFiltersChildEvents(true);
|
||||
// setFrameState(false);
|
||||
}
|
||||
|
||||
TechDraw::DrawProjGroup * QGIProjGroup::getDrawView() const
|
||||
@@ -53,51 +55,61 @@ TechDraw::DrawProjGroup * QGIProjGroup::getDrawView() const
|
||||
App::DocumentObject *obj = getViewObject();
|
||||
return dynamic_cast<TechDraw::DrawProjGroup *>(obj);
|
||||
}
|
||||
|
||||
bool QGIProjGroup::autoDistributeEnabled() const
|
||||
{
|
||||
return getDrawView() && getDrawView()->AutoDistribute.getValue();
|
||||
}
|
||||
|
||||
|
||||
// note that we are not actually handling any of these events (ie we don't return true, and we don't
|
||||
// set the the event to ignore) here.
|
||||
bool QGIProjGroup::sceneEventFilter(QGraphicsItem* watched, QEvent *event)
|
||||
{
|
||||
// i want to handle events before the child item that would ordinarily receive them
|
||||
auto qvpart = dynamic_cast<QGIViewPart*>(watched);
|
||||
if (!qvpart ||
|
||||
!isMember(qvpart->getViewObject())) {
|
||||
// if qwatched is not in this projgroup, we ignore the event as none of our business
|
||||
return false;
|
||||
}
|
||||
|
||||
// i want to handle events before the child item that would ordinarily receive them
|
||||
if(event->type() == QEvent::GraphicsSceneMousePress ||
|
||||
event->type() == QEvent::GraphicsSceneMouseMove ||
|
||||
event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||
|
||||
QGIView *qAnchor = getAnchorQItem();
|
||||
QGIView* qWatched = dynamic_cast<QGIView*>(watched);
|
||||
// If AutoDistribute is enabled, catch events and move the anchor directly
|
||||
if(qAnchor && (watched == qAnchor || (autoDistributeEnabled() && qWatched != nullptr))) {
|
||||
auto *mEvent = dynamic_cast<QGraphicsSceneMouseEvent*>(event);
|
||||
|
||||
// Disable moves on the view to prevent double drag
|
||||
std::vector<QGraphicsItem*> modifiedChildren;
|
||||
for (auto* child : childItems()) {
|
||||
if (child->isSelected() && (child->flags() & QGraphicsItem::ItemIsMovable)) {
|
||||
child->setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
modifiedChildren.push_back(child);
|
||||
}
|
||||
}
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::GraphicsSceneMousePress:
|
||||
mousePressEvent(mEvent);
|
||||
break;
|
||||
case QEvent::GraphicsSceneMouseMove:
|
||||
mouseMoveEvent(mEvent);
|
||||
break;
|
||||
case QEvent::GraphicsSceneMouseRelease:
|
||||
mouseReleaseEvent(qWatched, mEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (auto* child : modifiedChildren) {
|
||||
child->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
}
|
||||
return true;
|
||||
auto* qWatched = dynamic_cast<QGIView*>(watched);
|
||||
if (!qWatched) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto *mEvent = dynamic_cast<QGraphicsSceneMouseEvent*>(event);
|
||||
|
||||
// Disable moves on the view to prevent double drag
|
||||
std::vector<QGraphicsItem*> modifiedChildren;
|
||||
for (auto* child : childItems()) {
|
||||
if (child->isSelected() && (child->flags() & QGraphicsItem::ItemIsMovable)) {
|
||||
child->setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
modifiedChildren.push_back(child);
|
||||
}
|
||||
}
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::GraphicsSceneMousePress:
|
||||
mousePressEvent(mEvent);
|
||||
break;
|
||||
case QEvent::GraphicsSceneMouseMove:
|
||||
mouseMoveEvent(mEvent);
|
||||
break;
|
||||
case QEvent::GraphicsSceneMouseRelease:
|
||||
mouseReleaseEvent(qWatched, mEvent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (auto* child : modifiedChildren) {
|
||||
child->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -143,6 +155,7 @@ QVariant QGIProjGroup::itemChange(GraphicsItemChange change, const QVariant &val
|
||||
|
||||
void QGIProjGroup::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// save the new mousePos, but don't do anything else.
|
||||
QGIView *qAnchor = getAnchorQItem();
|
||||
if(qAnchor) {
|
||||
QPointF transPos = qAnchor->mapFromScene(event->scenePos());
|
||||
@@ -150,31 +163,32 @@ void QGIProjGroup::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
mousePos = event->screenPos();
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void QGIProjGroup::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
QGIView *qAnchor = getAnchorQItem();
|
||||
// this is obsolete too?
|
||||
if(scene() && qAnchor && (qAnchor == scene()->mouseGrabberItem() || autoDistributeEnabled())) {
|
||||
if((mousePos - event->screenPos()).manhattanLength() > 5) { //if the mouse has moved more than 5, process the mouse event
|
||||
QGIViewCollection::mouseMoveEvent(event);
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void QGIProjGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
mouseReleaseEvent(getAnchorQItem(), event);
|
||||
}
|
||||
|
||||
|
||||
void QGIProjGroup::mouseReleaseEvent(QGIView* originator, QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if(scene()) {
|
||||
// this assumes we are dragging?
|
||||
if((mousePos - event->screenPos()).manhattanLength() < 5) {
|
||||
if(originator && originator->shape().contains(event->pos())) {
|
||||
event->ignore();
|
||||
originator->mouseReleaseEvent(event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(scene() && originator) {
|
||||
@@ -217,3 +231,16 @@ void QGIProjGroup::drawBorder()
|
||||
// Base::Console().message("TRACE - QGIProjGroup::drawBorder - doing nothing!!\n");
|
||||
}
|
||||
|
||||
|
||||
//! true if dvpObj is a member of our projection group
|
||||
bool QGIProjGroup::isMember(App::DocumentObject* dvpObj) const
|
||||
{
|
||||
std::vector<App::DocumentObject*> groupOutlist = getViewObject()->getOutList();
|
||||
auto itMatch = std::find_if(groupOutlist.begin(), groupOutlist.end(),
|
||||
[dvpObj](App::DocumentObject* child) {
|
||||
return child == dvpObj;
|
||||
});
|
||||
return itMatch != groupOutlist.end();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ public:
|
||||
|
||||
void drawBorder() override;
|
||||
|
||||
bool isMember(App::DocumentObject* dvpObj) const;
|
||||
|
||||
protected:
|
||||
bool sceneEventFilter(QGraphicsItem* watched, QEvent *event) override;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
|
||||
@@ -168,7 +168,6 @@ void QGIView::alignTo(QGraphicsItem*item, const QString &alignment)
|
||||
|
||||
QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
// Base::Console().message("QGIV::itemChange(%d)\n", change);
|
||||
if(change == ItemPositionChange && scene()) {
|
||||
QPointF newPos = value.toPointF(); //position within parent!
|
||||
TechDraw::DrawView* viewObj = getViewObject();
|
||||
@@ -196,13 +195,10 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
return newPos;
|
||||
}
|
||||
|
||||
// wf: why scene()? because if our selected state has changed because we have been removed from
|
||||
// the scene, we don't do anything except wait to be deleted.
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
std::vector<Gui::SelectionObject> currentSelection = Gui::Selection().getSelectionEx();
|
||||
bool isViewObjectSelected = Gui::Selection().isSelected(getViewObject());
|
||||
bool hasSelectedSubElements =
|
||||
!DrawGuiUtil::getSubsForSelectedObject(currentSelection, getViewObject()).empty();
|
||||
|
||||
if (isViewObjectSelected || hasSelectedSubElements) {
|
||||
if (isSelected() || hasSelectedChildren(this)) {
|
||||
m_colCurrent = getSelectColor();
|
||||
m_border->show();
|
||||
m_label->show();
|
||||
@@ -220,7 +216,6 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
}
|
||||
}
|
||||
drawBorder();
|
||||
update();
|
||||
}
|
||||
|
||||
return QGraphicsItemGroup::itemChange(change, value);
|
||||
@@ -537,7 +532,6 @@ void QGIView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
m_lock->setVisible(getViewObject()->isLocked() && getViewObject()->showLock());
|
||||
|
||||
drawBorder();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -560,13 +554,11 @@ void QGIView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
}
|
||||
|
||||
drawBorder();
|
||||
update();
|
||||
}
|
||||
|
||||
//sets position in /Gui(graphics), not /App
|
||||
void QGIView::setPosition(qreal xPos, qreal yPos)
|
||||
{
|
||||
// Base::Console().message("QGIV::setPosition(%.3f, %.3f) (gui)\n", x, y);
|
||||
double newX = xPos;
|
||||
double newY = -yPos;
|
||||
double oldX = pos().x();
|
||||
@@ -595,8 +587,6 @@ QGIViewClip* QGIView::getClipGroup()
|
||||
|
||||
void QGIView::updateView(bool forceUpdate)
|
||||
{
|
||||
// Base::Console().message("QGIV::updateView() - %s\n", getViewObject()->getNameInDocument());
|
||||
|
||||
//allow/prevent dragging
|
||||
if (getViewObject()->isLocked()) {
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
@@ -678,7 +668,6 @@ void QGIView::toggleCache(bool state)
|
||||
|
||||
void QGIView::draw()
|
||||
{
|
||||
// Base::Console().message("QGIV::draw()\n");
|
||||
double xFeat, yFeat;
|
||||
if (getViewObject()) {
|
||||
xFeat = Rez::guiX(getViewObject()->X.getValue());
|
||||
@@ -742,10 +731,10 @@ void QGIView::layoutDecorations(const QRectF& contentArea,
|
||||
|
||||
void QGIView::drawBorder()
|
||||
{
|
||||
// Base::Console().message("QGIV::drawBorder() - %s\n", getViewName());
|
||||
auto feat = getViewObject();
|
||||
if (!feat)
|
||||
if (!feat) {
|
||||
return;
|
||||
}
|
||||
|
||||
prepareCaption();
|
||||
|
||||
@@ -810,6 +799,7 @@ QRectF QGIView::frameRect() const
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
// we only want the area defined by the edges
|
||||
child->type() != UserType::QGIRichAnno &&
|
||||
child->type() != UserType::QGEPath &&
|
||||
child->type() != UserType::QGMText &&
|
||||
@@ -845,7 +835,9 @@ QRectF QGIView::customChildrenBoundingRect() const
|
||||
child->type() != UserType::QGCustomBorder &&
|
||||
child->type() != UserType::QGCustomLabel &&
|
||||
child->type() != UserType::QGICaption &&
|
||||
child->type() != UserType::QGIVertex &&
|
||||
// we treat vertices as part of the boundingRect to allow loose vertices outside of the
|
||||
// area defined by the edges as in frameRect()
|
||||
// child->type() != UserType::QGIVertex &&
|
||||
child->type() != UserType::QGICMark) {
|
||||
QRectF childRect = mapFromItem(child, child->boundingRect()).boundingRect();
|
||||
result = result.united(childRect);
|
||||
@@ -1060,6 +1052,20 @@ void QGIView::makeMark(double xPos, double yPos, QColor color)
|
||||
vItem->setZValue(ZVALUE::VERTEX);
|
||||
}
|
||||
|
||||
//! true if parent has any children which are selected
|
||||
bool QGIView::hasSelectedChildren(QGIView* parent)
|
||||
{
|
||||
QList<QGraphicsItem*> children = parent->childItems();
|
||||
|
||||
auto itMatch = std::find_if(children.begin(), children.end(),
|
||||
[&](QGraphicsItem* child) {
|
||||
return child->isSelected();
|
||||
});
|
||||
|
||||
return itMatch != children.end();
|
||||
}
|
||||
|
||||
|
||||
void QGIView::makeMark(Base::Vector3d pos, QColor color)
|
||||
{
|
||||
makeMark(pos.x, pos.y, color);
|
||||
@@ -1070,6 +1076,7 @@ void QGIView::makeMark(QPointF pos, QColor color)
|
||||
makeMark(pos.x(), pos.y(), color);
|
||||
}
|
||||
|
||||
|
||||
//! Retrieves objects of type T with given indexes
|
||||
template <typename T>
|
||||
std::vector<T> QGIView::getObjects(std::vector<int> indexes)
|
||||
|
||||
@@ -174,6 +174,8 @@ public:
|
||||
|
||||
bool pseudoEventFilter(QGraphicsItem *watched, QEvent *event) { return sceneEventFilter(watched, event); }
|
||||
|
||||
static bool hasSelectedChildren(QGIView* parent);
|
||||
|
||||
protected:
|
||||
QGIView* getQGIVByName(std::string name) const;
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "ZVALUE.h"
|
||||
#include "PathBuilder.h"
|
||||
#include "QGIBreakLine.h"
|
||||
#include "QGSPage.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
@@ -101,14 +102,21 @@ QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant& valu
|
||||
bool selectState = value.toBool();
|
||||
if (!selectState && !isUnderMouse()) {
|
||||
// hide everything
|
||||
bool hideCenters = hideCenterMarks();
|
||||
for (auto& child : childItems()) {
|
||||
if (child->type() == UserType::QGIVertex || child->type() == UserType::QGICMark) {
|
||||
if (child->type() == UserType::QGIVertex) {
|
||||
child->hide();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child->type() == UserType::QGICMark &&
|
||||
hideCenters) {
|
||||
child->hide();
|
||||
}
|
||||
}
|
||||
return QGIView::itemChange(change, value);
|
||||
}
|
||||
// we are selected
|
||||
// we are selected, don't change anything?
|
||||
}
|
||||
else if (change == ItemSceneChange && scene()) {
|
||||
// This means we are finished?
|
||||
@@ -116,17 +124,22 @@ QVariant QGIViewPart::itemChange(GraphicsItemChange change, const QVariant& valu
|
||||
}
|
||||
else if (change == QGraphicsItem::ItemSceneHasChanged) {
|
||||
if (scene()) {
|
||||
// added to scene
|
||||
m_selectionChangedConnection = connect(scene(), &QGraphicsScene::selectionChanged, this, [this]() {
|
||||
// When selection changes, if the mouse is not over the view,
|
||||
// hide any non-selected vertices.
|
||||
if (!isUnderMouse()) {
|
||||
bool hideCenters = hideCenterMarks();
|
||||
for (auto* child : childItems()) {
|
||||
if ((child->type() == UserType::QGIVertex || child->type() == UserType::QGICMark) &&
|
||||
if (child->type() == UserType::QGIVertex &&
|
||||
!child->isSelected()) {
|
||||
child->hide();
|
||||
}
|
||||
if (child->type() == UserType::QGICMark &&
|
||||
hideCenters) {
|
||||
child->hide();
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -159,7 +172,6 @@ bool QGIViewPart::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||
//! selected, remove it from the view.
|
||||
bool QGIViewPart::removeSelectedCosmetic() const
|
||||
{
|
||||
// Base::Console().message("QGIVP::removeSelectedCosmetic()\n");
|
||||
auto dvp(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
|
||||
if (!dvp) {
|
||||
throw Base::RuntimeError("Graphic has no feature!");
|
||||
@@ -458,19 +470,20 @@ void QGIViewPart::drawAllVertexes()
|
||||
QColor vertexColor = PreferencesGui::getAccessibleQColor(PreferencesGui::vertexQColor());
|
||||
|
||||
const std::vector<TechDraw::VertexPtr>& verts = dvp->getVertexGeometry();
|
||||
std::vector<TechDraw::VertexPtr>::const_iterator vert = verts.begin();
|
||||
auto vert = verts.begin();
|
||||
for (int i = 0; vert != verts.end(); ++vert, i++) {
|
||||
if ((*vert)->isCenter()) {
|
||||
if (showCenterMarks()) {
|
||||
auto* cmItem = new QGICMark(i);
|
||||
addToGroup(cmItem);
|
||||
cmItem->setPos(Rez::guiX((*vert)->x()), Rez::guiX((*vert)->y()));
|
||||
cmItem->setThick(0.5F * getLineWidth());//need minimum?
|
||||
cmItem->setSize(getVertexSize() * vp->CenterScale.getValue());
|
||||
cmItem->setPrettyNormal();
|
||||
cmItem->setZValue(ZVALUE::VERTEX);
|
||||
cmItem->setVisible(m_isHovered);
|
||||
}
|
||||
auto* cmItem = new QGICMark(i);
|
||||
addToGroup(cmItem);
|
||||
cmItem->setPos(Rez::guiX((*vert)->x()), Rez::guiX((*vert)->y()));
|
||||
cmItem->setThick(0.5F * getLineWidth()); //need minimum?
|
||||
cmItem->setSize(getVertexSize() * vp->CenterScale.getValue());
|
||||
cmItem->setPrettyNormal();
|
||||
cmItem->setZValue(ZVALUE::VERTEX);
|
||||
bool showMark =
|
||||
( (!isExporting() && vp->ArcCenterMarks.getValue()) ||
|
||||
(isExporting() && Preferences::printCenterMarks()) );
|
||||
cmItem->setVisible(showMark);
|
||||
} else {
|
||||
//regular Vertex
|
||||
if (showVertices()) {
|
||||
@@ -482,7 +495,7 @@ void QGIViewPart::drawAllVertexes()
|
||||
item->setRadius(getVertexSize());
|
||||
item->setPrettyNormal();
|
||||
item->setZValue(ZVALUE::VERTEX);
|
||||
item->setVisible(m_isHovered);
|
||||
item->setVisible(m_isHovered || isSelected());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -513,39 +526,6 @@ bool QGIViewPart::showThisEdge(BaseGeomPtr geom)
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns true if vertex dots should be shown
|
||||
bool QGIViewPart::showVertices()
|
||||
{
|
||||
// dvp and vp already validated
|
||||
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
|
||||
|
||||
if (dvp->CoarseView.getValue()) {
|
||||
// never show vertices in CoarseView
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// returns true if arc center marks should be shown
|
||||
bool QGIViewPart::showCenterMarks()
|
||||
{
|
||||
// dvp and vp already validated
|
||||
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
|
||||
auto vp(static_cast<ViewProviderViewPart*>(getViewProvider(dvp)));
|
||||
|
||||
if (!vp->ArcCenterMarks.getValue()) {
|
||||
// no center marks if view property is false
|
||||
return false;
|
||||
}
|
||||
if (prefPrintCenters()) {
|
||||
// frames are off, view property is true and Print Center Marks is true
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
|
||||
{
|
||||
@@ -1202,11 +1182,6 @@ bool QGIViewPart::prefFaceEdges()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool QGIViewPart::prefPrintCenters()
|
||||
{
|
||||
bool printCenters = Preferences::getPreferenceGroup("Decorations")->GetBool("PrintCenterMarks", false);//true matches v0.18 behaviour
|
||||
return printCenters;
|
||||
}
|
||||
|
||||
Base::Color QGIViewPart::prefBreaklineColor()
|
||||
{
|
||||
@@ -1320,7 +1295,13 @@ void QGIViewPart::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
for (auto& child : childItems()) {
|
||||
if (child->type() == UserType::QGIVertex || child->type() == UserType::QGICMark) {
|
||||
child->show();
|
||||
continue;
|
||||
}
|
||||
if (child->type() == UserType::QGICMark &&
|
||||
!hideCenterMarks()) {
|
||||
child->show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
update();
|
||||
@@ -1330,11 +1311,87 @@ void QGIViewPart::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
QGIView::hoverLeaveEvent(event);
|
||||
|
||||
if (isSelected()) {
|
||||
// if the view is selected, we should leave things alone.
|
||||
return;
|
||||
}
|
||||
|
||||
bool hideCenters = hideCenterMarks();
|
||||
|
||||
for (auto& child : childItems()) {
|
||||
if ((child->type() == UserType::QGIVertex || child->type() == UserType::QGICMark) &&
|
||||
if (child->type() == UserType::QGIVertex &&
|
||||
!child->isSelected()) {
|
||||
child->hide();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (child->type() == UserType::QGICMark) {
|
||||
if (child->isSelected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (hideCenters) {
|
||||
child->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
bool QGIViewPart::isExporting() const
|
||||
{
|
||||
// dvp already validated
|
||||
auto viewPart {freecad_cast<TechDraw::DrawViewPart*>(getViewObject())};
|
||||
auto vpPage = getViewProviderPage(viewPart);
|
||||
|
||||
QGSPage* scenePage = vpPage->getQGSPage();
|
||||
if (!scenePage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return scenePage->getExportingAny();
|
||||
}
|
||||
|
||||
|
||||
// returns true if vertex dots should be shown
|
||||
// note this is only one of the "rules" around showing or hiding vertices.
|
||||
bool QGIViewPart::showVertices() const
|
||||
{
|
||||
// dvp already validated
|
||||
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
|
||||
return !dvp->CoarseView.getValue();
|
||||
}
|
||||
|
||||
|
||||
// returns true if arc center marks should be shown
|
||||
bool QGIViewPart::showCenterMarks() const
|
||||
{
|
||||
// dvp and vp already validated
|
||||
auto dvp(static_cast<TechDraw::DrawViewPart*>(getViewObject()));
|
||||
auto vp(static_cast<ViewProviderViewPart*>(getViewProvider(dvp)));
|
||||
|
||||
if (isExporting() && Preferences::printCenterMarks()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return vp->ArcCenterMarks.getValue();
|
||||
}
|
||||
|
||||
//! true if center marks (type of vertex) should be hidden
|
||||
bool QGIViewPart::hideCenterMarks() const
|
||||
{
|
||||
// printing
|
||||
if (isExporting() &&
|
||||
Preferences::printCenterMarks()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// on screen
|
||||
if (showCenterMarks()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,11 @@ public:
|
||||
virtual double getLineWidth();
|
||||
virtual double getVertexSize();
|
||||
|
||||
bool isExporting() const;
|
||||
bool hideCenterMarks() const;
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||
QPainterPath drawPainterPath(TechDraw::BaseGeomPtr baseGeom) const;
|
||||
@@ -142,14 +147,13 @@ protected:
|
||||
void removePrimitives();
|
||||
void removeDecorations();
|
||||
bool prefFaceEdges();
|
||||
bool prefPrintCenters();
|
||||
Base::Color prefBreaklineColor();
|
||||
|
||||
bool formatGeomFromCosmetic(std::string cTag, QGIEdge* item);
|
||||
bool formatGeomFromCenterLine(std::string cTag, QGIEdge* item);
|
||||
|
||||
bool showCenterMarks();
|
||||
bool showVertices();
|
||||
bool showCenterMarks() const;
|
||||
bool showVertices() const;
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem*> deleteItems;
|
||||
|
||||
@@ -136,10 +136,11 @@ public:
|
||||
TechDraw::DrawPage* getDrawPage();
|
||||
|
||||
void setExportingSvg(bool enable);
|
||||
bool getExportingSvg() { return m_exportingSvg; }
|
||||
bool getExportingSvg() const { return m_exportingSvg; }
|
||||
|
||||
void setExportingPdf(bool enable) { m_exportingPdf = enable; };
|
||||
bool getExportingPdf() const { return m_exportingPdf; }
|
||||
bool getExportingAny() const { return getExportingPdf() || getExportingSvg(); }
|
||||
|
||||
virtual void refreshViews();
|
||||
|
||||
|
||||
@@ -273,6 +273,10 @@ void QGTracker::onDoubleClick(QPointF pos)
|
||||
|
||||
void QGTracker::getPickedQGIV(QPointF pos)
|
||||
{
|
||||
if (m_qgParent) {
|
||||
return;
|
||||
}
|
||||
|
||||
setVisible(false);
|
||||
m_qgParent = nullptr;
|
||||
QList<QGraphicsView *> views = scene()->views();
|
||||
@@ -284,13 +288,12 @@ void QGTracker::getPickedQGIV(QPointF pos)
|
||||
if (topItem != pickedItem) {
|
||||
pickedItem = topItem;
|
||||
} //pickedItem sb a QGIV
|
||||
QGIView* qgParent = dynamic_cast<QGIView*>(pickedItem);
|
||||
auto* qgParent = dynamic_cast<QGIView*>(pickedItem);
|
||||
if (qgParent) {
|
||||
m_qgParent = qgParent;
|
||||
}
|
||||
}
|
||||
setVisible(true);
|
||||
return;
|
||||
}
|
||||
|
||||
QRectF QGTracker::boundingRect() const
|
||||
@@ -400,7 +403,7 @@ void QGTracker::setPoint(std::vector<QPointF> pts)
|
||||
auto point = new QGIVertex(-1);
|
||||
point->setParentItem(this);
|
||||
point->setPos(pts.front());
|
||||
point->setRadius(static_cast<QGIViewPart *>(m_qgParent)->getVertexSize());
|
||||
point->setRadius(Rez::guiX(getTrackerWeight()));
|
||||
point->setNormalColor(Qt::blue);
|
||||
point->setFillColor(Qt::blue);
|
||||
point->setPrettyNormal();
|
||||
@@ -420,6 +423,7 @@ std::vector<Base::Vector3d> QGTracker::convertPoints()
|
||||
void QGTracker::terminateDrawing()
|
||||
{
|
||||
setCursor(Qt::ArrowCursor);
|
||||
// should we care if m_qgParent is null?
|
||||
Q_EMIT drawingFinished(m_points, m_qgParent);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,8 @@ public:
|
||||
void setTrackerMode(TrackerMode m) { m_trackerMode = m; }
|
||||
QPointF snapToAngle(QPointF pt);
|
||||
|
||||
void setOwnerQView(QGIView* owner) { m_qgParent = owner; }
|
||||
|
||||
Q_SIGNALS:
|
||||
void drawingFinished(std::vector<QPointF> pts, TechDrawGui::QGIView* qgParent);
|
||||
void qViewPicked(QPointF pos, TechDrawGui::QGIView* qgParent);
|
||||
|
||||
@@ -185,6 +185,9 @@ void TaskCosVertex::startTracker()
|
||||
|
||||
if (!m_tracker) {
|
||||
m_tracker = new QGTracker(m_vpp->getQGSPage(), m_trackerMode);
|
||||
std::string parentName = m_baseFeat->getNameInDocument();
|
||||
QGIView* parentView = m_vpp->getQGSPage()->getQGIVByName(parentName);
|
||||
m_tracker->setOwnerQView(parentView);
|
||||
QObject::connect(
|
||||
m_tracker, &QGTracker::drawingFinished,
|
||||
this, &TaskCosVertex::onTrackerFinished
|
||||
|
||||
@@ -102,12 +102,11 @@ ViewProviderViewPart::ViewProviderViewPart()
|
||||
ADD_PROPERTY_TYPE(ExtraWidth, (weight), group, App::Prop_None, "The thickness of LineGroup Extra lines, if enabled");
|
||||
|
||||
double defScale = Preferences::getPreferenceGroup("Decorations")->GetFloat("CenterMarkScale", 0.50);
|
||||
bool defShowCenters = Preferences::getPreferenceGroup("Decorations")->GetBool("ShowCenterMarks", false);
|
||||
|
||||
//decorations
|
||||
ADD_PROPERTY_TYPE(HorizCenterLine ,(false), dgroup, App::Prop_None, "Show a horizontal centerline through view");
|
||||
ADD_PROPERTY_TYPE(VertCenterLine ,(false), dgroup, App::Prop_None, "Show a vertical centerline through view");
|
||||
ADD_PROPERTY_TYPE(ArcCenterMarks ,(defShowCenters), dgroup, App::Prop_None, "Center marks on/off");
|
||||
ADD_PROPERTY_TYPE(ArcCenterMarks ,(Preferences::showCenterMarks()), dgroup, App::Prop_None, "Center marks on/off");
|
||||
ADD_PROPERTY_TYPE(CenterScale, (defScale), dgroup, App::Prop_None, "Center mark size adjustment, if enabled");
|
||||
|
||||
//properties that affect Section Line
|
||||
|
||||
Reference in New Issue
Block a user