#include "LightApp_Module.h"
#include "LightApp_DataModel.h"
#include "LightApp_DataOwner.h"
+#include "LightApp_Displayer.h"
#include "LightApp_Study.h"
#include "LightApp_Preferences.h"
#include "LightApp_PreferencesDlg.h"
#endif
connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
+ connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
+ connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
+ this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
+
// Set existing font for the python console in resources
if( !aResMgr->hasValue( "PyConsole", "font" ) )
/*!Protected SLOT. On study closed.*/
void LightApp_Application::onStudyClosed( SUIT_Study* s )
{
+ /*
+ disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
+ this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
+ */
+
// stop auto-save timer
myAutoSaveTimer->stop();
if ( desk ) {
connect( desk, SIGNAL( message( const QString& ) ),
this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection );
+ connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
}
}
{
emit operationFinished( theModuleName, theOperationName, theEntryList );
}
+
+/*!
+ Update visibility state of given objects
+*/
+void LightApp_Application::updateVisibilityState( DataObjectList& theList,
+ SUIT_ViewModel* theViewModel )
+{
+ if ( !theViewModel || theList.isEmpty() ) return;
+
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
+ if ( !aStudy ) return;
+
+ SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
+
+ for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
+
+ if ( !obj || aStudy->isComponent( obj->entry() ) )
+ continue;
+
+ LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
+ if ( anObjModule ) {
+ LightApp_Displayer* aDisplayer = anObjModule->displayer();
+ if ( aDisplayer ) {
+ Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
+ if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
+ if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
+ anObjState = Qtx::ShownState;
+ else
+ anObjState = Qtx::HiddenState;
+ }
+ aStudy->setVisibilityState( obj->entry(), anObjState );
+ }
+ }
+ }
+}
+
+/*!
+ * Called when window activated
+ */
+void LightApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
+{
+ SUIT_DataBrowser* anOB = objectBrowser();
+ if ( !anOB )
+ return;
+ SUIT_DataObject* rootObj = anOB->root();
+ if ( !rootObj )
+ return;
+
+ DataObjectList listObj = rootObj->children( true );
+
+ SUIT_ViewModel* vmod = 0;
+ if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
+ vmod = vman->getViewModel();
+ updateVisibilityState( listObj, vmod );
+}
+
+/*!
+ Called then view manager removed
+*/
+void LightApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
+{
+ ViewManagerList lst;
+ viewManagers( lst );
+ if ( lst.count() == 1) { // in case if closed last view window
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( activeStudy() );
+ if ( aStudy )
+ aStudy->setVisibilityStateForAll( Qtx::UnpresentableState );
+ }
+}
#include "LightApp.h"
#include <SUIT_TreeModel.h>
+#include <SUIT_DataObject.h>
#include <CAM_Application.h>
#include <QPointer>
class SUIT_DataBrowser;
class SUIT_Study;
class SUIT_Accel;
+class SUIT_ViewModel;
class CAM_Module;
class QString;
void emitOperationFinished( const QString&, const QString&, const QStringList& );
+ void updateVisibilityState( DataObjectList& theList,
+ SUIT_ViewModel* theViewModel );
+
signals:
void studyOpened();
void studySaved();
protected slots:
virtual void onDesktopActivated();
+ virtual void onViewManagerRemoved( SUIT_ViewManager* );
+ virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
void onNewWindow();
void onModuleActivation( const QString& );
void onCloseView( SUIT_ViewManager* );
- void onStudyCreated( SUIT_Study* );
- void onStudyOpened( SUIT_Study* );
- void onStudySaved( SUIT_Study* );
- void onStudyClosed( SUIT_Study* );
+ virtual void onStudyCreated( SUIT_Study* );
+ virtual void onStudyOpened( SUIT_Study* );
+ virtual void onStudySaved( SUIT_Study* );
+ virtual void onStudyClosed( SUIT_Study* );
void onWCDestroyed( QObject* );
#include <SUIT_ShortcutMgr.h>
#include <SUIT_Desktop.h>
#include <SUIT_TreeModel.h>
+#include <SUIT_Session.h>
#ifndef DISABLE_SALOMEOBJECT
#include <SALOME_ListIO.hxx>
myDisplay( -1 ),
myErase( -1 ),
myDisplayOnly( -1 ),
- myEraseAll( -1 )
+ myEraseAll( -1 ),
+ myIsFirstActivate( true )
{
}
m->registerColumn( getApp()->objectBrowser(), EntryCol, LightApp_DataObject::EntryId );
treeModel->setAppropriate( EntryCol, Qtx::Toggled );
}*/
+
+ if ( myIsFirstActivate ) {
+ updateModuleVisibilityState();
+ myIsFirstActivate = false;
+ }
+
return res;
}
return CAM_Module::deactivateModule( study );
}
+/*! Redefined to reset internal flags valid for study instance */
+void LightApp_Module::studyClosed( SUIT_Study* theStudy )
+{
+ CAM_Module::studyClosed( theStudy );
+
+ myIsFirstActivate = true;
+
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>(application());
+ if ( app ) {
+ SUIT_DataBrowser* ob = app->objectBrowser();
+ if ( ob && ob->model() )
+ disconnect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
+ this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
+ }
+}
+
/*!NOT IMPLEMENTED*/
void LightApp_Module::MenuItem()
{
{
return false;
}
+
+/*!
+ Update visibility state for data objects
+*/
+void LightApp_Module::updateModuleVisibilityState()
+{
+ // update visibility state of objects
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>(SUIT_Session::session()->activeApplication());
+ if ( !app ) return;
+
+ SUIT_DataBrowser* ob = app->objectBrowser();
+ if ( !ob || !ob->model() ) return;
+
+ // connect to click on item
+ connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
+ this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection );
+
+ SUIT_DataObject* rootObj = ob->root();
+ if ( !rootObj ) return;
+
+ DataObjectList listObj = rootObj->children( true );
+
+ SUIT_ViewModel* vmod = 0;
+ if ( SUIT_ViewManager* vman = app->activeViewManager() )
+ vmod = vman->getViewModel();
+ app->updateVisibilityState( listObj, vmod );
+}
+
+/*!
+ * \brief Virtual public slot
+ *
+ * This method is called after the object inserted into data view to update their visibility state
+ * This is default implementation
+ */
+void LightApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
+{
+ if ( !isActiveModule() ) return;
+
+ // change visibility of object
+ if ( !theObject || theColumn != SUIT_DataObject::VisibilityId ) return;
+
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+ if ( !study ) return;
+
+ LightApp_DataObject* lo = dynamic_cast<LightApp_DataObject*>( theObject );
+ if ( !lo ) return;
+
+ // detect action index (from LightApp level)
+ int id = -1;
+
+ if ( study->visibilityState( lo->entry() ) == Qtx::ShownState )
+ id = myErase;
+ else if ( study->visibilityState( lo->entry() ) == Qtx::HiddenState )
+ id = myDisplay;
+
+ if ( id != -1 )
+ startOperation( id );
+}
virtual bool renameAllowed( const QString& ) const;
virtual bool renameObject( const QString&, const QString& );
+ virtual void updateModuleVisibilityState();
+
public slots:
virtual bool activateModule( SUIT_Study* );
virtual bool deactivateModule( SUIT_Study* );
+ virtual void studyClosed( SUIT_Study* );
+ virtual void onObjectClicked( SUIT_DataObject*, int );
void MenuItem();
protected:
int myDisplay, myErase, myDisplayOnly, myEraseAll;
+ bool myIsFirstActivate;
};
#ifdef WIN32
*/
void SUIT_TreeModel::setVisibilityStateForAll( Qtx::VisibilityState state )
{
- if ( state != Qtx::UnpresentableState ) {
- VisibilityMap::ConstIterator it = myVisibilityMap.begin();
- while ( it != myVisibilityMap.end() ) {
- if ( it.value() != state )
- setVisibilityState( it.key(), state );
- it++;
- }
- }
- else {
- QList<QString> anIds = myVisibilityMap.keys();
- myVisibilityMap.clear();
- QList<QString>::ConstIterator it = anIds.begin();
- while ( it != anIds.end() ) {
- QModelIndexList lst;
- if ( searcher() ) {
- SUIT_DataObject* o = searcher()->findObject( *it );
- if ( o ) lst << index( o );
- }
- else {
- lst = match( index( 0, root()->customData( Qtx::IdType ).toInt() ), DisplayRole, (*it), 1, Qt::MatchExactly | Qt::MatchRecursive );
- }
- if ( !lst.isEmpty() ) {
- QModelIndex idx = index( lst.first().row(), SUIT_DataObject::VisibilityId ,lst.first().parent() );
- emit dataChanged( idx, idx );
- }
- it++;
- }
- }
+ foreach( QString id, myVisibilityMap.keys() )
+ setVisibilityState( id, state );
}
/*!
#include <LightApp_SelectionMgr.h>
#include <LightApp_NameDlg.h>
#include <LightApp_DataOwner.h>
-#include <LightApp_Displayer.h>
#include <CAM_Module.h>
SalomeApp_Application::SalomeApp_Application()
: LightApp_Application()
{
- connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
- this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
connect( desktop(), SIGNAL( message( const QString& ) ),
this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection );
myIsSiman = false; // default
LightApp_Application::setDesktop( desk );
if ( desk ) {
- connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
- this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection );
connect( desk, SIGNAL( message( const QString& ) ),
this, SLOT( onLoadDocMessage( const QString& ) ), Qt::UniqueConnection );
}
loadDockWindowsState();
- connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
- this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
-
-
objectBrowserColumnsVisibility();
}
-/*!Called on Save study operation*/
-void SalomeApp_Application::onStudySaved( SUIT_Study* study )
-{
- LightApp_Application::onStudySaved( study );
-
- // temporary commented
- /*if ( objectBrowser() ) {
- updateSavePointDataObjects( dynamic_cast<SalomeApp_Study*>( study ) );
- objectBrowser()->updateTree( study->root() );
- }*/
-}
-
/*!Called on Open study operation*/
void SalomeApp_Application::onStudyOpened( SUIT_Study* study )
{
loadDockWindowsState();
- connect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
- this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ), Qt::UniqueConnection );
-
objectBrowserColumnsVisibility();
// temporary commented
printf("Error: Can't Invoke method %s\n", qPrintable(aDataList[1]));
}
-/*!
- * Called when window activated
- */
-void SalomeApp_Application::onWindowActivated( SUIT_ViewWindow* theViewWindow )
-{
- SUIT_DataBrowser* anOB = objectBrowser();
- if( !anOB )
- return;
- SUIT_DataObject* rootObj = anOB->root();
- if( !rootObj )
- return;
-
- DataObjectList listObj = rootObj->children( true );
-
- SUIT_ViewModel* vmod = 0;
- if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
- vmod = vman->getViewModel();
- updateVisibilityState( listObj, vmod );
-}
-
-/*!
- Update visibility state of given objects
- */
-void SalomeApp_Application::updateVisibilityState( DataObjectList& theList,
- SUIT_ViewModel* theViewModel )
-{
- LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
-
- if(!theViewModel)
- return;
-
- SALOME_View* aView = dynamic_cast<SALOME_View*>( theViewModel );
-
- if (theList.isEmpty() || !aStudy)
- return;
-
- for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr ) {
- LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
-
- if (!obj || aStudy->isComponent(obj->entry()))
- continue;
-
- LightApp_Module* anObjModule = dynamic_cast<LightApp_Module*>(obj->module());
- Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
-
- if(anObjModule) {
- LightApp_Displayer* aDisplayer = anObjModule->displayer();
- if(aDisplayer) {
- if( aDisplayer->canBeDisplayed(obj->entry(), theViewModel->getType()) ) {
- if(aView && aDisplayer->IsDisplayed(obj->entry(),aView))
- anObjState = Qtx::ShownState;
- else
- anObjState = Qtx::HiddenState;
- }
- aStudy->setVisibilityState( obj->entry(), anObjState );
- }
- }
- }
-}
-
-/*!
- Called then view manager removed
-*/
-void SalomeApp_Application::onViewManagerRemoved( SUIT_ViewManager* )
-{
- ViewManagerList lst;
- viewManagers(lst);
- if( lst.count() == 1) { // in case if closed last view window
- LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
- if(aStudy)
- aStudy->setVisibilityStateForAll(Qtx::UnpresentableState);
- }
-}
-
/*!
Checks that an object can be renamed.
\param entry entry of the object
#include "SalomeApp.h"
#include <LightApp_Application.h>
-#include <SUIT_DataObject.h>
-
#include <omniORB4/CORBA.h>
//#include <SALOMEconfig.h>
class LightApp_Preferences;
class SalomeApp_Study;
#ifndef DISABLE_PYCONSOLE
- class SalomeApp_NoteBook;
+class SalomeApp_NoteBook;
#endif
class SUIT_Desktop;
-
-class SUIT_ViewModel;
class SALOME_LifeCycleCORBA;
virtual SalomeApp_NoteBook* getNoteBook() const;
#endif
- //! update visibility state of objects
- void updateVisibilityState( DataObjectList& theList,
- SUIT_ViewModel* theViewModel );
-
virtual bool renameAllowed( const QString& ) const;
virtual bool renameObject( const QString&, const QString& );
protected slots:
void onStudyCreated( SUIT_Study* );
- void onStudySaved( SUIT_Study* );
void onStudyOpened( SUIT_Study* );
- void onStudyClosed( SUIT_Study* );
- void onViewManagerRemoved( SUIT_ViewManager* );
-
protected:
virtual void createActions();
virtual SUIT_Study* createNewStudy();
void onOpenWith();
void onExtAction();
- void onWindowActivated( SUIT_ViewWindow* theViewWindow );
-
private:
void createExtraActions();
/*!Constructor.*/
SalomeApp_Module::SalomeApp_Module( const QString& name )
- : LightApp_Module( name ),
- myIsFirstActivate( true )
+ : LightApp_Module( name )
{
}
{
}
-
-/*!Activate module.*/
-bool SalomeApp_Module::activateModule( SUIT_Study* theStudy )
-{
- bool state = LightApp_Module::activateModule( theStudy );
-
- if (!myIsFirstActivate)
- return state;
-
- updateModuleVisibilityState();
-
- myIsFirstActivate = false;
-
- return state;
-}
-
/*!
* \brief Virtual public
*
void SalomeApp_Module::restoreVisualParameters(int savePoint)
{
}
-
-/*! Redefined to reset internal flags valid for study instance */
-void SalomeApp_Module::studyClosed( SUIT_Study* theStudy )
-{
- LightApp_Module::studyClosed( theStudy );
-
- myIsFirstActivate = true;
-
- LightApp_Application* app = dynamic_cast<LightApp_Application*>(application());
- if (!app)
- return;
-
- SUIT_DataBrowser* ob = app->objectBrowser();
- if (ob && ob->model())
- disconnect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
- this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
-}
-
-
-/*!
- * \brief Virtual public slot
- *
- * This method is called after the object inserted into data view to update their visibility state
- * This is default implementation
- */
-void SalomeApp_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
-{
- if (!isActiveModule())
- return;
- // change visibility of object
- if (!theObject || theColumn != SUIT_DataObject::VisibilityId )
- return;
-
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
- if( !study )
- return;
-
- LightApp_DataObject* lo = dynamic_cast<LightApp_DataObject*>(theObject);
- if(!lo)
- return;
-
- // detect action index (from LightApp level)
- int id = -1;
-
- if ( study->visibilityState(lo->entry()) == Qtx::ShownState )
- id = myErase;
- else if ( study->visibilityState(lo->entry()) == Qtx::HiddenState )
- id = myDisplay;
-
- if ( id != -1 )
- startOperation( id );
-}
-
-
-/*!
- Called then study closed
-*/
-void SalomeApp_Application::onStudyClosed( SUIT_Study* theStudy){
- LightApp_Application::onStudyClosed(theStudy);
-
- disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
- this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
-}
-
-
-void SalomeApp_Module::updateModuleVisibilityState() {
-
- // update visibility state of objects
- SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
- if (!app)
- return;
-
- SUIT_DataBrowser* ob = app->objectBrowser();
- if (!ob || !ob->model())
- return;
-
- // connect to click on item
- connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
- this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection );
-
- SUIT_DataObject* rootObj = ob->root();
- if( !rootObj )
- return;
-
- DataObjectList listObj = rootObj->children( true );
-
- SUIT_ViewModel* vmod = 0;
- if ( SUIT_ViewManager* vman = app->activeViewManager() )
- vmod = vman->getViewModel();
- app->updateVisibilityState( listObj, vmod );
-}
virtual void restoreVisualParameters(int savePoint);
virtual LightApp_Selection* createSelection() const;
- public slots:
- virtual bool activateModule( SUIT_Study* );
- virtual void studyClosed( SUIT_Study* );
- virtual void onObjectClicked( SUIT_DataObject*, int );
-
- virtual void updateModuleVisibilityState();
-
protected:
virtual CAM_DataModel* createDataModel();
virtual void extractContainers( const SALOME_ListIO&, SALOME_ListIO& ) const;
-
-
- protected:
- bool myIsFirstActivate;
};
#endif