Core: Add App::LocalCoordinateSystem.

Most of App::Origin is moved into this sub class of App::Origin.
Add App::Point. Change graphics of the planes/axis.
Remove scale-by-content behavior and make it fixed size on screen.
This commit is contained in:
PaddleStroke
2024-11-26 10:16:03 +01:00
parent aa2e4ca1cb
commit 19702dcb21
23 changed files with 823 additions and 819 deletions

View File

@@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Inventor/nodes/SoText2.h>
# include <Inventor/nodes/SoAsciiText.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoIndexedLineSet.h>
@@ -32,6 +33,9 @@
# include <Inventor/nodes/SoTranslation.h>
#endif
#include <App/Datums.h>
#include <Gui/ViewParams.h>
#include "ViewProviderLine.h"
#include "ViewProviderOrigin.h"
@@ -51,14 +55,46 @@ ViewProviderLine::~ViewProviderLine() = default;
void ViewProviderLine::attach(App::DocumentObject *obj) {
ViewProviderDatum::attach(obj);
static const float size = ViewProviderOrigin::defaultSize ();
// Setup label text and line colors
const char* name = pcObject->getNameInDocument();
static const SbVec3f verts[2] = { SbVec3f(size, 0, 0), SbVec3f ( -size, 0, 0 ) };
bool noRole = false;
auto axisRoles = App::LocalCoordinateSystem::AxisRoles;
if (strncmp(name, axisRoles[0], strlen(axisRoles[0])) == 0) {
// X-axis: red
ShapeAppearance.setDiffuseColor(ViewParams::instance()->getAxisXColor());
pLabel->string.setValue(SbString("X"));
}
else if (strncmp(name, axisRoles[1], strlen(axisRoles[1])) == 0) {
// Y-axis: green
ShapeAppearance.setDiffuseColor(ViewParams::instance()->getAxisYColor());
pLabel->string.setValue(SbString("Y"));
}
else if (strncmp(name, axisRoles[2], strlen(axisRoles[2])) == 0) {
// Z-axis: blue
ShapeAppearance.setDiffuseColor(ViewParams::instance()->getAxisZColor());
pLabel->string.setValue(SbString("Z"));
}
else {
noRole = true;
}
static const float size = ViewProviderOrigin::defaultSize();
SbVec3f verts[2];
if (noRole) {
verts[0] = SbVec3f(2 * size, 0, 0);
verts[1] = SbVec3f(0, 0, 0);
}
else {
verts[0] = SbVec3f(size, 0, 0);
verts[1] = SbVec3f(0.2 * size, 0, 0);
}
// indexes used to create the edges
static const int32_t lines[4] = { 0, 1, -1 };
SoSeparator *sep = getOriginFeatureRoot ();
SoSeparator *sep = getRoot();
auto pCoords = new SoCoordinate3 ();
pCoords->point.setNum (2);
@@ -71,11 +107,11 @@ void ViewProviderLine::attach(App::DocumentObject *obj) {
sep->addChild ( pLines );
auto textTranslation = new SoTranslation ();
textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size / 30., 0 ) );
textTranslation->translation.setValue ( SbVec3f ( size * 1.1, 0, 0 ) );
sep->addChild ( textTranslation );
auto ps = new SoPickStyle();
ps->style.setValue(SoPickStyle::BOUNDING_BOX);
ps->style.setValue(SoPickStyle::SHAPE_ON_TOP);
sep->addChild(ps);
sep->addChild ( getLabel () );