Skip to content

Commit 5cca022

Browse files
committed
Fem: Remove unused view properties
1 parent 5e11e5d commit 5cca022

14 files changed

+48
-83
lines changed

src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp

+25-44
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@
2424
#include "PreCompiled.h"
2525

2626
#ifndef _PreComp_
27-
#include <Inventor/nodes/SoBaseColor.h>
2827
#include <Inventor/nodes/SoCone.h>
2928
#include <Inventor/nodes/SoCube.h>
3029
#include <Inventor/nodes/SoCylinder.h>
31-
#include <Inventor/nodes/SoFontStyle.h>
30+
#include <Inventor/nodes/SoMaterial.h>
3231
#include <Inventor/nodes/SoMultipleCopy.h>
32+
#include <Inventor/nodes/SoPickStyle.h>
3333
#include <Inventor/nodes/SoRotation.h>
3434
#include <Inventor/nodes/SoSeparator.h>
3535
#include <Inventor/nodes/SoShapeHints.h>
36-
#include <Inventor/nodes/SoText2.h>
3736
#include <Inventor/nodes/SoTranslation.h>
3837
#include <QAction>
3938
#include <QDockWidget>
@@ -67,40 +66,19 @@ ViewProviderFemConstraint::ViewProviderFemConstraint()
6766
, wizardSubLayout(nullptr)
6867
, constraintDialog(nullptr)
6968
{
70-
ADD_PROPERTY(TextColor, (0.0f, 0.0f, 0.0f));
71-
ADD_PROPERTY(FaceColor, (1.0f, 0.0f, 0.2f));
72-
ADD_PROPERTY(FontSize, (18));
73-
ADD_PROPERTY(DistFactor, (1.0));
74-
ADD_PROPERTY(Mirror, (false));
75-
76-
pFont = new SoFontStyle();
77-
pFont->ref();
78-
pLabel = new SoText2();
79-
pLabel->ref();
80-
pTextColor = new SoBaseColor();
81-
pTextColor->ref();
8269
pShapeSep = new SoSeparator();
8370
pShapeSep->ref();
8471
pMultCopy = new SoMultipleCopy();
8572
pMultCopy->ref();
8673

87-
pMaterials = new SoBaseColor();
88-
pMaterials->ref();
89-
pMaterials->rgb.setValue(1.0f, 0.0f, 0.2f);
90-
91-
TextColor.touch();
92-
FontSize.touch();
93-
FaceColor.touch();
74+
ShapeAppearance.setDiffuseColor(1.0f, 0.0f, 0.2f);
75+
ShapeAppearance.setSpecularColor(0.0f, 0.0f, 0.0f);
9476

9577
Gui::ViewProviderSuppressibleExtension::initExtension(this);
9678
}
9779

9880
ViewProviderFemConstraint::~ViewProviderFemConstraint()
9981
{
100-
pFont->unref();
101-
pLabel->unref();
102-
pTextColor->unref();
103-
pMaterials->unref();
10482
pMultCopy->unref();
10583
pShapeSep->unref();
10684
}
@@ -118,7 +96,7 @@ void ViewProviderFemConstraint::attach(App::DocumentObject* pcObject)
11896
hints->vertexOrdering.setValue(SoShapeHints::COUNTERCLOCKWISE);
11997
sep->addChild(ps);
12098
sep->addChild(hints);
121-
sep->addChild(pMaterials);
99+
sep->addChild(pcShapeMaterial);
122100
sep->addChild(pShapeSep);
123101
addDisplayMaskMode(sep, "Base");
124102
}
@@ -191,23 +169,7 @@ void ViewProviderFemConstraint::setupContextMenu(QMenu* menu, QObject* receiver,
191169

192170
void ViewProviderFemConstraint::onChanged(const App::Property* prop)
193171
{
194-
if (prop == &Mirror) {
195-
updateData(prop);
196-
}
197-
else if (prop == &TextColor) {
198-
const App::Color& c = TextColor.getValue();
199-
pTextColor->rgb.setValue(c.r, c.g, c.b);
200-
}
201-
else if (prop == &FaceColor) {
202-
const App::Color& c = FaceColor.getValue();
203-
pMaterials->rgb.setValue(c.r, c.g, c.b);
204-
}
205-
else if (prop == &FontSize) {
206-
pFont->size = FontSize.getValue();
207-
}
208-
else {
209-
ViewProviderDocumentObject::onChanged(prop); // clazy:exclude=skipped-base-method
210-
}
172+
ViewProviderGeometryObject::onChanged(prop);
211173
}
212174

213175
void ViewProviderFemConstraint::updateData(const App::Property* prop)
@@ -223,6 +185,25 @@ void ViewProviderFemConstraint::updateData(const App::Property* prop)
223185
}
224186
}
225187

188+
void ViewProviderFemConstraint::handleChangedPropertyName(Base::XMLReader& reader,
189+
const char* typeName,
190+
const char* propName)
191+
{
192+
if (strcmp(propName, "FaceColor") == 0
193+
&& Base::Type::fromName(typeName) == App::PropertyColor::getClassTypeId()) {
194+
App::PropertyColor color;
195+
color.Restore(reader);
196+
ShapeAppearance.setDiffuseColor(color.getValue());
197+
}
198+
else if (strcmp(propName, "ShapeMaterial") == 0
199+
&& Base::Type::fromName(typeName) == App::PropertyMaterial::getClassTypeId()) {
200+
// nothing
201+
}
202+
else {
203+
ViewProviderGeometryObject::handleChangedPropertyName(reader, typeName, propName);
204+
}
205+
}
206+
226207
void ViewProviderFemConstraint::updateSymbol()
227208
{
228209
auto obj = static_cast<const Fem::Constraint*>(this->getObject());

src/Mod/Fem/Gui/ViewProviderFemConstraint.h

+3-15
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535

3636

3737
class SbRotation;
38-
class SoFontStyle;
39-
class SoText2;
40-
class SoBaseColor;
41-
class SoMaterial;
4238
class SoMultipleCopy;
4339

4440
namespace FemGui
@@ -56,13 +52,6 @@ class FemGuiExport ViewProviderFemConstraint: public Gui::ViewProviderGeometryOb
5652
ViewProviderFemConstraint();
5753
~ViewProviderFemConstraint() override;
5854

59-
// Display properties
60-
App::PropertyColor TextColor;
61-
App::PropertyColor FaceColor;
62-
App::PropertyInteger FontSize;
63-
App::PropertyFloat DistFactor;
64-
App::PropertyBool Mirror;
65-
6655
void attach(App::DocumentObject*) override;
6756
void updateData(const App::Property* prop) override;
6857
std::vector<std::string> getDisplayModes() const override;
@@ -98,6 +87,9 @@ class FemGuiExport ViewProviderFemConstraint: public Gui::ViewProviderGeometryOb
9887
void onChanged(const App::Property* prop) override;
9988
bool setEdit(int ModNum) override;
10089
void unsetEdit(int ModNum) override;
90+
void handleChangedPropertyName(Base::XMLReader& reader,
91+
const char* typeName,
92+
const char* propName) override;
10193

10294
void updateSymbol();
10395
virtual void
@@ -165,10 +157,6 @@ class FemGuiExport ViewProviderFemConstraint: public Gui::ViewProviderGeometryOb
165157
const bool gap = false);
166158

167159
private:
168-
SoFontStyle* pFont;
169-
SoText2* pLabel;
170-
SoBaseColor* pTextColor;
171-
SoBaseColor* pMaterials;
172160
bool rotateSymbol;
173161

174162
protected:

src/Mod/Fem/Gui/ViewProviderFemConstraintContact.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ViewProviderFemConstraintContact::ViewProviderFemConstraintContact()
4444
loadSymbol((resourceSymbolDir + "ConstraintContact.iv").c_str());
4545
// Note change "Contact" in line above to new constraint name, make sure it is the same as in
4646
// taskFem* cpp file
47-
ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f));
47+
ShapeAppearance.setDiffuseColor(0.2f, 0.3f, 0.2f);
4848
}
4949

5050
ViewProviderFemConstraintContact::~ViewProviderFemConstraintContact() = default;

src/Mod/Fem/Gui/ViewProviderFemConstraintDisplacement.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ViewProviderFemConstraintDisplacement::ViewProviderFemConstraintDisplacement()
4545
{
4646
sPixmap = "FEM_ConstraintDisplacement";
4747
loadSymbol((resourceSymbolDir + "ConstraintDisplacement.iv").c_str());
48-
ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f));
48+
ShapeAppearance.setDiffuseColor(0.2f, 0.3f, 0.2f);
4949

5050
// do not rotate symbol according to boundary normal
5151
setRotateSymbol(false);

src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#include "PreCompiled.h"
2525

2626
#ifndef _PreComp_
27-
#include <Inventor/SbRotation.h>
28-
#include <Inventor/SbVec3f.h>
29-
#include <Inventor/nodes/SoMultipleCopy.h>
30-
#include <Inventor/nodes/SoSeparator.h>
3127
#include <QMessageBox>
3228
#endif
3329

src/Mod/Fem/Gui/ViewProviderFemConstraintFluidBoundary.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,19 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
134134
std::string boundaryType = pcConstraint->BoundaryType.getValueAsString();
135135
if (prop == &pcConstraint->BoundaryType) {
136136
if (boundaryType == "wall") {
137-
FaceColor.setValue(0.0, 1.0, 1.0);
137+
ShapeAppearance.setDiffuseColor(0.0, 1.0, 1.0);
138138
}
139139
else if (boundaryType == "interface") {
140-
FaceColor.setValue(0.0, 1.0, 0.0);
140+
ShapeAppearance.setDiffuseColor(0.0, 1.0, 0.0);
141141
}
142142
else if (boundaryType == "freestream") {
143-
FaceColor.setValue(1.0, 1.0, 0.0);
143+
ShapeAppearance.setDiffuseColor(1.0, 1.0, 0.0);
144144
}
145145
else if (boundaryType == "inlet") {
146-
FaceColor.setValue(1.0, 0.0, 0.0);
146+
ShapeAppearance.setDiffuseColor(1.0, 0.0, 0.0);
147147
}
148148
else { //(boundaryType == "outlet")
149-
FaceColor.setValue(0.0, 0.0, 1.0);
149+
ShapeAppearance.setDiffuseColor(0.0, 0.0, 1.0);
150150
}
151151
}
152152

src/Mod/Fem/Gui/ViewProviderFemConstraintHeatflux.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ ViewProviderFemConstraintHeatflux::ViewProviderFemConstraintHeatflux()
4444
{
4545
sPixmap = "FEM_ConstraintHeatflux";
4646
loadSymbol((resourceSymbolDir + "ConstraintHeatFlux.iv").c_str());
47-
48-
FaceColor.setValue(1.0f, 0.0f, 0.0f);
47+
ShapeAppearance.setDiffuseColor(1.0f, 0.0f, 0.0f);
4948
}
5049

5150
ViewProviderFemConstraintHeatflux::~ViewProviderFemConstraintHeatflux() = default;

src/Mod/Fem/Gui/ViewProviderFemConstraintInitialTemperature.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ PROPERTY_SOURCE(FemGui::ViewProviderFemConstraintInitialTemperature,
4040
ViewProviderFemConstraintInitialTemperature::ViewProviderFemConstraintInitialTemperature()
4141
{
4242
sPixmap = "FEM_ConstraintInitialTemperature";
43-
ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f));
43+
ShapeAppearance.setDiffuseColor(0.2f, 0.3f, 0.2f);
4444
}
4545

4646
ViewProviderFemConstraintInitialTemperature::~ViewProviderFemConstraintInitialTemperature() =

src/Mod/Fem/Gui/ViewProviderFemConstraintOnBoundary.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ void ViewProviderFemConstraintOnBoundary::highlightReferences(const bool on)
9999
std::vector<App::Color> colors = originalFaceColors[base];
100100

101101
// go through the subelements with constraint and recolor them
102-
// TODO: Replace `FaceColor` with anything more appropriate
103-
PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(),
104-
colors.empty() ? FaceColor.getValue()
105-
: colors[0]);
102+
// TODO: Replace shape DiffuseColor with anything more appropriate
103+
PartGui::ReferenceHighlighter highlighter(
104+
base->Shape.getValue(),
105+
colors.empty() ? ShapeAppearance.getDiffuseColor() : colors[0]);
106106
highlighter.getFaceColors(subSet.second, colors);
107107
vp->DiffuseColor.setValues(colors);
108108
}

src/Mod/Fem/Gui/ViewProviderFemConstraintPlaneRotation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ ViewProviderFemConstraintPlaneRotation::ViewProviderFemConstraintPlaneRotation()
4545
loadSymbol((resourceSymbolDir + "ConstraintPlaneRotation.iv").c_str());
4646
// Note change "planerotation" in line above to new constraint name, make sure it is the same as
4747
// in taskFem* cpp file
48-
ADD_PROPERTY(FaceColor, (0.2f, 0.3f, 0.2f));
48+
ShapeAppearance.setDiffuseColor(0.2f, 0.3f, 0.2f);
4949
}
5050

5151
ViewProviderFemConstraintPlaneRotation::~ViewProviderFemConstraintPlaneRotation() = default;

src/Mod/Fem/Gui/ViewProviderFemConstraintPressure.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ ViewProviderFemConstraintPressure::ViewProviderFemConstraintPressure()
4545
{
4646
sPixmap = "FEM_ConstraintPressure";
4747
loadSymbol((resourceSymbolDir + "ConstraintPressure.iv").c_str());
48-
49-
ADD_PROPERTY(FaceColor, (0.0f, 0.2f, 0.8f));
48+
ShapeAppearance.setDiffuseColor(0.0f, 0.2f, 0.8f);
5049
}
5150

5251
ViewProviderFemConstraintPressure::~ViewProviderFemConstraintPressure() = default;

src/Mod/Fem/Gui/ViewProviderFemConstraintSpring.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ViewProviderFemConstraintSpring::ViewProviderFemConstraintSpring()
4242
{
4343
sPixmap = "FEM_ConstraintSpring";
4444
loadSymbol((resourceSymbolDir + "ConstraintSpring.iv").c_str());
45-
ADD_PROPERTY(FaceColor, (0.0f, 0.2f, 0.8f));
45+
ShapeAppearance.setDiffuseColor(0.0f, 0.2f, 0.8f);
4646
}
4747

4848
ViewProviderFemConstraintSpring::~ViewProviderFemConstraintSpring() = default;

src/Mod/Fem/Gui/ViewProviderFemConstraintTemperature.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ ViewProviderFemConstraintTemperature::ViewProviderFemConstraintTemperature()
4343
{
4444
sPixmap = "FEM_ConstraintTemperature";
4545
loadSymbol((resourceSymbolDir + "ConstraintTemperature.iv").c_str());
46-
47-
FaceColor.setValue(1.0f, 0.0f, 0.0f);
46+
ShapeAppearance.setDiffuseColor(1.0f, 0.0f, 0.0f);
4847
}
4948

5049
ViewProviderFemConstraintTemperature::~ViewProviderFemConstraintTemperature() = default;

src/Mod/Fem/femviewprovider/view_constraint_tie.py

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class VPConstraintTie(view_base_femconstraint.VPBaseFemConstraint):
4040

4141
def __init__(self, vobj):
4242
super().__init__(vobj)
43+
mat = vobj.ShapeAppearance[0]
44+
mat.DiffuseColor = (0.3, 0.7, 0.5, 0.0)
45+
vobj.ShapeAppearance = mat
4346

4447
def setEdit(self, vobj, mode=0):
4548
view_base_femconstraint.VPBaseFemConstraint.setEdit(

0 commit comments

Comments
 (0)