24
#include "PreCompiled.h"
27
# include <Inventor/nodes/SoAsciiText.h>
28
# include <Inventor/nodes/SoCoordinate3.h>
29
# include <Inventor/nodes/SoFaceSet.h>
30
# include <Inventor/nodes/SoIndexedLineSet.h>
31
# include <Inventor/nodes/SoMaterial.h>
32
# include <Inventor/nodes/SoPickStyle.h>
33
# include <Inventor/nodes/SoSeparator.h>
34
# include <Inventor/nodes/SoShapeHints.h>
35
# include <Inventor/nodes/SoTranslation.h>
36
# include <Inventor/SbColor.h>
39
#include "ViewProviderPlane.h"
40
#include "ViewProviderOrigin.h"
45
PROPERTY_SOURCE(Gui::ViewProviderPlane, Gui::ViewProviderOriginFeature)
48
ViewProviderPlane::ViewProviderPlane()
50
sPixmap = "Std_Plane";
53
ViewProviderPlane::~ViewProviderPlane() = default;
55
void ViewProviderPlane::attach ( App::DocumentObject *obj ) {
56
ViewProviderOriginFeature::attach ( obj );
57
static const float size = ViewProviderOrigin::defaultSize ();
59
static const SbVec3f verts[4] = {
60
SbVec3f(size,size,0), SbVec3f(size,-size,0),
61
SbVec3f(-size,-size,0), SbVec3f(-size,size,0),
65
static const int32_t lines[6] = { 0, 1, 2, 3, 0, -1 };
67
SoSeparator *sep = getOriginFeatureRoot ();
69
auto pCoords = new SoCoordinate3 ();
70
pCoords->point.setNum (4);
71
pCoords->point.setValues ( 0, 4, verts );
72
sep->addChild ( pCoords );
74
auto pLines = new SoIndexedLineSet ();
75
pLines->coordIndex.setNum(6);
76
pLines->coordIndex.setValues(0, 6, lines);
77
sep->addChild ( pLines );
80
auto faceSeparator = new SoSeparator();
81
sep->addChild(faceSeparator);
83
auto material = new SoMaterial();
84
material->transparency.setValue(0.95f);
87
color.setPackedValue(ViewProviderOrigin::defaultColor, alpha);
88
material->ambientColor.setValue(color);
89
material->diffuseColor.setValue(color);
90
faceSeparator->addChild(material);
93
auto shapeHints = new SoShapeHints();
94
shapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
95
shapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
96
faceSeparator->addChild(shapeHints);
99
auto pickStyle = new SoPickStyle();
100
pickStyle->style = SoPickStyle::UNPICKABLE;
101
faceSeparator->addChild(pickStyle);
103
auto faceSet = new SoFaceSet();
104
auto vertexProperty = new SoVertexProperty();
105
vertexProperty->vertex.setValues(0, 4, verts);
106
faceSet->vertexProperty.setValue(vertexProperty);
107
faceSeparator->addChild(faceSet);
109
auto textTranslation = new SoTranslation ();
110
textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size * 9./10., 0 ) );
111
sep->addChild ( textTranslation );
113
auto ps = new SoPickStyle();
114
ps->style.setValue(SoPickStyle::BOUNDING_BOX);
117
sep->addChild ( getLabel () );