Fix several regressions:
+ improve PropertyMaterialList::readString + fix transparency handling in ViewProviderPartExt + do not register the private member '_diffuseColor' as property because it would be exposed to the public where it can be modified + fix ViewProviderPartExt::finishRestoring() to correctly restore old project files + fix ViewProviderPartExt::setHighlightedFaces() to correctly show face colours if VBO is enabled + fix ViewProviderBoolean::updateData() fix ViewProviderMultiFuse::updateData() fix ViewProviderMultiCommon::updateData() fix ViewProviderCompound::updateData() fix ViewProviderFillet::updateData() fix ViewProviderChamfer::updateData() that all set invalid transparency values + Filter ShapeAppearance in ViewProviderBody::unifyVisualProperty because body features usually have different number of faces than the body itself + manually fix some bad looking auto-formatted code + clean up code and remove duplicated code
This commit is contained in:
@@ -3203,8 +3203,8 @@ void PropertyMaterialList::RestoreDocFileV3(Base::Reader& reader)
|
||||
uint32_t count = 0;
|
||||
str >> count;
|
||||
std::vector<Material> values(count);
|
||||
uint32_t value; // must be 32 bit long
|
||||
float valueF;
|
||||
uint32_t value {}; // must be 32 bit long
|
||||
float valueF {};
|
||||
for (auto& it : values) {
|
||||
str >> value;
|
||||
it.ambientColor.setPackedValue(value);
|
||||
@@ -3227,18 +3227,15 @@ void PropertyMaterialList::RestoreDocFileV3(Base::Reader& reader)
|
||||
setValues(values);
|
||||
}
|
||||
|
||||
void PropertyMaterialList::readString(Base::InputStream& str,
|
||||
std::string& value)
|
||||
void PropertyMaterialList::readString(Base::InputStream& str, std::string& value)
|
||||
{
|
||||
uint32_t uCt;
|
||||
uint32_t uCt {};
|
||||
str >> uCt;
|
||||
|
||||
char *temp = new char[uCt];
|
||||
std::vector<char> temp(uCt);
|
||||
|
||||
str.read(temp, uCt);
|
||||
value.assign(temp, static_cast<std::size_t>(uCt));
|
||||
|
||||
delete [] temp;
|
||||
str.read(temp.data(), uCt);
|
||||
value.assign(temp.data(), temp.size());
|
||||
}
|
||||
|
||||
const char* PropertyMaterialList::getEditorName() const
|
||||
|
||||
@@ -22,10 +22,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "DlgMaterialPropertiesImp.h"
|
||||
#include "ui_DlgMaterialProperties.h"
|
||||
#include "ViewProvider.h"
|
||||
|
||||
@@ -95,7 +95,6 @@ public:
|
||||
|
||||
/// Get the python wrapper for that ViewProvider
|
||||
PyObject* getPyObject() override;
|
||||
static App::Material getUserDefinedMaterial();
|
||||
|
||||
protected:
|
||||
/// get called by the container whenever a property has been changed
|
||||
|
||||
@@ -109,7 +109,6 @@ private:
|
||||
PyObject* initModule()
|
||||
{
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
;
|
||||
}
|
||||
|
||||
} // namespace PartGui
|
||||
@@ -140,15 +139,17 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/parametric"));
|
||||
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/tools"));
|
||||
|
||||
static struct PyModuleDef pAttachEngineTextsModuleDef = {PyModuleDef_HEAD_INIT,
|
||||
"AttachEngineResources",
|
||||
"AttachEngineResources",
|
||||
-1,
|
||||
AttacherGui::AttacherGuiPy::Methods,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr};
|
||||
// clang-format off
|
||||
static struct PyModuleDef pAttachEngineTextsModuleDef = {
|
||||
PyModuleDef_HEAD_INIT,
|
||||
"AttachEngineResources",
|
||||
"AttachEngineResources",
|
||||
-1,
|
||||
AttacherGui::AttacherGuiPy::Methods,
|
||||
nullptr, nullptr, nullptr, nullptr
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
PyObject* pAttachEngineTextsModule = PyModule_Create(&pAttachEngineTextsModuleDef);
|
||||
|
||||
Py_INCREF(pAttachEngineTextsModule);
|
||||
@@ -218,7 +219,6 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
PartGui::Workbench ::init();
|
||||
auto manip = std::make_shared<PartGui::WorkbenchManipulator>();
|
||||
Gui::WorkbenchManipulator::installManipulator(manip);
|
||||
// clang-format on
|
||||
|
||||
// instantiating the commands
|
||||
CreatePartCommands();
|
||||
@@ -226,8 +226,8 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
CreateParamPartCommands();
|
||||
CreatePartSelectCommands();
|
||||
try {
|
||||
Py::Object ae =
|
||||
Base::Interpreter().runStringObject("__import__('AttachmentEditor.Commands').Commands");
|
||||
const char* cmd = "__import__('AttachmentEditor.Commands').Commands";
|
||||
Py::Object ae = Base::Interpreter().runStringObject(cmd);
|
||||
Py::Module(partGuiModule).setAttr(std::string("AttachmentEditor"), ae);
|
||||
}
|
||||
catch (Base::PyException& err) {
|
||||
@@ -235,29 +235,18 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
}
|
||||
|
||||
// register preferences pages
|
||||
Gui::Dialog::DlgPreferencesImp::setGroupData("Part/Part Design",
|
||||
"Part design",
|
||||
QObject::tr("Part and Part Design workbench"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgSettingsGeneral>(
|
||||
QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgSettings3DViewPart>(
|
||||
QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgSettingsObjectColor>(
|
||||
QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgImportExportIges>(
|
||||
QT_TRANSLATE_NOOP("QObject", "Import-Export"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgImportExportStep>(
|
||||
QT_TRANSLATE_NOOP("QObject", "Import-Export"));
|
||||
Gui::Dialog::DlgPreferencesImp::setGroupData("Part/Part Design", "Part design", QObject::tr("Part and Part Design workbench"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgSettingsGeneral>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgSettings3DViewPart>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgSettingsObjectColor>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgImportExportIges>(QT_TRANSLATE_NOOP("QObject", "Import-Export"));
|
||||
(void)new Gui::PrefPageProducer<PartGui::DlgImportExportStep>(QT_TRANSLATE_NOOP("QObject", "Import-Export"));
|
||||
Gui::ViewProviderBuilder::add(Part::PropertyPartShape::getClassTypeId(),
|
||||
PartGui::ViewProviderPart::getClassTypeId());
|
||||
// clang-format on
|
||||
|
||||
// add resources and reloads the translators
|
||||
loadPartResource();
|
||||
|
||||
// register bitmaps
|
||||
// Gui::BitmapFactoryInst& rclBmpFactory = Gui::BitmapFactory();
|
||||
// rclBmpFactory.addXPM("Part_Feature",(const char**) PartFeature_xpm);
|
||||
// rclBmpFactory.addXPM("Part_FeatureImport",(const char**) PartFeatureImport_xpm);
|
||||
|
||||
PyMOD_Return(partGuiModule);
|
||||
}
|
||||
|
||||
@@ -720,38 +720,34 @@ void PartGui::DlgProjectionOnSurface::higlight_object(Part::Feature* iCurrentObj
|
||||
auto vp = dynamic_cast<PartGui::ViewProviderPartExt*>(
|
||||
Gui::Application::Instance->getViewProvider(iCurrentObject));
|
||||
if (vp) {
|
||||
App::Color aColor;
|
||||
aColor.setPackedValue(iColor);
|
||||
std::vector<App::Color> colors;
|
||||
App::Color defaultColor;
|
||||
if (currentShapeType == TopAbs_FACE) {
|
||||
std::vector<App::Material> colors = vp->ShapeAppearance.getValues();
|
||||
App::Color defaultColor = vp->ShapeAppearance.getDiffuseColor();
|
||||
|
||||
if (static_cast<Standard_Integer>(colors.size()) != anIndices.Extent()) {
|
||||
colors.resize(anIndices.Extent(), vp->ShapeAppearance[0]);
|
||||
}
|
||||
|
||||
if (iHighlight) {
|
||||
colors.at(index - 1).diffuseColor = aColor;
|
||||
}
|
||||
else {
|
||||
colors.at(index - 1).diffuseColor = defaultColor;
|
||||
}
|
||||
vp->ShapeAppearance.setValues(colors);
|
||||
colors = vp->ShapeAppearance.getDiffuseColors();
|
||||
defaultColor = colors.front();
|
||||
}
|
||||
else if (currentShapeType == TopAbs_EDGE) {
|
||||
std::vector<App::Color> colors = vp->LineColorArray.getValues();
|
||||
App::Color defaultColor = vp->LineColor.getValue();
|
||||
colors = vp->LineColorArray.getValues();
|
||||
defaultColor = vp->LineColor.getValue();
|
||||
}
|
||||
|
||||
if (static_cast<Standard_Integer>(colors.size()) != anIndices.Extent()) {
|
||||
colors.resize(anIndices.Extent(), defaultColor);
|
||||
}
|
||||
if (static_cast<Standard_Integer>(colors.size()) != anIndices.Extent()) {
|
||||
colors.resize(anIndices.Extent(), defaultColor);
|
||||
}
|
||||
|
||||
if (iHighlight) {
|
||||
colors.at(index - 1) = aColor;
|
||||
}
|
||||
else {
|
||||
colors.at(index - 1) = defaultColor;
|
||||
}
|
||||
if (iHighlight) {
|
||||
App::Color aColor;
|
||||
aColor.setPackedValue(iColor);
|
||||
colors.at(index - 1) = aColor;
|
||||
}
|
||||
else {
|
||||
colors.at(index - 1) = defaultColor;
|
||||
}
|
||||
if (currentShapeType == TopAbs_FACE) {
|
||||
vp->ShapeAppearance.setDiffuseColors(colors);
|
||||
}
|
||||
else if (currentShapeType == TopAbs_EDGE) {
|
||||
vp->LineColorArray.setValues(colors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ void ViewProviderPart::applyColor(const Part::ShapeHistory& hist,
|
||||
}
|
||||
|
||||
void ViewProviderPart::applyMaterial(const Part::ShapeHistory& hist,
|
||||
const App::PropertyMaterialList& colBase,
|
||||
std::vector<App::Material>& colBool)
|
||||
const std::vector<App::Material>& colBase,
|
||||
std::vector<App::Material>& colBool)
|
||||
{
|
||||
std::map<int, std::vector<int>>::const_iterator jt;
|
||||
// apply color from modified faces
|
||||
@@ -85,8 +85,7 @@ void ViewProviderPart::applyMaterial(const Part::ShapeHistory& hist,
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPart::applyTransparency(const float& transparency,
|
||||
std::vector<App::Color>& colors)
|
||||
void ViewProviderPart::applyTransparency(float transparency, std::vector<App::Color>& colors)
|
||||
{
|
||||
if (transparency != 0.0) {
|
||||
// transparency has been set object-wide
|
||||
@@ -99,7 +98,7 @@ void ViewProviderPart::applyTransparency(const float& transparency,
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderPart::applyTransparency(const float& transparency, std::vector<App::Material>& colors)
|
||||
void ViewProviderPart::applyTransparency(float transparency, std::vector<App::Material>& colors)
|
||||
{
|
||||
if (transparency != 0.0) {
|
||||
// transparency has been set object-wide
|
||||
|
||||
@@ -58,12 +58,10 @@ protected:
|
||||
const std::vector<App::Color>& colBase,
|
||||
std::vector<App::Color>& colBool);
|
||||
void applyMaterial(const Part::ShapeHistory& hist,
|
||||
const App::PropertyMaterialList& colBase,
|
||||
const std::vector<App::Material>& colBase,
|
||||
std::vector<App::Material>& colBool);
|
||||
void applyTransparency(const float& transparency,
|
||||
std::vector<App::Color>& colors);
|
||||
void applyTransparency(const float& transparency,
|
||||
std::vector<App::Material>& colors);
|
||||
void applyTransparency(float transparency, std::vector<App::Color>& colors);
|
||||
void applyTransparency(float transparency, std::vector<App::Material>& colors);
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
||||
@@ -100,27 +100,27 @@ void ViewProviderBoolean::updateData(const App::Property* prop)
|
||||
auto vpTool = dynamic_cast<PartGui::ViewProviderPart*>(
|
||||
Gui::Application::Instance->getViewProvider(objTool));
|
||||
if (vpBase && vpTool) {
|
||||
std::vector<App::Material> colBase = vpBase->ShapeAppearance.getValues();
|
||||
std::vector<App::Material> colTool = vpTool->ShapeAppearance.getValues();
|
||||
std::vector<App::Material> colBool;
|
||||
colBool.resize(boolMap.Extent(), this->ShapeAppearance[0]);
|
||||
vpBase->ShapeAppearance.setTransparency(vpBase->Transparency.getValue());
|
||||
vpTool->ShapeAppearance.setTransparency(vpTool->Transparency.getValue());
|
||||
applyTransparency(vpBase->Transparency.getValue(),colBase);
|
||||
applyTransparency(vpTool->Transparency.getValue(),colTool);
|
||||
|
||||
if (static_cast<int>(vpBase->ShapeAppearance.getSize()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[0], vpBase->ShapeAppearance, colBool);
|
||||
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[0], colBase, colBool);
|
||||
}
|
||||
else if (vpBase->ShapeAppearance.getSize() > 0
|
||||
&& vpBase->ShapeAppearance[0] != this->ShapeAppearance[0]) {
|
||||
vpBase->ShapeAppearance.setSize(baseMap.Extent(), vpBase->ShapeAppearance[0]);
|
||||
applyMaterial(hist[0], vpBase->ShapeAppearance, colBool);
|
||||
else if (!colBase.empty() && colBase[0] != this->ShapeAppearance[0]) {
|
||||
colBase.resize(baseMap.Extent(), colBase[0]);
|
||||
applyMaterial(hist[0], colBase, colBool);
|
||||
}
|
||||
|
||||
if (static_cast<int>(vpTool->ShapeAppearance.getSize()) == toolMap.Extent()) {
|
||||
applyMaterial(hist[1], vpTool->ShapeAppearance, colBool);
|
||||
if (static_cast<int>(colTool.size()) == toolMap.Extent()) {
|
||||
applyMaterial(hist[1], colTool, colBool);
|
||||
}
|
||||
else if (vpTool->ShapeAppearance.getSize() > 0
|
||||
&& vpTool->ShapeAppearance[0] != this->ShapeAppearance[0]) {
|
||||
vpTool->ShapeAppearance.setSize(toolMap.Extent(), vpTool->ShapeAppearance[0]);
|
||||
applyMaterial(hist[1], vpTool->ShapeAppearance, colBool);
|
||||
else if (!colTool.empty() && colTool[0] != this->ShapeAppearance[0]) {
|
||||
colTool.resize(toolMap.Extent(), colTool[0]);
|
||||
applyMaterial(hist[1], colTool, colBool);
|
||||
}
|
||||
|
||||
// If the view provider has set a transparency then override the values
|
||||
@@ -201,14 +201,14 @@ void ViewProviderMultiFuse::updateData(const App::Property* prop)
|
||||
|
||||
auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
|
||||
if (vpBase) {
|
||||
vpBase->ShapeAppearance.setTransparency(vpBase->Transparency.getValue());
|
||||
if (static_cast<int>(vpBase->ShapeAppearance.getSize()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[index], vpBase->ShapeAppearance, colBool);
|
||||
std::vector<App::Material> colBase = vpBase->ShapeAppearance.getValues();
|
||||
applyTransparency(vpBase->Transparency.getValue(),colBase);
|
||||
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[index], colBase, colBool);
|
||||
}
|
||||
else if (vpBase->ShapeAppearance.getSize() > 0
|
||||
&& vpBase->ShapeAppearance[0] != this->ShapeAppearance[0]) {
|
||||
vpBase->ShapeAppearance.setSize(baseMap.Extent(), vpBase->ShapeAppearance[0]);
|
||||
applyMaterial(hist[index], vpBase->ShapeAppearance, colBool);
|
||||
else if (!colBase.empty() && colBase[0] != this->ShapeAppearance[0]) {
|
||||
colBase.resize(baseMap.Extent(), colBase[0]);
|
||||
applyMaterial(hist[index], colBase, colBool);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,14 +336,14 @@ void ViewProviderMultiCommon::updateData(const App::Property* prop)
|
||||
|
||||
auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
|
||||
if (vpBase) {
|
||||
vpBase->ShapeAppearance.setTransparency(vpBase->Transparency.getValue());
|
||||
if (static_cast<int>(vpBase->ShapeAppearance.getSize()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[index], vpBase->ShapeAppearance, colBool);
|
||||
std::vector<App::Material> colBase = vpBase->ShapeAppearance.getValues();
|
||||
applyTransparency(vpBase->Transparency.getValue(),colBase);
|
||||
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[index], colBase, colBool);
|
||||
}
|
||||
else if (vpBase->ShapeAppearance.getSize() > 0
|
||||
&& vpBase->ShapeAppearance[0] != this->ShapeAppearance[0]) {
|
||||
vpBase->ShapeAppearance.setSize(baseMap.Extent(), vpBase->ShapeAppearance[0]);
|
||||
applyMaterial(hist[index], vpBase->ShapeAppearance, colBool);
|
||||
else if (!colBase.empty() && colBase[0] != this->ShapeAppearance[0]) {
|
||||
colBase.resize(baseMap.Extent(), colBase[0]);
|
||||
applyMaterial(hist[index], colBase, colBool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,14 +111,14 @@ void ViewProviderCompound::updateData(const App::Property* prop)
|
||||
|
||||
auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
|
||||
if (vpBase) {
|
||||
vpBase->ShapeAppearance.setTransparency(vpBase->Transparency.getValue());
|
||||
if (static_cast<int>(vpBase->ShapeAppearance.getSize()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[index], vpBase->ShapeAppearance, compCol);
|
||||
std::vector<App::Material> baseCol = vpBase->ShapeAppearance.getValues();
|
||||
applyTransparency(vpBase->Transparency.getValue(), baseCol);
|
||||
if (static_cast<int>(baseCol.size()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[index], baseCol, compCol);
|
||||
}
|
||||
else if (vpBase->ShapeAppearance.getSize() > 0
|
||||
&& vpBase->ShapeAppearance[0] != this->ShapeAppearance[0]) {
|
||||
vpBase->ShapeAppearance.setSize(baseMap.Extent(), vpBase->ShapeAppearance[0]);
|
||||
applyMaterial(hist[index], vpBase->ShapeAppearance, compCol);
|
||||
else if (!baseCol.empty() && baseCol[0] != this->ShapeAppearance[0]) {
|
||||
baseCol.resize(baseMap.Extent(), baseCol[0]);
|
||||
applyMaterial(hist[index], baseCol, compCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
# include <Inventor/nodes/SoPolygonOffset.h>
|
||||
# include <Inventor/nodes/SoSeparator.h>
|
||||
# include <Inventor/nodes/SoShapeHints.h>
|
||||
# include <Inventor/nodes/SoTexture3.h>
|
||||
|
||||
# include <boost/algorithm/string/predicate.hpp>
|
||||
#endif
|
||||
@@ -199,16 +198,6 @@ ViewProviderPartExt::ViewProviderPartExt()
|
||||
ADD_PROPERTY_TYPE(DrawStyle,((long int)0), osgroup, App::Prop_None, "Defines the style of the edges in the 3D view.");
|
||||
DrawStyle.setEnums(DrawStyleEnums);
|
||||
|
||||
// This is needed to restore old DiffuseColor values since the restore
|
||||
// function is asynchronous
|
||||
App::PropertyColor noColor;
|
||||
ADD_PROPERTY_TYPE(_diffuseColor,
|
||||
(noColor.getValue()),
|
||||
osgroup,
|
||||
App::Prop_NoPersist,
|
||||
"Object diffuse color.");
|
||||
_diffuseColor.setStatus(App::Property::PropHidden, true);
|
||||
|
||||
coords = new SoCoordinate3();
|
||||
coords->ref();
|
||||
faceset = new SoBrepFaceSet();
|
||||
@@ -353,7 +342,7 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
else if (prop == &_diffuseColor) {
|
||||
// Used to load the old DiffuseColor values asynchronously
|
||||
ShapeAppearance.setDiffuseColors(_diffuseColor.getValues());
|
||||
ShapeAppearance.setTransparency(Transparency.getValue() / 100.0f);
|
||||
ShapeAppearance.setTransparency(Transparency.getValue() / 100.0F);
|
||||
}
|
||||
else if (prop == &ShapeAppearance) {
|
||||
setHighlightedFaces(ShapeAppearance);
|
||||
@@ -364,11 +353,7 @@ void ViewProviderPartExt::onChanged(const App::Property* prop)
|
||||
long value = toPercent(Mat.transparency);
|
||||
if (value != Transparency.getValue()) {
|
||||
float trans = fromPercent(Transparency.getValue());
|
||||
|
||||
App::PropertyContainer* parent = ShapeAppearance.getContainer();
|
||||
ShapeAppearance.setContainer(nullptr);
|
||||
ShapeAppearance.setTransparency(trans);
|
||||
ShapeAppearance.setContainer(parent);
|
||||
}
|
||||
}
|
||||
else if (prop == &Lighting) {
|
||||
@@ -615,6 +600,12 @@ std::vector<Base::Vector3d> ViewProviderPartExt::getSelectionShape(const char* /
|
||||
|
||||
void ViewProviderPartExt::setHighlightedFaces(const std::vector<App::Material>& materials)
|
||||
{
|
||||
if (getObject() && getObject()->testStatus(App::ObjectStatus::TouchOnColorChange))
|
||||
getObject()->touch(true);
|
||||
|
||||
Gui::SoUpdateVBOAction action;
|
||||
action.apply(this->faceset);
|
||||
|
||||
int size = static_cast<int>(materials.size());
|
||||
if (size > 1 && size == this->faceset->partIndex.getNum()) {
|
||||
pcFaceBind->value = SoMaterialBinding::PER_PART;
|
||||
@@ -654,49 +645,7 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector<App::Material>&
|
||||
|
||||
void ViewProviderPartExt::setHighlightedFaces(const App::PropertyMaterialList& appearance)
|
||||
{
|
||||
int size = static_cast<int>(appearance.getSize());
|
||||
if (size > 1 && size == this->faceset->partIndex.getNum()) {
|
||||
pcFaceBind->value = SoMaterialBinding::PER_PART;
|
||||
texture.activateMaterial();
|
||||
|
||||
pcShapeMaterial->diffuseColor.setNum(size);
|
||||
pcShapeMaterial->ambientColor.setNum(size);
|
||||
pcShapeMaterial->specularColor.setNum(size);
|
||||
pcShapeMaterial->emissiveColor.setNum(size);
|
||||
pcShapeMaterial->shininess.setNum(size);
|
||||
|
||||
SbColor* dc = pcShapeMaterial->diffuseColor.startEditing();
|
||||
SbColor* ac = pcShapeMaterial->ambientColor.startEditing();
|
||||
SbColor* sc = pcShapeMaterial->specularColor.startEditing();
|
||||
SbColor* ec = pcShapeMaterial->emissiveColor.startEditing();
|
||||
float* sh = pcShapeMaterial->shininess.startEditing();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
dc[i].setValue(appearance.getDiffuseColor(i).r,
|
||||
appearance.getDiffuseColor(i).g,
|
||||
appearance.getDiffuseColor(i).b);
|
||||
ac[i].setValue(appearance.getAmbientColor(i).r,
|
||||
appearance.getAmbientColor(i).g,
|
||||
appearance.getAmbientColor(i).b);
|
||||
sc[i].setValue(appearance.getSpecularColor(i).r,
|
||||
appearance.getSpecularColor(i).g,
|
||||
appearance.getSpecularColor(i).b);
|
||||
ec[i].setValue(appearance.getEmissiveColor(i).r,
|
||||
appearance.getEmissiveColor(i).g,
|
||||
appearance.getEmissiveColor(i).b);
|
||||
sh[i] = appearance.getShininess(i);
|
||||
}
|
||||
|
||||
pcShapeMaterial->diffuseColor.finishEditing();
|
||||
pcShapeMaterial->ambientColor.finishEditing();
|
||||
pcShapeMaterial->specularColor.finishEditing();
|
||||
pcShapeMaterial->emissiveColor.finishEditing();
|
||||
pcShapeMaterial->shininess.finishEditing();
|
||||
}
|
||||
else if (size == 1) {
|
||||
pcFaceBind->value = SoMaterialBinding::OVERALL;
|
||||
setCoinAppearance(appearance[0]);
|
||||
}
|
||||
setHighlightedFaces(appearance.getValues());
|
||||
}
|
||||
|
||||
std::map<std::string,App::Color> ViewProviderPartExt::getElementColors(const char *element) const {
|
||||
@@ -790,7 +739,6 @@ std::map<std::string,App::Color> ViewProviderPartExt::getElementColors(const cha
|
||||
|
||||
void ViewProviderPartExt::unsetHighlightedFaces()
|
||||
{
|
||||
// DiffuseColor.touch();
|
||||
ShapeAppearance.touch();
|
||||
Transparency.touch();
|
||||
}
|
||||
@@ -913,7 +861,9 @@ void ViewProviderPartExt::finishRestoring()
|
||||
// and currently sets a single color.
|
||||
// In case DiffuseColor has defined multiple colors they will
|
||||
// be passed to the scene graph now.
|
||||
ShapeAppearance.touch();
|
||||
if (_diffuseColor.getSize() > 1) {
|
||||
onChanged(&_diffuseColor);
|
||||
}
|
||||
Gui::ViewProviderGeometryObject::finishRestoring();
|
||||
}
|
||||
|
||||
@@ -1359,8 +1309,7 @@ void ViewProviderPartExt::updateVisual()
|
||||
VisualTouched = false;
|
||||
|
||||
// The material has to be checked again
|
||||
// setHighlightedFaces(DiffuseColor.getValues());
|
||||
setHighlightedFaces(ShapeAppearance);
|
||||
setHighlightedFaces(ShapeAppearance.getValues());
|
||||
setHighlightedEdges(LineColorArray.getValues());
|
||||
setHighlightedPoints(PointColorArray.getValue());
|
||||
}
|
||||
|
||||
@@ -263,18 +263,17 @@ void ViewProviderFillet::updateData(const App::Property* prop)
|
||||
|
||||
auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
|
||||
if (vpBase) {
|
||||
// std::vector<App::Color> colBase = vpBase->DiffuseColor.getValues();
|
||||
auto colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->ShapeAppearance.getValues();
|
||||
std::vector<App::Material> colFill;
|
||||
colFill.resize(fillMap.Extent(), vpBase->ShapeAppearance[0]);
|
||||
vpBase->ShapeAppearance.setTransparency(vpBase->Transparency.getValue());
|
||||
colFill.resize(fillMap.Extent(), colBase[0]);
|
||||
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(), colBase);
|
||||
|
||||
if (static_cast<int>(vpBase->ShapeAppearance.getSize()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[0], vpBase->ShapeAppearance, colFill);
|
||||
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[0], colBase, colFill);
|
||||
}
|
||||
else if (vpBase->ShapeAppearance.getSize() > 0
|
||||
&& vpBase->ShapeAppearance[0] != this->ShapeAppearance[0]) {
|
||||
vpBase->ShapeAppearance.setSize(baseMap.Extent(), vpBase->ShapeAppearance[0]);
|
||||
applyMaterial(hist[0], vpBase->ShapeAppearance, colFill);
|
||||
else if (!colBase.empty() && colBase[0] != this->ShapeAppearance[0]) {
|
||||
colBase.resize(baseMap.Extent(), colBase[0]);
|
||||
applyMaterial(hist[0], colBase, colFill);
|
||||
}
|
||||
|
||||
// If the view provider has set a transparency then override the values
|
||||
@@ -374,17 +373,16 @@ void ViewProviderChamfer::updateData(const App::Property* prop)
|
||||
|
||||
auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
|
||||
if (vpBase) {
|
||||
// std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
|
||||
auto& colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->ShapeAppearance;
|
||||
auto colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->ShapeAppearance.getValues();
|
||||
std::vector<App::Material> colCham;
|
||||
colCham.resize(chamMap.Extent(), colBase[0]);
|
||||
colBase.setTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue());
|
||||
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(), colBase);
|
||||
|
||||
if (static_cast<int>(colBase.getSize()) == baseMap.Extent()) {
|
||||
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
|
||||
applyMaterial(hist[0], colBase, colCham);
|
||||
}
|
||||
else if (colBase.getSize() > 0 && colBase[0] != this->ShapeAppearance[0]) {
|
||||
colBase.setSize(baseMap.Extent(), colBase[0]);
|
||||
else if (!colBase.empty() && colBase[0] != this->ShapeAppearance[0]) {
|
||||
colBase.resize(baseMap.Extent(), colBase[0]);
|
||||
applyMaterial(hist[0], colBase, colCham);
|
||||
}
|
||||
|
||||
|
||||
@@ -427,6 +427,7 @@ void ViewProviderBody::unifyVisualProperty(const App::Property* prop) {
|
||||
if (prop == &Visibility ||
|
||||
prop == &Selectable ||
|
||||
prop == &DisplayModeBody ||
|
||||
prop == &ShapeAppearance ||
|
||||
prop == &PointColorArray ||
|
||||
prop == &LineColorArray) {
|
||||
return;
|
||||
|
||||
@@ -172,8 +172,8 @@ void ViewProviderSections::highlightReferences(ShapeType type, const References&
|
||||
// check again that the index is in range because it's possible that
|
||||
// the sub-names are invalid
|
||||
if (idx < materials.size()) {
|
||||
materials[idx].diffuseColor =
|
||||
App::Color(1.0, 0.0, 1.0); // magenta
|
||||
// magenta
|
||||
materials[idx].diffuseColor = App::Color(1.0, 0.0, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user