FieldseriesHandlerList getFieldseriesListOnMesh(in long meshId);
FieldHandlerList getFieldListInFieldseries(in long fieldseriesId);
+ long getFieldIdAtTimestamp(in long fieldseriesId, in double timestamp);
+
FieldHandler getFieldHandler(in long fieldHandlerId);
FieldHandlerList getFieldHandlerList();
// __GBO__ Maybe it could be useful to define a getFieldHandlerList with a datasourceId in argument
//void saveFields(in FieldHandlerList fieldHandlerList, in string filepath);
- double getFieldTimeStep(in long fieldHandlerId);
+ double getFieldTimestamp(in long fieldHandlerId);
void changeUnderlyingMesh(in long fieldHandlerId, in long meshHandlerId)
raises (SALOME::SALOME_Exception);
return filepath;
}
+/*!
+ * Check if a source (from its uri name) is in a file or in memory
+ */
+bool MEDDataManager_i::isSourceInFile(const char * sourceName)
+{
+ std::string sourceString(sourceName);
+ return (sourceString.substr(0, 7) == std::string("file://"));
+}
+
+
+
/*!
* This function loads the meta-data from the specified med file and
* returns the associated datasource handler. The data source handler
* the different time iterations defined for the specified field id.
*/
MEDCALC::FieldHandlerList * MEDDataManager_i::getFieldListInFieldseries(CORBA::Long fieldseriesId) {
-
// We initiate a list with the maximum length
MEDCALC::FieldHandlerList_var fieldHandlerList = new MEDCALC::FieldHandlerList();
fieldHandlerList->length(_fieldHandlerMap.size());
return fieldHandlerList._retn();
}
+/*!
+ * Get the field id of a field series at a given timestep
+ */
+CORBA::Long MEDDataManager_i::getFieldIdAtTimestamp(CORBA::Long fieldseriesId, double timestampOfPvAnimation) {
+ // Scan the map looking for field defined on the specified mesh at given timestep
+ int itemIdx = 0;
+ CORBA::Long fieldId = 0;
+ double timestampOfField;
+ FieldHandlerMapIterator it;
+ for ( it=_fieldHandlerMap.begin(); it != _fieldHandlerMap.end(); it++) {
+ if ( it->second->fieldseriesId == fieldseriesId ) {
+ if (itemIdx == 0) {
+ // set the fieldId to the first one in case it is not found
+ fieldId = it->second->id;
+ }
+ timestampOfField = getFieldTimestamp(it->second->id);
+ if (timestampOfField == timestampOfPvAnimation) {
+ fieldId = it->second->id;
+ break;
+ }
+ itemIdx++;
+ }
+ }
+ return fieldId;
+}
+
/*!
* This returns the whole set of fields handlers for all datasource
* that have been loaded using loadDatasource.
}
/**
- * Get the timestep associated to a field
+ * Get the timestamp associated to a field
*/
-double MEDDataManager_i::getFieldTimeStep(CORBA::Long fieldHandlerId)
+double MEDDataManager_i::getFieldTimestamp(CORBA::Long fieldHandlerId)
{
- int iteration, order;
- // WARN: note that the variables "iteration" and "order" are passed
- // by reference to the function getTime (see documentation of
- // MEDCouplingField). As a consequence, the values of these
- // variables are updated by this function call. This is the means to
- // retrieve the iteration and order of the field.
+ LOG("getFieldTimestamp(" << fieldHandlerId << ")");
+ double timestamp(0);
MEDCALC::FieldHandler * fieldHandler = getFieldHandler(fieldHandlerId);
- MEDCouplingFieldDouble* fieldDouble = getFieldDouble(fieldHandler);
- double timestamp = fieldDouble->getTime(iteration, order);
+
+ // if the field is in a file, get the timestamp by MEDLoader tiny information
+ long meshHandlerId = fieldHandler->meshid;
+ long sourceid = _meshHandlerMap[meshHandlerId]->sourceid;
+ if (isSourceInFile(fieldHandler->source))
+ {
+ const char * meshSourceUri = (_datasourceHandlerMap[sourceid])->uri;
+ std::string fileName(source_to_file(meshSourceUri));
+ const char * fieldName = fieldHandler->fieldname;
+ const char * meshName = _meshHandlerMap[meshHandlerId]->name;
+ timestamp = GetTimeAttachedOnFieldIteration(fileName.c_str(), fieldName, fieldHandler->iteration, fieldHandler->order);
+ LOG("timestamp in med file is " << timestamp);
+ }
+ else
+ {
+ // else get the timestamp with MEDCouplingField
+ int iteration, order;
+ // WARN: note that the variables "iteration" and "order" are passed
+ // by reference to the function getTime (see documentation of
+ // MEDCouplingField). As a consequence, the values of these
+ // variables are updated by this function call. This is the means to
+ // retrieve the iteration and order of the field.
+ MEDCouplingFieldDouble* fieldDouble = getFieldDouble(fieldHandler);
+ timestamp = fieldDouble->getTime(iteration, order);
+ LOG("timestamp in MEDCouplingFieldDouble is " << timestamp);
+ }
return timestamp;
}
MEDCALC_EXPORT MEDCALC::FieldseriesHandlerList * getFieldseriesListOnMesh(CORBA::Long meshId);
MEDCALC_EXPORT MEDCALC::FieldHandlerList * getFieldListInFieldseries(CORBA::Long fieldseriesId);
+ MEDCALC_EXPORT CORBA::Long getFieldIdAtTimestamp(CORBA::Long fieldseriesId, double timestamp);
+
MEDCALC_EXPORT MEDCALC::FieldHandler * getFieldHandler(CORBA::Long fieldHandlerId);
MEDCALC_EXPORT char * getFieldRepresentation(CORBA::Long fieldHandlerId);
MEDCALC_EXPORT MEDCALC::FieldHandlerList * getFieldHandlerList();
std::string file_to_source(const char * filepath);
std::string source_to_file(const char * source);
+ bool isSourceInFile(const char * sourceName);
long getDatasourceId(const char *filepath);
MEDCouplingUMesh * getUMesh(long meshHandlerId);
long getUMeshId(const MEDCouplingMesh * mesh);
- double getFieldTimeStep(CORBA::Long fieldHandlerId);
+ double getFieldTimestamp(CORBA::Long fieldHandlerId);
INTERP_KERNEL::IntersectionType _getIntersectionType(const char* intersType);
MEDCoupling::NatureOfField _getNatureOfField(const char* fieldNature);
}
/*
- * Set the timestep of the animation to the timestep of the field.
+ * Set the timestamp of the animation to the timestamp of the field.
* Especially useful when working on a field's iteration:
* in the workspace, in the python console, or using changeUnderlyingMesh.
*/
void
-MEDPresentation::setTimestep()
+MEDPresentation::setTimestamp()
{
- // get the timestep of the field
- double timestep = MEDFactoryClient::getDataManager()->getFieldTimeStep(_handlerId);
+ // get the timestamp of the field
+ double timestamp = MEDFactoryClient::getDataManager()->getFieldTimestamp(_handlerId);
+ STDLOG("Displaying timestamp : " << timestamp);
std::ostringstream oss;
- // go to the right timestep in animation (view and VCR toolbar)
+ // go to the right timestamp in animation (view and VCR toolbar)
pushAndExecPyLine("pvs.GetAnimationScene().UpdateAnimationUsingDataTimeSteps()");
- oss << "pvs.GetAnimationScene().AnimationTime = " << timestep << ";";
+ oss << "pvs.GetAnimationScene().AnimationTime = " << timestamp << ";";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << "pvs.GetTimeKeeper().Time = " << timestamp << ";";
pushAndExecPyLine(oss.str()); oss.str("");
}
// The most common elements of the ParaView pipeline:
void setOrCreateRenderView();
void createSource();
- void setTimestep();
+ void setTimestamp();
void selectFieldComponent();
void showObject();
void colorBy();
MEDPyLockWrapper lock;
createSource();
+ setTimestamp();
// Populate internal array of available components:
fillAvailableFieldComponents();
MEDPyLockWrapper lock;
createSource();
+ setTimestamp();
// Populate internal array of available components:
fillAvailableFieldComponents();
setOrCreateRenderView(); // instantiate __viewXXX
createSource();
+ setTimestamp();
// Populate internal array of available components:
fillAvailableFieldComponents();
setOrCreateRenderView(); // instantiate __viewXXX
createSource();
- setTimestep();
+ setTimestamp();
// Populate internal array of available components:
fillAvailableFieldComponents();
std::ostringstream oss;
createSource();
+ setTimestamp();
// Populate internal array of available components:
fillAvailableFieldComponents();
MEDPyLockWrapper lock;
createSource();
+ setTimestamp();
// Populate internal array of available components:
fillAvailableFieldComponents();
#include <pqAnimationManager.h>
#include <pqPVApplicationCore.h>
+#include <pqAnimationScene.h>
//! The only instance of the reference to engine
MED_ORB::MED_Gen_var MEDModule::_MED_engine;
#endif
}
+double
+MEDModule::getCurrentAnimationTimestamp()
+{
+ double timestamp = pqPVApplicationCore::instance()->animationManager()->getActiveScene()->getAnimationTime();
+ return timestamp;
+}
+
void
MEDModule::createModuleActions() {
_datasourceController->createActions();
int getIntParamFromStudyEditor(SALOMEDS::SObject_var obj, const char* name);
+ double getCurrentAnimationTimestamp();
+
signals:
void presentationSelected(int presId, const QString& presType, const QString& presName);
std::string name(_studyEditor->getName(soObj));
if (soObj->_is_nil() || name == "MEDCalc")
return;
-
int fieldId = _salomeModule->getIntParamFromStudyEditor(soObj, FIELD_ID);
int meshId = _salomeModule->getIntParamFromStudyEditor(soObj, MESH_ID);
MEDCALC::FieldHandler* fieldHandler = 0;
if ( fieldSeriesId < 0)
continue;
- MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldSeriesId);
- if (fieldHandlerList->length() < 0)
- continue;
- // For a field series, get the first real field entry:
- MEDCALC::FieldHandler fieldHandler = (*fieldHandlerList)[0];
- fieldId = fieldHandler.id;
+ // get the current timestamp
+ double timestamp = _salomeModule->getCurrentAnimationTimestamp();
+ // get the field id a the current timestamp
+ fieldId = MEDFactoryClient::getDataManager()->getFieldIdAtTimestamp(fieldSeriesId, timestamp);
}
fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
}
datafile = os.path.join(GetMEDFileDirTUI(), "agitateur.med")
source_id = medcalc.LoadDataSource(datafile)
-# Field 55 = VITESSE_ELEM_DOM (ON_CELLS)
-presentation_id = medcalc.MakeVectorField(accessField(55), viewMode=MEDCALC.VIEW_MODE_REPLACE,
+# Field 55 = VITESSE_ELEM_DOM (ON_CELLS) at timestamp 0
+# Field 65 = VITESSE_ELEM_DOM (ON_CELLS) at timestamp 10
+presentation_id = medcalc.MakeVectorField(accessField(65), viewMode=MEDCALC.VIEW_MODE_REPLACE,
colorMap=MEDCALC.COLOR_MAP_BLUE_TO_RED_RAINBOW,
scalarBarRange=MEDCALC.SCALAR_BAR_CURRENT_TIMESTEP
)