Sketcher: Port and fix internal faces from RealThunder's branch
Co-authored-by: Zheng Lei <realthunder.dev@gmail.com> Co-authored-by: Kacper Donat <kacper@kadet.net> Co-authored-by: Pierre-Louis Boyer <pierrelouis.boyer@gmail.com>
This commit is contained in:
@@ -163,6 +163,7 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
PartGui::SoBrepEdgeSet ::initClass();
|
||||
PartGui::SoBrepPointSet ::initClass();
|
||||
PartGui::SoFCControlPoints ::initClass();
|
||||
PartGui::SoFCShape ::initClass();
|
||||
PartGui::SoPreviewShape ::initClass();
|
||||
PartGui::ViewProviderAttachExtension ::init();
|
||||
PartGui::ViewProviderAttachExtensionPython ::init();
|
||||
|
||||
@@ -47,6 +47,23 @@
|
||||
|
||||
using namespace PartGui;
|
||||
|
||||
SO_NODE_SOURCE(SoFCShape);
|
||||
|
||||
SoFCShape::SoFCShape()
|
||||
: coords(new SoCoordinate3)
|
||||
, norm(new SoNormal)
|
||||
, faceset(new SoBrepFaceSet)
|
||||
, lineset(new SoBrepEdgeSet)
|
||||
, nodeset(new SoBrepPointSet)
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoFCShape);
|
||||
}
|
||||
|
||||
void SoFCShape::initClass()
|
||||
{
|
||||
SO_NODE_INIT_CLASS(SoFCShape, SoSeparator, "Separator");
|
||||
}
|
||||
|
||||
SO_NODE_SOURCE(SoFCControlPoints)
|
||||
|
||||
void SoFCControlPoints::initClass()
|
||||
|
||||
@@ -23,14 +23,34 @@
|
||||
#ifndef PARTGUI_SOFCSHAPEOBJECT_H
|
||||
#define PARTGUI_SOFCSHAPEOBJECT_H
|
||||
|
||||
#include "SoBrepEdgeSet.h"
|
||||
#include "SoBrepFaceSet.h"
|
||||
#include "SoBrepPointSet.h"
|
||||
|
||||
#include <Inventor/fields/SoSFColor.h>
|
||||
#include <Inventor/fields/SoSFUInt32.h>
|
||||
#include <Inventor/nodes/SoCoordinate3.h>
|
||||
#include <Inventor/nodes/SoNormal.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoShape.h>
|
||||
#include <Mod/Part/PartGlobal.h>
|
||||
|
||||
|
||||
namespace PartGui {
|
||||
|
||||
class PartGuiExport SoFCShape : public SoSeparator {
|
||||
using inherited = SoSeparator;
|
||||
SO_NODE_HEADER(SoFCShape);
|
||||
|
||||
public:
|
||||
SoFCShape();
|
||||
static void initClass();
|
||||
|
||||
SoCoordinate3* coords;
|
||||
SoNormal* norm;
|
||||
SoBrepFaceSet* faceset;
|
||||
SoBrepEdgeSet* lineset;
|
||||
SoBrepPointSet* nodeset;
|
||||
};
|
||||
|
||||
class PartGuiExport SoFCControlPoints : public SoShape {
|
||||
using inherited = SoShape;
|
||||
|
||||
|
||||
@@ -1311,6 +1311,23 @@ void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
|
||||
# endif
|
||||
}
|
||||
|
||||
void ViewProviderPartExt::setupCoinGeometry(TopoDS_Shape shape,
|
||||
SoFCShape* node,
|
||||
double deviation,
|
||||
double angularDeflection,
|
||||
bool normalsFromUV)
|
||||
{
|
||||
setupCoinGeometry(shape,
|
||||
node->coords,
|
||||
node->faceset,
|
||||
node->norm,
|
||||
node->lineset,
|
||||
node->nodeset,
|
||||
deviation,
|
||||
angularDeflection,
|
||||
normalsFromUV);
|
||||
}
|
||||
|
||||
void ViewProviderPartExt::updateVisual()
|
||||
{
|
||||
Gui::SoUpdateVBOAction action;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#ifndef PARTGUI_VIEWPROVIDERPARTEXT_H
|
||||
#define PARTGUI_VIEWPROVIDERPARTEXT_H
|
||||
|
||||
#include "SoFCShapeObject.h"
|
||||
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
@@ -169,7 +172,13 @@ public:
|
||||
SoBrepPointSet* nodeset,
|
||||
double deviation,
|
||||
double angularDeflection,
|
||||
bool normalsFromUV);
|
||||
bool normalsFromUV = false);
|
||||
|
||||
static void setupCoinGeometry(TopoDS_Shape shape,
|
||||
SoFCShape* node,
|
||||
double deviation,
|
||||
double angularDeflection,
|
||||
bool normalsFromUV = false);
|
||||
|
||||
protected:
|
||||
bool setEdit(int ModNum) override;
|
||||
|
||||
@@ -45,11 +45,6 @@ SO_NODE_SOURCE(SoPreviewShape);
|
||||
const SbColor SoPreviewShape::defaultColor = SbColor(1.F, 0.F, 1.F);
|
||||
|
||||
SoPreviewShape::SoPreviewShape()
|
||||
: coords(new SoCoordinate3)
|
||||
, norm(new SoNormal)
|
||||
, faceset(new PartGui::SoBrepFaceSet)
|
||||
, lineset(new PartGui::SoBrepEdgeSet)
|
||||
, nodeset(new PartGui::SoBrepPointSet)
|
||||
{
|
||||
SO_NODE_CONSTRUCTOR(SoPreviewShape);
|
||||
|
||||
@@ -216,14 +211,9 @@ void ViewProviderPreviewExtension::updatePreviewShape(Part::TopoShape shape,
|
||||
|
||||
const auto updatePreviewShape = [vp](SoPreviewShape* preview, Part::TopoShape shape) {
|
||||
ViewProviderPartExt::setupCoinGeometry(shape.getShape(),
|
||||
preview->coords,
|
||||
preview->faceset,
|
||||
preview->norm,
|
||||
preview->lineset,
|
||||
preview->nodeset,
|
||||
preview,
|
||||
vp->Deviation.getValue(),
|
||||
vp->AngularDeflection.getValue(),
|
||||
false);
|
||||
vp->AngularDeflection.getValue());
|
||||
};
|
||||
|
||||
try {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "SoBrepEdgeSet.h"
|
||||
#include "SoBrepFaceSet.h"
|
||||
#include "SoBrepPointSet.h"
|
||||
#include "SoFCShapeObject.h"
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
@@ -47,8 +48,8 @@
|
||||
|
||||
namespace PartGui {
|
||||
|
||||
class PartGuiExport SoPreviewShape : public SoSeparator {
|
||||
using inherited = SoSeparator;
|
||||
class PartGuiExport SoPreviewShape : public SoFCShape {
|
||||
using inherited = SoFCShape;
|
||||
SO_NODE_HEADER(SoPreviewShape);
|
||||
|
||||
public:
|
||||
@@ -62,13 +63,6 @@ public:
|
||||
SoSFColor color;
|
||||
SoSFFloat transparency;
|
||||
SoSFFloat lineWidth;
|
||||
|
||||
SoCoordinate3* coords;
|
||||
SoNormal* norm;
|
||||
|
||||
SoBrepFaceSet* faceset;
|
||||
SoBrepEdgeSet* lineset;
|
||||
SoBrepPointSet* nodeset;
|
||||
};
|
||||
|
||||
class PartGuiExport ViewProviderPreviewExtension : public Gui::ViewProviderExtension {
|
||||
|
||||
@@ -134,6 +134,7 @@ PyMOD_INIT_FUNC(SketcherGui)
|
||||
SketcherGui::ViewProviderCustom ::init();
|
||||
SketcherGui::ViewProviderCustomPython ::init();
|
||||
SketcherGui::SoZoomTranslation ::initClass();
|
||||
SketcherGui::SoSketchFaces ::initClass();
|
||||
SketcherGui::PropertyConstraintListItem ::init();
|
||||
SketcherGui::ViewProviderSketchGeometryExtension ::init();
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ void SketcherSettings::saveSettings()
|
||||
ui->checkBoxHorVerAuto->onSave();
|
||||
ui->checkBoxLineGroup->onSave();
|
||||
ui->checkBoxAddExtGeo->onSave();
|
||||
ui->checkBoxMakeInternals->onSave();
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -190,8 +191,7 @@ void SketcherSettings::loadSettings()
|
||||
ui->checkBoxHorVerAuto->onRestore();
|
||||
setProperty("checkBoxHorVerAuto", ui->checkBoxHorVerAuto->isChecked());
|
||||
ui->checkBoxAddExtGeo->onRestore();
|
||||
setProperty("checkBoxLineGroup", ui->checkBoxLineGroup->isChecked());
|
||||
ui->checkBoxAddExtGeo->onRestore();
|
||||
ui->checkBoxMakeInternals->onRestore();
|
||||
|
||||
// Dimensioning constraints mode
|
||||
ui->dimensioningMode->clear();
|
||||
@@ -597,6 +597,8 @@ void SketcherSettingsAppearance::saveSettings()
|
||||
ui->ExternalWidth->onSave();
|
||||
ui->ExternalDefiningWidth->onSave();
|
||||
|
||||
ui->InternalFaceColor->onSave();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/View");
|
||||
QVariant data = ui->EdgePattern->itemData(ui->EdgePattern->currentIndex());
|
||||
@@ -652,6 +654,9 @@ void SketcherSettingsAppearance::loadSettings()
|
||||
ui->ExternalWidth->onRestore();
|
||||
ui->ExternalDefiningWidth->onRestore();
|
||||
|
||||
ui->InternalFaceColor->setAllowTransparency(true);
|
||||
ui->InternalFaceColor->onRestore();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/View");
|
||||
int pattern = hGrp->GetInt("EdgePattern", 0b1111111111111111);
|
||||
|
||||
@@ -234,6 +234,22 @@ Requires to re-enter edit mode to take effect.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="checkBoxMakeInternals">
|
||||
<property name="toolTip">
|
||||
<string>Closed loops will automatically generate internal faces which are selectable to be used with other tools</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate internal faces</string>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher</cstring>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>MakeInternals</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -872,83 +872,112 @@
|
||||
<property name="title">
|
||||
<string>Colors Outside Sketcher</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Vertex</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="SketchVertexColor">
|
||||
<property name="toolTip">
|
||||
<string>Color of vertices outside edit mode</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SketchVertexColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="SketchEdgeColor">
|
||||
<property name="toolTip">
|
||||
<string>Color of edges outside edit mode</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SketchEdgeColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Vertex</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="SketchVertexColor">
|
||||
<property name="toolTip">
|
||||
<string>Color of vertices outside edit mode</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SketchVertexColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="SketchEdgeColor">
|
||||
<property name="toolTip">
|
||||
<string>Color of edges outside edit mode</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SketchEdgeColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Face</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="InternalFaceColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Color of internal faces formed by intersecting geometry or closed loops in the sketch</string>
|
||||
</property>
|
||||
<property name="color" stdset="0">
|
||||
<color alpha="62">
|
||||
<red>84</red>
|
||||
<green>171</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SketchFaceColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/Sketcher/General</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <Gui/Selection/Selection.h>
|
||||
#include <Gui/Selection/SelectionObject.h>
|
||||
#include <Gui/Selection/SoFCUnifiedSelection.h>
|
||||
// #include <Gui/Inventor/SoFCSwitch.h>
|
||||
#include <Gui/Utilities.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
@@ -74,6 +75,8 @@
|
||||
#include "ViewProviderSketchGeometryExtension.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
#include <Mod/Part/Gui/SoFCShapeObject.h>
|
||||
|
||||
|
||||
// clang-format off
|
||||
FC_LOG_LEVEL_INIT("Sketch", true, true)
|
||||
@@ -150,6 +153,20 @@ void ViewProviderSketch::ParameterObserver::updateColorProperty(const std::strin
|
||||
colorprop->setValue(elementAppColor);
|
||||
}
|
||||
|
||||
void ViewProviderSketch::ParameterObserver::updateShapeAppearanceProperty(const std::string& string, App::Property* property)
|
||||
{
|
||||
auto matProp = static_cast<App::PropertyMaterialList*>(property);
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher/General");
|
||||
unsigned long shcol = hGrp->GetUnsigned(string.c_str(), 0x54abff40);
|
||||
float r = ((shcol >> 24) & 0xff) / 255.0;
|
||||
float g = ((shcol >> 16) & 0xff) / 255.0;
|
||||
float b = ((shcol >> 8) & 0xff) / 255.0;
|
||||
float a = (shcol & 0xff) / 255.0;
|
||||
matProp->setDiffuseColor(r, g, b);
|
||||
matProp->setTransparency(1 - a);
|
||||
}
|
||||
|
||||
void ViewProviderSketch::ParameterObserver::updateGridSize(const std::string& string,
|
||||
App::Property* property)
|
||||
{
|
||||
@@ -380,6 +397,13 @@ void ViewProviderSketch::ParameterObserver::initParameters()
|
||||
}
|
||||
},
|
||||
&Client.PointColor}},
|
||||
{"SketchFaceColor",
|
||||
{[this](const std::string& string, App::Property* property) {
|
||||
if (Client.AutoColor.getValue()) {
|
||||
updateShapeAppearanceProperty(string, property);
|
||||
}
|
||||
},
|
||||
&Client.ShapeAppearance}},
|
||||
};
|
||||
|
||||
for (auto& val : parameterMap) {
|
||||
@@ -463,7 +487,30 @@ QString ViewProviderSketch::ToolManager::getToolWidgetText() const
|
||||
}
|
||||
}
|
||||
|
||||
/*************************** SoSketchFaces **************************/
|
||||
|
||||
SO_NODE_SOURCE(SoSketchFaces);
|
||||
|
||||
SoSketchFaces::SoSketchFaces(){
|
||||
SO_NODE_CONSTRUCTOR(SoSketchFaces);
|
||||
|
||||
SO_NODE_ADD_FIELD(color, (SbColor(1.0f, 1.0f, 1.0f)));
|
||||
SO_NODE_ADD_FIELD(transparency, (0.8));
|
||||
//
|
||||
auto* material = new SoMaterial;
|
||||
material->diffuseColor.connectFrom(&color);
|
||||
material->transparency.connectFrom(&transparency);
|
||||
|
||||
SoSeparator::addChild(material);
|
||||
SoSeparator::addChild(coords);
|
||||
SoSeparator::addChild(norm);
|
||||
SoSeparator::addChild(faceset);
|
||||
}
|
||||
|
||||
void SoSketchFaces::initClass()
|
||||
{
|
||||
SO_NODE_INIT_CLASS(SoSketchFaces, SoFCShape, "FCShape");
|
||||
}
|
||||
|
||||
/*************************** ViewProviderSketch **************************/
|
||||
|
||||
@@ -477,7 +524,6 @@ SbVec2s ViewProviderSketch::DoubleClick::newCursorPos;
|
||||
// Construction/Destruction
|
||||
|
||||
/* TRANSLATOR SketcherGui::ViewProviderSketch */
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(SketcherGui::ViewProviderSketch, PartGui::ViewProvider2DObject)
|
||||
|
||||
|
||||
@@ -485,6 +531,8 @@ ViewProviderSketch::ViewProviderSketch()
|
||||
: SelectionObserver(false)
|
||||
, toolManager(this)
|
||||
, Mode(STATUS_NONE)
|
||||
, pcSketchFaces(new SoSketchFaces)
|
||||
, pcSketchFacesToggle(new SoToggleSwitch)
|
||||
, listener(nullptr)
|
||||
, editCoinManager(nullptr)
|
||||
, snapManager(nullptr)
|
||||
@@ -588,6 +636,10 @@ ViewProviderSketch::ViewProviderSketch()
|
||||
rubberband = std::make_unique<Gui::Rubberband>();
|
||||
|
||||
cameraSensor.setFunction(&ViewProviderSketch::camSensCB);
|
||||
|
||||
updateColorPropertiesVisibility();
|
||||
|
||||
pcSketchFacesToggle->addChild(pcSketchFaces);
|
||||
}
|
||||
|
||||
ViewProviderSketch::~ViewProviderSketch()
|
||||
@@ -2895,10 +2947,22 @@ void ViewProviderSketch::drawEditMarkers(const std::vector<Base::Vector2d>& Edit
|
||||
}
|
||||
|
||||
void ViewProviderSketch::updateData(const App::Property* prop) {
|
||||
ViewProvider2DObject::updateData(prop);
|
||||
if (std::string(prop->getName()) != "ShapeMaterial") {
|
||||
// We don't want material to override the colors of sketches.
|
||||
ViewProvider2DObject::updateData(prop);
|
||||
}
|
||||
|
||||
if (prop != &getSketchObject()->Constraints)
|
||||
if (prop == &getSketchObject()->InternalShape) {
|
||||
const auto& shape = getSketchObject()->InternalShape.getValue();
|
||||
setupCoinGeometry(shape,
|
||||
pcSketchFaces,
|
||||
Deviation.getValue(),
|
||||
AngularDeflection.getValue());
|
||||
}
|
||||
|
||||
if (prop != &getSketchObject()->Constraints) {
|
||||
signalElementsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderSketch::slotSolverUpdate()
|
||||
@@ -2931,6 +2995,8 @@ void ViewProviderSketch::slotSolverUpdate()
|
||||
|
||||
void ViewProviderSketch::onChanged(const App::Property* prop)
|
||||
{
|
||||
ViewProvider2DObject::onChanged(prop);
|
||||
|
||||
if (prop == &VisualLayerList) {
|
||||
if (isInEditMode()) {
|
||||
// Configure and rebuild Coin SceneGraph
|
||||
@@ -2940,23 +3006,38 @@ void ViewProviderSketch::onChanged(const App::Property* prop)
|
||||
}
|
||||
|
||||
if (prop == &AutoColor) {
|
||||
auto usesAutomaticColors = AutoColor.getValue();
|
||||
|
||||
// when auto color is enabled don't save color information in the document
|
||||
// so it does not cause unnecessary updates if multiple users use different colors
|
||||
LineColor.setStatus(App::Property::Transient, usesAutomaticColors);
|
||||
PointColor.setStatus(App::Property::Transient, usesAutomaticColors);
|
||||
|
||||
// and mark this property as read-only hidden so it's not possible to change manually
|
||||
LineColor.setStatus(App::Property::ReadOnly, usesAutomaticColors);
|
||||
LineColor.setStatus(App::Property::Hidden, usesAutomaticColors);
|
||||
PointColor.setStatus(App::Property::ReadOnly, usesAutomaticColors);
|
||||
PointColor.setStatus(App::Property::Hidden, usesAutomaticColors);
|
||||
|
||||
updateColorPropertiesVisibility();
|
||||
return;
|
||||
}
|
||||
|
||||
ViewProvider2DObject::onChanged(prop);
|
||||
if (prop == &Visibility) {
|
||||
pcSketchFacesToggle->on = Visibility.getValue();
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop == &ShapeAppearance) {
|
||||
pcSketchFaces->color.setValue(Base::convertTo<SbColor>(ShapeAppearance.getDiffuseColor()));
|
||||
pcSketchFaces->transparency.setValue(ShapeAppearance.getTransparency());
|
||||
}
|
||||
}
|
||||
|
||||
void SketcherGui::ViewProviderSketch::updateColorPropertiesVisibility()
|
||||
{
|
||||
auto usesAutomaticColors = AutoColor.getValue();
|
||||
|
||||
// when auto color is enabled don't save color information in the document
|
||||
// so it does not cause unnecessary updates if multiple users use different colors
|
||||
LineColor.setStatus(App::Property::Transient, usesAutomaticColors);
|
||||
PointColor.setStatus(App::Property::Transient, usesAutomaticColors);
|
||||
ShapeAppearance.setStatus(App::Property::Transient, usesAutomaticColors);
|
||||
|
||||
// and mark this property as read-only hidden so it's not possible to change manually
|
||||
LineColor.setStatus(App::Property::ReadOnly, usesAutomaticColors);
|
||||
LineColor.setStatus(App::Property::Hidden, usesAutomaticColors);
|
||||
PointColor.setStatus(App::Property::ReadOnly, usesAutomaticColors);
|
||||
PointColor.setStatus(App::Property::Hidden, usesAutomaticColors);
|
||||
ShapeAppearance.setStatus(App::Property::ReadOnly, usesAutomaticColors);
|
||||
ShapeAppearance.setStatus(App::Property::Hidden, usesAutomaticColors);
|
||||
}
|
||||
|
||||
void SketcherGui::ViewProviderSketch::startRestoring()
|
||||
@@ -2987,12 +3068,74 @@ void SketcherGui::ViewProviderSketch::finishRestoring()
|
||||
// update colors according to current user preferences
|
||||
pObserver->updateFromParameter("SketchEdgeColor");
|
||||
pObserver->updateFromParameter("SketchVertexColor");
|
||||
pObserver->updateFromParameter("SketchFaceColor");
|
||||
|
||||
updateColorPropertiesVisibility();
|
||||
}
|
||||
|
||||
if (getSketchObject()->MakeInternals.getValue()) {
|
||||
updateVisual();
|
||||
}
|
||||
}
|
||||
|
||||
// clang-format on
|
||||
bool ViewProviderSketch::getElementPicked(const SoPickedPoint* pp, std::string& subname) const
|
||||
{
|
||||
if (pp->getPath()->containsNode(pcSketchFaces) && !isInEditMode()) {
|
||||
if (ViewProvider2DObject::getElementPicked(pp, subname)) {
|
||||
subname = SketchObject::internalPrefix() + subname;
|
||||
auto& elementMap = getSketchObject()->getInternalElementMap();
|
||||
|
||||
if (auto it = elementMap.find(subname); it != elementMap.end()) {
|
||||
subname = it->second;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return ViewProvider2DObject::getElementPicked(pp, subname);
|
||||
}
|
||||
|
||||
bool ViewProviderSketch::getDetailPath(const char* subname,
|
||||
SoFullPath* pPath,
|
||||
bool append,
|
||||
SoDetail*& det) const
|
||||
{
|
||||
const auto getLastPartOfName = [](const char* subname) -> const char* {
|
||||
const char* realName = strrchr(subname, '.');
|
||||
|
||||
return realName ? realName + 1 : subname;
|
||||
};
|
||||
|
||||
if (!isInEditMode() && subname) {
|
||||
const char* realName = getLastPartOfName(subname);
|
||||
|
||||
realName = SketchObject::convertInternalName(realName);
|
||||
if (realName) {
|
||||
auto len = pPath->getLength();
|
||||
if (append) {
|
||||
pPath->append(pcRoot);
|
||||
pPath->append(pcModeSwitch);
|
||||
}
|
||||
|
||||
if (!ViewProvider2DObject::getDetailPath(realName, pPath, false, det)) {
|
||||
pPath->truncate(len);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return ViewProvider2DObject::getDetailPath(subname, pPath, append, det);
|
||||
}
|
||||
// clang-format off
|
||||
|
||||
void ViewProviderSketch::attach(App::DocumentObject* pcFeat)
|
||||
{
|
||||
ViewProvider2DObject::attach(pcFeat);
|
||||
|
||||
getAnnotation()->addChild(pcSketchFacesToggle);
|
||||
}
|
||||
|
||||
void ViewProviderSketch::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
#include "ShortcutListener.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#include <Gui/Inventor/SoToggleSwitch.h>
|
||||
#include <Mod/Part/Gui/ViewProviderPreviewExtension.h>
|
||||
|
||||
|
||||
class TopoDS_Shape;
|
||||
class TopoDS_Face;
|
||||
@@ -97,6 +100,20 @@ class DrawSketchHandler;
|
||||
using GeoList = Sketcher::GeoList;
|
||||
using GeoListFacade = Sketcher::GeoListFacade;
|
||||
|
||||
class SketcherGuiExport SoSketchFaces: public PartGui::SoFCShape
|
||||
{
|
||||
using inherited = SoFCShape;
|
||||
SO_NODE_HEADER(SoSketchFaces);
|
||||
|
||||
public:
|
||||
SoSketchFaces();
|
||||
|
||||
static void initClass();
|
||||
|
||||
SoSFColor color;
|
||||
SoSFFloat transparency;
|
||||
};
|
||||
|
||||
/** @brief The Sketch ViewProvider
|
||||
*
|
||||
* @details
|
||||
@@ -191,6 +208,8 @@ private:
|
||||
float g,
|
||||
float b);
|
||||
|
||||
void updateShapeAppearanceProperty(const std::string& string, App::Property* property);
|
||||
|
||||
void updateEscapeKeyBehaviour(const std::string& string, App::Property* property);
|
||||
|
||||
void updateAutoRecompute(const std::string& string, App::Property* property);
|
||||
@@ -747,6 +766,12 @@ protected:
|
||||
void startRestoring() override;
|
||||
void finishRestoring() override;
|
||||
|
||||
bool getElementPicked(const SoPickedPoint* pp, std::string& subname) const override;
|
||||
bool getDetailPath(const char* subname,
|
||||
SoFullPath* pPath,
|
||||
bool append,
|
||||
SoDetail*& det) const override;
|
||||
|
||||
private:
|
||||
/// function to handle OCCT BSpline weight calculation singularities and representation
|
||||
void scaleBSplinePoleCirclesAndUpdateSolverAndSketchObjectGeometry(
|
||||
@@ -828,6 +853,8 @@ private:
|
||||
|
||||
void slotToolWidgetChanged(QWidget* newwidget);
|
||||
|
||||
void updateColorPropertiesVisibility();
|
||||
|
||||
/** @name Attorney functions*/
|
||||
//@{
|
||||
/* private functions to decouple Attorneys and Clients from the internal implementation of
|
||||
@@ -944,6 +971,9 @@ private:
|
||||
std::string editObjName;
|
||||
std::string editSubName;
|
||||
|
||||
Gui::CoinPtr<SoSketchFaces> pcSketchFaces;
|
||||
Gui::CoinPtr<SoToggleSwitch> pcSketchFacesToggle;
|
||||
|
||||
ShortcutListener* listener;
|
||||
|
||||
std::unique_ptr<EditModeCoinManager> editCoinManager;
|
||||
|
||||
Reference in New Issue
Block a user