]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Interface/Plugins.cxx
Merge ssh://git.creatis.insa-lyon.fr/cpPlugins
[cpPlugins.git] / lib / cpPlugins / Interface / Plugins.cxx
1 #include <cpPlugins/Interface/Plugins.h>
2
3 #include <stdexcept>
4
5 #include <cpPlugins/Interface/Image.h>
6 #include <cpPlugins/Interface/Mesh.h>
7
8 #ifdef cpPlugins_Interface_QT4
9
10 #include <QApplication>
11 #include <QFileDialog>
12 #include <QMessageBox>
13 #include <QWidget>
14
15 #ifdef _WIN32
16 #  define PLUGIN_PREFIX ""
17 #  define PLUGIN_EXT "dll"
18 #  define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)"
19 #else // Linux
20 #  define PLUGIN_PREFIX "lib"
21 #  define PLUGIN_EXT "so"
22 #  define PLUGIN_REGEX "Plugins file (*.so);;All files (*)"
23 #endif // _WIN32
24
25 #endif // cpPlugins_Interface_QT4
26
27 // -------------------------------------------------------------------------
28 cpPlugins::Interface::Plugins::
29 Plugins( )
30   : m_Widget( NULL ),
31     m_Application( NULL ),
32     m_LastLoadedPlugin( "" ),
33     m_ActiveFilter( NULL )
34 {
35 }
36
37 // -------------------------------------------------------------------------
38 cpPlugins::Interface::Plugins::
39 ~Plugins( )
40 {
41 }
42
43 // -------------------------------------------------------------------------
44 QWidget* cpPlugins::Interface::Plugins::
45 GetWidget( )
46 {
47   return( this->m_Widget );
48 }
49
50 // -------------------------------------------------------------------------
51 const QWidget* cpPlugins::Interface::Plugins::
52 GetWidget( ) const
53 {
54   return( this->m_Widget );
55 }
56
57 // -------------------------------------------------------------------------
58 void cpPlugins::Interface::Plugins::
59 SetWidget( QWidget* widget )
60 {
61   this->m_Widget = widget;
62 }
63
64 // -------------------------------------------------------------------------
65 void cpPlugins::Interface::Plugins::
66 BlockWidget( )
67 {
68 #ifdef cpPlugins_Interface_QT4
69   if( this->m_Widget != NULL )
70   {
71     QApplication::setOverrideCursor( Qt::WaitCursor );
72     this->m_Widget->setEnabled( false );
73
74   } // fi
75 #endif // cpPlugins_Interface_QT4
76 }
77
78 // -------------------------------------------------------------------------
79 void cpPlugins::Interface::Plugins::
80 UnblockWidget( )
81 {
82 #ifdef cpPlugins_Interface_QT4
83   if( this->m_Widget != NULL )
84   {
85     QApplication::restoreOverrideCursor( );
86     this->m_Widget->setEnabled( true );
87
88   } // fi
89 #endif // cpPlugins_Interface_QT4
90 }
91
92 // -------------------------------------------------------------------------
93 void cpPlugins::Interface::Plugins::
94 DialogLoadPlugins( )
95 {
96 #ifdef cpPlugins_Interface_QT4
97   if( this->m_Widget != NULL )
98   {
99     QFileDialog dialog( this->m_Widget );
100     dialog.setFileMode( QFileDialog::ExistingFile );
101     dialog.setDirectory( this->m_LastLoadedPlugin.c_str( ) );
102     dialog.setNameFilter( QFileDialog::tr( PLUGIN_REGEX ) );
103     dialog.setDefaultSuffix( QFileDialog::tr( PLUGIN_EXT ) );
104     if( !( dialog.exec( ) ) )
105       return;
106
107     std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
108     if( !( this->LoadPlugins( fname ) ) )
109       QMessageBox::critical(
110         this->m_Widget,
111         QMessageBox::tr( "Ignoring plugin" ),
112         QMessageBox::tr( fname.c_str( ) )
113         );
114
115   } // fi
116 #endif // cpPlugins_Interface_QT4
117 }
118
119 // -------------------------------------------------------------------------
120 cpPlugins::Interface::
121 BaseApplication* cpPlugins::Interface::Plugins::
122 GetApplication( )
123 {
124   return( this->m_Application );
125 }
126
127 // -------------------------------------------------------------------------
128 const cpPlugins::Interface::
129 BaseApplication* cpPlugins::Interface::Plugins::
130 GetApplication( ) const
131 {
132   return( this->m_Application );
133 }
134
135 // -------------------------------------------------------------------------
136 void cpPlugins::Interface::Plugins::
137 SetApplication( BaseApplication* a )
138 {
139   this->m_Application = a;
140 }
141
142 // -------------------------------------------------------------------------
143 bool cpPlugins::Interface::Plugins::
144 LoadPluginsPath( const std::string& path, bool r )
145 {
146   this->BlockWidget( );
147
148   // Load all plugins from given folder
149   std::list< std::string > files =
150     this->m_Interface.LoadFromFolder( path, r );
151
152   // Update a simple track
153   bool ret = false;
154   if( files.size( ) > 0 )
155   {
156     for( auto fIt = files.begin( ); fIt != files.end( ); ++fIt )
157     {
158       this->m_LoadedPlugins.insert( *fIt );
159       this->m_LastLoadedPlugin = *fIt;
160       ret = true;
161
162     } // rof
163     this->_UpdateLoadedPluginsInformation( );
164
165   } // fi
166
167   this->UnblockWidget( );
168   return( ret );
169 }
170
171 // -------------------------------------------------------------------------
172 bool cpPlugins::Interface::Plugins::
173 LoadPlugins( const std::string& fname )
174 {
175   this->BlockWidget( );
176
177   // Is it already loaded?
178   bool ret = true;
179   if( this->m_LoadedPlugins.find( fname ) == this->m_LoadedPlugins.end( ) )
180   {
181     // Was it succesfully loaded?
182     ret = this->m_Interface.Load( fname );
183
184     // Update a simple track
185     if( ret )
186     {
187       this->m_LoadedPlugins.insert( fname );
188       this->m_LastLoadedPlugin = fname;
189       this->_UpdateLoadedPluginsInformation( );
190
191     } // fi
192
193   } // fi
194
195   this->UnblockWidget( );
196   return( ret );
197 }
198
199 // -------------------------------------------------------------------------
200 bool cpPlugins::Interface::Plugins::
201 LoadPluginsConfigurationFile( const std::string& fname )
202 {
203   // Load file into a char buffer
204   std::ifstream in(
205     fname.c_str( ), std::ios::in | std::ios::binary | std::ios::ate
206     );
207   if( !in.is_open( ) )
208     return( false );
209
210   std::streampos size = in.tellg( );
211   char* buffer = new char[ size ];
212   in.seekg( 0, std::ios::beg );
213   in.read( buffer, size );
214   in.close( );
215
216   // Read stream
217   std::stringstream in_stream( buffer );
218   char line[ 4096 ];
219   while( in_stream )
220   {
221     in_stream.getline( line, 4096 );
222     this->LoadPlugins( line );
223
224   } // elihw
225   delete buffer;
226
227   return( true );
228 }
229
230 // -------------------------------------------------------------------------
231 const cpPlugins::Interface::Plugins::
232 TStringContainer& cpPlugins::Interface::Plugins::
233 GetLoadedPlugins( ) const
234 {
235   return( this->m_LoadedPlugins );
236 }
237
238 // -------------------------------------------------------------------------
239 void cpPlugins::Interface::Plugins::
240 GetLoadedCategories( TStringContainer& categories ) const
241 {
242   categories.clear( );
243   auto fIt = this->m_LoadedFilters.begin( );
244   for( ; fIt != this->m_LoadedFilters.end( ); ++fIt )
245     categories.insert( fIt->first );
246 }
247
248 // -------------------------------------------------------------------------
249 void cpPlugins::Interface::Plugins::
250 GetLoadedFilters( TStringContainer& filters ) const
251 {
252   filters.clear( );
253   auto pIt = this->m_LoadedFilters.begin( );
254   for( ; pIt != this->m_LoadedFilters.end( ); ++pIt )
255     for( auto fIt = pIt->second.begin( ); fIt != pIt->second.end( ); ++fIt )
256       filters.insert( *fIt );
257 }
258
259 // -------------------------------------------------------------------------
260 const cpPlugins::Interface::Plugins::
261 TStringContainer& cpPlugins::Interface::Plugins::
262 GetLoadedFilters( const std::string& category ) const
263 {
264   static const TStringContainer EMPTY;
265   auto pIt = this->m_LoadedFilters.find( category );
266   if( pIt != this->m_LoadedFilters.end( ) )
267     return( pIt->second );
268   else
269     return( EMPTY );
270 }
271
272 // -------------------------------------------------------------------------
273 void cpPlugins::Interface::Plugins::
274 AddInteractor( vtkRenderWindowInteractor* interactor )
275 {
276   this->m_Interactors.insert( interactor );
277 }
278
279 // -------------------------------------------------------------------------
280 void cpPlugins::Interface::Plugins::
281 RemoveInteractor( vtkRenderWindowInteractor* interactor )
282 {
283   this->m_Interactors.erase( interactor );
284 }
285
286 // -------------------------------------------------------------------------
287 void cpPlugins::Interface::Plugins::
288 ClearInteractors( )
289 {
290   this->m_Interactors.clear( );
291 }
292
293 // -------------------------------------------------------------------------
294 #define cpPlugins_Plugins_HasMacro( F )                                 \
295   bool cpPlugins::Interface::Plugins::                                  \
296   Has##F( ) const                                                       \
297   {                                                                     \
298     return( this->m_IOFilters.find( #F ) != this->m_IOFilters.end( ) ); \
299   }
300
301 cpPlugins_Plugins_HasMacro( ImageReader );
302 cpPlugins_Plugins_HasMacro( DicomSeriesReader );
303 cpPlugins_Plugins_HasMacro( MeshReader );
304 cpPlugins_Plugins_HasMacro( ImageWriter );
305 cpPlugins_Plugins_HasMacro( MeshWriter );
306
307 // -------------------------------------------------------------------------
308 std::string cpPlugins::Interface::Plugins::
309 ReadImage( const std::string& fname, const std::string& parent )
310 {
311   std::vector< std::string > fnames( 1, fname );
312   return( this->ReadImage( fnames, parent ) );
313 }
314
315 // -------------------------------------------------------------------------
316 std::string cpPlugins::Interface::Plugins::
317 ReadImage(
318   const std::vector< std::string >& fnames, const std::string& parent
319   )
320 {
321   // Load source
322   this->_ActivateIOFilter( "ImageReader" );
323
324   // Configure reader
325   TParameters* params = this->GetActiveFilterParameters( );
326   params->ClearStringList( "FileNames" );
327   for( auto nIt = fnames.begin( ); nIt != fnames.end( ); ++nIt )
328     params->AddToStringList( "FileNames", *nIt );
329
330   // Execute filter
331   return( this->_ReadData( parent ) );
332 }
333
334 // -------------------------------------------------------------------------
335 std::string cpPlugins::Interface::Plugins::
336 ReadImage( const std::string& parent )
337 {
338   // Load source
339   this->_ActivateIOFilter( "ImageReader" );
340
341   // Try to configure source
342   if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
343   {
344     this->DeactivateFilter( );
345     return( "" );
346
347   } // fi
348
349   // Execute filter
350   return( this->_ReadData( parent ) );
351 }
352
353 // -------------------------------------------------------------------------
354 std::string cpPlugins::Interface::Plugins::
355 ReadDicomSeries( const std::string& parent )
356 {
357   // Load source
358   this->_ActivateIOFilter( "DicomSeriesReader" );
359
360   // Try to configure source
361   if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
362   {
363     this->DeactivateFilter( );
364     return( "" );
365
366   } // fi
367
368   // Execute filter
369   return( this->_ReadData( parent ) );
370 }
371
372 // -------------------------------------------------------------------------
373 std::string cpPlugins::Interface::Plugins::
374 ReadMesh( const std::string& fname, const std::string& parent )
375 {
376   // Load source
377   this->_ActivateIOFilter( "MeshReader" );
378
379   // Configure reader
380   TParameters* params = this->GetActiveFilterParameters( );
381   params->SetString( "FileName", fname );
382
383   // Execute filter
384   return( this->_ReadData( parent ) );
385 }
386
387 // -------------------------------------------------------------------------
388 std::string cpPlugins::Interface::Plugins::
389 ReadMesh( const std::string& parent )
390 {
391   // Load source
392   this->_ActivateIOFilter( "MeshReader" );
393
394   // Try to configure source
395   if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
396   {
397     this->DeactivateFilter( );
398     return( "" );
399
400   } // fi
401
402   // Execute filter
403   return( this->_ReadData( parent ) );
404 }
405
406 // -------------------------------------------------------------------------
407 bool cpPlugins::Interface::Plugins::
408 WriteDataObject( const std::string& fname, const std::string& name )
409 {
410   typedef cpPlugins::Interface::Image _TImage;
411   typedef cpPlugins::Interface::Mesh  _TMesh;
412
413   // Activate sink
414   TDataObject* obj = this->GetData< TDataObject >( name );
415   if( dynamic_cast< cpPlugins::Interface::Image* >( obj ) != NULL )
416     this->_ActivateIOFilter( "ImageWriter" );
417   else if( dynamic_cast< cpPlugins::Interface::Mesh* >( obj ) != NULL )
418     this->_ActivateIOFilter( "MeshWriter" );
419   else
420   {
421     this->DeactivateFilter( );
422     return( false );
423
424   } // fi
425
426   // Configure writer
427   TParameters* params = this->GetActiveFilterParameters( );
428   params->SetString( "FileName", fname );
429
430   // Execute filter
431   return( this->_WriteData( name ) );
432 }
433
434 // -------------------------------------------------------------------------
435 bool cpPlugins::Interface::Plugins::
436 WriteDataObject( const std::string& name )
437 {
438   typedef cpPlugins::Interface::Image _TImage;
439   typedef cpPlugins::Interface::Mesh  _TMesh;
440
441   // Activate sink
442   TDataObject* obj = this->GetData< TDataObject >( name );
443   if( dynamic_cast< cpPlugins::Interface::Image* >( obj ) != NULL )
444     this->_ActivateIOFilter( "ImageWriter" );
445   else if( dynamic_cast< cpPlugins::Interface::Mesh* >( obj ) != NULL )
446     this->_ActivateIOFilter( "MeshWriter" );
447   else
448   {
449     this->DeactivateFilter( );
450     return( false );
451
452   } // fi
453
454   // Try to configure source
455   if( this->ConfigureActiveFilter( ) == TProcessObject::DialogResult_Cancel )
456   {
457     this->DeactivateFilter( );
458     return( false );
459
460   } // fi
461
462   // Execute filter
463   return( this->_WriteData( name ) );
464 }
465
466 // -------------------------------------------------------------------------
467 void cpPlugins::Interface::Plugins::
468 ClearDataObjects( )
469 {
470   this->m_DataObjects.clear( );
471 }
472
473 // -------------------------------------------------------------------------
474 void cpPlugins::Interface::Plugins::
475 DeleteDataObject( const std::string& name )
476 {
477   // Find and delete object
478   auto oIt = this->m_DataObjects.find( name );
479   if( oIt == this->m_DataObjects.end( ) )
480     return;
481   this->m_DataObjects.erase( oIt );
482
483   // Delete children
484   TStringContainer children;
485   this->GetChildren( children, name );
486   auto cIt = children.begin( );
487   for( ; cIt != children.end( ); ++cIt )
488     this->DeleteDataObject( *cIt );
489 }
490
491 // -------------------------------------------------------------------------
492 void cpPlugins::Interface::Plugins::
493 GetDataObjects( TStringContainer& names )
494 {
495   names.clear( );
496   auto oIt = this->m_DataObjects.begin( );
497   for( ; oIt != this->m_DataObjects.end( ); ++oIt )
498     names.insert( oIt->first );
499 }
500
501 // -------------------------------------------------------------------------
502 std::string cpPlugins::Interface::Plugins::
503 GetParent( const std::string& name ) const
504 {
505   // Find and delete object
506   auto oIt = this->m_DataObjects.find( name );
507   if( oIt != this->m_DataObjects.end( ) )
508     return( oIt->second.first );
509   else
510     return( "" );
511 }
512
513 // -------------------------------------------------------------------------
514 void cpPlugins::Interface::Plugins::
515 GetChildren( TStringContainer& names, const std::string& name ) const
516 {
517   names.clear( );
518   auto oIt = this->m_DataObjects.begin( );
519   for( ; oIt != this->m_DataObjects.end( ); ++oIt )
520     if( oIt->second.first == name )
521       names.insert( oIt->first );
522 }
523
524 // -------------------------------------------------------------------------
525 void cpPlugins::Interface::Plugins::
526 GetRoots( TStringContainer& names ) const
527 {
528   this->GetChildren( names, "" );
529 }
530
531 // -------------------------------------------------------------------------
532 bool cpPlugins::Interface::Plugins::
533 ActivateFilter( const std::string& name )
534 {
535   this->m_ActiveFilter = this->m_Interface.CreateObject( name );
536   if( this->m_ActiveFilter.IsNotNull( ) )
537   {
538     this->m_ActiveFilter->SetPlugins( this );
539     auto iIt = this->m_Interactors.begin( );
540     for( ; iIt != this->m_Interactors.end( ); ++iIt )
541       this->m_ActiveFilter->AddInteractor( *iIt );
542     return( true );
543   }
544   else
545     return( false );
546 }
547
548 // -------------------------------------------------------------------------
549 void cpPlugins::Interface::Plugins::
550 DeactivateFilter( )
551 {
552   this->m_ActiveFilter = NULL;
553 }
554
555 // -------------------------------------------------------------------------
556 bool cpPlugins::Interface::Plugins::
557 HasActiveFilter( ) const
558 {
559   return( this->m_ActiveFilter.IsNotNull( ) );
560 }
561
562 // -------------------------------------------------------------------------
563 bool cpPlugins::Interface::Plugins::
564 IsActiveFilterInteractive( ) const
565 {
566   if( this->m_ActiveFilter.IsNotNull( ) )
567     return( this->m_ActiveFilter->GetInteractive( ) );
568   else
569     return( false );
570 }
571
572 // -------------------------------------------------------------------------
573 void cpPlugins::Interface::Plugins::
574 GetActiveFilterInputsNames( TStringContainer& names ) const
575 {
576   if( this->m_ActiveFilter.IsNotNull( ) )
577     this->m_ActiveFilter->GetInputsNames( names );
578 }
579
580 // -------------------------------------------------------------------------
581 void cpPlugins::Interface::Plugins::
582 GetActiveFilterOutputsNames( TStringContainer& names ) const
583 {
584   if( this->m_ActiveFilter.IsNotNull( ) )
585     this->m_ActiveFilter->GetOutputsNames( names );
586 }
587
588 // -------------------------------------------------------------------------
589 bool cpPlugins::Interface::Plugins::
590 ConnectInputInActiveFilter(
591   const std::string& object_name, const std::string& input_name
592   )
593 {
594   if( this->m_ActiveFilter.IsNotNull( ) )
595   {
596     TDataObject* dobj = this->GetData< TDataObject >( object_name );
597     if( dobj != NULL )
598     {
599       this->m_ActiveFilter->SetInput( input_name, dobj );
600       return( true );
601
602     } // fi
603
604   } // fi
605   return( false );
606 }
607
608 // -------------------------------------------------------------------------
609 bool cpPlugins::Interface::Plugins::
610 SetOutputNameInActiveFilter(
611   const std::string& new_object_name, const std::string& output_name
612   )
613 {
614   if( this->m_ActiveFilter.IsNotNull( ) )
615     return(
616       this->m_ActiveFilter->SetOutputObjectName(
617         new_object_name, output_name
618         )
619       );
620   else
621     return( false );
622 }
623
624 // -------------------------------------------------------------------------
625 cpPlugins::Interface::Plugins::
626 TParameters* cpPlugins::Interface::Plugins::
627 GetActiveFilterParameters( )
628 {
629   if( this->m_ActiveFilter.IsNotNull( ) )
630     return( this->m_ActiveFilter->GetParameters( ) );
631   else
632     return( NULL );
633 }
634
635 // -------------------------------------------------------------------------
636 const cpPlugins::Interface::Plugins::
637 TParameters* cpPlugins::Interface::Plugins::
638 GetActiveFilterParameters( ) const
639 {
640   if( this->m_ActiveFilter.IsNotNull( ) )
641     return( this->m_ActiveFilter->GetParameters( ) );
642   else
643     return( NULL );
644 }
645
646 // -------------------------------------------------------------------------
647 cpPlugins::Interface::Plugins::
648 TProcessObject::DialogResult cpPlugins::Interface::Plugins::
649 ConfigureActiveFilter( )
650 {
651   if( this->m_ActiveFilter.IsNotNull( ) )
652     return( this->m_ActiveFilter->ExecConfigurationDialog( this->m_Widget ) );
653   else
654     return( TProcessObject::DialogResult_Cancel );
655 }
656
657 // -------------------------------------------------------------------------
658 bool cpPlugins::Interface::Plugins::
659 UpdateActiveFilter( TStringContainer& outputs, const std::string& parent )
660 {
661   if( this->m_ActiveFilter.IsNull( ) )
662     return( false );
663   
664   // Execute filter
665   this->BlockWidget( );
666   std::string err = this->m_ActiveFilter->Update( );
667   this->UnblockWidget( );
668
669   // Associate outputs
670   outputs.clear( );
671   if( err == "" )
672   {
673     std::set< std::string > names;
674     this->m_ActiveFilter->GetOutputsNames( names );
675     for( auto oIt = names.begin( ); oIt != names.end( ); ++oIt )
676     {
677       TDataObject* dobj =
678         this->m_ActiveFilter->GetOutput< TDataObject >( *oIt );
679       this->_InsertNewData( dobj, parent );
680       outputs.insert( dobj->GetName( ) );
681
682     } // rof
683     this->m_ActiveFilter->DisconnectOutputs( );
684     return( true );
685   }
686   else
687   {
688 #ifdef cpPlugins_Interface_QT4
689     if( this->m_Widget != NULL )
690       QMessageBox::critical(
691         this->m_Widget,
692         QMessageBox::tr( "Error reading image." ),
693         QMessageBox::tr( err.c_str( ) )
694         );
695     else
696       throw std::runtime_error(
697         std::string( "Error reading image: " ) + err
698         );
699 #else // cpPlugins_Interface_QT4
700     throw std::runtime_error(
701       std::string( "Error reading image: " ) + err
702       );
703 #endif // cpPlugins_Interface_QT4
704     return( false );
705
706   } // fi
707 }
708
709 // -------------------------------------------------------------------------
710 void cpPlugins::Interface::Plugins::
711 _UpdateLoadedPluginsInformation( )
712 {
713   this->m_LoadedFilters.clear( );
714   const TInterface::TClasses& cls = this->m_Interface.GetClasses( );
715   for( auto i = cls.begin( ); i != cls.end( ); ++i )
716   {
717     TProcessObject::Pointer o = this->m_Interface.CreateObject( i->first );
718     std::string name = o->GetClassName( );
719     std::string category = o->GetClassCategory( );
720
721     if(
722       category == "ImageReader" ||
723       category == "ImageWriter" ||
724       category == "MeshReader" ||
725       category == "MeshWriter" ||
726       category == "DicomSeriesReader"
727       )
728       this->m_IOFilters[ category ] = o;
729     else
730       this->m_LoadedFilters[ category ].insert( name );
731
732   } // rof
733 }
734
735 // -------------------------------------------------------------------------
736 bool cpPlugins::Interface::Plugins::
737 _ActivateIOFilter( const std::string& filter )
738 {
739   // Activate reader
740   auto fIt = this->m_IOFilters.find( filter );
741   if( fIt != this->m_IOFilters.end( ) )
742   {
743     this->m_ActiveFilter = fIt->second;
744     return( true );
745   }
746   else
747     return( false );
748 }
749
750 // -------------------------------------------------------------------------
751 std::string cpPlugins::Interface::Plugins::
752 _ReadData( const std::string& parent )
753 {
754   if( !( this->HasActiveFilter( ) ) )
755     return( "" );
756
757   TStringContainer outputs;
758   if( this->UpdateActiveFilter( outputs, parent ) )
759     return( *( outputs.begin( ) ) );
760   else
761     return( "" );
762 }
763
764 // ------------------------------------------------------------------------
765 bool cpPlugins::Interface::Plugins::
766 _WriteData( const std::string& name )
767 {
768   if( !( this->HasActiveFilter( ) ) )
769     return( false );
770
771   TStringContainer inputs;
772   this->GetActiveFilterInputsNames( inputs );
773   bool r = true;
774   for( auto iIt = inputs.begin( ); iIt != inputs.end( ); ++iIt )
775     r &= this->ConnectInputInActiveFilter( name, *iIt );
776
777   if( r )
778   {
779     TStringContainer outputs;
780     return( this->UpdateActiveFilter( outputs, "" ) );
781   }
782   else
783     return( false );
784 }
785
786 // -------------------------------------------------------------------------
787 bool cpPlugins::Interface::Plugins::
788 _InsertNewData( TDataObject* dobj, const std::string& parent )
789 {
790   if( parent != "" )
791   {
792     auto oIt = this->m_DataObjects.find( parent );
793     if( oIt == this->m_DataObjects.end( ) )
794       return( false );
795
796   } // fi
797   this->m_DataObjects[ dobj->GetName( ) ] = _TTreeNode( parent, dobj );
798   return( true );
799 }
800
801 // eof - $RCSfile$