//==========================================================
// Datasource management
//==========================================================
- DatasourceHandler addDatasource(in string filepath);
+ DatasourceHandler loadDatasource(in string filepath);
+ DatasourceHandler getDatasourceHandler(in string filepath);
//==========================================================
// Mesh data management
* is a key to retrieve all informations concerning the data (meshes,
* fields).
*/
-MEDOP::DatasourceHandler * MEDDataManager_i::addDatasource(const char *filepath) {
+MEDOP::DatasourceHandler * MEDDataManager_i::loadDatasource(const char *filepath) {
// We first check that this datasource is not already registered
long sourceid = getDatasourceId(filepath);
return LONG_UNDEFINED;
}
+MEDOP::DatasourceHandler*
+MEDDataManager_i::getDatasourceHandler(const char *filepath)
+{
+ std::string uri(file_to_source(filepath));
+ DatasourceHandlerMapIterator it = _datasourceHandlerMap.begin();
+ while ( it != _datasourceHandlerMap.end() ) {
+ if ( strcmp(it->second->uri,uri.c_str()) == 0 ) {
+ return it->second;
+ }
+ ++it;
+ }
+ return NULL;
+}
+
MEDOP::MeshHandler * MEDDataManager_i::getMesh(CORBA::Long meshId) {
if ( _meshHandlerMap.count(meshId) == 0 ) {
/*!
* This returns the whole set of fields handlers for all datasource
- * that have been loaded using addDatasource.
+ * that have been loaded using loadDatasource.
*/
MEDOP::FieldHandlerList * MEDDataManager_i::getFieldHandlerList() {
MEDOP::FieldHandlerList_var fieldHandlerSeq = new MEDOP::FieldHandlerList();
// At this step, the mesh handler needs a meshid correctly
// set. Normally, we should arrive at this step only in the case
// where the field is loaded from a file ==> the meshid is defined
- // (see the addDatasource function).
+ // (see the loadDatasource function).
//
// >>>> __GBO__ TO BE CHECKED AND SERIOUSLY TESTED. There at least
// one case where we can arrive here with no previous call to
- // addDataSource: for example the field handler list can be obtained
- // from a call to addFieldsFromFile instead of addDataSource (see
+ // loadDataSource: for example the field handler list can be obtained
+ // from a call to addFieldsFromFile instead of loadDataSource (see
// for exemple the getFieldRepresentation service of the
// dataManager, that comes here and then calls getUMesh where we
- // need a map initialized only in addDataSource) <<<<
+ // need a map initialized only in loadDataSource) <<<<
long meshid = fieldHandler->meshid;
// We first have to check if the associated mesh is already loaded
//
// -----------------------------------------------------------
// Datasource management
- MEDOP::DatasourceHandler * addDatasource(const char *filepath);
+ MEDOP::DatasourceHandler * loadDatasource(const char *filepath);
+ MEDOP::DatasourceHandler * getDatasourceHandler(const char *filepath);
// -----------------------------------------------------------
// Mesh management
void
MEDPresentationManager_i::MakeScalarMap(const MEDOP::ScalarMapParameters& params)
{
- std::cout << "View mode: " << params.viewMode << std::endl;
std::cout << "MEDPresentationManager_i::MakeScalarMap: Not implemented yet\n";
}
#
def TEST_getDataManager():
dataManager = factory.getDataManager()
- if "addDatasource" not in dir(dataManager):
+ if "loadDatasource" not in dir(dataManager):
return False
return True
-def TEST_addDatasource():
+def TEST_loadDatasource():
dataManager = factory.getDataManager()
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
if datasource.name != testFileName:
print "ERR: datasource.name=%s (should be %s)"%(datasource.name,testFilePath)
return False
# We try to load the file twice. It should not load twice and
# return the same datasource as previously registered (same id).
sourceid_ref = datasource.id
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
if datasource.id != sourceid_ref:
print "ERR: datasource.id=%s (should be %s)"%(datasource.id,sourceid_ref)
return False
-
+
return True
def TEST_getFieldHandlerList():
dataManager = factory.getDataManager()
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
fieldHandlerList = dataManager.getFieldHandlerList()
if fieldHandlerList is None or len(fieldHandlerList) == 0:
return False
def TEST_getFieldRepresentation():
dataManager = factory.getDataManager()
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
fieldHandlerList = dataManager.getFieldHandlerList()
fieldHandler0 = fieldHandlerList[0]
def TEST_updateFieldMetadata():
dataManager = factory.getDataManager()
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
fieldHandlerList = dataManager.getFieldHandlerList()
fieldHandler0 = fieldHandlerList[0]
fieldid = fieldHandler0.id
newname = fieldHandler0.fieldname + " modified"
-
+
dataManager.updateFieldMetadata(fieldid, newname,
fieldHandler0.iteration,
fieldHandler0.order,
def TEST_saveFields():
dataManager = factory.getDataManager()
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
fieldHandlerList = dataManager.getFieldHandlerList()
fieldHandler0 = fieldHandlerList[0]
fieldIdList = [fieldHandler0.id]
print "fieldIdList = %s"%fieldIdList
print "filepath = %s"%filepath
-
+
dataManager.saveFields(filepath,fieldIdList)
# We just control that the file exists. But we should reload the
# contents to check the fields
#
def TEST_MEDDataManager_getMeshList():
dataManager = factory.getDataManager()
- datasourceHandler = dataManager.addDatasource(testFilePath)
+ datasourceHandler = dataManager.loadDatasource(testFilePath)
meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
print meshHandlerList
if len(meshHandlerList) == 0:
return False
return True
-
+
def TEST_MEDDataManager_getMesh():
dataManager = factory.getDataManager()
- datasourceHandler = dataManager.addDatasource(testFilePath)
+ datasourceHandler = dataManager.loadDatasource(testFilePath)
meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
for mRef in meshHandlerList:
meshId = mRef.id
if ( mRes.name != mRef.name ) or ( mRes.sourceid != mRef.sourceid):
return False
return True
-
+
def TEST_MEDDataManager_getFieldseriesListOnMesh():
dataManager = factory.getDataManager()
- datasourceHandler = dataManager.addDatasource(testFilePath)
+ datasourceHandler = dataManager.loadDatasource(testFilePath)
meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
# We look for the fieldseries defined on the first mesh of the list
testFilePath = os.path.join(RESDIR,testFileName)
testFilePath = getFilePath("timeseries.med")
- datasourceHandler = dataManager.addDatasource(testFilePath)
+ datasourceHandler = dataManager.loadDatasource(testFilePath)
meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
# We look for the fieldseries defined on the first mesh of the list
#
def TEST_Calculator_basics():
dataManager = factory.getDataManager()
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
fieldHandlerList = dataManager.getFieldHandlerList()
# Try to operate on the two first fields
div = calculator.div(fieldHandler0, fieldHandler1)
print div
#power = calculator.pow(fieldHandler0, 2)
- #print power
+ #print power
linear = calculator.lin(fieldHandler0, 3,2)
print linear
def TEST_Calculator_applyFunc():
dataManager = factory.getDataManager()
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
fieldHandlerList = dataManager.getFieldHandlerList()
fieldHandler = fieldHandlerList[0]
#
def TEST_markAsPersistent():
dataManager = factory.getDataManager()
- datasource = dataManager.addDatasource(testFilePath)
+ datasource = dataManager.loadDatasource(testFilePath)
fieldHandlerList = dataManager.getFieldHandlerList()
fieldHandler0 = fieldHandlerList[0]
fieldHandler1 = fieldHandlerList[1]
def test_getDataManager(self):
self.assertTrue(TEST_getDataManager())
- def test_addDatasource(self):
- self.assertTrue(TEST_addDatasource())
+ def test_loadDatasource(self):
+ self.assertTrue(TEST_loadDatasource())
def test_getFieldHandlerList(self):
self.assertTrue(TEST_getFieldHandlerList())
L'exécution imprime un rapport détaillant le résultat pour chaque
fonction de test::
-
+
test_Calculator_applyFunc (__main__.MyTestSuite) ... ok
test_Calculator_basics (__main__.MyTestSuite) ... ok
test_MEDDataManager_getFieldListInFieldseries (__main__.MyTestSuite) ... ok
test_MEDDataManager_getFieldseriesListOnMesh (__main__.MyTestSuite) ... ok
test_MEDDataManager_getMesh (__main__.MyTestSuite) ... ok
test_MEDDataManager_getMeshList (__main__.MyTestSuite) ... ok
- test_addDatasource (__main__.MyTestSuite) ... ok
+ test_loadDatasource (__main__.MyTestSuite) ... ok
test_getDataManager (__main__.MyTestSuite) ... ok
test_getFieldHandlerList (__main__.MyTestSuite) ... ok
test_getFieldRepresentation (__main__.MyTestSuite) ... ok
Le chargement des métadonnées de description se fait par la méthode::
- addDatasource(const char \*filepath)
+ loadDatasource(const char \*filepath)
MEDOP::FieldHandlerList * MyFunction(...) {
vector<MEDOP::FieldHandler*> fieldHandlerList;
...
-
+
fieldHandlerList.push_back(fieldHandler);
-
+
// Map the resulting list to a CORBA sequence for return:
MEDOP::FieldHandlerList_var fieldHandlerSeq = new MEDOP::FieldHandlerList();
int nbFieldHandler = fieldHandlerList.size();
fieldHandlerSeq->length(nbFieldHandler);
for (int i=0; i<nbFieldHandler; i++) {
fieldHandlerSeq[i] = *fieldHandlerList[i];
- }
+ }
return fieldHandlerSeq._retn();
}
Cette commande installe un répertoire ``xsalome`` contenant l'ensemble
des sources de la bibliothèque XSALOME.
-
+
.. note:: La bibliothèque XSALOME n'est pas un module SALOME mais une
simple bibliothèque de fonctions qui complète ou rend plus facile
d'utilisation les fonctions de SALOME. Elle NE DOIT EN AUCUN CAS
Cette commande génére un répertoire ``appli`` à l'emplacement où elle
est exécutée. Il reste à lancer l'application SALOME au moyen de la
commande::
-
+
$ ./appli/runAppli -k
L'exécution imprime un rapport détaillant le résultat pour chaque
fonction de test::
-
+
test_Calculator_applyFunc (__main__.MyTestSuite) ... ok
test_Calculator_basics (__main__.MyTestSuite) ... ok
test_MEDDataManager_getFieldListInFieldseries (__main__.MyTestSuite) ... ok
test_MEDDataManager_getFieldseriesListOnMesh (__main__.MyTestSuite) ... ok
test_MEDDataManager_getMesh (__main__.MyTestSuite) ... ok
test_MEDDataManager_getMeshList (__main__.MyTestSuite) ... ok
- test_addDatasource (__main__.MyTestSuite) ... ok
+ test_loadDatasource (__main__.MyTestSuite) ... ok
test_getDataManager (__main__.MyTestSuite) ... ok
test_getFieldHandlerList (__main__.MyTestSuite) ... ok
test_getFieldRepresentation (__main__.MyTestSuite) ... ok
Le chargement des métadonnées de description se fait par la méthode::
- addDatasource(const char \*filepath)
+ loadDatasource(const char \*filepath)
MEDOP::FieldHandlerList * MyFunction(...) {
vector<MEDOP::FieldHandler*> fieldHandlerList;
...
-
+
fieldHandlerList.push_back(fieldHandler);
-
+
// Map the resulting list to a CORBA sequence for return:
MEDOP::FieldHandlerList_var fieldHandlerSeq = new MEDOP::FieldHandlerList();
int nbFieldHandler = fieldHandlerList.size();
fieldHandlerSeq->length(nbFieldHandler);
for (int i=0; i<nbFieldHandler; i++) {
fieldHandlerSeq[i] = *fieldHandlerList[i];
- }
+ }
return fieldHandlerSeq._retn();
}
Cette commande installe un répertoire ``xsalome`` contenant l'ensemble
des sources de la bibliothèque XSALOME.
-
+
.. note:: La bibliothèque XSALOME n'est pas un module SALOME mais une
simple bibliothèque de fonctions qui complète ou rend plus facile
d'utilisation les fonctions de SALOME. Elle NE DOIT EN AUCUN CAS
Cette commande génére un répertoire ``appli`` à l'emplacement où elle
est exécutée. Il reste à lancer l'application SALOME au moyen de la
commande::
-
+
$ ./appli/runAppli -k
* informations to the GUI, and the GUI creates a tree view of these
* data in the study object browser.
*/
-MEDOP::DatasourceHandler * DatasourceController::addDatasource(const char * filename) {
-
- MEDOP::DatasourceHandler * datasourceHandler =
- MEDOPFactoryClient::getDataManager()->addDatasource(filename);
+void
+DatasourceController::addDatasource(const char* filename)
+{
+ DatasourceEvent* event = new DatasourceEvent();
+ event->eventtype = DatasourceEvent::EVENT_ADD_DATASOURCE;
+ event->objectalias = filename;
+ emit datasourceSignal(event);
+}
+// call to this function is trigerred by workspace (itself from python console)
+void
+DatasourceController::updateTreeViewWithNewDatasource(const MEDOP::DatasourceHandler* datasourceHandler)
+{
+ if (!datasourceHandler) {
+ return;
+ }
// We need a studyEditor updated on the active study
_studyEditor->updateActiveStudy();
_studyEditor->setParameterBool(soFieldseries,OBJECT_IS_IN_WORKSPACE,false);
}
}
-
- return datasourceHandler;
}
}
void
-DatasourceController::processWorkspaceEvent(const MEDOP::MedEvent * event)
+DatasourceController::processWorkspaceEvent(const MEDOP::MedEvent* event)
{
if ( event->type == MEDOP::EVENT_ADD_DATASOURCE ) {
- this->addDatasource(event->filename);
+ MEDOP::DatasourceHandler* datasourceHandler = MEDOPFactoryClient::getDataManager()->getDatasourceHandler(event->filename);
+ this->updateTreeViewWithNewDatasource(datasourceHandler);
_salomeModule->updateObjBrowser(true);
}
}
EVENT_IMPORT_OBJECT, // Simply import the object in the workspace
EVENT_USE_OBJECT, // Import in the workspace AND define a proxy
// variable in the tui console to use it
- EVENT_VIEW_OBJECT_SCALAR_MAP
+ EVENT_VIEW_OBJECT_SCALAR_MAP,
+ EVENT_ADD_DATASOURCE // to forward action to workspace (and then to python console)
};
int eventtype;
XmedDataObject * objectdata;
~DatasourceController();
void createActions();
- MEDOP::DatasourceHandler * addDatasource(const char * filename);
public slots:
// Callback connected to dialog box validation signals
private:
void visualize(DatasourceEvent::EventType);
+ void addDatasource(const char* filename);
+ void updateTreeViewWithNewDatasource(const MEDOP::DatasourceHandler*);
private:
StandardApp_Module * _salomeModule;
commands += QString("MakeScalarMap(get(%1), %2)").arg(fieldHandler->id).arg(viewMode);
_consoleDriver->exec(commands);
}
+ else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) {
+ QStringList commands;
+ commands += QString("from medpresentation import LoadDataSource");
+ commands += QString("LoadDataSource('%1')").arg(event->objectalias);
+ _consoleDriver->exec(commands);
+ }
else {
STDLOG("The event "<<event->eventtype<<" is not implemented yet");
}
__manager = xmed.factory.getPresentationManager()
def LoadDataSource(filename):
+ xmed.dataManager.loadDatasource(filename)
from xmed.fieldproxy import notifyGui_addsource
notifyGui_addsource(filename)
#
print "viewMode:", viewMode, " [", type(viewMode), "]"
- params = MEDOP.ScalarMapParameters(proxy.id, viewMode);
+ params = MEDOP.ScalarMapParameters(proxy.id, viewMode)
__manager.MakeScalarMap(params)
#
"""
xmed.dataManager.addDatasource(filepath)
print status(local=False,remote=True)
+ from xmed.fieldproxy import notifyGui_addsource
+ notifyGui_addsource(filename)
def get(fieldHandlerId):
"""
# Load some test data in the MedDataManager
filepath = properties.testFilePath
-xmed.dataManager.addDatasource(filepath)
+xmed.dataManager.loadDatasource(filepath)
fieldHandlerList = xmed.dataManager.getFieldHandlerList()
def setup():
# The addition can be done using field handler directly
addFieldHandler = xmed.calculator.add(fieldHandler0, fieldHandler1)
print addFieldHandler
-
+
# Or with a field proxy that ease the writing of operations
fieldProxy0 = FieldProxy(fieldHandler0)
fieldProxy1 = FieldProxy(fieldHandler1)
-
+
res = fieldProxy0 + fieldProxy1
if res is None: return False
if res is None: return False
return True
-
+
def TEST_litteral_equation():
fieldProxy0 = FieldProxy(fieldHandlerList[0])
res = fieldProxy0.ope("abs(u)^2")
#TEST_unary_operations()
#TEST_update_metadata()
#TEST_composition()
-
+
if __name__ == "__main__":
#myusecases()
myunittests()