Gui: Make datum planes bigger

This commit is contained in:
Kacper Donat
2025-08-25 00:55:03 +02:00
parent 2bcfe3f2b1
commit b942275957
11 changed files with 395 additions and 185 deletions

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>499</width>
<height>600</height>
<height>708</height>
</rect>
</property>
<property name="windowTitle">
@@ -137,25 +137,25 @@ in the corner in % of height/width of the viewport</string>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>AxisXColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>204</red>
<green>51</green>
<blue>51</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>AxisXColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -177,25 +177,25 @@ in the corner in % of height/width of the viewport</string>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>AxisYColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>51</red>
<green>204</green>
<blue>51</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>AxisYColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -217,19 +217,19 @@ in the corner in % of height/width of the viewport</string>
<property name="text">
<string/>
</property>
<property name="prefEntry" stdset="0">
<cstring>AxisZColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>51</red>
<green>51</green>
<blue>204</blue>
</color>
</property>
<property name="prefEntry" stdset="0">
<cstring>AxisZColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
</layout>
@@ -324,75 +324,20 @@ report this setting as enabled when seeking support.</string>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QComboBox" name="comboAliasing">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Method of multisample anti-aliasing</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="markerSizeLabel">
<property name="toolTip">
<string/>
</property>
<item row="0" column="0">
<widget class="QLabel" name="renderCacheLabel">
<property name="text">
<string>Marker size</string>
<string>Render cache</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="aliasingLAbel">
<item row="5" column="0">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Anti-aliasing</string>
<string>Eye to eye distance for stereo modes</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="transparentRenderLabel">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Transparent objects</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefComboBox" name="comboTransparentRender">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Render types of transparent objects</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>TransparentObjectRenderType</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
<item>
<property name="text">
<string>One pass</string>
</property>
</item>
<item>
<property name="text">
<string>Backface pass</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="renderCache">
<property name="minimumSize">
@@ -430,22 +375,8 @@ but slower response to any scene changes.</string>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="renderCacheLabel">
<property name="text">
<string>Render cache</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Eye to eye distance for stereo modes</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="boxMarkerSize">
<item row="1" column="1">
<widget class="QComboBox" name="comboAliasing">
<property name="minimumSize">
<size>
<width>120</width>
@@ -453,11 +384,18 @@ but slower response to any scene changes.</string>
</size>
</property>
<property name="toolTip">
<string>Size of vertices in the Sketcher, TechDraw and other workbenches</string>
<string>Method of multisample anti-aliasing</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="1" column="0">
<widget class="QLabel" name="aliasingLAbel">
<property name="text">
<string>Anti-aliasing</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="Gui::PrefDoubleSpinBox" name="FloatSpinBox_EyeDistance">
<property name="minimumSize">
<size>
@@ -493,6 +431,117 @@ bounding box size of the 3D object that is currently displayed.</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::PrefComboBox" name="comboTransparentRender">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Render types of transparent objects</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>TransparentObjectRenderType</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
<item>
<property name="text">
<string>One pass</string>
</property>
</item>
<item>
<property name="text">
<string>Backface pass</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="transparentRenderLabel">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Transparent objects</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="markerSizeLabel">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Marker size</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="boxMarkerSize">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Size of vertices in the Sketcher, TechDraw and other workbenches</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="markerSizeLabel_2">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Datum size</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::PrefDoubleSpinBox" name="FloatSpinBox_DatumScale">
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Eye-to-eye distance used for stereo projections.
The specified value is a factor that will be multiplied with the
bounding box size of the 3D object that is currently displayed.</string>
</property>
<property name="suffix">
<string>%</string>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>400.000000000000000</double>
</property>
<property name="singleStep">
<double>5.000000000000000</double>
</property>
<property name="value">
<double>100.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>DatumScale</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>View</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@@ -69,6 +69,7 @@ void DlgSettings3DViewImp::saveSettings()
ui->CheckBox_use_SW_OpenGL->onSave();
ui->CheckBox_useVBO->onSave();
ui->FloatSpinBox_EyeDistance->onSave();
ui->FloatSpinBox_DatumScale->onSave();
ui->axisLetterColor->onSave();
ui->radioPerspective->onSave();
ui->radioOrthographic->onSave();
@@ -86,6 +87,7 @@ void DlgSettings3DViewImp::loadSettings()
ui->CheckBox_use_SW_OpenGL->onRestore();
ui->CheckBox_useVBO->onRestore();
ui->FloatSpinBox_EyeDistance->onRestore();
ui->FloatSpinBox_DatumScale->onRestore();
ui->axisLetterColor->onRestore();
ui->radioPerspective->onRestore();
ui->radioOrthographic->onRestore();

View File

@@ -70,7 +70,10 @@ public:
FC_VIEW_PARAM(NeutralColor,unsigned long,Unsigned,0xB3B38000) \
FC_VIEW_PARAM(PlacementIndicatorScale,double,Float,40.0) \
FC_VIEW_PARAM(DraggerScale,double,Float,0.03) \
FC_VIEW_PARAM(DatumScale,double,Float,100.0) \
FC_VIEW_PARAM(DatumPlaneSize,double,Float,62.0) \
FC_VIEW_PARAM(DatumLineSize,double,Float,70.0) \
FC_VIEW_PARAM(DatumTemporaryScaleFactor,double,Float,2.0) \
#undef FC_VIEW_PARAM
#define FC_VIEW_PARAM(_name,_ctype,_type,_def) \

View File

@@ -32,6 +32,7 @@
# include <Inventor/nodes/SoTranslation.h>
#endif
#include <Base/Tools.h>
#include <App/Datums.h>
#include <Gui/Utilities.h>
#include <Gui/ViewParams.h>
@@ -39,6 +40,8 @@
#include "ViewProviderLine.h"
#include "ViewProviderCoordinateSystem.h"
#include <SoTextLabel.h>
using namespace Gui;
@@ -49,7 +52,14 @@ ViewProviderLine::ViewProviderLine()
{
sPixmap = "Std_Axis";
pLabel = new SoText2();
pLabel = new SoFrameLabel();
pLabel->textColor.setValue(1.0, 1.0, 1.0);
pLabel->horAlignment = SoImage::CENTER;
pLabel->vertAlignment = SoImage::HALF;
pLabel->border = false;
pLabel->frame = false;
pLabel->textUseBaseColor = true;
pLabel->size = 8; // NOLINT
}
ViewProviderLine::~ViewProviderLine() = default;
@@ -58,6 +68,39 @@ void ViewProviderLine::attach(App::DocumentObject *obj)
{
ViewProviderDatum::attach(obj);
// indexes used to create the edges
static const int32_t lines[4] = { 0, 1, -1 };
SoSeparator *sep = getDatumRoot();
pCoords = new SoCoordinate3();
sep->addChild(pCoords);
auto pLines = new SoIndexedLineSet();
pLines->coordIndex.setNum(3);
pLines->coordIndex.setValues(0, 3, lines);
sep->addChild(pLines);
pLabelTranslation = new SoTranslation();
sep->addChild(pLabelTranslation);
auto ps = new SoPickStyle();
ps->style.setValue(SoPickStyle::SHAPE_ON_TOP);
sep->addChild(ps);
sep->addChild(pLabel);
handlers.addDelayedHandler(
ViewParams::instance()->getHandle(),
{"DatumLineSize", "DatumScale"},
[this](const ParameterGrp::handle&) { updateLineSize(); }
);
updateLineSize();
}
void ViewProviderLine::updateLineSize()
{
// Setup label text and line colors
const char* name = pcObject->getNameInDocument();
@@ -82,11 +125,13 @@ void ViewProviderLine::attach(App::DocumentObject *obj)
noRole = true;
}
static const float size = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetFloat("DatumLineSize", 70.0);
const auto params = ViewParams::instance();
const float size = params->getDatumLineSize() * Base::fromPercent(params->getDatumScale());
auto line = getObject<App::Line>();
Base::Vector3d dir = line->getBaseDirection();
SbVec3f verts[2];
if (noRole) {
verts[0] = Base::convertTo<SbVec3f>(dir * 2 * size);
verts[1] = SbVec3f(0, 0, 0);
@@ -96,28 +141,8 @@ void ViewProviderLine::attach(App::DocumentObject *obj)
verts[1] = Base::convertTo<SbVec3f>(dir * 0.2 * size);
}
// indexes used to create the edges
static const int32_t lines[4] = { 0, 1, -1 };
pCoords->point.setNum(2);
pCoords->point.setValues(0, 2, verts);
SoSeparator *sep = getDatumRoot();
auto pCoords = new SoCoordinate3 ();
pCoords->point.setNum (2);
pCoords->point.setValues ( 0, 2, verts );
sep->addChild ( pCoords );
auto pLines = new SoIndexedLineSet ();
pLines->coordIndex.setNum(3);
pLines->coordIndex.setValues(0, 3, lines);
sep->addChild ( pLines );
auto textTranslation = new SoTranslation ();
textTranslation->translation.setValue(Base::convertTo<SbVec3f>(dir * 1.1 * size));
sep->addChild ( textTranslation );
auto ps = new SoPickStyle();
ps->style.setValue(SoPickStyle::SHAPE_ON_TOP);
sep->addChild(ps);
sep->addChild (pLabel);
pLabelTranslation->translation.setValue(Base::convertTo<SbVec3f>(dir * 1.2 * size));
}

View File

@@ -27,22 +27,38 @@
#include "ViewProviderDatum.h"
class SoText2;
#include "ParamHandler.h"
class SoCoordinate3;
class SoTranslation;
namespace Gui
{
class SoFrameLabel;
}
namespace Gui
{
class GuiExport ViewProviderLine : public ViewProviderDatum {
PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderLine);
public:
/// Constructor
ViewProviderLine();
~ViewProviderLine() override;
void attach ( App::DocumentObject * ) override;
void attach(App::DocumentObject*) override;
private:
void updateLineSize();
protected:
CoinPtr<SoText2> pLabel;
CoinPtr<SoFrameLabel> pLabel;
CoinPtr<SoCoordinate3> pCoords;
CoinPtr<SoTranslation> pLabelTranslation;
ParamHandlers handlers;
};
} //namespace Gui

View File

@@ -43,13 +43,19 @@
#include "ViewProviderPlane.h"
#include "ViewProviderCoordinateSystem.h"
#include <Utilities.h>
#include <Base/Tools.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/events/SoEvent.h>
#include <Inventor/nodes/SoFontStyle.h>
using namespace Gui;
PROPERTY_SOURCE(Gui::ViewProviderPlane, Gui::ViewProviderDatum)
ViewProviderPlane::ViewProviderPlane()
ViewProviderPlane::ViewProviderPlane() : SelectionObserver(true)
{
sPixmap = "Std_Plane";
lineThickness = 1.0;
@@ -72,37 +78,23 @@ void ViewProviderPlane::attach(App::DocumentObject * obj) {
// and faceSeparator...
//ShapeAppearance.setTransparency(0.8);
auto material = new SoMaterial();
material->transparency.setValue(0.95f);
material->transparency.setValue(0.85f);
if (!role.empty()) {
ShapeAppearance.setDiffuseColor(getColor(role));
SbColor color;
float alpha = 0.0f;
color.setPackedValue(getColor(role), alpha);
material->ambientColor.setValue(color);
material->diffuseColor.setValue(color);
}
static const float size = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View")->GetFloat("DatumPlaneSize", 40.0);
static const float startSize = 0.25 * size; //NOLINT
SbColor color = ShapeAppearance.getDiffuseColor().asValue<SbColor>();
material->ambientColor.setValue(color);
material->diffuseColor.setValue(color);
SbVec3f verts[4];
if (role.empty()) {
verts[0] = SbVec3f(size, size, 0);
verts[1] = SbVec3f(size, -size, 0);
verts[2] = SbVec3f(-size, -size, 0);
verts[3] = SbVec3f(-size, size, 0);
}
else {
verts[0] = SbVec3f(size, size, 0);
verts[1] = SbVec3f(size, startSize, 0);
verts[2] = SbVec3f(startSize, startSize, 0);
verts[3] = SbVec3f(startSize, size, 0);
}
auto ps = new SoPickStyle();
ps->style.setValue(SoPickStyle::SHAPE_ON_TOP);
auto pCoords = new SoCoordinate3();
pCoords->point.setNum(4);
pCoords->point.setValues(0, 4, verts);
pCoords = new SoCoordinate3();
sep->addChild(pCoords);
sep->addChild(material);
sep->addChild(ps);
auto lineSeparator = new SoSeparator();
auto pLines = new SoIndexedLineSet();
@@ -110,9 +102,6 @@ void ViewProviderPlane::attach(App::DocumentObject * obj) {
pLines->coordIndex.setNum(6);
pLines->coordIndex.setValues(0, 6, lines);
auto ps = new SoPickStyle();
ps->style.setValue(SoPickStyle::SHAPE_ON_TOP);
lineSeparator->addChild(ps);
lineSeparator->addChild(pLines);
sep->addChild(lineSeparator);
@@ -120,8 +109,6 @@ void ViewProviderPlane::attach(App::DocumentObject * obj) {
auto faceSeparator = new SoSeparator();
sep->addChild(faceSeparator);
faceSeparator->addChild(material);
// disable backface culling and render with two-sided lighting
auto shapeHints = new SoShapeHints();
shapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
@@ -130,21 +117,42 @@ void ViewProviderPlane::attach(App::DocumentObject * obj) {
auto faceSet = new SoFaceSet();
auto vertexProperty = new SoVertexProperty();
vertexProperty->vertex.setValues(0, 4, verts);
vertexProperty->vertex.connectFrom(&pCoords->point);
faceSet->vertexProperty.setValue(vertexProperty);
faceSeparator->addChild(faceSet);
auto textTranslation = new SoTranslation();
SbVec3f centeringVec = size * SbVec3f(0.36F, 0.49F, 0.0F); // NOLINT
textTranslation->translation.setValue(centeringVec);
sep->addChild(textTranslation);
pTextTranslation = new SoTranslation();
sep->addChild(pTextTranslation);
pLabel->string.setValue(getLabelText(role).c_str());
pLabel->justification = SoAsciiText::RIGHT;
labelSwitch = new SoSwitch();
setLabelVisibility(false);
auto font = new SoFontStyle();
font->size = 10.0;
font->style = SoFontStyle::BOLD;
font->family = SoFontStyle::SANS;
auto labelMaterial = static_cast<SoMaterial*>(material->copy());
labelMaterial->transparency = 0.0;
labelSwitch->addChild(font);
labelSwitch->addChild(labelMaterial);
labelSwitch->addChild(pTextTranslation);
labelSwitch->addChild(pLabel);
updatePlaneSize();
sep->addChild(labelSwitch);
handlers.addDelayedHandler(
ViewParams::instance()->getHandle(),
{"DatumLineSize", "DatumScale"},
[this](ParameterGrp::handle) { updatePlaneSize(); }
);
updatePlaneSize();
}
void ViewProviderPlane::setLabelVisibility(bool val)
@@ -152,6 +160,42 @@ void ViewProviderPlane::setLabelVisibility(bool val)
labelSwitch->whichChild = val ? SO_SWITCH_ALL : SO_SWITCH_NONE;
}
void ViewProviderPlane::onSelectionChanged(const SelectionChanges&)
{
isSelected = Gui::Selection().isSelected(getObject());
isHovered = Gui::Selection().getPreselection().Object.getSubObject() == getObject() || Gui::Selection().getPreselection().Object.getObject() == getObject();
updatePlaneSize();
}
void ViewProviderPlane::updatePlaneSize()
{
const auto params = ViewParams::instance();
const float size = params->getDatumPlaneSize() * Base::fromPercent(params->getDatumScale());
const float offset = 8.0F;
SbVec3f verts[4];
bool isSelectedOrHovered = isSelected || isHovered;
if (!getRole().empty() && !isSelectedOrHovered) {
verts[0] = SbVec3f(size, size, 0);
verts[1] = SbVec3f(size, offset, 0);
verts[2] = SbVec3f(offset, offset, 0);
verts[3] = SbVec3f(offset, size, 0);
} else {
verts[0] = SbVec3f(size, size, 0);
verts[1] = SbVec3f(size, -size, 0);
verts[2] = SbVec3f(-size, -size, 0);
verts[3] = SbVec3f(-size, size, 0);
}
pTextTranslation->translation.setValue(verts[0] / 2 - SbVec3f(2, 6, 0)); // NOLINT
pCoords->point.setNum(4);
pCoords->point.setValues(0, 4, verts);
}
unsigned long ViewProviderPlane::getColor(const std::string& role) const
{
auto planesRoles = App::LocalCoordinateSystem::PlaneRoles;
@@ -169,18 +213,17 @@ unsigned long ViewProviderPlane::getColor(const std::string& role) const
std::string ViewProviderPlane::getLabelText(const std::string& role) const
{
std::string text;
auto planesRoles = App::LocalCoordinateSystem::PlaneRoles;
if (role == planesRoles[0]) {
text = "XY";
return "XY";
}
else if (role == planesRoles[1]) {
text = "XZ";
return "XZ";
}
else if (role == planesRoles[2]) {
text = "YZ";
return "YZ";
}
return text;
return getObject()->getNameInDocument();
}
std::string ViewProviderPlane::getRole() const

View File

@@ -27,13 +27,19 @@
#include "ViewProviderDatum.h"
#include "Selection/Selection.h"
#include "ParamHandler.h"
class SoSwitch;
class SoTranslation;
class SoAsciiText;
class SoCoordinate3;
namespace Gui
{
class GuiExport ViewProviderPlane : public ViewProviderDatum
class GuiExport ViewProviderPlane : public ViewProviderDatum, public SelectionObserver
{
PROPERTY_HEADER_WITH_OVERRIDE(Gui::ViewProviderPlane);
public:
@@ -48,9 +54,20 @@ public:
std::string getLabelText(const std::string& role) const;
void setLabelVisibility(bool val);
void onSelectionChanged(const SelectionChanges&) override;
private:
void updatePlaneSize();
bool isHovered { false };
bool isSelected { false };
CoinPtr<SoSwitch> labelSwitch;
CoinPtr<SoAsciiText> pLabel;
CoinPtr<SoCoordinate3> pCoords;
CoinPtr<SoTranslation> pTextTranslation;
ParamHandlers handlers;
};
} //namespace Gui

View File

@@ -51,10 +51,13 @@
#include <Mod/Part/Gui/TaskAttacher.h>
#include "TaskAttacher.h"
#include "ViewProviderDatum.h"
#include "ViewProvider2DObject.h"
#include "ui_TaskAttacher.h"
#include <Gui/ViewParams.h>
using namespace PartGui;
using namespace Gui;
@@ -218,6 +221,21 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject* ViewProvider, QWidge
ui->attachmentOffsetPitch->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(), std::string("AttachmentOffset.Rotation.Pitch")));
ui->attachmentOffsetRoll->bind(App::ObjectIdentifier::parse(ViewProvider->getObject(), std::string("AttachmentOffset.Rotation.Roll")));
auto document = ViewProvider->getObject()->getDocument();
for (auto planeDocumentObject : document->getObjectsOfType(App::Plane::getClassTypeId())) {
auto planeViewProvider = Application::Instance->getViewProvider<Gui::ViewProviderPlane>(planeDocumentObject);
if (!planeViewProvider) {
continue;
}
modifiedPlaneViewProviders.push_back(planeViewProvider);
planeViewProvider->setTemporaryScale(ViewParams::instance()->getDatumTemporaryScaleFactor());
planeViewProvider->setLabelVisibility(true);
};
visibilityAutomation(true);
updateAttachmentOffsetUI();
updateReferencesUI();
@@ -231,9 +249,9 @@ TaskAttacher::TaskAttacher(Gui::ViewProviderDocumentObject* ViewProvider, QWidge
auto bnd1 = std::bind(&TaskAttacher::objectDeleted, this, sp::_1);
auto bnd2 = std::bind(&TaskAttacher::documentDeleted, this, sp::_1);
//NOLINTEND
Gui::Document* document = Gui::Application::Instance->getDocument(ViewProvider->getObject()->getDocument());
connectDelObject = document->signalDeletedObject.connect(bnd1);
connectDelDocument = document->signalDeleteDocument.connect(bnd2);
Gui::Document* guiDocument = Gui::Application::Instance->getDocument(ViewProvider->getObject()->getDocument());
connectDelObject = guiDocument->signalDeletedObject.connect(bnd1);
connectDelDocument = guiDocument->signalDeleteDocument.connect(bnd2);
handleInitialSelection();
}
@@ -248,6 +266,11 @@ TaskAttacher::~TaskAttacher()
connectDelObject.disconnect();
connectDelDocument.disconnect();
for (auto planeViewProvider : modifiedPlaneViewProviders) {
planeViewProvider->resetTemporarySize();
planeViewProvider->setLabelVisibility(false);
}
}
void TaskAttacher::objectDeleted(const Gui::ViewProviderDocumentObject& view)

View File

@@ -42,6 +42,7 @@ class Property;
}
namespace Gui {
class ViewProviderPlane;
class ViewProvider;
}
@@ -158,6 +159,8 @@ private:
Connection connectDelObject;
Connection connectDelDocument;
std::vector<Gui::ViewProviderPlane*> modifiedPlaneViewProviders;
App::PropertyOverrideContext overrides;
};

View File

@@ -55,6 +55,8 @@
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/ViewParams.h>
#include <Gui/ViewProviderPlane.h>
#include <Gui/Selection/SelectionFilter.h>
using namespace PartDesignGui;
@@ -502,6 +504,7 @@ public:
SketchRequestSelection(Gui::Document* guidocument, PartDesign::Body* activeBody)
: guidocument(guidocument)
, activeBody(activeBody)
, planeFinder(guidocument->getDocument(), activeBody)
{
}
@@ -567,7 +570,7 @@ private:
Gui::Application::Instance->getViewProvider(origin));
if (vpo) {
vpo->setTemporaryVisibility(Gui::DatumElement::Planes | Gui::DatumElement::Axes);
vpo->setTemporaryScale(3.0); // NOLINT
vpo->setTemporaryScale(Gui::ViewParams::instance()->getDatumTemporaryScaleFactor());
vpo->setPlaneLabelVisibility(true);
}
}
@@ -584,14 +587,14 @@ private:
PartDesign::Body* partDesignBody = activeBody;
auto onAccept = [partDesignBody, sketch]() {
SketchRequestSelection::resetOriginVisibility(partDesignBody);
resetOriginVisibility(partDesignBody);
Gui::Selection().clearSelection();
PartDesignGui::setEdit(sketch, partDesignBody);
};
auto onReject = [partDesignBody]() {
SketchRequestSelection::resetOriginVisibility(partDesignBody);
resetOriginVisibility(partDesignBody);
};
Gui::Selection().clearSelection();
@@ -616,7 +619,7 @@ private:
void findAndSelectPlane()
{
App::Document* appdocument = guidocument->getDocument();
PlaneFinder planeFinder{appdocument, activeBody};
planeFinder.findBasePlanes();
planeFinder.findDatumPlanes();
planeFinder.findShapeBinderPlanes();
@@ -625,14 +628,35 @@ private:
std::vector<PartDesignGui::TaskFeaturePick::featureStatus> status = planeFinder.getStatus();
unsigned validPlaneCount = planeFinder.countValidPlanes();
for (auto& plane : planes) {
auto* planeViewProvider = Gui::Application::Instance->getViewProvider<Gui::ViewProviderPlane>(plane);
// skip updating planes from coordinate systems
if (!planeViewProvider->getRole().empty()) {
continue;
}
planeViewProvider->setLabelVisibility(true);
planeViewProvider->setTemporaryScale(Gui::ViewParams::instance()->getDatumTemporaryScaleFactor());
}
//
// Lambda definitions
//
App::Document* documentOfBody = appdocument;
PartDesign::Body* partDesignBody = activeBody;
auto restorePlaneVisibility = [planes]() {
for (auto& plane : planes) {
auto* planeViewProvider = Gui::Application::Instance->getViewProvider<Gui::ViewProviderPlane>(plane);
planeViewProvider->resetTemporarySize();
planeViewProvider->setLabelVisibility(false);
}
};
// Determines if user made a valid selection in dialog
auto acceptFunction = [](const std::vector<App::DocumentObject*>& features) -> bool {
auto acceptFunction = [restorePlaneVisibility](const std::vector<App::DocumentObject*>& features) -> bool {
restorePlaneVisibility();
return !features.empty();
};
@@ -643,7 +667,8 @@ private:
// Called by dialog for "Cancel", or "OK" if accepter returns false
std::string docname = documentOfBody->getName();
auto rejectFunction = [docname]() {
auto rejectFunction = [docname, restorePlaneVisibility]() {
restorePlaneVisibility();
Gui::Document* document = Gui::Application::Instance->getDocument(docname.c_str());
if (document)
document->abortCommand();
@@ -729,6 +754,8 @@ private:
private:
Gui::Document* guidocument;
PartDesign::Body* activeBody;
PlaneFinder planeFinder;
};
}

View File

@@ -54,6 +54,8 @@
#include "TaskFeaturePick.h"
#include "Utils.h"
#include <Gui/ViewParams.h>
using namespace PartDesignGui;
using namespace Attacher;
@@ -159,7 +161,7 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
Gui::Application::Instance->getViewProvider(origin));
if (vpo) {
vpo->setTemporaryVisibility(originVisStatus[origin]);
vpo->setTemporaryScale(4.0); // NOLINT
vpo->setTemporaryScale(Gui::ViewParams::instance()->getDatumTemporaryScaleFactor());
vpo->setPlaneLabelVisibility(true);
origins.push_back(vpo);
}