Skip to content

Commit f3e9fad

Browse files
committed
Fem: Remove unused view properties
1 parent 74ebf38 commit f3e9fad

14 files changed

+39
-76
lines changed

src/Mod/Fem/Gui/ViewProviderFemConstraint.cpp

+18-37
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>
27+
#include <Inventor/nodes/SoMaterial.h>
2828
#include <Inventor/nodes/SoCone.h>
2929
#include <Inventor/nodes/SoCube.h>
3030
#include <Inventor/nodes/SoCylinder.h>
31-
#include <Inventor/nodes/SoFontStyle.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,39 +66,23 @@ 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();
69+
Transparency.setStatus(App::Property::Hidden, true);
70+
8271
pShapeSep = new SoSeparator();
8372
pShapeSep->ref();
8473
pMultCopy = new SoMultipleCopy();
8574
pMultCopy->ref();
86-
87-
pMaterials = new SoBaseColor();
75+
pMaterials = new SoMaterial();
8876
pMaterials->ref();
89-
pMaterials->rgb.setValue(1.0f, 0.0f, 0.2f);
9077

91-
TextColor.touch();
92-
FontSize.touch();
93-
FaceColor.touch();
78+
ShapeAppearance.setDiffuseColor(1.0f, 0.0f, 0.2f);
79+
ShapeAppearance.setSpecularColor(0.0f, 0.0f, 0.0f);
9480

9581
Gui::ViewProviderSuppressibleExtension::initExtension(this);
9682
}
9783

9884
ViewProviderFemConstraint::~ViewProviderFemConstraint()
9985
{
100-
pFont->unref();
101-
pLabel->unref();
102-
pTextColor->unref();
10386
pMaterials->unref();
10487
pMultCopy->unref();
10588
pShapeSep->unref();
@@ -182,19 +165,17 @@ void ViewProviderFemConstraint::setupContextMenu(QMenu* menu, QObject* receiver,
182165

183166
void ViewProviderFemConstraint::onChanged(const App::Property* prop)
184167
{
185-
if (prop == &Mirror) {
186-
updateData(prop);
187-
}
188-
else if (prop == &TextColor) {
189-
const App::Color& c = TextColor.getValue();
190-
pTextColor->rgb.setValue(c.r, c.g, c.b);
191-
}
192-
else if (prop == &FaceColor) {
193-
const App::Color& c = FaceColor.getValue();
194-
pMaterials->rgb.setValue(c.r, c.g, c.b);
195-
}
196-
else if (prop == &FontSize) {
197-
pFont->size = FontSize.getValue();
168+
if (prop == &ShapeAppearance) {
169+
const App::Color& d = ShapeAppearance.getDiffuseColor();
170+
pMaterials->diffuseColor.setValue(d.r, d.g, d.b);
171+
const App::Color& s = ShapeAppearance.getSpecularColor();
172+
pMaterials->specularColor.setValue(s.r, s.g, s.b);
173+
const App::Color& e = ShapeAppearance.getEmissiveColor();
174+
pMaterials->emissiveColor.setValue(e.r, e.g, e.b);
175+
const App::Color& a = ShapeAppearance.getAmbientColor();
176+
pMaterials->ambientColor.setValue(a.r, a.g, a.b);
177+
pMaterials->shininess.setValue(ShapeAppearance.getShininess());
178+
pMaterials->transparency.setValue(ShapeAppearance.getTransparency());
198179
}
199180
else {
200181
ViewProviderDocumentObject::onChanged(prop); // clazy:exclude=skipped-base-method

src/Mod/Fem/Gui/ViewProviderFemConstraint.h

+1-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;
@@ -165,10 +154,7 @@ class FemGuiExport ViewProviderFemConstraint: public Gui::ViewProviderGeometryOb
165154
const bool gap = false);
166155

167156
private:
168-
SoFontStyle* pFont;
169-
SoText2* pLabel;
170-
SoBaseColor* pTextColor;
171-
SoBaseColor* pMaterials;
157+
SoMaterial* pMaterials;
172158
bool rotateSymbol;
173159

174160
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)