#ifndef DISABLE_PVVIEWER
#include "PVViewer_ViewModel.h"
+#include "PVViewer_GUIElements.h"
#endif
+
+#include "MEDFactoryClient.hxx"
+#include "MEDPresentationManager_i.hxx"
#include <QTimer>
#include <sstream>
+#include <pqAnimationManager.h>
+#include <pqPVApplicationCore.h>
+
+
//! The only instance of the reference to engine
-MED_ORB::MED_Gen_var MEDModule::myEngine;
+MED_ORB::MED_Gen_var MEDModule::_MED_engine;
+//! The only instance of the MEDPresentationManager
+MEDCALC::MEDPresentationManager_ptr MEDModule::_presManager;
MEDModule::MEDModule() :
- SalomeApp_Module("MED"), _studyEditor(0), _datasourceController(0), _workspaceController(0),
- _presentationController(0), _processingController(0)
+ SalomeApp_Module("MED"), _studyEditor(0),
+ _datasourceController(0), _workspaceController(0), _presentationController(0),
+ _processingController(0), _pvGuiElements(0)
{
// Note also that we can't use the getApp() function here because
// the initialize(...) function has not been called yet.
MEDModule::engine()
{
init(); // initialize engine, if necessary
- return myEngine;
+ return _MED_engine;
}
void
MEDModule::init()
{
// initialize MED module engine (load, if necessary)
- if ( CORBA::is_nil( myEngine ) ) {
+ if ( CORBA::is_nil( _MED_engine ) ) {
Engines::EngineComponent_var comp =
SalomeApp_Application::lcc()->FindOrLoad_Component( "FactoryServer", "MED" );
- myEngine = MED_ORB::MED_Gen::_narrow( comp );
+ _MED_engine = MED_ORB::MED_Gen::_narrow( comp );
}
+
+ // Retrieve MEDFactory to get MEDPresentationManager (sometimes
+ if ( ! _presManager ) {
+ _presManager = MEDFactoryClient::getFactory()->getPresentationManager();
+ }
}
//void MEDModule::onEventLoopStarted()
// call the parent implementation
SalomeApp_Module::initialize( app );
+ getApp()->objectBrowser()->setAutoOpenLevel(5);
+
if (app && app->desktop()) {
connect((QObject*) (getApp()->objectBrowser()->treeView()), SIGNAL(doubleClicked(const QModelIndex&)),
this, SLOT(onDblClick(const QModelIndex&)));
+ connect((QObject*) (getApp()->objectBrowser()->treeView()), SIGNAL(clicked(const QModelIndex&)),
+ this, SLOT(onClick(const QModelIndex&)));
}
// The following initializes the GUI widget and associated actions
MEDModule::engineIOR() const
{
init(); // initialize engine, if necessary
- CORBA::String_var anIOR = getApp()->orb()->object_to_string( myEngine.in() );
+ CORBA::String_var anIOR = getApp()->orb()->object_to_string( _MED_engine.in() );
return QString( anIOR.in() );
}
bool
MEDModule::activateModule( SUIT_Study* theStudy )
{
- if ( CORBA::is_nil( myEngine ) )
+ if ( CORBA::is_nil( _MED_engine ) )
return false;
// call parent implementation
connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
_presentationController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
+
+ // Now that the workspace controller is created, ParaView core application has normally been started,
+ // and hidden GUI elements have been created. We can fire the VCR toolbar activation:
+ initToolbars();
+}
+
+void
+MEDModule::initToolbars()
+{
+ // VCR and Time toolbars:
+ SUIT_Desktop* dsk = getApp()->desktop();
+ _pvGuiElements = PVViewer_GUIElements::GetInstance(dsk);
+
+ _pvGuiElements->getVCRToolbar(); // make sure VCR toolbar is built
+ _pvGuiElements->setToolBarVisible(false);
+ _pvGuiElements->setVCRTimeToolBarVisible(true);
+
+ // Emit signal in order to make sure that animation scene is set - same trick as in PARAVIS module activation
+ QMetaObject::invokeMethod( pqPVApplicationCore::instance()->animationManager(),
+ "activeSceneChanged",
+ Q_ARG( pqAnimationScene*, pqPVApplicationCore::instance()->animationManager()->getActiveScene() ) );
+
#ifdef MED_HAS_QTTESTING
connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)),
_testController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*)));
MEDModule::addActionInPopupMenu(int actionId,const QString& menus,const QString& rule)
{
// _GBO_ for a fine customization of the rule (for example with a
- // test on the type of the selected object), see the LIGTH module:
+ // test on the type of the selected object), see the LIGHT module:
// implement "LightApp_Selection* createSelection() const;"
int parentId = -1;
QtxPopupMgr* mgr = this->popupMgr();
return _presentationController->getSelectedColorMap();
}
-void
-MEDModule::onDblClick(const QModelIndex& index)
+bool
+MEDModule::itemClickGeneric(const QModelIndex & index, std::string & name, int & fieldId, int & presId) const
{
DataObjectList dol = getApp()->objectBrowser()->getSelected();
if (dol.isEmpty())
- return;
+ return false;
SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
if (!item)
- return;
+ return false;
SalomeApp_DataModel *model = dynamic_cast<SalomeApp_DataModel*>(dataModel());
if (!model)
- return;
+ return false;
if (item->componentDataType().toStdString() != "MED")
- return;
+ return false;
_PTR(SObject) obj = item->object();
_PTR(GenericAttribute) anAttribute;
if (! obj->FindAttribute(anAttribute, "AttributeName"))
- return;
+ return false;
_PTR(AttributeName) attrName(anAttribute);
- std::string name = attrName->Value();
+ name = attrName->Value();
if (! obj->FindAttribute(anAttribute, "AttributeParameter"))
- return;
+ return false;
_PTR(AttributeParameter) attrParam(anAttribute);
if (! attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN)
|| ! attrParam->GetBool(IS_PRESENTATION)) { // Not a presentation
- return;
+ return false;
}
if (!attrParam->IsSet(FIELD_ID, PT_INTEGER))
+ return false;
+ fieldId = attrParam->GetInt(FIELD_ID);
+ if (!attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+ return false;
+ presId = attrParam->GetInt(PRESENTATION_ID);
+ return true;
+}
+
+void
+MEDModule::onClick(const QModelIndex & index)
+{
+ int fieldId, presId;
+ std::string name;
+ if (!itemClickGeneric(index, name, fieldId, presId))
+ return;
+
+ STDLOG("Presentation selection (activate view)");
+ std::ostringstream oss;
+ oss << fieldId << " / " << presId;
+ STDLOG(" - Field id / pres id: " + oss.str());
+ STDLOG(" - Presentation name: " + name);
+
+ _presManager->activateView(presId);
+}
+
+void
+MEDModule::onDblClick(const QModelIndex& index)
+{
+ int fieldId, presId;
+ std::string name;
+ if (!itemClickGeneric(index, name, fieldId, presId))
return;
- int fieldId = attrParam->GetInt(FIELD_ID);
STDLOG("Presentation edition: NOT IMPLEMENTED YET");
STDLOG(" Presention infos:");
- STDLOG(" - Component: " + item->componentDataType().toStdString());
- STDLOG(" - Item entry: " + item->entry().toStdString());
- STDLOG(" - Item name: " + item->name().toStdString());
+// STDLOG(" - Component: " + item->componentDataType().toStdString());
+// STDLOG(" - Item entry: " + item->entry().toStdString());
+// STDLOG(" - Item name: " + item->name().toStdString());
std::ostringstream oss;
oss << fieldId;
STDLOG(" - Field id: " + oss.str());