VISU_Event* ve = dynamic_cast<VISU_Event*>( se );
if ( ve ) {
switch ( se->getType() ) {
+ case VISU_Event::Create3DView:
+ case VISU_Event::CreateTableView:
+ case VISU_Event::CreateXYPlot:
+ case VISU_Event::DestroyView:
+ OnViewEvent( ve );
+ break;
case VISU_Event::CreateTestViewEvent:
- VisuGUI::CreateTestView();
+ CreateTestView();
break;
case VISU_Event::ShowTestObjectEvent:
- VisuGUI::ShowTestObject();
+ ShowTestObject();
break;
}
return true;
return ;
}
+// SAN - QT_EVENT prototype
+// SALOME event handlers
+//===========================================================
+/*!
+ * Function: VisuGUI::OnViewEvent
+ * Purpose: Handles events posted by VISU_ViewManager_i
+ */
+//===========================================================
+void VisuGUI::OnViewEvent( VISU_Event* e )
+{
+ if ( !e )
+ return;
+
+ VISU_ViewEvent* ve = dynamic_cast<VISU_ViewEvent*>( e );
+ if ( !ve )
+ return;
+
+ VISU::ViewManager_i* aVmImpl = dynamic_cast<VISU::ViewManager_i*>( ve->sender());
+ if ( !aVmImpl )
+ return;
+
+ switch( ve->getType() ) {
+ case VISU_Event::Create3DView:
+ {
+ VISU::View3D_ptr aView = aVmImpl->OnCreate3DView();
+ ve->setView( aView );
+ break;
+ }
+ case VISU_Event::CreateTableView:
+ {
+ VISU::Table_var aTable = VISU::Table::_narrow( ve->getArg() );
+ VISU::TableView_ptr aView = aVmImpl->OnCreateTableView( aTable.in() );
+ ve->setView( aView );
+ break;
+ }
+ case VISU_Event::CreateXYPlot:
+ {
+ VISU::XYPlot_ptr aView = aVmImpl->OnCreateXYPlot();
+ ve->setView( aView );
+ break;
+ }
+ case VISU_Event::DestroyView:
+ aVmImpl->OnDestroy( ve->getView() );
+ ve->setView( VISU::View::_nil() );
+ break;
+ default:
+ break;
+ }
+}
+
void VisuGUI::CreateTestView()
{
QAD_Desktop* desktop = VisuGUI::GetDesktop();
vf->getRenderer()->AddActor(sphere);
vf->Repaint();
}
+// SAN - QT_EVENT prototype
class VTKViewer_ViewFrame;
#include "VISUConfig.hh"
+class VISU_Event;
+class VISU_ViewEvent;
class VISU_Actor;
class VISU_MeshAct;
class VISU_ScalarMapAct;
static SALOMEDS::Study_var GetStudyDocument();
static SALOMEDS::StudyBuilder_var NewBuilder();
static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject);
- static void CreateTestView();
- static void ShowTestObject();
static VISU::Result_i* CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult);
void SelectionInfo();
+private:
+ // SAN - QT_EVENT prototype
+ // SALOME event handlers
+ void OnViewEvent( VISU_Event* e );
+
+ void CreateTestView();
+ void ShowTestObject();
+ // SAN - QT_EVENT prototype
+
private :
QDialog* myActiveDialogBox;
int myState ;
LIB_SRC = \
VISU_Event.cxx
+LIB_CLIENT_IDL = SALOME_GenericObj.idl \
+ VISU_Gen.idl
+
# additionnal information to compil and link file
CPPFLAGS += $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
* Constructor
*/
//===========================================================
-VISU_Event::VISU_Event( int eventType, bool wait, bool autoRelease ) : SALOME_Event ( eventType, wait, autoRelease )
+VISU_Event::VISU_Event( int eventType, bool wait, VISU::Base_i* aSender, bool autoRelease )
+: SALOME_Event ( eventType, wait, autoRelease ),
+ mySender( aSender )
{
}
//===========================================================
/*!
- * VISU_Event::VISU_Event
+ * VISU_Event::~VISU_Event
* Destructor
*/
//===========================================================
VISU_Event::~VISU_Event()
{
}
+
+//===========================================================
+/*!
+ * VISU_ViewEvent::VISU_ViewEvent
+ * Constructor
+ */
+//===========================================================
+VISU_ViewEvent::VISU_ViewEvent( int eventType, bool wait, VISU::Base_i* aSender, bool autoRelease )
+: VISU_Event ( eventType, wait, aSender, autoRelease )
+{
+ myArg = VISU::Base::_nil();
+ myView = VISU::View::_nil();
+}
+
+//===========================================================
+/*!
+ * VISU_ViewEvent::~VISU_ViewEvent
+ * Destructor
+ */
+//===========================================================
+VISU_ViewEvent::~VISU_ViewEvent()
+{
+}
+
+//===========================================================
+/*!
+ * Function: VISU_ViewEvent::SetArg
+ * Purpose: Sets argument of view creation
+ */
+//===========================================================
+void VISU_ViewEvent::setArg( VISU::Base_ptr theArg )
+{
+ myArg = theArg;
+}
+
+//===========================================================
+/*!
+ * Function: VISU_ViewEvent::GetArg
+ * Purpose: Returns argument of view creation
+ */
+//===========================================================
+VISU::Base_ptr VISU_ViewEvent::getArg()
+{
+ return myArg;
+}
+
+//===========================================================
+/*!
+ * Function: VISU_ViewEvent::SetView
+ * Purpose:
+ */
+//===========================================================
+void VISU_ViewEvent::setView( VISU::View_ptr theView )
+{
+ myView = theView;
+}
+
+//===========================================================
+/*!
+ * Function: VISU_ViewEvent::GetView
+ * Purpose:
+ */
+//===========================================================
+VISU::View_ptr VISU_ViewEvent::getView()
+{
+ return myView;
+}
+
#include "SALOME_Event.hxx"
+#include "VISUConfig.hh"
+
// VISU event types: 10000...10999
#define VISU_START_EVENT 10000
class VISU_Event : public SALOME_Event {
public:
enum {
- CreateTestViewEvent = VISU_START_EVENT,
+ Create3DView = VISU_START_EVENT,
+ CreateTableView,
+ CreateXYPlot,
+ DestroyView,
+ // san - test events
+ CreateTestViewEvent,
ShowTestObjectEvent,
+ // san - test events
LastEvent = VISU_START_EVENT + 1000 };
- VISU_Event( int eventType, bool wait, bool autoRelease = false );
+ VISU_Event( int eventType, bool wait, VISU::Base_i* sender = 0, bool autoRelease = false );
virtual ~VISU_Event();
- // Custom data can be added here...
+ VISU::Base_i* sender() { return mySender; }
+
+private:
+ VISU::Base_i* mySender;
+};
+
+class VISU_ViewEvent : public VISU_Event
+{
+public:
+ VISU_ViewEvent( int eventType, bool wait, VISU::Base_i* sender = 0, bool autoRelease = false );
+ virtual ~VISU_ViewEvent();
+
+ void setArg( VISU::Base_ptr );
+ VISU::Base_ptr getArg();
+
+ void setView( VISU::View_ptr );
+ VISU::View_ptr getView();
+private:
+ VISU::Base_ptr myArg;
+ VISU::View_ptr myView;
};
#endif
*/
void VISU_Gen_i::CreateTestView() {
if(myMutex){
- VISU_Event* ve = new VISU_Event( VISU_Event::CreateTestViewEvent, true );
+ VISU_Event* ve = new VISU_Event( VISU_Event::CreateTestViewEvent, true, this );
ve->process();
ve->release();
return;
void VISU_Gen_i::ShowTestObject() {
if(myMutex){
- VISU_Event* ve = new VISU_Event( VISU_Event::ShowTestObjectEvent, true );
+ VISU_Event* ve = new VISU_Event( VISU_Event::ShowTestObjectEvent, true, this );
ve->process();
ve->release();
return;
#include "VISU_ScalarBarActor.hxx"
#include "VISU_Actor.h"
+#include "VISU_Event.h"
+
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Tools.h"
}
}
}
+
+ QAD_Study* CheckStudy( SALOMEDS::Study_ptr theStudy ) {
+ QAD_Desktop* aDesktop = QAD_Application::getDesktop();
+ QAD_Study* aStudy = aDesktop->findStudy(theStudy);
+ if(!aStudy){
+ CORBA::String_var aName = theStudy->Name();
+ aFileInfo.setFile(aName.in());
+ if (aFileInfo.exists())
+ aStudy = aDesktop->loadStudy(aFileInfo.baseName());
+ else
+ aStudy = aDesktop->loadStudy(aName.in());
+ if (!aStudy) {
+ MESSAGE("CheckStudy()::ERROR: Can't load study");
+ }
+ }
+ return aStudy;
+ }
//===========================================================================
/*
#include <qthread.h>
myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
//TViewManager* aTViewManager = new TViewManager(theStudy);
//aTViewManager->start();
- QAD_Desktop* aDesktop = QAD_Application::getDesktop();
- QAD_Study* aStudy = aDesktop->findStudy(theStudy);
- if(!aStudy){
- CORBA::String_var aName = theStudy->Name();
- aFileInfo.setFile(aName.in());
- if (aFileInfo.exists())
- aStudy = aDesktop->loadStudy(aFileInfo.baseName());
- else aStudy = aDesktop->loadStudy(aName.in());
- if (!aStudy)
- MESSAGE("ViewManager_i::ERROR: Can't load study");
- }
}
VISU::View3D_ptr ViewManager_i::Create3DView(){
- Mutex mt(myMutex,qApp,MYDELAY);
if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView");
- VISU::View3D_i* pView = new View3D_i(myStudyDocument);
- if(pView->Create(1) != NULL)
- return VISU::View3D::_duplicate(pView->_this());
- return VISU::View3D::_nil();
+ VISU_ViewEvent* ve = new VISU_ViewEvent( VISU_Event::Create3DView, true, this );
+ ve->process();
+ VISU::View3D_ptr aView = VISU::View3D::_narrow( ve->getView() );
+ ve->release();
+ return aView;
}
VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){
if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot");
- Mutex mt(myMutex,qApp,MYDELAY);
- VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
- if(pView->Create(1) != NULL)
- return VISU::XYPlot::_duplicate(pView->_this());
- return VISU::XYPlot::_nil();
+ VISU_ViewEvent* ve = new VISU_ViewEvent( VISU_Event::CreateXYPlot, true, this );
+ ve->process();
+ VISU::XYPlot_ptr aView = VISU::XYPlot::_narrow( ve->getView() );
+ ve->release();
+ return aView;
}
VISU::TableView_ptr ViewManager_i::CreateTableView(VISU::Table_ptr theTable){
if(MYDEBUG) MESSAGE("ViewManager_i::CreateTableView");
- Mutex mt(myMutex,qApp,MYDELAY);
- VISU::TableView_i* pView = new TableView_i(myStudyDocument);
- if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL)
- return VISU::TableView::_duplicate(pView->_this());
- return VISU::TableView::_nil();
+ VISU_ViewEvent* ve = new VISU_ViewEvent( VISU_Event::CreateTableView, true, this );
+ ve->setArg( theTable );
+ ve->process();
+ VISU::TableView_ptr aView = VISU::TableView::_narrow( ve->getView() );
+ ve->release();
+ return aView;
}
void ViewManager_i::Destroy(View_ptr theView){
if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - "<<theView->_is_nil());
+ VISU_ViewEvent* ve = new VISU_ViewEvent( VISU_Event::DestroyView, true, this );
+ ve->setView( theView );
+ ve->process();
+ ve->release();
+ }
+
+ // SAN - QT_EVENT prototype
+ // SALOME event handlers
+ View3D_ptr ViewManager_i::OnCreate3DView() {
+ Mutex mt(myMutex,qApp,MYDELAY);
+ if(MYDEBUG) MESSAGE("ViewManager_i::OnCreate3DView");
+ // Make sure that myStudyDocument is opened in the desktop
+ if ( CheckStudy( myStudyDocument ) ) {
+ VISU::View3D_i* pView = new View3D_i(myStudyDocument);
+ if(pView->Create(1) != NULL)
+ return VISU::View3D::_duplicate(pView->_this());
+ }
+ return VISU::View3D::_nil();
+ }
+
+ VISU::TableView_ptr ViewManager_i::OnCreateTableView(VISU::Table_ptr theTable){
+ if(MYDEBUG) MESSAGE("ViewManager_i::OnCreateTableView");
+ Mutex mt(myMutex,qApp,MYDELAY);
+ if ( CheckStudy( myStudyDocument ) ) {
+ VISU::TableView_i* pView = new TableView_i(myStudyDocument);
+ if(pView->Create(VISU::Table::_duplicate(theTable)) != NULL)
+ return VISU::TableView::_duplicate(pView->_this());
+ }
+ return VISU::TableView::_nil();
+ }
+
+ VISU::XYPlot_ptr ViewManager_i::OnCreateXYPlot(){
+ if(MYDEBUG) MESSAGE("ViewManager_i::OnCreateXYPlot");
+ Mutex mt(myMutex,qApp,MYDELAY);
+ if ( CheckStudy( myStudyDocument ) ) {
+ VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument);
+ if(pView->Create(1) != NULL)
+ return VISU::XYPlot::_duplicate(pView->_this());
+ }
+ return VISU::XYPlot::_nil();
+ }
+
+ void ViewManager_i::OnDestroy(View_ptr theView){
+ if(MYDEBUG) MESSAGE("ViewManager_i::OnDestroy - "<<theView->_is_nil());
if(theView->_is_nil()) return;
CORBA::Object_var aView = VISU::View::_narrow(theView);
if(!CORBA::is_nil(aView)){
- if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - VISU::View"<<(!CORBA::is_nil(aView)));
+ if(MYDEBUG) MESSAGE("ViewManager_i::OnDestroy - VISU::View"<<(!CORBA::is_nil(aView)));
VISU::View_i* pView = dynamic_cast<VISU::View_i*>(VISU::GetServant(aView).in());
- if(MYDEBUG) MESSAGE("ViewManager_i::Destroy - dynamic_cast"<<pView);
+ if(MYDEBUG) MESSAGE("ViewManager_i::OnDestroy - dynamic_cast"<<pView);
if(pView) {
pView->Close();
pView->_remove_ref();
}
- //if(pView) delete pView;
return;
}
}
-
-
- void ViewManager_i::ProcessEvents() {
- while (true) {
- qApp->lock();
- qApp->syncX();
- qApp->flushX();
- qApp->processEvents();
- qApp->unlock();
- //sleep(1);
- }
- }
+ // SAN - QT_EVENT prototype
//===========================================================================
View_i::View_i(SALOMEDS::Study_ptr theStudy) {
if(MYDEBUG) MESSAGE("View_i::View_i");
CORBA::String_var aName = theStudy->Name();
- QAD_Desktop* aDesktop = QAD_Application::getDesktop();
- myStudy = aDesktop->findStudy(theStudy);
- if(!myStudy){
- aFileInfo.setFile(aName.in());
- if ( aFileInfo.exists() )
- myStudy = aDesktop->loadStudy(aFileInfo.baseName());
- else myStudy = aDesktop->loadStudy(aName.in());
- }
+ myStudy = CheckStudy(theStudy);
if(MYDEBUG) MESSAGE("View_i::View_i - isStudyOpened = "<<myStudy<<"; aName = "<<aName.in());
}
virtual ~ViewManager_i() {};
virtual VISU::VISUType GetType() { return VISU::TVIEWMANAGER;};
- virtual View3D_ptr Create3DView();
- virtual View_ptr GetCurrentView();
+ virtual View3D_ptr Create3DView();
+ virtual View_ptr GetCurrentView();
virtual TableView_ptr CreateTableView(VISU::Table_ptr theTable);
- virtual XYPlot_ptr CreateXYPlot();
- virtual void Destroy(View_ptr theView);
- virtual void ProcessEvents();
+ virtual XYPlot_ptr CreateXYPlot();
+ virtual void Destroy(View_ptr theView);
+
+ // SAN - QT_EVENT prototype
+ // SALOME event handlers
+ virtual View3D_ptr OnCreate3DView();
+ virtual TableView_ptr OnCreateTableView(VISU::Table_ptr theTable);
+ virtual XYPlot_ptr OnCreateXYPlot();
+ virtual void OnDestroy(View_ptr theView);
+ // SAN - QT_EVENT prototype
protected:
SALOMEDS::Study_var myStudyDocument;