Origin axis: use same colors as axis cross and make bigger than planes

for easier selection and visualization
This commit is contained in:
Ronny Standtke
2023-04-29 19:53:48 +02:00
committed by Adrián Insaurralde Avalos
parent adb40e5634
commit f8ae7ba722
3 changed files with 25 additions and 4 deletions

View File

@@ -182,9 +182,9 @@ void ViewProviderOrigin::onChanged(const App::Property* prop) {
if (vpPlaneXY) { vpPlaneXY->Size.setValue ( szXY ); }
if (vpPlaneXZ) { vpPlaneXZ->Size.setValue ( szXZ ); }
if (vpPlaneYZ) { vpPlaneYZ->Size.setValue ( szYZ ); }
if (vpLineX) { vpLineX->Size.setValue ( szX ); }
if (vpLineY) { vpLineY->Size.setValue ( szY ); }
if (vpLineZ) { vpLineZ->Size.setValue ( szZ ); }
if (vpLineX) { vpLineX->Size.setValue ( szX * axesScaling ); }
if (vpLineY) { vpLineY->Size.setValue ( szY * axesScaling ); }
if (vpLineZ) { vpLineZ->Size.setValue ( szZ * axesScaling ); }
} catch (const Base::Exception &ex) {
// While restoring a document don't report errors if one of the lines or planes

View File

@@ -77,6 +77,9 @@ public:
/// Returns default size. Use this if it is not possible to determine appropriate size by other means
static double defaultSize();
// the factor by which the axes are longer than the planes
static constexpr float axesScaling = 1.5f;
// default color for origini: light-blue (50, 150, 250, 255 stored as 0xRRGGBBAA)
static const uint32_t defaultColor = 0x3296faff;
protected:

View File

@@ -35,6 +35,7 @@
#include <App/Document.h>
#include <App/OriginFeature.h>
#include <App/Origin.h>
#include "ViewProviderOriginFeature.h"
#include "SoFCSelection.h"
@@ -98,7 +99,24 @@ void ViewProviderOriginFeature::attach(App::DocumentObject* pcObject)
// Setup font size
auto font = new SoFont ();
font->size.setValue ( defaultSz/10.);
float fontRatio = 10.0f;
if ( pcObject->getTypeId() == App::Line::getClassTypeId() ) {
// keep font size on axes equal to font size on planes
fontRatio *= ViewProviderOrigin::axesScaling;
const char* axisName = pcObject->getNameInDocument();
auto axisRoles = App::Origin::AxisRoles;
if ( strncmp(axisName, axisRoles[0], strlen(axisRoles[0]) ) == 0 ) {
// X-axis: red
ShapeColor.setValue ( 0xFF0000FF );
} else if ( strncmp(axisName, axisRoles[1], strlen(axisRoles[1]) ) == 0 ) {
// Y-axis: green
ShapeColor.setValue ( 0x00FF00FF );
} else if ( strncmp(axisName, axisRoles[2], strlen(axisRoles[2]) ) == 0 ) {
// Z-axis: blue
ShapeColor.setValue ( 0x0000FFFF );
}
}
font->size.setValue ( defaultSz / fontRatio );
sep->addChild ( font );
// Create the selection node