MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / initBasisAxesObject_

Method initBasisAxesObject_

source/MRViewer/MRViewer.cpp:2107–2180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2105}
2106
2107void Viewer::initBasisAxesObject_()
2108{
2109 // store basis axes in the corner
2110 const float cubeSzie = 0.8f;
2111 const float size = 1.0f;
2112 std::shared_ptr<Mesh> basisAxesMesh = std::make_shared<Mesh>( makeBasisAxes( size, size * 0.03f, size * 0.03f, 0.0f ) );
2113 const Vector3f translation = Vector3f::diagonal( -cubeSzie * 0.5f );
2114 basisAxesMesh->transform( AffineXf3f::translation( translation ) );
2115
2116 basisAxes = std::make_shared<ObjectMesh>();
2117 basisAxes->setMesh( basisAxesMesh );
2118 basisAxes->setName("Basis axes mesh");
2119 basisAxes->setFlatShading( true );
2120
2121 auto numF = basisAxesMesh->topology.edgePerFace().size();
2122 // setting color to faces
2123 const Color colorX = ColorTheme::getViewportColor( ColorTheme::ViewportColorsType::AxisX );
2124 const Color colorY = ColorTheme::getViewportColor( ColorTheme::ViewportColorsType::AxisY );
2125 const Color colorZ = ColorTheme::getViewportColor( ColorTheme::ViewportColorsType::AxisZ );
2126 FaceColors colorMap( numF );
2127 const auto arrowSize = numF / 3;
2128 for (int i = 0; i < arrowSize; i++)
2129 {
2130 colorMap[FaceId( i )] = colorX;
2131 colorMap[FaceId( i + arrowSize )] = colorY;
2132 colorMap[FaceId( i + arrowSize * 2 )] = colorZ;
2133 }
2134 const float labelPos = size + 0.2f;
2135
2136 addLabel( *basisAxes, "X", labelPos * Vector3f::plusX() + translation, true );
2137 addLabel( *basisAxes, "Y", labelPos * Vector3f::plusY() + translation, true );
2138 addLabel( *basisAxes, "Z", labelPos * Vector3f::plusZ() + translation, true );
2139
2140 basisAxes->setFacesColorMap( std::move( colorMap ) );
2141 basisAxes->setVisualizeProperty( false, MeshVisualizePropertyType::EnableShading, ViewportMask::all() );
2142 basisAxes->setColoringType( ColoringType::FacesColorMap );
2143
2144 connections_->uiUpdateConnections.push_back( ColorTheme::instance().onChanged( [this, numF] ()
2145 {
2146 if ( !basisAxes )
2147 return;
2148
2149 const Color colorX = ColorTheme::getViewportColor( ColorTheme::ViewportColorsType::AxisX );
2150 const Color colorY = ColorTheme::getViewportColor( ColorTheme::ViewportColorsType::AxisY );
2151 const Color colorZ = ColorTheme::getViewportColor( ColorTheme::ViewportColorsType::AxisZ );
2152 FaceColors colorMap;
2153 basisAxes->updateFacesColorMap( colorMap ); // swap with empty with real
2154 const auto arrowSize = numF / 3;
2155 for ( int i = 0; i < arrowSize; i++ ) // update real
2156 {
2157 colorMap[FaceId( i )] = colorX;
2158 colorMap[FaceId( i + arrowSize )] = colorY;
2159 colorMap[FaceId( i + arrowSize * 2 )] = colorZ;
2160 }
2161 basisAxes->updateFacesColorMap( colorMap ); // swap updated real with empty
2162
2163 const Color& color = SceneColors::get( SceneColors::Type::Labels );
2164

Callers

nothing calls this directly

Calls 15

makeBasisAxesFunction · 0.85
diagonalFunction · 0.85
addLabelFunction · 0.85
instanceFunction · 0.85
setMeshMethod · 0.80
setVisualizePropertyMethod · 0.80
setColoringTypeMethod · 0.80
push_backMethod · 0.80
setFontHeightMethod · 0.80
menuScalingMethod · 0.80
getFunction · 0.50
transformMethod · 0.45

Tested by

no test coverage detected