1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: LightApp_Module.cxx
24 // Created: 6/20/2005 16:30:56 AM
27 #include "LightApp_Module.h"
29 #include "CAM_Application.h"
31 #include "LightApp_Application.h"
32 #include "LightApp_DataModel.h"
33 #include "LightApp_DataObject.h"
34 #include "LightApp_Study.h"
35 #include "LightApp_Preferences.h"
36 #include "LightApp_Selection.h"
37 #include "LightApp_Operation.h"
38 #include "LightApp_SwitchOp.h"
39 #include "LightApp_UpdateFlags.h"
40 #include "LightApp_ShowHideOp.h"
41 #include "LightApp_SelectionMgr.h"
43 #include <SUIT_Study.h>
44 #include <SUIT_DataObject.h>
45 #include <SUIT_DataBrowser.h>
46 #include <SUIT_Operation.h>
47 #include <SUIT_ViewManager.h>
48 #include <SUIT_ResourceMgr.h>
49 #include <SUIT_ShortcutMgr.h>
50 #include <SUIT_Desktop.h>
51 #include <SUIT_TreeModel.h>
52 #include <SUIT_Session.h>
54 #ifndef DISABLE_SALOMEOBJECT
55 #include <SALOME_ListIO.hxx>
58 #ifndef DISABLE_VTKVIEWER
59 #ifndef DISABLE_SALOMEOBJECT
60 #include <SVTK_ViewWindow.h>
61 #include <SVTK_ViewModel.h>
63 #include <VTKViewer_ViewWindow.h>
65 #include <VTKViewer_ViewModel.h>
67 #ifndef DISABLE_OCCVIEWER
68 #include <OCCViewer_ViewWindow.h>
69 #include <OCCViewer_ViewPort3d.h>
70 #ifndef DISABLE_SALOMEOBJECT
71 #include <SOCC_ViewModel.h>
73 #include <OCCViewer_ViewModel.h>
76 #ifndef DISABLE_GLVIEWER
77 #include <GLViewer_ViewFrame.h>
78 #include <GLViewer_ViewPort.h>
80 #ifndef DISABLE_PVVIEWER
81 #include <PVViewer_ViewManager.h>
82 #include <PVViewer_ViewWindow.h>
84 #ifndef DISABLE_PV3DVIEWER
85 #include <PV3DViewer_ViewWindow.h>
86 #include <PV3DViewer_ViewModel.h>
88 #ifndef DISABLE_PLOT2DVIEWER
89 #include <Plot2d_ViewWindow.h>
90 #include <Plot2d_ViewFrame.h>
91 #ifndef DISABLE_SALOMEOBJECT
92 #include <SPlot2d_ViewModel.h>
94 #include <Plot2d_ViewModel.h>
98 #include <QtxPopupMgr.h>
102 #include <QStringList>
108 LightApp_Module::LightApp_Module( const QString& name )
109 : CAM_Module( name ),
116 myIsFirstActivate( true )
121 LightApp_Module::~LightApp_Module()
127 /*!Initialize module.*/
128 void LightApp_Module::initialize( CAM_Application* app )
130 CAM_Module::initialize( app );
132 SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0;
134 resMgr->raiseTranslators( name() );
138 void LightApp_Module::windows( QMap<int, int>& ) const
143 void LightApp_Module::viewManagers( QStringList& ) const
147 /*!Context menu popup.*/
148 void LightApp_Module::contextMenuPopup( const QString& client, QMenu* menu, QString& /*title*/ )
150 LightApp_Selection* sel = createSelection();
151 sel->init( client, getApp()->selectionMgr() );
153 popupMgr()->setSelection( sel );
154 popupMgr()->setMenu( menu );
155 popupMgr()->updateMenu();
156 popupMgr()->setSelection( 0 );
159 /*!Update object browser.
160 * For updating model or whole object browser use update() method can be used.
162 void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel,
163 SUIT_DataObject* theDataObject )
165 if (!getApp()->objectBrowser())
167 bool upd = getApp()->objectBrowser()->autoUpdate();
168 getApp()->objectBrowser()->setAutoUpdate( false );
170 if( theIsUpdateDataModel ){
171 if( CAM_DataModel* aDataModel = dataModel() ){
172 if ( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) ) {
173 //SUIT_DataObject* aParent = NULL;
174 //if(theDataObject && theDataObject != aDataModel->root())
175 // aParent = theDataObject->parent();
177 LightApp_DataObject* anObject = dynamic_cast<LightApp_DataObject*>(theDataObject);
178 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(getApp()->activeStudy());
179 aModel->update( anObject, aStudy );
184 getApp()->objectBrowser()->setAutoUpdate( upd );
185 getApp()->objectBrowser()->updateTree( 0, false );
189 void LightApp_Module::selectionChanged()
193 /*! \brief If return false, selection will be cleared at module activation
195 bool LightApp_Module::isSelectionCompatible()
197 // return true if selected objects belong to this module
198 bool isCompatible = true;
199 #ifndef DISABLE_SALOMEOBJECT
200 SALOME_ListIO selected;
201 if ( LightApp_SelectionMgr *Sel = getApp()->selectionMgr() )
202 Sel->selectedObjects( selected );
204 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
205 LightApp_DataObject* aRoot = dynamic_cast<LightApp_DataObject*>( dataModel()->root() );
206 if ( aStudy && aRoot ) {
208 QString moduleDataType = aRoot->componentDataType();
209 // check data type of selection
210 SALOME_ListIteratorOfListIO It( selected );
211 for ( ; isCompatible && It.More(); It.Next()) {
212 Handle(SALOME_InteractiveObject) io = It.Value();
213 isCompatible = ( aStudy->componentDataType( io->getEntry() ) == moduleDataType );
220 /*!Activate module.*/
221 bool LightApp_Module::activateModule( SUIT_Study* study )
223 bool res = CAM_Module::activateModule( study );
225 if ( !isSelectionCompatible() )// PAL19290, PAL18352
226 getApp()->selectionMgr()->clearSelected();
228 if ( res && application() && application()->resourceMgr() )
229 application()->resourceMgr()->raiseTranslators( name() );
231 connect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
232 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
233 connect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
234 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
236 if ( mySwitchOp == 0 )
237 mySwitchOp = new LightApp_SwitchOp( this );
239 // Enable Display and Erase actions
240 if ( action(myDisplay) )
241 action(myDisplay)->setEnabled(true);
242 if ( action(myErase) )
243 action(myErase)->setEnabled(true);
245 application()->shortcutMgr()->setSectionEnabled( moduleName() );
247 /* BUG 0020498 : The Entry column is always shown at module activation
248 The registration of column is moved into LightApp_Application
250 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
251 LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
254 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
255 m->registerColumn( getApp()->objectBrowser(), EntryCol, LightApp_DataObject::EntryId );
256 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
262 /*!Deactivate module.*/
263 bool LightApp_Module::deactivateModule( SUIT_Study* study )
268 disconnect( application(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ),
269 this, SLOT( onViewManagerAdded( SUIT_ViewManager* ) ) );
270 disconnect( application(), SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
271 this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
273 // abort all operations
274 MapOfOperation::const_iterator anIt;
275 for( anIt = myOperations.begin(); anIt != myOperations.end(); anIt++ ) {
276 anIt.value()->abort();
279 // Disable Display and Erase action
280 if ( action(myDisplay) )
281 action(myDisplay)->setEnabled(false);
282 if ( action(myErase) )
283 action(myErase)->setEnabled(false);
285 application()->shortcutMgr()->setSectionEnabled( moduleName(), false );
287 /* BUG 0020498 : The Entry column is always shown at module activation
288 QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
289 LightApp_DataModel* m = dynamic_cast<LightApp_DataModel*>( dataModel() );
292 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
294 treeModel->setAppropriate( EntryCol, Qtx::Shown );
295 m->unregisterColumn( getApp()->objectBrowser(), EntryCol );
298 return CAM_Module::deactivateModule( study );
301 /*! Redefined to reset internal flags valid for study instance */
302 void LightApp_Module::studyClosed( SUIT_Study* theStudy )
304 CAM_Module::studyClosed( theStudy );
306 myIsFirstActivate = true;
308 LightApp_Application* app = dynamic_cast<LightApp_Application*>(application());
310 SUIT_DataBrowser* ob = app->objectBrowser();
311 if ( ob && ob->model() )
312 disconnect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
313 this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
318 void LightApp_Module::MenuItem()
323 void LightApp_Module::updateInfoPanel()
328 void LightApp_Module::createPreferences()
333 void LightApp_Module::preferencesChanged( const QString&, const QString& )
338 void LightApp_Module::message( const QString& )
342 /*!Gets application.*/
343 LightApp_Application* LightApp_Module::getApp() const
345 return (LightApp_Application*)application();
349 * \brief Update something in accordance with update flags
350 * \param theFlags - update flags
352 * Update viewer or/and object browser etc. in accordance with update flags ( see
353 * LightApp_UpdateFlags enumeration ). Derived modules can redefine this method for their
356 void LightApp_Module::update( const int theFlags )
358 if ( theFlags & UF_Model )
360 if( CAM_DataModel* aDataModel = dataModel() )
361 if( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) )
362 aModel->update( 0, dynamic_cast<LightApp_Study*>( getApp()->activeStudy() ) );
365 if ( theFlags & UF_ObjBrowser )
366 getApp()->objectBrowser()->updateTree( 0 );
368 if ( theFlags & UF_Controls )
370 if ( theFlags & UF_Viewer )
372 if ( SUIT_ViewManager* viewMgr = getApp()->activeViewManager() )
373 if ( SUIT_ViewWindow* viewWnd = viewMgr->getActiveView() )
375 #ifndef DISABLE_VTKVIEWER
376 #ifndef DISABLE_SALOMEOBJECT
377 if ( viewWnd->inherits( "SVTK_ViewWindow" ) )
378 ( (SVTK_ViewWindow*)viewWnd )->Repaint();
380 if ( viewWnd->inherits( "VTKViewer_ViewWindow" ) )
381 ( (VTKViewer_ViewWindow*)viewWnd )->Repaint();
384 #ifndef DISABLE_PV3DVIEWER
385 // if ( viewWnd->inherits( "SPV3D_ViewWindow" ) )
386 // ( (SPV3D_ViewWindow*)viewWnd )->Repaint();
387 // if ( viewWnd->inherits( "PV3DViewer_ViewWindow" ) )
388 // ( (PV3DViewer_ViewWindow*)viewWnd )->getMultiViewManager()->Repaint();
390 #ifndef DISABLE_OCCVIEWER
391 if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) )
392 ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate();
394 #ifndef DISABLE_PLOT2DVIEWER
395 if ( viewWnd->inherits( "Plot2d_ViewWindow" ) )
396 ( (Plot2d_ViewWindow*)viewWnd )->getViewFrame()->Repaint();
398 #ifndef DISABLE_GLVIEWER
399 if ( viewWnd->inherits( "GLViewer_ViewFrame" ) )
400 ( (GLViewer_ViewFrame*)viewWnd )->getViewPort()->onUpdate();
402 #ifndef DISABLE_PVVIEWER
403 // if ( viewWnd->inherits( "PVViewer_ViewWindow" ) )
404 // ( (PVViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate();
410 * \brief Updates controls
412 * Updates (i.e. disable/enable) controls states (menus, tool bars etc.). This method is
413 * called from update( UF_Controls ). You may redefine it in concrete module.
415 void LightApp_Module::updateControls()
419 /*!Create new instance of data model and return it.*/
420 CAM_DataModel* LightApp_Module::createDataModel()
422 return new LightApp_DataModel( this );
425 /*!Create and return instance of LightApp_Selection.*/
426 LightApp_Selection* LightApp_Module::createSelection() const
428 return new LightApp_Selection();
432 void LightApp_Module::onModelOpened()
437 void LightApp_Module::onModelSaved()
442 void LightApp_Module::onModelClosed()
446 /*!Gets popup manager.(create if not exist)*/
447 QtxPopupMgr* LightApp_Module::popupMgr()
451 myPopupMgr = new QtxPopupMgr( 0, this );
454 SUIT_Desktop* d = application()->desktop();
457 *disp = createAction( -1, tr( "TOP_SHOW" ), p, tr( "MEN_SHOW" ), tr( "STB_SHOW" ),
458 0, d, false, this, SLOT( onShowHide() ), QString("General:Show object(s)") ),
459 *erase = createAction( -1, tr( "TOP_HIDE" ), p, tr( "MEN_HIDE" ), tr( "STB_HIDE" ),
460 0, d, false, this, SLOT( onShowHide() ) , QString("General:Hide object(s)") ),
461 *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
462 0, d, false, this, SLOT( onShowHide() ) ),
463 *eraseAll = createAction( -1, tr( "TOP_ERASE_ALL" ), p, tr( "MEN_ERASE_ALL" ), tr( "STB_ERASE_ALL" ),
464 0, d, false, this, SLOT( onShowHide() ) );
465 myDisplay = actionId( disp );
466 myErase = actionId( erase );
467 myDisplayOnly = actionId( dispOnly );
468 myEraseAll = actionId( eraseAll );
470 myPopupMgr->insert( disp, -1, 0 );
471 myPopupMgr->insert( erase, -1, 0 );
472 myPopupMgr->insert( dispOnly, -1, 0 );
473 myPopupMgr->insert( eraseAll, -1, 0 );
474 myPopupMgr->insert( separator(), -1, 0 );
476 QString oneAndNotActive = "( count( $component ) = 1 ) and ( not( activeModule in $component ) ) and ( not($displayer={'%3'}) )";
477 QString uniform = "true in $canBeDisplayed and %1 and ( activeModule = '%2' )";
478 uniform = uniform.arg( oneAndNotActive ).arg( name() ).arg( LightApp_Application::moduleDisplayer( name() ) );
479 myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, QtxPopupMgr::VisibleRule );
480 myPopupMgr->setRule( erase, /*QString( "( isVisible ) and " ) + */ uniform, QtxPopupMgr::VisibleRule );
481 myPopupMgr->setRule( dispOnly, uniform, QtxPopupMgr::VisibleRule );
485 #ifndef DISABLE_OCCVIEWER
486 #ifndef DISABLE_SALOMEOBJECT
487 viewers.append( SOCC_Viewer::Type() );
489 viewers.append( OCCViewer_Viewer::Type() );
492 #ifndef DISABLE_VTKVIEWER
493 #ifndef DISABLE_SALOMEOBJECT
494 viewers.append( SVTK_Viewer::Type() );
496 viewers.append( VTKViewer_Viewer::Type() );
499 #ifndef DISABLE_PV3DVIEWER
500 // #ifndef DISABLE_SALOMEOBJECT
501 // viewers.append( SPV3D_ViewModel::Type() );
503 viewers.append( PV3DViewer_ViewModel::Type() );
506 #ifndef DISABLE_PLOT2DVIEWER
507 #ifndef DISABLE_SALOMEOBJECT
508 viewers.append( SPlot2d_Viewer::Type() );
510 viewers.append( Plot2d_Viewer::Type() );
514 if( !viewers.isEmpty() )
516 QString strViewers = "{ ", temp = "'%1' ";
517 QStringList::const_iterator anIt = viewers.begin(), aLast = viewers.end();
518 for( ; anIt!=aLast; anIt++ )
519 strViewers+=temp.arg( *anIt );
521 myPopupMgr->setRule( eraseAll, QString( "client in %1" ).arg( strViewers ), QtxPopupMgr::VisibleRule );
527 /*!Gets preferences.*/
528 LightApp_Preferences* LightApp_Module::preferences() const
530 LightApp_Preferences* pref = 0;
532 pref = getApp()->preferences();
536 /*!Add preference to preferences.*/
537 int LightApp_Module::addPreference( const QString& label )
539 LightApp_Preferences* pref = preferences();
543 int catId = pref->addPreference( moduleName(), -1 );
547 return pref->addPreference( label, catId );
550 /*!Add preference to preferences.*/
551 int LightApp_Module::addPreference( const QString& label, const int pId, const int type,
552 const QString& section, const QString& param )
554 LightApp_Preferences* pref = preferences();
558 return pref->addPreference( moduleName(), label, pId, type, section, param );
561 /*!Gets property of preferences.*/
562 QVariant LightApp_Module::preferenceProperty( const int id, const QString& prop ) const
565 LightApp_Preferences* pref = preferences();
567 var = pref->itemProperty( prop, id );
571 /*!Set property of preferences.*/
572 void LightApp_Module::setPreferenceProperty( const int id, const QString& prop, const QVariant& var )
574 LightApp_Preferences* pref = preferences();
576 pref->setItemProperty( prop, var, id );
580 * \brief Starts operation with given identifier
581 * \param id - identifier of operation to be started
583 * Module stores operations in map. This method starts operation by id.
584 * If operation isn't in map, then it will be created by createOperation method
585 * and will be inserted to map
587 void LightApp_Module::startOperation( const int id )
589 LightApp_Operation* op = 0;
590 if( myOperations.contains( id ) && reusableOperation( id ) )
591 op = myOperations[ id ];
594 op = createOperation( id );
597 myOperations.insert( id, op );
598 op->setModule( this );
599 connect( op, SIGNAL( stopped( SUIT_Operation* ) ), this, SLOT( onOperationStopped( SUIT_Operation* ) ) );
600 connect( op, SIGNAL( destroyed() ), this, SLOT( onOperationDestroyed() ) );
606 // be sure that operation has correct study pointer
607 op->setStudy( application() ? application()->activeStudy() : 0 );
613 * \brief Creates operation with given identifier
614 * \param id - identifier of operation to be started
615 * \return Pointer on created operation or NULL if operation is not created
617 * Creates operation with given id. You should not call this method, it will be called
618 * automatically from startOperation. You may redefine this method in concrete module to
621 LightApp_Operation* LightApp_Module::createOperation( const int id ) const
627 return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY );
628 else if( id==myErase )
629 return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE );
630 else if( id==myDisplayOnly )
631 return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY_ONLY );
632 else if( id==myEraseAll )
633 return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE_ALL );
639 * \brief Virtual protected slot called when operation stopped
640 * \param theOp - stopped operation
642 * Virtual protected slot called when operation stopped. Redefine this slot if you want to
643 * perform actions after stopping operation
645 void LightApp_Module::onOperationStopped( SUIT_Operation* /*theOp*/ )
650 * \brief Virtual protected slot called when operation destroyed
651 * \param theOp - destroyed operation
653 * Virtual protected slot called when operation destroyed. Redefine this slot if you want to
654 * perform actions after destroying operation. Base implementation removes pointer on
655 * destroyed operation from the map of operations
657 void LightApp_Module::onOperationDestroyed()
659 const QObject* s = sender();
660 if( s && s->inherits( "LightApp_Operation" ) )
662 const LightApp_Operation* op = ( LightApp_Operation* )s;
663 MapOfOperation::const_iterator anIt = myOperations.begin(),
664 aLast = myOperations.end();
665 for( ; anIt!=aLast; anIt++ )
666 if( anIt.value()==op )
668 myOperations.remove( anIt.key() );
675 Must be redefined in order to use standard displayer mechanism
676 \return displayer of module
678 LightApp_Displayer* LightApp_Module::displayer()
684 SLOT: called on activating of standard operations show/hide
686 void LightApp_Module::onShowHide()
688 if( !sender()->inherits( "QAction" ) || !popupMgr() )
691 QAction* act = ( QAction* )sender();
692 int id = actionId( act );
694 startOperation( id );
698 virtual SLOT: called on view manager adding
700 void LightApp_Module::onViewManagerAdded( SUIT_ViewManager* )
705 virtual SLOT: called on view manager removing
707 void LightApp_Module::onViewManagerRemoved( SUIT_ViewManager* )
712 \brief Returns instance of operation by its id; if there is no operation
713 corresponding to this id, null pointer is returned
714 \param id - operation id
715 \return operation instance
717 LightApp_Operation* LightApp_Module::operation( const int id ) const
719 return myOperations.contains( id ) ? myOperations[id] : 0;
723 virtual method called to manage the same operations
725 bool LightApp_Module::reusableOperation( const int /*id*/ )
732 \return true if module can copy the current selection
734 bool LightApp_Module::canCopy() const
741 \return true if module can paste previously copied data
743 bool LightApp_Module::canPaste() const
750 \brief Copies the current selection into clipboard
752 void LightApp_Module::copy()
758 \brief Pastes the current data in the clipboard
760 void LightApp_Module::paste()
766 \return true if module allows dragging the given object
768 bool LightApp_Module::isDraggable( const SUIT_DataObject* /*what*/ ) const
775 \return true if module allows dropping one or more objects (currently selected) on the object \c where
777 bool LightApp_Module::isDropAccepted( const SUIT_DataObject* /*where*/ ) const
784 Complete drag-n-drop operation by processing objects \a what being dragged, dropped to the line \a row
785 within the object \a where. The drop action being performed is specified by \a action.
787 void LightApp_Module::dropObjects( const DataObjectList& /*what*/, SUIT_DataObject* /*where*/,
788 const int /*row*/, Qt::DropAction /*action*/ )
793 \brief Return \c true if object can be renamed
795 bool LightApp_Module::renameAllowed( const QString& /*entry*/ ) const
801 Rename object by entry.
802 \param entry entry of the object
803 \param name new name of the object
804 \brief Return \c true if rename operation finished successfully, \c false otherwise.
806 bool LightApp_Module::renameObject( const QString& /*entry*/, const QString& /*name*/ )
812 Update visibility state for data objects
814 void LightApp_Module::updateModuleVisibilityState()
816 // update visibility state of objects
817 LightApp_Application* app = dynamic_cast<LightApp_Application*>(SUIT_Session::session()->activeApplication());
820 SUIT_DataBrowser* ob = app->objectBrowser();
821 if ( !ob || !ob->model() ) return;
823 if ( !myIsFirstActivate )
826 myIsFirstActivate = false;
828 // connect to click on item
829 connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
830 this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection );
831 // connect to click on item
832 connect( ob, SIGNAL( destroyed( QObject* ) ),
833 this, SLOT( onOBDestroyed() ), Qt::UniqueConnection );
835 SUIT_DataObject* rootObj = ob->root();
836 if ( !rootObj ) return;
838 DataObjectList listObj = rootObj->children( true );
840 SUIT_ViewModel* vmod = 0;
841 if ( SUIT_ViewManager* vman = app->activeViewManager() )
842 vmod = vman->getViewModel();
843 app->updateVisibilityState( listObj, vmod );
847 * \brief Virtual public slot
849 * This method is called after the object inserted into data view to update their visibility state
850 * This is default implementation
852 void LightApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
854 if ( !isActiveModule() ) return;
856 // change visibility of object
857 if ( !theObject || theColumn != SUIT_DataObject::VisibilityId ) return;
859 LightApp_Study* study = dynamic_cast<LightApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
860 if ( !study ) return;
862 LightApp_DataObject* lo = dynamic_cast<LightApp_DataObject*>( theObject );
865 // detect action index (from LightApp level)
868 if ( study->visibilityState( lo->entry() ) == Qtx::ShownState )
870 else if ( study->visibilityState( lo->entry() ) == Qtx::HiddenState )
874 startOperation( id );
877 void LightApp_Module::onOBDestroyed()
879 myIsFirstActivate = true;