SalomeApp_CheckFileDlg.h \
SalomeApp_Operation.h \
SalomeApp_Dialog.h \
- SalomeApp_UpdateFlags.h
+ SalomeApp_UpdateFlags.h \
+ SalomeApp_SwitchOp.cxx
# .po files to transform in .qm
PO_FILES = SalomeApp_images.po \
SalomeApp_ListView.cxx \
SalomeApp_CheckFileDlg.cxx \
SalomeApp_Operation.cxx \
- SalomeApp_Dialog.cxx
+ SalomeApp_Dialog.cxx \
+ SalomeApp_SwitchOp.cxx
LIB_MOC = SalomeApp_AboutDlg.h \
SalomeApp_Application.h \
SalomeApp_ListView.h \
SalomeApp_CheckFileDlg.h \
SalomeApp_Operation.h \
- SalomeApp_Dialog.h
+ SalomeApp_Dialog.h \
+ SalomeApp_SwitchOp.h
LIB_CLIENT_IDL = SALOMEDS.idl \
SALOME_Exception.idl \
SalomeApp_Dialog::SalomeApp_Dialog( QWidget* parent, const char* name, bool modal,
bool allowResize, const int f, WFlags wf )
: QtxDialog( parent, name, modal, allowResize, f, wf ),
- myIsExclusive( true )
+ myIsExclusive( true ),
+ myIsAutoResumed( false )
{
setObjectPixmap( "SalomeApp", tr( "ICON_SELECT" ) );
}
//! Set exclusive state
void setExclusive( const bool );
+ //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
+ bool isAutoResumed() const;
+
+ //! Set auto resumed state
+ void setAutoResumed( const bool );
+
//! Show widgets corresponding to id
void showObject( const int );
private:
ObjectMap myObjects;
QMap<int,QString> myTypeNames;
- bool myIsExclusive;
+ bool myIsExclusive, myIsAutoResumed;
QPixmap myPixmap;
};
#include "SalomeApp_Preferences.h"
#include "SalomeApp_UpdateFlags.h"
#include "SalomeApp_Operation.h"
+#include "SalomeApp_SwitchOp.h"
#include <OB_Browser.h>
SalomeApp_Module::SalomeApp_Module( const QString& name )
: CAM_Module( name ),
-myPopupMgr( 0 )
+myPopupMgr( 0 ),
+mySwitchOp( 0 )
{
}
op->setModule( this );
connect( op, SIGNAL( stopped( SUIT_Operation* ) ), this, SLOT( onOperationStopped( SUIT_Operation* ) ) );
connect( op, SIGNAL( destroyed() ), this, SLOT( onOperationDestroyed() ) );
+ if ( mySwitchOp == 0 )
+ {
+ mySwitchOp = new SalomeApp_SwitchOp( this );
+ printf( "sln: new SalomeApp_SwitchOp\n" );
+ }
+ mySwitchOp->connect( op );
}
}
class SalomeApp_Preferences;
class SalomeApp_SelectionManager;
class SalomeApp_Operation;
+class SalomeApp_SwitchOp;
/*
Class : SalomeApp_Module
private:
QtxPopupMgr* myPopupMgr;
MapOfOperation myOperations;
+ SalomeApp_SwitchOp* mySwitchOp;
};
#endif
#include <SUIT_Desktop.h>
+#include <qapplication.h>
+
/*
Class : SalomeApp_Operation
Description : Base class for all operations
{
if( e )
{
- if( isAutoResumed() &&
- ( e->type()==QEvent::Enter ||
- e->type()==QEvent::WindowActivate ||
- e->type()==QEvent::MouseButtonPress ||
- e->type()==QEvent::MouseButtonDblClick ) )
- resume();
+// if( isAutoResumed() &&
+// ( e->type()==QEvent::Enter ||
+// e->type()==QEvent::WindowActivate ||
+// e->type()==QEvent::MouseButtonPress ||
+// e->type()==QEvent::MouseButtonDblClick ) )
+// resume();
- else if( e->type()==QEvent::MouseButtonRelease ||
- e->type()==QEvent::MouseButtonDblClick ||
- e->type()==QEvent::MouseMove ||
- e->type()==QEvent::KeyPress ||
- e->type()==QEvent::KeyRelease )
+ if( e->type()==QEvent::MouseButtonRelease ||
+ e->type()==QEvent::MouseButtonDblClick ||
+ e->type()==QEvent::MouseMove ||
+ e->type()==QEvent::KeyPress ||
+ e->type()==QEvent::KeyRelease )
return true;
}
void SalomeApp_Operation::setDialogActive( const bool active )
{
if( dlg() )
+ {
if( active )
{
dlg()->removeEventFilter( this );
activateSelection();
+ dlg()->setActiveWindow();
}
else
dlg()->installEventFilter( this );
+ }
}
//=======================================================================
//! Check if operation will be resumed automatically when mouse enter the dialog
bool isAutoResumed() const;
-
-protected:
-
- //! Set auto resumed state
- void setAutoResumed( const bool );
-
- // Important virtual methods (should be redefined in the derived classes)
virtual SalomeApp_Dialog* dlg() const;
// Get dialog. This method should be redefined in derived classes
// 2. activated in resumeOperation method
// 3. hidden in abortOperation and commitOperation methods
+protected:
+
+ //! Set auto resumed state
+ void setAutoResumed( const bool );
+
+ // Important virtual methods (should be redefined in the derived classes)
+
virtual void setDialogActive( const bool );
// Change the active state of dialog (given by dlg())
--- /dev/null
+/**
+* SALOME SalomeApp
+*
+* Copyright (C) 2005 CEA/DEN, EDF R&D
+*
+*
+*
+* File : SalomeApp_SwitchOp.h
+* Author : Sergey LITONIN
+* Module : SALOME
+*/
+
+#include "SalomeApp_SwitchOp.h"
+#include "SalomeApp_Module.h"
+#include "SalomeApp_Operation.h"
+#include "SalomeApp_Dialog.h"
+#include <CAM_Application.h>
+#include <SUIT_Operation.h>
+#include <SUIT_Study.h>
+#include <qevent.h>
+#include <qwidget.h>
+#include <qptrlist.h>
+#include <qapplication.h>
+
+/*!
+ * \brief Constructor
+ * \param theParent - parent of object
+*
+* Creates instance of the object. Connects signals and slots. Install eveny filter
+* on application
+*/
+SalomeApp_SwitchOp::SalomeApp_SwitchOp( SalomeApp_Module* theModule )
+: QObject( theModule )
+{
+ qApp->installEventFilter( this );
+}
+
+/*!
+ * \brief Destructor
+*/
+SalomeApp_SwitchOp::~SalomeApp_SwitchOp()
+{
+
+}
+
+/*!
+ * \brief SLOT. Called when number of operations changed
+*
+*
+*/
+void SalomeApp_SwitchOp::onOperation()
+{
+}
+
+/*!
+ * \brief Get module
+*
+* Get module. Module is a parent of this class
+*/
+SalomeApp_Module* SalomeApp_SwitchOp::module() const
+{
+ return ( SalomeApp_Module* )parent();
+}
+
+/*!
+ * \brief Get study
+ * \return Active study of application (in current realisation)
+*
+* Get study
+*/
+SUIT_Study* SalomeApp_SwitchOp::study() const
+{
+ return module()->application()->activeStudy();
+}
+
+/*!
+ * \brief Get operation by widget
+ * \param theWg - key widget to find operation
+ * \return Pointer to the operations if it is found or zero
+*
+* Find operation containing dialog with given widget
+*/
+SalomeApp_Operation* SalomeApp_SwitchOp::operation( QWidget* theWg ) const
+{
+ // get dialog from widget
+ SalomeApp_Dialog* aDlg = 0;
+ QWidget* aParent = theWg;
+ while( aParent && !aParent->inherits( "SalomeApp_Dialog" ) )
+ aParent = aParent->parentWidget();
+
+ if ( aParent && aParent->inherits( "SalomeApp_Dialog" ) )
+ aDlg = (SalomeApp_Dialog*)aParent;
+
+ // try to find operation corresponding to the dialog
+ if ( aDlg != 0 && study() != 0 )
+ {
+ QPtrListIterator<SUIT_Operation> anIter( study()->operations() );
+ while( SUIT_Operation* anOp = anIter.current() )
+ {
+ if ( anOp->inherits( "SalomeApp_Operation" ) &&
+ ((SalomeApp_Operation*)anOp)->dlg() == aDlg )
+ return ((SalomeApp_Operation*)anOp);
+ ++anIter;
+ }
+ }
+
+ return 0;
+}
+
+/*!
+ * \brief Connect signals of operation on the slots of object
+ * \param theOp - operation for connection
+*
+* Connect signals of operation on the slots of object. This method is called by module
+* when it creates operation
+*/
+void SalomeApp_SwitchOp::connect( SalomeApp_Operation* theOp )
+{
+// to do: ???
+// void started( SUIT_Operation* );
+// void aborted( SUIT_Operation* );
+// void resumed( SUIT_Operation* );
+// void committed( SUIT_Operation* );
+// void suspended( SUIT_Operation* );
+// void stopped( SUIT_Operation* );
+}
+
+/*!
+ * \brief Event filter
+ * \param theObj - object
+ * \param theEv - event
+*
+* Event filter. Catched signals off application. If event concerns to dialog then
+* corresponding operation is found and activated.
+*/
+bool SalomeApp_SwitchOp::eventFilter( QObject* theObj, QEvent* theEv )
+{
+ if ( theObj->inherits( "QWidget" ) && ( theEv->type() == QEvent::Enter ) )
+ {
+ SalomeApp_Operation* anOp = operation( (QWidget*)theObj );
+ if ( anOp && !anOp->isActive() && anOp->isAutoResumed() )
+ {
+ if ( study() )
+ {
+ if ( study()->canActivate( anOp ) )
+ study()->resume( anOp );
+ }
+ }
+ }
+
+ return QObject::eventFilter( theObj, theEv );
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+/**
+* SALOME SalomeApp
+*
+* Copyright (C) 2005 CEA/DEN, EDF R&D
+*
+*
+*
+* File : SalomeApp_SwitchOp.h
+* Author : Sergey LITONIN
+* Module : SALOME
+*/
+
+
+
+#ifndef SalomeApp_SwitchOp_H
+#define SalomeApp_SwitchOp_H
+
+#include <qobject.h>
+
+class SalomeApp_Module;
+class SalomeApp_Operation;
+class QEvent;
+class SUIT_Study;
+
+/*!
+ * \brief This class is intended for controling switching between operation
+ *
+ * Several operation may be launched simultaneously. This class is intended for
+ * controlling switching between such operations. This class works with operations having
+ * dialogs (activation of other operations is performed by SUIT_Study). When several
+ * operations is launched simultaneously corresponding dialogs are shown on the screen.
+ * Only one operation from the launched ones can be active (active operation). Other
+ * operations are suspended. As result only one dialog from shown ones can be active too.
+ * Other dialogs are disabled. This class installs event filter on application. When mouse
+ * cursor is moved above disabled dialog corresponding event is catched by this class.
+ * It finds corresponding operation and verify whether operation can be resumed (see
+ * SUIT_Study::canActivate( SUIT_Operation* ) method). If yes then current active
+ * operation is suspended and new operation activated. Module contains this class as a
+ * field. Then module is created instance of this class created too.
+ */
+class SalomeApp_SwitchOp : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ SalomeApp_SwitchOp( SalomeApp_Module* );
+ virtual ~SalomeApp_SwitchOp();
+
+ void connect( SalomeApp_Operation* );
+
+ // Redefined from base class
+ bool eventFilter( QObject*, QEvent* );
+
+private slots:
+
+ void onOperation();
+
+private:
+
+ SalomeApp_Module* module() const;
+ SalomeApp_Operation* operation( QWidget* ) const;
+ SUIT_Study* study() const;
+
+private:
+
+
+};
+
+#endif
+
+
+
+
+
+