Node that defines the pattern to use when rendering shapes. More...
#include <Inventor/nodes/SoPattern.h>
Public Types | |
enum | FilterType { INCLUSIVE_FILTER, EXCLUSIVE_FILTER } |
Public Member Functions | |
virtual SoType | getTypeId () const |
SoPattern () | |
virtual void | setOverride (const SbBool state) |
virtual SbBool | isOverride () const |
Static Public Member Functions | |
static SoType | getClassTypeId () |
static SoNONUNICODE SbBool | loadPatterns (const char *fileName, int numFilters=0, const SbString *filterNames=NULL, FilterType filterType=INCLUSIVE_FILTER) |
static SbBool | loadPatterns (const SbString &fileName, int numFilters=0, const SbString *filterNames=NULL, FilterType filterType=INCLUSIVE_FILTER) |
static void | getPatternNames (int &number, SbString *&names, const char *category=NULL) |
static SoNONUNICODE void | addPattern (const char *category, const char *name, const unsigned char *bytes) |
static void | addPattern (const SbString &category, const SbString &name, const unsigned char *bytes) |
static SoNONUNICODE void | getPattern (const char *category, const char *name, unsigned char *&bytes) |
static void | getPattern (const SbString &category, const SbString &name, unsigned char *&bytes) |
Public Attributes | |
SoSFString | category |
SoSFString | name |
This node specifies the current pattern for all subsequent shape nodes in a scene graph.
A pattern is a 32x32 bitmap that is interpreted as a mask of 0s and 1s. Where a 1 appears, the corresponding pixel in the polygon is drawn; where a 0 appears, nothing is drawn.
You can load a pattern file containing one or more patterns using the loadPatterns() method. You can also define and load patterns programmatically using the addPattern() method.
Here is a sample showing the pattern file format.
"GEOLOGY" # The first string is the category name of the first pattern. # This is a comment ! "PATTERN N1" # The second string is the name of the pattern. # To define the pattern, you must define a 32x32 sequence of # '1' and '0'. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ... #============================================ "PATTERN N2" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ...
Note:
Usage Notes
category | "" |
name | "" |
NOTE: When you write a pattern node out to a file, the file will not contain enough information to fully reconstruct the original scene graph. The pattern node and its current fields are written out (as expected). However, the current fields only specify a category name and a pattern name. They do not specify the actual pattern(s) (like a typical attribute node) or a filename to get the patterns from (like a texture node).
Possible value of the filterType used by the method loadPatterns.
In the case INCLUSIVE_FILTER, we only load patterns of the file define by the list of patterns names. In the case EXCLUSIVE_FILTER, we load all patterns defined in the file without those define by the list of patterns names.
SoPattern::SoPattern | ( | ) |
Constructor.
static void SoPattern::addPattern | ( | const SbString & | category, | |
const SbString & | name, | |||
const unsigned char * | bytes | |||
) | [static] |
Adds a new pattern specified as an array of 128 bytes.
A category and a name are specified for this pattern. If the category and name are already in the list of patterns, the new pattern will not be added. If either the category or the name is an empty string, no pattern is added.
static SoNONUNICODE void SoPattern::addPattern | ( | const char * | category, | |
const char * | name, | |||
const unsigned char * | bytes | |||
) | [static] |
Adds a new pattern specified as an array of 128 bytes.
A category and a name are specified for this pattern. If the category and name are already in the list of patterns, the new pattern will not be added. If either the category or the name is an empty string, no pattern is added.
static SoType SoPattern::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoNode.
static void SoPattern::getPattern | ( | const SbString & | category, | |
const SbString & | name, | |||
unsigned char *& | bytes | |||
) | [static] |
Retrieves a pattern bitmap (an array of 128 bytes) specified by its category and name.
the pattern data pointed to by bytes is read-only.
static SoNONUNICODE void SoPattern::getPattern | ( | const char * | category, | |
const char * | name, | |||
unsigned char *& | bytes | |||
) | [static] |
Retrieves a pattern bitmap (an array of 128 bytes) specified by its category and name.
the pattern data pointed to by bytes is read-only.
static void SoPattern::getPatternNames | ( | int & | number, | |
SbString *& | names, | |||
const char * | category = NULL | |||
) | [static] |
Gets the names of loaded patterns.
Category is optional. You are responsible for deleting the names array when it is no longer needed. For example, delete []names;
virtual SoType SoPattern::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoNode.
virtual SbBool SoPattern::isOverride | ( | ) | const [inline, virtual] |
Returns the state of the override field.
Reimplemented from SoNode.
static SbBool SoPattern::loadPatterns | ( | const SbString & | fileName, | |
int | numFilters = 0 , |
|||
const SbString * | filterNames = NULL , |
|||
FilterType | filterType = INCLUSIVE_FILTER | |||
) | [static] |
Loads a pattern file, with optional filtering of patterns.
You can specify the file name with or without a full path. If you specify the file name without the path, the file will be loaded from the directory $OIVHOME/data/patterns. If the file name is not found, a default pattern will be used.
filterNames is an array of pattern names. This will be an array of patterns to include (or exclude) depending on the FilterType. The size of this array is numFilters.
static SoNONUNICODE SbBool SoPattern::loadPatterns | ( | const char * | fileName, | |
int | numFilters = 0 , |
|||
const SbString * | filterNames = NULL , |
|||
FilterType | filterType = INCLUSIVE_FILTER | |||
) | [static] |
Loads a pattern file, with optional filtering of patterns.
You can specify the file name with or without a full path. If you specify the file name without the path, the file will be loaded from the directory $OIVHOME/data/patterns. If the file name is not found, a default pattern will be used.
filterNames is an array of pattern names. This will be an array of patterns to include (or exclude) depending on the FilterType. The size of this array is numFilters.
virtual void SoPattern::setOverride | ( | const SbBool | state | ) | [inline, virtual] |
Specifies the name of a group of patterns.
If the category name is invalid or not found, the default pattern is used.
Specifies the name of a pattern within a category.
If the pattern name is invalid or not found, the default pattern is used.