Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Attaching a Legend

In GraphMaster we have seen how to associate a legend with a curve visualization using PoItemLegend node. Other legend nodes derived from PoLegend are very useful in 3DdataMaster. These legends will allow you to visualize the data-color mapping and to “explain” your results.

3DdataMaster provides two main types of legends: automatic and non-automatic. Automatic legends will specify the geometry of inside “items” on their own, unlike non-automatic legends where your application must specify the geometry of each item.

"Note" to build a legend, using data mapping and an isovalues list:

Example : Use of value legend

// tutorialMesh02.cxx
#include <Inventor/Xt/SoXt.h>
#include <Inventor/Xt/viewers/SoXtPlaneViewer.h>
#include <Inventor/nodes/SoAnnotation.h>
#include <MeshViz/graph/PoLinearValueLegend.h>
#include <MeshViz/nodes/PoIsovaluesList.h>
#include <MeshViz/nodes/PoLinearDataMapping.h>
int
main( int, char** argv )
{
// Initialize Inventor and Xt
Widget myWindow = SoXt::init( argv[0] );
if ( myWindow == NULL )
exit( 1 );
// Initialize MeshViz
PoMeshViz::init();
// Define the data-color mapping
PoLinearDataMapping* myDataMapping = new PoLinearDataMapping;
myDataMapping->color1 = SbColor( 0, 0, 1 );
myDataMapping->value1 = 0;
myDataMapping->color2 = SbColor( 1, 0, 0 );
myDataMapping->value1 = 10;
// Define list of values
PoIsovaluesList* myList = new PoIsovaluesList;
myList->setRegularIsoList( 0., 9., 10 );
// Create the legend node
PoLinearValueLegend* legend = new PoLinearValueLegend( SbVec2f( 0., 0. ), SbVec2f( 0.3, 1.0 ) );
legend->set( "backgroundApp.material", "diffuseColor .4 .4 .4" );
// Create the root of our scene graph
SoAnnotation* root = new SoAnnotation;
root->ref();
root->addChild( myDataMapping );
root->addChild( myList );
root->addChild( legend );
SoXtPlaneViewer* viewer = new SoXtPlaneViewer( myWindow );
viewer->setBackgroundColor( SbColor( 1., 1., 1. ) );
viewer->setSceneGraph( root );
viewer->show();
SoXt::show( myWindow );
SoXt::mainLoop();
return 0;
}