CheckDisplayFilter question

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/04/2011 at 13:29, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   12 
Platform:   Windows  ;   
Language(s) :     C++  ;

---------
Sorry for this stupid question. But I don't understand what what the SDK is trying to tell me.
I'm trying to get access to the filters located under the selection->Selection filters menu. And I'm stuck on what the SDK shows as "docdata".

BaseObject *obj = doc->GetFirstObject();          
 LONG filter = docdata.GetLong(SELECTIONFILTERBIT_POLYGON); //<--Where does docdata come from?  
  if (CheckDisplayFilter(obj, filter))  
  {  
  GePrint("true"); // prints true if the polygon filter option is enabled  
  }

I assume that "docdata" is some class that was instantiated using that name.
But what class is this referring to?

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/04/2011 at 18:32, xxxxxxxx wrote:

Looks to be the BaseContainer of the current BaseDocument (doc).  The 'docs' (documentation) isn't always decipherable unless you understand 'this is what I mean' language. LOL

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 28/04/2011 at 19:59, xxxxxxxx wrote:

That was also my impression of what it's asking for.
But when I tried it. I got an error:

Bool SimplePlugin::Execute(BaseDocument *doc)  
{  
 BaseObject *obj = doc->GetFirstObject();  
 BaseContainer *docdata = doc->GetDataInstance();  
  
 LONG filter = docdata.GetLong(SELECTIONFILTERBIT_POLYGON); //<--Error:docdata must have a class type  
  if (CheckDisplayFilter(obj, filter))  
  {  
  GePrint("true"); // prints true if the polygon filter is enabled  
  }  
    
  return true;  
}

But I might not be writing the base container code for the document correctly.

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/04/2011 at 03:31, xxxxxxxx wrote:

The R12 docs are currently wrong about CheckDisplayFilter. I will try to get an updated description of the function.

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 29/04/2011 at 07:04, xxxxxxxx wrote:

Doh!
I was afraid of that.

If I use this instead:  LONG filter = docdata->GetLong(SELECTIONFILTERBIT_POLYGON);
It doesn't produce any errors...However the state of the filter doesn't seem to respond properly.

Thanks for looking into this.
-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 12/05/2011 at 09:12, xxxxxxxx wrote:

I know you're probably very busy Matthias.
But is there any update on this yet?

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/05/2011 at 06:15, xxxxxxxx wrote:

Sorry for the delay, here are some examples how to access the selection and display filters.

Selection filter:

  
// retrieve the document info container that includes the selection filter bit mask  
BaseContainer bc = doc->GetData(DOCUMENTSETTINGS_DOCUMENT);  
  
// get the filter bit mask  
LONG sf = bc.GetLong(DOCUMENT_SELECTIONFILTER);  
  
// check if a bit is set or not  
if (!(sf & SELECTIONFILTERBIT_NULL))  
{  
  // do something  
  GePrint("Null");  
}  

Display filter:

  
BaseDraw *bd = doc->GetActiveBaseDraw();  
  
LONG i;  
  
// iterate through all display filters  
for (i=(BASEDRAW_DISPLAYFILTER_BEGIN+1); i<BASEDRAW_DISPLAYFILTER_END; i++)  
{  
  if (bd->GetParameterData(i).GetLong())  
  {  
      // i is the ID of the set filter; do something  
      GePrint(LongToString(i));  
  }  
}  

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/05/2011 at 11:44, xxxxxxxx wrote:

Nice.
Thank you sir. :thumbsup:

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 17/05/2011 at 17:31, xxxxxxxx wrote:

Darn it!
Getting the state of the tool is only half of the solution.
I still can't figure out how to toggle their bits to turn them on/off in the menu.

BaseContainer bc = doc->GetData(DOCUMENTSETTINGS_DOCUMENT);   
LONG sf = bc.GetLong(DOCUMENT_SELECTIONFILTER);  
if (!(sf & SELECTIONFILTERBIT_POLYGON)) // If the polygon option is enabled  
{  
  // How do I Set the bit to 1(off) to turn it off in the menu?     
}

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 18/05/2011 at 00:19, xxxxxxxx wrote:

I guess you would do:

  
sf = sf | SELECTIONFILTERBIT_POLYGON;   
bc.SetLong(DOCUMENT_SELECTIONFILTER);   
doc->SetData(DOCUMENTSETTINGS_DOCUMENT, bc);   

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 18/05/2011 at 08:16, xxxxxxxx wrote:

Thanks spedler.
That works for turning the option off:

BaseContainer bc = doc->GetData(DOCUMENTSETTINGS_DOCUMENT); // Gets the document info container that includes the selection filter bit mask  
 LONG sf = bc.GetLong(DOCUMENT_SELECTIONFILTER); // Get the filter bit mask  
   
 if (!(sf & SELECTIONFILTERBIT_POLYGON)) // If the polygon option is enabled  
  {       
LONG f = sf | SELECTIONFILTERBIT_POLYGON; //Turns the poygon option off  
bc.SetLong(DOCUMENT_SELECTIONFILTER, f);  
  }  
 doc->SetData(DOCUMENTSETTINGS_DOCUMENT, bc);  
 EventAdd();

But how do I toggle it on?
I looked up the bitwise operators on the internet and tried them. But none of them worked.
If I use the || bitwise operator. It turns on the Null option no matter which filter name I use.

I was kind of hoping I could use ToggleBit(BIT_ACTIVE) with this. But I keep running into pointer errors when trying to use it.

-ScottA

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 18/05/2011 at 08:26, xxxxxxxx wrote:

The opposite of a bitwise OR '|' is AND-NOT '&~'.

So, setting bits (to 1) is accomplished with:

sf |= BITFLAGS;

And unsetting bits (to 0) is accomplished with:

sf &= ~BITFLAGS;

(Note that BITFLAGS is just an example constant.  To do more than one flag in either case, wrap in () and | them, such as sf &= ~(BITFLAG_0|BITFLAG_1|BITFLAG_4); which unsets all three of these bits).

Hope that helps! :D

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 18/05/2011 at 08:29, xxxxxxxx wrote:

The || operator is not a bit operator but a logic operator. The bit operator is just one |.

Btw. for the selection filter mask the behaviour is like this, if a bit is set the option is disabled.

cheers,
Matthias

THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

On 18/05/2011 at 09:25, xxxxxxxx wrote:

&~ did the trick.

So many little things to learn. It seems to never end. :wink:
Thanks a lot for the help guys.

-ScottA