Salome HOME
Fix for bug IPAL10387 : Supervisor viewer has no "View Operations" toolbar.
[modules/gui.git] / src / SalomeApp / SalomeApp_TypeFilter.cxx
1 #include "SalomeApp_TypeFilter.h"
2
3 #include "LightApp_DataOwner.h"
4 #include "SalomeApp_Study.h"
5
6 #include <SALOMEDS_SObject.hxx>
7
8 /*!
9   Constructor.
10 */
11 SalomeApp_TypeFilter::SalomeApp_TypeFilter( SalomeApp_Study* study, const QString& kind )
12   : SalomeApp_Filter( study ) 
13 {
14   myKind = kind;
15 }
16
17 /*!
18   Destructor.
19 */
20 SalomeApp_TypeFilter::~SalomeApp_TypeFilter()
21 {
22 }
23
24 /*!
25   Check: data owner is valid?
26 */
27 bool SalomeApp_TypeFilter::isOk( const SUIT_DataOwner* sOwner ) const
28 {  
29   const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*> ( sOwner );
30
31   SalomeApp_Study* aDoc =  getStudy();
32   if (owner && aDoc && aDoc->studyDS())
33     {
34       _PTR(Study) aStudy = aDoc->studyDS();
35       QString entry = owner->entry();
36       
37       _PTR(SObject) aSObj( aStudy->FindObjectID( entry.latin1() ) );
38       if (aSObj)
39         {
40           _PTR(SComponent) aComponent(aSObj->GetFatherComponent());
41           if ( aComponent && (aComponent->ComponentDataType() == myKind.latin1()) )
42             return true;
43         }
44     }
45
46   return false;
47 }