MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / attach

Method attach

src/Gui/ViewProviderPlane.cpp:66–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64ViewProviderPlane::~ViewProviderPlane() = default;
65
66void ViewProviderPlane::attach(App::DocumentObject* obj)
67{
68 ViewProviderDatum::attach(obj);
69
70 std::string role = getRole();
71
72 SoSeparator* sep = getDatumRoot();
73
74 // Setup colors
75 // Can't use transparency because of https://github.com/FreeCAD/FreeCAD/issues/18395
76 // When this issue is fixed then we can use the below and remove the material here
77 // and faceSeparator...
78 // ShapeAppearance.setTransparency(0.8);
79 auto material = new SoMaterial();
80 material->transparency.setValue(0.85f);
81
82 if (!role.empty()) {
83 ShapeAppearance.setDiffuseColor(getColor(role));
84 }
85
86 SbColor color = ShapeAppearance.getDiffuseColor().asValue<SbColor>();
87 material->ambientColor.setValue(color);
88 material->diffuseColor.setValue(color);
89
90 auto ps = new SoPickStyle();
91 ps->style.setValue(SoPickStyle::SHAPE_ON_TOP);
92
93 pCoords = new SoCoordinate3();
94 sep->addChild(pCoords);
95 sep->addChild(material);
96 sep->addChild(ps);
97
98 auto lineSeparator = new SoSeparator();
99 auto pLines = new SoIndexedLineSet();
100 static const int32_t lines[6] = {0, 1, 2, 3, 0, -1};
101 pLines->coordIndex.setNum(6);
102 pLines->coordIndex.setValues(0, 6, lines);
103
104 lineSeparator->addChild(pLines);
105 sep->addChild(lineSeparator);
106
107 // add semi transparent face
108 auto faceSeparator = new SoSeparator();
109 sep->addChild(faceSeparator);
110
111 // disable backface culling and render with two-sided lighting
112 auto shapeHints = new SoShapeHints();
113 shapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
114 shapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
115 faceSeparator->addChild(shapeHints);
116
117 auto faceSet = new SoFaceSet();
118 auto vertexProperty = new SoVertexProperty();
119 vertexProperty->vertex.connectFrom(&pCoords->point);
120 faceSet->vertexProperty.setValue(vertexProperty);
121 faceSeparator->addChild(faceSet);
122
123 pTextTranslation = new SoTranslation();

Callers

nothing calls this directly

Calls 13

getDatumRootFunction · 0.85
getLabelTextFunction · 0.85
getColorFunction · 0.70
instanceFunction · 0.70
setValueMethod · 0.45
emptyMethod · 0.45
setDiffuseColorMethod · 0.45
getDiffuseColorMethod · 0.45
addChildMethod · 0.45
setValuesMethod · 0.45
c_strMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected