#include <VTKViewer_ViewModel.h>
#endif
+#ifndef DISABLE_SALOMEOBJECT
+ #include <SALOME_Prs.h>
+ #include <SUIT_DataObject.h>
+#endif
+
//#ifndef DISABLE_SUPERVGRAPHVIEWER
// #include <SUPERVGraph_ViewModel.h>
// #include <SUPERVGraph_ViewFrame.h>
if( m )
m->paste();
}
+
+#ifndef DISABLE_SALOMEOBJECT
+/*!
+ Update visibility state of given objects
+ */
+void LightApp_Application::updateVisibilityState( DataObjectList& /*theList*/,
+ SALOME_View* /*theView*/ )
+{
+}
+#endif
class SUIT_Accel;
class CAM_Module;
+#ifndef DISABLE_SALOMEOBJECT
+class SALOME_View;
+#include <LightApp_DataObject.h>
+#endif
+
class QString;
class QWidget;
class QStringList;
//! Removes ViewManagers only of known type
virtual void clearKnownViewManagers();
+#ifndef DISABLE_SALOMEOBJECT
+ //! update visibility state of objects
+ virtual void updateVisibilityState( DataObjectList& theList,
+ SALOME_View* theView );
+#endif
+
signals:
void studyOpened();
void studySaved();
#include <CAM_Module.h>
#include <SUIT_DataObjectKey.h>
+#include <SUIT_DataObjectIterator.h>
#include <QVariant>
return CAM_DataObject::compare( left, right, id );
}
+/*!
+ \brief Constructor.
+ \param theRoot - main parent object
+ \param theMap - map of entry-object relation
+*/
+void LightApp_DataObject::FillEntryObjMap( SUIT_DataObject* theRoot,
+ LightApp_EntryObjMap& theMap )
+{
+ if (!theRoot)
+ return;
+ SUIT_DataObjectIterator it( theRoot, SUIT_DataObjectIterator::DepthLeft );
+ for ( ; it.current(); ++it ) {
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
+ if ( obj )
+ theMap.insert( obj->entry(), obj );
+ }
+}
+
/*!
\class LightApp_ModuleObject
\brief Used for optimized access to the data model from the data objects.
#include "LightApp.h"
#include <CAM_DataObject.h>
+#include <QMap>
class CAM_DataModel;
class LightApp_Study;
+class LightApp_DataObject;
+
+//! entry - data object relationship map
+typedef QMap<QString, LightApp_DataObject*> LightApp_EntryObjMap;
class LIGHTAPP_EXPORT LightApp_DataObject : public virtual CAM_DataObject
{
virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
virtual int groupId() const;
+ static void FillEntryObjMap( SUIT_DataObject* theRoot,
+ LightApp_EntryObjMap& theMap );
+
+
protected:
QString myCompDataType;
SUIT_DataObject* myCompObject;
#include <SUIT_ViewWindow.h>
#include <QString>
+#include <QStringList>
#ifndef DISABLE_SALOMEOBJECT
- #include "SALOME_InteractiveObject.hxx"
+#include <SALOME_InteractiveObject.hxx>
+#include <SUIT_DataObjectIterator.h>
#endif
/*!
\param updateViewer - is it necessary to update viewer
\param theViewFrame - view
*/
-void LightApp_Displayer::Display( const QString& entry, const bool updateViewer, SALOME_View* theViewFrame )
+void LightApp_Displayer::Display( const QString& entry, const bool updateViewer,
+ SALOME_View* theViewFrame, const bool updateVisState )
{
- SALOME_Prs* prs = buildPresentation( entry, theViewFrame );
- if ( prs )
+ QStringList aList;
+ aList.append( entry );
+ Display( aList, updateViewer, theViewFrame, updateVisState );
+}
+
+/*!
+ Displays object in view
+ \param list - object entries
+ \param updateViewer - is it necessary to update viewer
+ \param theViewFrame - view
+*/
+void LightApp_Displayer::Display( const QStringList& list, const bool updateViewer,
+ SALOME_View* theViewFrame, const bool updateVisState )
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+ QStringList::const_iterator it = list.constBegin();
+ for ( ; it != list.constEnd(); ++it)
{
- SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
- if ( vf )
+ SALOME_Prs* prs = buildPresentation( *it, vf );
+ if ( prs )
{
- vf->BeforeDisplay( this );
- vf->Display( prs );
- vf->AfterDisplay( this );
-
- if ( updateViewer )
- vf->Repaint();
+ if ( vf )
+ {
+ vf->BeforeDisplay( this );
+ vf->Display( prs );
+ vf->AfterDisplay( this );
+ if ( updateViewer )
+ vf->Repaint();
+ }
delete prs; // delete presentation because displayer is its owner
}
}
+ if ( updateVisState )
+ updateVisibilityState( list, vf );
}
/*!
SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
if( view && ( IsDisplayed( entry, view ) || view == GetActiveView() ) )
{
- Erase( entry, true, false, view );
- Display( entry, updateViewer, view );
+ Erase( entry, true, false, view, false );
+ Display( entry, updateViewer, view, false );
}
}
}
\param theViewFrame - view
*/
void LightApp_Displayer::Erase( const QString& entry, const bool forced,
- const bool updateViewer, SALOME_View* theViewFrame )
+ const bool updateViewer,
+ SALOME_View* theViewFrame, const bool updateVisState )
+{
+ QStringList aList;
+ aList.append( entry );
+ Erase( aList, forced, updateViewer, theViewFrame, updateVisState );
+}
+
+/*!
+ Erases object in view
+ \param list - object entries
+ \param forced - deletes object from viewer (otherwise it will be erased, but cached)
+ \param updateViewer - is it necessary to update viewer
+ \param theViewFrame - view
+*/
+void LightApp_Displayer::Erase( const QStringList& list, const bool forced,
+ const bool updateViewer,
+ SALOME_View* theViewFrame, const bool updateVisState )
{
SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
- if ( vf ) {
- SALOME_Prs* prs = vf->CreatePrs( entry.toLatin1() );
+ if ( !vf )
+ return;
+
+ QStringList::const_iterator it = list.constBegin();
+ for ( ; it != list.constEnd(); ++it)
+ {
+ SALOME_Prs* prs = vf->CreatePrs( (*it).toLatin1().data() );
if ( prs ) {
vf->Erase( prs, forced );
if ( updateViewer )
delete prs; // delete presentation because displayer is its owner
}
}
+ if ( updateVisState )
+ updateVisibilityState( list, vf );
}
/*!
\param updateViewer - is it necessary to update viewer
\param theViewFrame - view
*/
-void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) const
+void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer,
+ SALOME_View* theViewFrame, const bool updateVisState ) const
{
SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
if ( updateViewer )
vf->Repaint();
}
+ if ( updateVisState )
+ updateVisibilityState( vf );
+}
+
+/*!
+ updte visibility state of all objects
+ \param theViewFrame - view
+*/
+void LightApp_Displayer::updateVisibilityState( SALOME_View* theViewFrame ) const
+{
+ // this code wrapped by pre-processor directive, becase it works with SALOME_View
+ // and has no effect in case of SALOMEOBJECT disabled
+#ifndef DISABLE_SALOMEOBJECT
+ SUIT_Session* session = SUIT_Session::session();
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>(session->activeApplication());
+ if (!app)
+ return;
+ SUIT_Study* study = app->activeStudy();
+ if (!study)
+ return;
+
+ DataObjectList anObjList;
+ SUIT_DataObjectIterator it( study->root(), SUIT_DataObjectIterator::DepthLeft );
+ for ( ; it.current(); ++it )
+ anObjList.append( it.current() );
+ app->updateVisibilityState( anObjList, theViewFrame );
+#endif
+}
+
+/*!
+ updte visibility state of given objects
+ \param theList - objects to update state
+ \param theViewFrame - view
+*/
+void LightApp_Displayer::updateVisibilityState( const QStringList& theList,
+ SALOME_View* theViewFrame ) const
+{
+ // this code wrapped by pre-processor directive, becase it works with SALOME_View
+ // and has no effect in case of SALOMEOBJECT disabled
+#ifndef DISABLE_SALOMEOBJECT
+ SUIT_Session* session = SUIT_Session::session();
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>(session->activeApplication());
+ if (!app)
+ return;
+ SUIT_Study* study = app->activeStudy();
+ if (!study)
+ return;
+
+ LightApp_EntryObjMap anEntryObjMap;
+ LightApp_DataObject::FillEntryObjMap( study->root(), anEntryObjMap );
+ if (anEntryObjMap.isEmpty())
+ return;
+
+ // take data objects by entries
+ DataObjectList anObjList;
+ QStringList::const_iterator it = theList.constBegin();
+ for ( ; it != theList.constEnd(); ++it) {
+ if (anEntryObjMap.contains( *it ) )
+ anObjList.append( anEntryObjMap[ *it ] );
+ }
+
+ app->updateVisibilityState( anObjList, theViewFrame );
+#endif
}
/*!
#include <SALOME_Prs.h>
class QString;
+class QStringList;
/*!
\class LightApp_Displayer
LightApp_Displayer();
virtual ~LightApp_Displayer();
- void Display( const QString&, const bool = true, SALOME_View* = 0 );
- void Redisplay( const QString&, const bool = true );
- void Erase( const QString&, const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 );
- void EraseAll( const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ) const;
+ void Display( const QString&, const bool = true,
+ SALOME_View* = 0, const bool updateVisState = true );
+ void Display( const QStringList&, const bool = true,
+ SALOME_View* = 0, const bool updateVisState= true );
+ void Redisplay( const QString&, const bool = true );
+ void Erase( const QString&, const bool forced = false,
+ const bool updateViewer = true, SALOME_View* = 0, const bool updateVisState = true );
+ void Erase( const QStringList&, const bool forced = false,
+ const bool updateViewer = true, SALOME_View* = 0, const bool updateVisState = true );
+ void EraseAll( const bool forced = false, const bool updateViewer = true,
+ SALOME_View* = 0, const bool updateVisState = true ) const;
bool IsDisplayed( const QString&, SALOME_View* = 0 ) const;
void UpdateViewer() const;
protected:
virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
+
+ void updateVisibilityState( SALOME_View* theViewFrame ) const;
+ void updateVisibilityState( const QStringList& theList,
+ SALOME_View* theViewFrame ) const;
};
#endif
SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0;
if ( resMgr )
resMgr->raiseTranslators( name() );
+
+ // create show-hide actions
+ QPixmap p;
+ SUIT_Desktop* d = app->desktop();
+ QAction
+ *disp = createAction( -1, tr( "TOP_SHOW" ), p, tr( "MEN_SHOW" ), tr( "STB_SHOW" ),
+ 0, d, false, this, SLOT( onShowHide() ), QString("General:Show object(s)") ),
+ *erase = createAction( -1, tr( "TOP_HIDE" ), p, tr( "MEN_HIDE" ), tr( "STB_HIDE" ),
+ 0, d, false, this, SLOT( onShowHide() ) , QString("General:Hide object(s)") ),
+ *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
+ 0, d, false, this, SLOT( onShowHide() ) ),
+ *eraseAll = createAction( -1, tr( "TOP_ERASE_ALL" ), p, tr( "MEN_ERASE_ALL" ), tr( "STB_ERASE_ALL" ),
+ 0, d, false, this, SLOT( onShowHide() ) );
+ // store actions indeces in protected fields
+ myDisplay = actionId( disp );
+ myErase = actionId( erase );
+ myDisplayOnly = actionId( dispOnly );
+ myEraseAll = actionId( eraseAll );
}
/*!NOT IMPLEMENTED*/
{
myPopupMgr = new QtxPopupMgr( 0, this );
- QPixmap p;
- SUIT_Desktop* d = application()->desktop();
-
+ // take already created actions
QAction
- *disp = createAction( -1, tr( "TOP_SHOW" ), p, tr( "MEN_SHOW" ), tr( "STB_SHOW" ),
- 0, d, false, this, SLOT( onShowHide() ), QString("General:Show object(s)") ),
- *erase = createAction( -1, tr( "TOP_HIDE" ), p, tr( "MEN_HIDE" ), tr( "STB_HIDE" ),
- 0, d, false, this, SLOT( onShowHide() ) , QString("General:Hide object(s)") ),
- *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
- 0, d, false, this, SLOT( onShowHide() ) ),
- *eraseAll = createAction( -1, tr( "TOP_ERASE_ALL" ), p, tr( "MEN_ERASE_ALL" ), tr( "STB_ERASE_ALL" ),
- 0, d, false, this, SLOT( onShowHide() ) );
- myDisplay = actionId( disp );
- myErase = actionId( erase );
- myDisplayOnly = actionId( dispOnly );
- myEraseAll = actionId( eraseAll );
+ *disp = action( myDisplay ),
+ *erase = action( myErase ),
+ *dispOnly = action( myDisplayOnly ),
+ *eraseAll = action( myEraseAll );
myPopupMgr->insert( disp, -1, 0 );
myPopupMgr->insert( erase, -1, 0 );
return;
if( myEntries.count() == 0 || myModifiedTime < myBrowser->getModifiedTime() )
- fillEntries( myEntries );
+ fillEntries();
DataObjectList objList;
for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin();
\brief Fill map of the data objects currently shown in the Object Browser.
\param entries map to be filled
*/
-void LightApp_OBSelector::fillEntries( QMap<QString, LightApp_DataObject*>& entries )
+void LightApp_OBSelector::fillEntries()
{
- entries.clear();
+ myEntries.clear();
if ( !myBrowser )
return;
-
- for ( SUIT_DataObjectIterator it( myBrowser->root(),
- SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
- LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
- if ( obj )
- entries.insert( obj->entry(), obj );
- }
+ LightApp_DataObject::FillEntryObjMap( myBrowser->root(), myEntries );
setModified();
}
#define LIGHTAPP_OBSELECTOR_H
#include "LightApp.h"
+#include "LightApp_DataObject.h"
#include <SUIT_Selector.h>
#include <SUIT_DataOwner.h>
#include <QObject>
class SUIT_DataBrowser;
-class LightApp_DataObject;
class LIGHTAPP_EXPORT LightApp_OBSelector : public QObject, public SUIT_Selector
{
unsigned long getModifiedTime() const;
void setModified();
-
+
private slots:
void onSelectionChanged();
virtual void setSelection( const SUIT_DataOwnerPtrList& );
private:
- void fillEntries( QMap<QString, LightApp_DataObject*>& );
+ void fillEntries();
private:
- SUIT_DataBrowser* myBrowser;
- SUIT_DataOwnerPtrList mySelectedList;
- QMap<QString, LightApp_DataObject*> myEntries;
- unsigned long myModifiedTime;
+ SUIT_DataBrowser* myBrowser;
+ SUIT_DataOwnerPtrList mySelectedList;
+ LightApp_EntryObjMap myEntries;
+ unsigned long myModifiedTime;
};
#endif
void LightApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QString& theType,
const bool convertReferences ) const
{
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
+ if ( !study )
+ return;
+
theList.Clear();
SUIT_DataOwnerPtrList aList;
if( !owner )
continue;
- LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
- if ( !study )
- return;
-
entry = owner->entry();
// Entry to check object uniqueness.
// It is selected owner entry in the case, when we do not convert references,
const bool convertReferences ) const
{
theList.clear();
-
+
SUIT_DataOwnerPtrList aList;
selected( aList, theType );
if( !owner )
continue;
- LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
- if ( !study )
- return;
-
entry = owner->entry();
if( !theList.contains( entry ) )
theList.append( entry );
else
entries.append( entry );
}
+ // be sure to use real obejct entries
+ QStringList objEntries;
+ QStringList::const_iterator it = entries.begin(), last = entries.end();
+ for ( ; it!=last; ++it )
+ objEntries.append( study->referencedToEntry( *it ) );
+
+ if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
+ d->Display( objEntries, false, 0, true );
+ else if( myActionType==ERASE )
+ d->Erase( objEntries, false, false, 0, true );
- for( QStringList::const_iterator it = entries.begin(), last = entries.end(); it!=last; it++ )
- {
- QString e = study->referencedToEntry( *it );
- if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
- d->Display( e, false, 0 );
- else if( myActionType==ERASE )
- d->Erase( e, false, false, 0 );
- }
d->UpdateViewer();
commit();
}
class SALOME_View;
class SALOME_Displayer;
+class SALOME_ListIO;
class Handle_SALOME_InteractiveObject;
/*!
//! \retval Return false.
virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; }
virtual void Repaint() {} //!< Null body here.
+ virtual void GetVisible( SALOME_ListIO& theList ) {}
};
/*!
return myIOR;
}
+/*!
+ * Redefined to invokec correct version
+ */
+bool SALOME_PYQT_Module::activateModule( SUIT_Study* study )
+{
+ return SalomeApp_Module::activateModule( study );
+}
+
/*!
* Tries to get engine IOR from the Python module using engineIOR() function.
* That function can load module engine using appropriate container if required.
virtual QString engineIOR() const;
public slots:
+ virtual bool activateModule( SUIT_Study* );
void preferenceChanged( const QString&,
const QString&,
const QString& );
#include <SALOME_AISShape.hxx>
#include <SALOME_AISObject.hxx>
#include <SALOME_InteractiveObject.hxx>
+#include <SALOME_ListIO.hxx>
// Temporarily commented to avoid awful dependecy on SALOMEDS
// TODO: better mechanism of storing display/erse status in a study
return false;
}
+/*!
+ \Collect objects visible in viewer
+ \param theList - visible objects collection
+*/
+void SOCC_Viewer::GetVisible( SALOME_ListIO& theList )
+{
+ AIS_ListOfInteractive List;
+ getAISContext()->DisplayedObjects(List);
+
+ AIS_ListIteratorOfListOfInteractive ite(List);
+ for ( ; ite.More(); ite.Next() )
+ {
+ Handle(SALOME_InteractiveObject) anObj =
+ Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
+
+ if ( !anObj.IsNull() && anObj->hasEntry() )
+ theList.Append( anObj );
+ }
+}
+
/*!
Sets color of object
\param obj - object to be updated
#include "SALOME_Prs.h"
#include "OCCViewer_ViewModel.h"
+class SALOME_ListIO;
class Handle(SALOME_InteractiveObject);
class SOCC_EXPORT SOCC_Viewer: public OCCViewer_Viewer, public SALOME_View
virtual void LocalSelection( const SALOME_OCCPrs*, const int );
virtual void GlobalSelection( const bool = false ) const;
virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
+ virtual void GetVisible( SALOME_ListIO& );
virtual void Repaint();
// a utility function, used by SALOME_View_s methods
return aViewFrame->isVisible( curve );
}
+/*!
+ \Collect objects visible in viewer
+ \param theList - visible objects collection
+*/
+void SPlot2d_Viewer::GetVisible( SALOME_ListIO& theList )
+{
+ Plot2d_ViewFrame* aViewFrame = getActiveViewFrame();
+ if(aViewFrame == NULL) return;
+ CurveDict aCurves = aViewFrame->getCurves();
+ CurveDict::Iterator it = aCurves.begin();
+ for( ; it != aCurves.end(); ++it ) {
+ SPlot2d_Curve* aCurve = dynamic_cast<SPlot2d_Curve*>(it.value());
+ if ( aCurve && aCurve->hasIO() && aViewFrame->isVisible( aCurve ) )
+ theList.Append( aCurve->getIO() );
+ }
+}
+
/*!
Return interactive obeject if is presented in the viewer
*/
#include "SPlot2d.h"
-#include "SALOME_Prs.h"
+#include <SALOME_Prs.h>
#include "Plot2d_ViewModel.h"
-#include "SALOME_InteractiveObject.hxx"
+#include <SALOME_InteractiveObject.hxx>
+#include <SALOME_ListIO.hxx>
#include "Plot2d_ViewFrame.h"
#include "Plot2d_ViewWindow.h"
#include "SPlot2d_Curve.h"
virtual void BeforeDisplay( SALOME_Displayer* d );
virtual void AfterDisplay ( SALOME_Displayer* d );
virtual bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
+ virtual void GetVisible( SALOME_ListIO& theList );
/* operations */
void STD_Application::setDesktop( SUIT_Desktop* desk )
{
SUIT_Desktop* prev = desktop();
+ if ( prev == desk )
+ return;
+
+ if ( prev != 0 )
+ disconnect( prev, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
+ this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
SUIT_Application::setDesktop( desk );
- if ( prev != desk && desk )
+ if ( desk )
connect( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
}
if ( m ) {
SUIT_DataObject* obj = m->object( index );
- if ( obj ) emit( clicked( obj ) );
+ if ( obj )
+ {
+ emit( clicked( obj ) );
+ emit( clicked( obj, index.column() ) );
+ }
}
}
signals:
void requestUpdate();
void clicked( SUIT_DataObject* );
+ void clicked( SUIT_DataObject*, int );
void doubleClicked( SUIT_DataObject* );
private slots:
: myParent( 0 ),
myOpen( false ),
myCheck( false ),
- myAutoDel( true )
+ myAutoDel( true ),
+ myVisState( Unpresentable )
{
setParent( p );
signal()->emitCreated( this );
myOpen = on;
}
+/*!
+ \brief Returns the visibility state of the object.
+ \sa setVisibilityState()
+*/
+SUIT_DataObject::VisibilityState SUIT_DataObject::visibilityState() const
+{
+ return myVisState;
+}
+
+/*!
+ \brief Set the visibility state of the object.
+ \param on new "opened" state of the object
+ \sa isOpen()
+*/
+void SUIT_DataObject::setVisibilityState( const VisibilityState theState )
+{
+ if (myVisState == theState)
+ return;
+ myVisState = theState;
+ signal()->emitUpdated( this );
+}
+
/*!
\brief Check if the specified column supports custom sorting.
emit( removed( object, parent ) );
}
+/*!
+ \brief Emit signal about data object modification
+ \param object data object being updated
+*/
+void SUIT_DataObject::Signal::emitUpdated( SUIT_DataObject* object )
+{
+ if ( object )
+ emit updated( object );
+}
+
/*!
\brief Schedule data object for the late deleting.
\param object data object to be deleted later
//! Column id
enum
{
+ VisibilityId, //!< visibility state column
NameId //!< name column
};
+ //! object visibility state
+ typedef enum
+ {
+ Shown,
+ Hidden,
+ Unpresentable,
+ } VisibilityState;
+
SUIT_DataObject( SUIT_DataObject* = 0 );
virtual ~SUIT_DataObject();
virtual bool isOpen() const;
virtual void setOpen( const bool );
+ virtual VisibilityState visibilityState() const;
+ virtual void setVisibilityState( const VisibilityState );
+
virtual void update();
virtual bool customSorting( const int = NameId ) const;
virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const;
bool myCheck;
bool myAutoDel;
DataObjectList myChildren;
+ VisibilityState myVisState;
static Signal* mySignal;
void emitDestroyed( SUIT_DataObject* );
void emitInserted( SUIT_DataObject*, SUIT_DataObject* );
void emitRemoved( SUIT_DataObject*, SUIT_DataObject* );
+ void emitUpdated( SUIT_DataObject* );
void deleteLater( SUIT_DataObject* );
void destroyed( SUIT_DataObject* );
void inserted( SUIT_DataObject*, SUIT_DataObject* );
void removed( SUIT_DataObject*, SUIT_DataObject* );
+ void updated( SUIT_DataObject* );
friend class SUIT_DataObject;
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ),
+ this, SLOT( onUpdated( SUIT_DataObject* ) ) );
delete myRoot;
}
}
}
+/*!
+ \brief Return column name by group and custom indeces
+ \param group_id - unique data object group identificator
+ \param custom_id - custom column id that should be passed into method SUIT_DataObject::data()
+ \return column name or empty string if column not found
+ */
+QString SUIT_TreeModel::columnName( const int group_id, const int custom_id )
+{
+ QString name = QString::null;
+ for( int i = 0, n = myColumns.size(); i<n; ++i )
+ {
+
+ if (myColumns[i].myIds.contains( group_id ) &&
+ myColumns[i].myIds[ group_id ] == custom_id) {
+ name = myColumns[i].myName;
+ break;
+ }
+ }
+ return name;
+}
+
/*!
\brief Change column icon.
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ),
+ this, SLOT( onUpdated( SUIT_DataObject* ) ) );
delete myRoot;
}
// data size hint
// NOTE! not supported currently
break;
+ case VisibilityRole:
+ // visibility state
+ val = obj->visibilityState();
+ break;
default:
break;
} // ... switch ( role ) ...
return true;
}
break;
+ case VisibilityRole:
+ // visibility state
+ if ( (int)obj->visibilityState() != value.toInt() ) {
+ obj->setVisibilityState( (SUIT_DataObject::VisibilityState)value.toInt() );
+ emit( dataChanged( index, index ) );
+ return true;
+ }
+ break;
default:
break;
}
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ),
+ this, SLOT( onUpdated( SUIT_DataObject* ) ) );
myAutoUpdate = on;
if ( myAutoUpdate ) {
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::connect( SIGNAL( updated( SUIT_DataObject* ) ),
+ this, SLOT( onUpdated( SUIT_DataObject* ) ) );
updateTree();
}
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ),
+ this, SLOT( onUpdated( SUIT_DataObject* ) ) );
if ( autoUpdate() ) {
SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) );
SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ),
this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) );
+ SUIT_DataObject::connect( SIGNAL( updated( SUIT_DataObject* ) ),
+ this, SLOT( onUpdated( SUIT_DataObject* ) ) );
}
myItems.clear(); // ????? is it really necessary
if ( !myRootItem )
myRootItem = new TreeItem( 0 );
+ QString VisCol = QObject::tr( "VISIBILITY_COLUMN" );
+ registerColumn( 0, VisCol, SUIT_DataObject::VisibilityId );
registerColumn( 0, QObject::tr( "NAME_COLUMN" ), SUIT_DataObject::NameId );
+ setAppropriate( VisCol, Qtx::Hidden );
updateTree();
}
updateTree( parent );
}
+/*!
+ \brief Called when the data object is modified (their data updated)
+ \param object data object being modified
+*/
+void SUIT_TreeModel::onUpdated( SUIT_DataObject* object )
+{
+ if ( !object )
+ return;
+ // update all columns corresponding to the given data object
+ QModelIndex firstIdx = index( object, 0 );
+ QModelIndex lastIdx = index( object, columnCount() - 1 );
+ emit dataChanged( firstIdx, lastIdx );
+}
+
/*!
\class SUIT_ProxyModel
\brief Proxy model which can be used above the SUIT_TreeMovel class
treeModel()->unregisterColumn( group_id, name );
}
+/*!
+ \brief Return column name by group and custom indeces
+ \param group_id - unique data object group identificator
+ \param custom_id - custom column id that should be passed into method SUIT_DataObject::data()
+ \return column name or empty string if column not found
+ */
+QString SUIT_ProxyModel::columnName( const int group_id, const int custom_id )
+{
+ return treeModel() ? treeModel()->columnName( group_id, custom_id ) : QString::null;
+}
+
/*!
\brief Change column icon.
virtual void registerColumn( const int group_id, const QString& name, const int custom_id ) = 0;
virtual void unregisterColumn( const int group_id, const QString& name ) = 0;
+ virtual QString columnName( const int group_id, const int custom_id ) = 0;
virtual void setColumnIcon( const QString& name, const QPixmap& icon ) = 0;
virtual QPixmap columnIcon( const QString& name ) const = 0;
virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr ) = 0;
TextColorRole, //!< (editor) text color (Qt::UserRole + 1)
HighlightRole, //!< highlight color (Qt::UserRole + 2)
HighlightedTextRole, //!< highlighted text color (Qt::UserRole + 3)
+ VisibilityRole, //!< visibility state role (Qt::UserRole + 4)
AppropriateRole = Qtx::AppropriateRole //!< appropriate flag (Qt::UserRole + 100)
} Role;
virtual int rowCount( const QModelIndex& = QModelIndex() ) const;
virtual void registerColumn( const int group_id, const QString& name, const int custom_id );
virtual void unregisterColumn( const int group_id, const QString& name );
+ virtual QString columnName( const int group_id, const int custom_id );
virtual void setColumnIcon( const QString& name, const QPixmap& icon );
virtual QPixmap columnIcon( const QString& name ) const;
virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr );
private slots:
void onInserted( SUIT_DataObject*, SUIT_DataObject* );
void onRemoved( SUIT_DataObject*, SUIT_DataObject* );
+ void onUpdated( SUIT_DataObject* );
private:
typedef QMap<SUIT_DataObject*, TreeItem*> ItemMap;
virtual bool lessThan( const QModelIndex&, const QModelIndex& ) const;
virtual void registerColumn( const int group_id, const QString& name, const int custom_id );
virtual void unregisterColumn( const int group_id, const QString& name );
+ virtual QString columnName( const int group_id, const int custom_id );
virtual void setColumnIcon( const QString& name, const QPixmap& icon );
virtual QPixmap columnIcon( const QString& name ) const;
virtual void setAppropriate( const QString& name, const Qtx::Appropriate appr );
dist_salomescript_DATA = addvars2notebook.py
dist_salomeres_DATA = \
+ resources/icon_visibility_on.png \
+ resources/icon_visibility_off.png\
resources/SalomeApp.ini \
resources/SalomeApp.xml
-I$(srcdir)/../STD -I$(srcdir)/../VTKViewer -I$(srcdir)/../ObjBrowser \
-I$(srcdir)/../PyConsole -I$(srcdir)/../TOOLSGUI \
-I$(srcdir)/../PyInterp -I$(srcdir)/../Session -I$(top_builddir)/idl \
- -I$(srcdir)/../Event -I$(srcdir)/../CASCatch \
+ -I$(srcdir)/../Event -I$(srcdir)/../CASCatch -I$(srcdir)/../Prs \
@CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @LIBXML_INCLUDES@
libSalomeApp_la_LDFLAGS = $(PYTHON_LIBS) $(QT_MT_LIBS)
libSalomeApp_la_LIBADD = $(KERNEL_LDFLAGS) -lOpUtil -lSALOMELocalTrace -lSalomeDSClient \
../SVTK/libSVTK.la ../SOCC/libSOCC.la ../PyInterp/libPyInterp.la \
../PyConsole/libPyConsole.la ../LogWindow/libLogWindow.la \
../LightApp/libLightApp.la ../TOOLSGUI/libToolsGUI.la ../Session/libSalomeSession.la \
- ../Event/libEvent.la ../CASCatch/libCASCatch.la $(CAS_KERNEL)
+ ../Event/libEvent.la ../CASCatch/libCASCatch.la ../Prs/libSalomePrs.la $(CAS_KERNEL)
#include "SalomeApp_StudyPropertiesDlg.h"
#include "SalomeApp_LoadStudiesDlg.h"
#include "SalomeApp_NoteBookDlg.h"
+#include "SalomeApp_Module.h"
#include "SalomeApp_ExitDlg.h"
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_TreeModel.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewModel.h>
#include <QtxTreeView.h>
#include <SALOMEDSClient_ClientFactory.hxx>
#include <Basics_Utils.hxx>
-#include <SALOME_ListIteratorOfListIO.hxx>
#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_Prs.h>
#include <ToolsGUI_CatalogGeneratorDlg.h>
#include <ToolsGUI_RegWidget.h>
{
connect( desktop(), SIGNAL( message( const QString& ) ),
this, SLOT( onDesktopMessage( const QString& ) ) );
+ connect( desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
setNoteBook(0);
}
}
+/*!Set desktop:*/
+void SalomeApp_Application::setDesktop( SUIT_Desktop* desk )
+{
+ SUIT_Desktop* prev = desktop();
+ if ( prev == desk )
+ return;
+
+ if ( prev != 0 )
+ {
+ disconnect( prev, SIGNAL( message( const QString& ) ),
+ this, SLOT( onDesktopMessage( const QString& ) ) );
+ disconnect( prev, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
+ }
+
+ LightApp_Application::setDesktop( desk );
+
+ if ( desk != 0 )
+ {
+ connect( desk, SIGNAL( message( const QString& ) ),
+ this, SLOT( onDesktopMessage( const QString& ) ) );
+ connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
+ this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) );
+ }
+}
+
/*!
\brief Close application.
*/
EntryCol = QObject::tr( "ENTRY_COLUMN" );
SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
- treeModel->registerColumn( 0, EntryCol, SalomeApp_DataObject::EntryId );
- treeModel->registerColumn( 0, ValueCol, SalomeApp_DataObject::ValueId );
- treeModel->registerColumn( 0, IORCol, SalomeApp_DataObject::IORId );
- treeModel->registerColumn( 0, RefCol, SalomeApp_DataObject::RefEntryId );
- treeModel->setAppropriate( EntryCol, Qtx::Toggled );
- treeModel->setAppropriate( ValueCol, Qtx::Toggled );
- treeModel->setAppropriate( IORCol, Qtx::Toggled );
- treeModel->setAppropriate( RefCol, Qtx::Toggled );
-
+ if (treeModel)
+ {
+ treeModel->registerColumn( 0, EntryCol, SalomeApp_DataObject::EntryId );
+ treeModel->registerColumn( 0, ValueCol, SalomeApp_DataObject::ValueId );
+ treeModel->registerColumn( 0, IORCol, SalomeApp_DataObject::IORId );
+ treeModel->registerColumn( 0, RefCol, SalomeApp_DataObject::RefEntryId );
+ treeModel->setAppropriate( EntryCol, Qtx::Toggled );
+ treeModel->setAppropriate( ValueCol, Qtx::Toggled );
+ treeModel->setAppropriate( IORCol, Qtx::Toggled );
+ treeModel->setAppropriate( RefCol, Qtx::Toggled );
+ // show visibility column
+ treeModel->setAppropriate( treeModel->columnName( 0, SalomeApp_DataObject::VisibilityId ), Qtx::Toggled );
+ }
+
bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", true );
{
// update "non-existing" (not loaded yet) data models
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
+ SUIT_DataBrowser* ob = objectBrowser();
+ if ( !ob )
+ {
+ getWindow( WT_ObjectBrowser );
+ ob = objectBrowser();
+ }
+
if ( study )
{
_PTR(Study) stdDS = study->studyDS();
if ( aComponent->ComponentDataType() == "Interface Applicative" )
continue; // skip the magic "Interface Applicative" component
-
- if ( !objectBrowser() )
- getWindow( WT_ObjectBrowser );
- const bool isAutoUpdate = objectBrowser()->autoUpdate();
- objectBrowser()->setAutoUpdate( false );
- SalomeApp_DataModel::synchronize( aComponent, study );
- objectBrowser()->setAutoUpdate( isAutoUpdate );
+
+ if (ob)
+ {
+ const bool isAutoUpdate = ob->autoUpdate();
+ ob->setAutoUpdate( false );
+ SalomeApp_DataModel::synchronize( aComponent, study );
+ ob->setAutoUpdate( isAutoUpdate );
+ }
}
}
}
/*! Show/hide object browser colums according to preferences */
void SalomeApp_Application::objectBrowserColumnsVisibility()
{
- if ( objectBrowser() )
+ SUIT_DataBrowser* ob = objectBrowser();
+ if ( ob )
for ( int i = SalomeApp_DataObject::EntryId; i <= SalomeApp_DataObject::RefEntryId; i++ )
{
bool shown = resourceMgr()->booleanValue( "ObjectBrowser", QString( "visibility_column_id_%1" ).arg( i ), true );
- objectBrowser()->treeView()->setColumnHidden( i, !shown );
+ ob->treeView()->setColumnHidden( i, !shown );
}
}
if (!QMetaObject::invokeMethod(aModule, qPrintable(aDataList[1]), Q_ARG(QString, aEntry)))
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 );
+
+ SALOME_View* sView = 0;
+ if ( SUIT_ViewManager* vman = theViewWindow->getViewManager() )
+ if ( SUIT_ViewModel* vmod = vman->getViewModel() )
+ sView = dynamic_cast<SALOME_View*>( vmod );
+ updateVisibilityState( listObj, sView );
+}
+
+/*!
+ Update visibility state of given objects
+ */
+void SalomeApp_Application::updateVisibilityState( DataObjectList& theList,
+ SALOME_View* theView )
+{
+ if (theList.isEmpty() || !theView )
+ return;
+ // take visibale objects from current view
+ QMap<QString,int> aVisEntityMap;
+ SALOME_ListIO aListOfIO;
+ theView->GetVisible( aListOfIO );
+ SALOME_ListIteratorOfListIO anIter(aListOfIO);
+ for(; anIter.More(); anIter.Next())
+ {
+ Handle_SALOME_InteractiveObject& anObj = anIter.Value();
+ if (!anObj.IsNull() && anObj->hasEntry())
+ aVisEntityMap[ anObj->getEntry() ] = 1;
+ }
+
+ for ( DataObjectList::iterator itr = theList.begin(); itr != theList.end(); ++itr )
+ {
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>(*itr);
+ if (!obj) continue;
+ if (aVisEntityMap.contains( obj->entry() ) )
+ obj->setVisibilityState( SUIT_DataObject::Shown );
+ else if (obj->visibilityState() == SUIT_DataObject::Shown)
+ obj->setVisibilityState( SUIT_DataObject::Hidden );
+ }
+}
#include "SalomeApp.h"
#include <LightApp_Application.h>
+#include <SUIT_DataObject.h>
+
#include <CORBA.h>
//#include <SALOMEconfig.h>
class LightApp_Preferences;
class SalomeApp_Study;
class SalomeApp_NoteBookDlg;
-class SUIT_DataObject;
+class SUIT_Desktop;
+class SALOME_View;
class SALOME_LifeCycleCORBA;
virtual bool checkDataObject(LightApp_DataObject* theObj);
+ virtual void setDesktop( SUIT_Desktop* );
+
static CORBA::ORB_var orb();
static SALOMEDSClient_StudyManager* studyMgr();
static SALOME_NamingService* namingService();
virtual void setNoteBook(SalomeApp_NoteBookDlg* theNoteBook);
virtual SalomeApp_NoteBookDlg* getNoteBook() const;
+ //! update visibility state of objects
+ void updateVisibilityState( DataObjectList& theList,
+ SALOME_View* theView );
+
public slots:
virtual void onLoadDoc();
virtual bool onLoadDoc( const QString& );
void onOpenWith();
void onExtAction();
+ void onWindowActivated( SUIT_ViewWindow* theViewWindow );
+
private:
void createExtraActions();
#include <QObject>
#include <QVariant>
+#include <QMap>
/*!
\class SalomeApp_DataObject
return txt;
}
+/*!
+ \brief Map to store data object icons
+*/
+typedef QMap<QString,QPixmap> MapKeyPixmap;
+
/*!
\brief Get data object icon for the specified column.
\param id column id
*/
QPixmap SalomeApp_DataObject::icon( const int id ) const
{
- // we display icon only for the first (NameId ) column
+ // we display icon only for the NameId and VisibilityId columns
+ QString pixmapName = QString::null;
+ QString componentType = QString::null;
if ( id == NameId ) {
+ componentType = componentDataType();
_PTR(GenericAttribute) anAttr;
if ( myObject && myObject->FindAttribute( anAttr, "AttributePixMap" ) ){
_PTR(AttributePixMap) aPixAttr ( anAttr );
if ( aPixAttr->HasPixMap() ) {
- QString componentType = componentDataType();
- QString pixmapID = aPixAttr->GetPixMap().c_str();
+ QString pixmapID = aPixAttr->GetPixMap().c_str();
// select a plugin within a component
QStringList plugin_pixmap = pixmapID.split( "::", QString::KeepEmptyParts );
if ( plugin_pixmap.size() == 2 ) {
componentType = plugin_pixmap.front();
pixmapID = plugin_pixmap.back();
}
- QString pixmapName = QObject::tr( pixmapID.toLatin1().constData() );
- LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
- if ( aRoot && aRoot->study() ) {
- SUIT_ResourceMgr* mgr = aRoot->study()->application()->resourceMgr();
- return mgr->loadPixmap( componentType, pixmapName, false );
- }
+ pixmapName = QObject::tr( pixmapID.toLatin1().constData() );
}
}
}
+ else if ( id == VisibilityId ) {
+ componentType = "SalomeApp";
+ if (visibilityState() == Shown)
+ pixmapName = QObject::tr( "ICON_DATAOBJ_VISIBLE" );
+ else if (visibilityState() == Hidden)
+ pixmapName = QObject::tr( "ICON_DATAOBJ_INVISIBLE" );
+ else
+ return QPixmap();
+ }
+ if (pixmapName.isEmpty())
+ return LightApp_DataObject::icon( id );
+
+ // here we assume that user doesnot reaplce icons during application work
+ static QMap<QString,MapKeyPixmap> CompKeyMap;
+ if (!CompKeyMap.contains ( componentType ))
+ CompKeyMap.insert( componentType, MapKeyPixmap() );
+ MapKeyPixmap& keyPixMap = CompKeyMap[ componentType ];
+ if (!keyPixMap.contains( pixmapName ))
+ {
+ // load from resources
+ SUIT_ResourceMgr* mgr = 0;
+ LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
+ if ( aRoot && aRoot->study() )
+ mgr = aRoot->study()->application()->resourceMgr();
+ if (mgr)
+ keyPixMap.insert( pixmapName, mgr->loadPixmap( componentType, pixmapName, false ) );
+ }
+ if (keyPixMap.contains( pixmapName ))
+ return keyPixMap[ pixmapName ];
+
return LightApp_DataObject::icon( id );
}
#include "SalomeApp_DataModel.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Study.h"
+#include "SalomeApp_DataObject.h"
#include "LightApp_Selection.h"
+#include "LightApp_DataObject.h"
#include "CAM_DataModel.h"
#include <SALOME_InteractiveObject.hxx>
#include <SUIT_Session.h>
+#include <SUIT_DataObject.h>
+#include <SUIT_DataBrowser.h>
#include <QString>
/*!Constructor.*/
SalomeApp_Module::SalomeApp_Module( const QString& name )
-: LightApp_Module( name )
+ : LightApp_Module( name ),
+ myIsFirstActivate( true )
{
+ SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ),
+ this, SLOT( onObjectInserted( SUIT_DataObject* ) ) );
}
/*!Destructor.*/
{
}
+/*!Returns module data object module*/
+static SalomeApp_Module* objectModule( CAM_Application* theApp,
+ SalomeApp_DataObject* theObj )
+{
+ SalomeApp_Module* mod = 0;
+ if ( !theApp || !theObj )
+ return mod;
+
+ mod = dynamic_cast<SalomeApp_Module*>
+ (theApp->module(theApp->moduleTitle( theObj->componentDataType() )));
+
+ return mod;
+}
+
+/*! 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)
+ disconnect( ob, SIGNAL( clicked( SUIT_DataObject*, int ) ),
+ this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
+}
+
+/*!Activate module.*/
+bool SalomeApp_Module::activateModule( SUIT_Study* theStudy )
+{
+ bool state = LightApp_Module::activateModule( theStudy );
+ if (!myIsFirstActivate)
+ return state;
+
+ myIsFirstActivate = false;
+
+ // update visibility state of objects
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>(application());
+ if (!app)
+ return state;
+
+ SUIT_DataBrowser* ob = app->objectBrowser();
+ if (!ob)
+ return state;
+
+ // connect to click on item
+ connect( ob, SIGNAL( clicked( SUIT_DataObject*, int ) ),
+ this, SLOT( onObjectClicked( SUIT_DataObject*, int ) ) );
+
+ SUIT_DataObject* rootObj = ob->root();
+ if( !rootObj )
+ return state;
+ DataObjectList listObj = rootObj->children( true );
+ for ( DataObjectList::iterator itr = listObj.begin(); itr != listObj.end(); ++itr )
+ {
+ SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(*itr);
+ if ( !obj || dynamic_cast<LightApp_ModuleObject*>(obj) || obj->isReference() )
+ continue;
+
+ SalomeApp_Module* mod = objectModule( app, obj );
+ if (mod && mod == this)
+ mod->initVisibilityState( obj );
+ }
+ return state;
+}
+
+/*!
+ * \brief Virtual public slot
+ *
+ * This method is called after the object inserted into data view
+ * This is default implementation
+ */
+void SalomeApp_Module::onObjectInserted( SUIT_DataObject* theObject )
+{
+ SalomeApp_DataObject* anObj = dynamic_cast<SalomeApp_DataObject*>( theObject );
+ if (!anObj)
+ return;
+
+ // no visibility state for module root and reference objects
+ if ( dynamic_cast<LightApp_ModuleObject*>(anObj) || anObj->isReference())
+ {
+ anObj->setVisibilityState( SUIT_DataObject::Unpresentable );
+ return;
+ }
+
+ // update visibility state in native object module
+ SalomeApp_Module* mod = objectModule( application(), anObj );
+ if ( mod )
+ mod->initVisibilityState( anObj );
+}
+
+/*!
+ * \brief Virtual protected method
+ *
+ * This method is intended to update their visibility state
+ * This is default implementation
+ */
+void SalomeApp_Module::initVisibilityState( SUIT_DataObject* theObject )
+{
+ if ( theObject )
+ theObject->setVisibilityState( SUIT_DataObject::Unpresentable );
+}
+
+/*!
+ * \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;
+ // detect action index (from LightApp level)
+ int id = -1;
+ if ( theObject->visibilityState() == SUIT_DataObject::Shown )
+ id = myErase;
+ else if ( theObject->visibilityState() == SUIT_DataObject::Hidden )
+ id = myDisplay;
+ if ( id != -1 )
+ startOperation( id );
+}
class LightApp_Selection;
class SALOME_ListIO;
class QString;
+class SUIT_DataObject;
/*!
* \brief Base class for all salome modules
virtual void restoreVisualParameters(int savePoint);
virtual LightApp_Selection* createSelection() const;
+public slots:
+ virtual bool activateModule( SUIT_Study* );
+ virtual void studyClosed( SUIT_Study* );
+ virtual void onObjectInserted( SUIT_DataObject* );
+ virtual void onObjectClicked( SUIT_DataObject*, int );
+
protected:
virtual CAM_DataModel* createDataModel();
virtual void extractContainers( const SALOME_ListIO&, SALOME_ListIO& ) const;
+ virtual void initVisibilityState( SUIT_DataObject* );
+
+ protected:
+ bool myIsFirstActivate;
};
#endif
See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-->
+<context>
+ <name>@default</name>
+ <message>
+ <source>ICON_DATAOBJ_VISIBLE</source>
+ <translation>icon_visibility_on.png</translation>
+ </message>
+ <message>
+ <source>ICON_DATAOBJ_INVISIBLE</source>
+ <translation>icon_visibility_off.png</translation>
+ </message>
+</context>
</TS>