24
24
#include " PreCompiled.h"
25
25
26
26
#ifndef _PreComp_
27
- #include < Inventor/nodes/SoBaseColor.h>
28
27
#include < Inventor/nodes/SoCone.h>
29
28
#include < Inventor/nodes/SoCube.h>
30
29
#include < Inventor/nodes/SoCylinder.h>
31
- #include < Inventor/nodes/SoFontStyle .h>
30
+ #include < Inventor/nodes/SoMaterial .h>
32
31
#include < Inventor/nodes/SoMultipleCopy.h>
32
+ #include < Inventor/nodes/SoPickStyle.h>
33
33
#include < Inventor/nodes/SoRotation.h>
34
34
#include < Inventor/nodes/SoSeparator.h>
35
35
#include < Inventor/nodes/SoShapeHints.h>
36
- #include < Inventor/nodes/SoText2.h>
37
36
#include < Inventor/nodes/SoTranslation.h>
38
37
#include < QAction>
39
38
#include < QDockWidget>
@@ -67,40 +66,19 @@ ViewProviderFemConstraint::ViewProviderFemConstraint()
67
66
, wizardSubLayout(nullptr )
68
67
, constraintDialog(nullptr )
69
68
{
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 ();
82
69
pShapeSep = new SoSeparator ();
83
70
pShapeSep->ref ();
84
71
pMultCopy = new SoMultipleCopy ();
85
72
pMultCopy->ref ();
86
73
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 );
94
76
95
77
Gui::ViewProviderSuppressibleExtension::initExtension (this );
96
78
}
97
79
98
80
ViewProviderFemConstraint::~ViewProviderFemConstraint ()
99
81
{
100
- pFont->unref ();
101
- pLabel->unref ();
102
- pTextColor->unref ();
103
- pMaterials->unref ();
104
82
pMultCopy->unref ();
105
83
pShapeSep->unref ();
106
84
}
@@ -118,7 +96,7 @@ void ViewProviderFemConstraint::attach(App::DocumentObject* pcObject)
118
96
hints->vertexOrdering .setValue (SoShapeHints::COUNTERCLOCKWISE);
119
97
sep->addChild (ps);
120
98
sep->addChild (hints);
121
- sep->addChild (pMaterials );
99
+ sep->addChild (pcShapeMaterial );
122
100
sep->addChild (pShapeSep);
123
101
addDisplayMaskMode (sep, " Base" );
124
102
}
@@ -191,23 +169,7 @@ void ViewProviderFemConstraint::setupContextMenu(QMenu* menu, QObject* receiver,
191
169
192
170
void ViewProviderFemConstraint::onChanged (const App::Property* prop)
193
171
{
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);
211
173
}
212
174
213
175
void ViewProviderFemConstraint::updateData (const App::Property* prop)
@@ -223,6 +185,25 @@ void ViewProviderFemConstraint::updateData(const App::Property* prop)
223
185
}
224
186
}
225
187
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
+
226
207
void ViewProviderFemConstraint::updateSymbol ()
227
208
{
228
209
auto obj = static_cast <const Fem::Constraint*>(this ->getObject ());
0 commit comments