X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCalc%2Fgui%2FDatasourceController.cxx;h=dda57da3db4d9206c9725a240d2f4b2ef1445932;hb=00da15b7d297827f6c0f4b2797ac8c79f20d9d0b;hp=bd939552487b53f11e7c8a946717e1ad6234df1d;hpb=2c7c0978186a9b812808ef44791dbb8c16440d2d;p=modules%2Fmed.git diff --git a/src/MEDCalc/gui/DatasourceController.cxx b/src/MEDCalc/gui/DatasourceController.cxx index bd9395524..dda57da3d 100644 --- a/src/MEDCalc/gui/DatasourceController.cxx +++ b/src/MEDCalc/gui/DatasourceController.cxx @@ -20,7 +20,7 @@ // Author : Guillaume Boulant (EDF) #include "DatasourceController.hxx" -#include "DatasourceConstants.hxx" +#include #include #include @@ -45,6 +45,7 @@ #include #include #include +#include #include "DlgAlias.hxx" @@ -104,6 +105,7 @@ void DatasourceController::createActions() { icon = tr("ICO_DATASOURCE_USE"); actionId = _salomeModule->createStandardAction(label,this,SLOT(OnUseInWorkspace()),icon); _salomeModule->addActionInPopupMenu(actionId); + } /** @@ -120,8 +122,14 @@ DatasourceController::addDatasource(const char* filename) DatasourceEvent* event = new DatasourceEvent(); event->eventtype = DatasourceEvent::EVENT_ADD_DATASOURCE; event->objectalias = filename; - emit datasourceSignal(event); + emit datasourceSignal(event); // --> WorkspaceController::processDatasourceEvent() +//#ifdef MED_WITH_QTTESTING +// _dirtyAddDataSource = true; +// while(_dirtyAddDataSource) +// QApplication::processEvents(); +//#endif } + // After above data source creation, python console emits a signal, forwarded by workspace, to update the GUI void DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler* datasourceHandler) @@ -137,6 +145,10 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH // update Object browser _salomeModule->getApp()->updateObjectBrowser(true); + +//#ifdef MED_WITH_QTTESTING +// _dirtyAddDataSource = false; +//#endif } void DatasourceController::OnAddDatasource() @@ -149,10 +161,15 @@ void DatasourceController::OnAddDatasource() if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) anInitialPath = QDir::currentPath(); - QStringList filenames = SUIT_FileDlg::getOpenFileNames( _salomeModule->getApp()->desktop(), +// QStringList filenames = SUIT_FileDlg::getOpenFileNames( _salomeModule->getApp()->desktop(), +// anInitialPath, +// filter, +// tr("IMPORT_MED_FIELDS") ); + // [ABN] the below to be compatible with QtTesting: + QStringList filenames = QFileDialog::getOpenFileNames( _salomeModule->getApp()->desktop(), + tr("IMPORT_MED_FIELDS"), anInitialPath, - filter, - tr("IMPORT_MED_FIELDS") ); + tr("FILE_FILTER_MED") ); if ( filenames.count() <= 0 ) return; for ( QStringList::ConstIterator itFile = filenames.begin(); @@ -201,7 +218,7 @@ void DatasourceController::OnAddImagesource() DatasourceEvent* event = new DatasourceEvent(); event->eventtype = DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE; event->objectalias = imageFilename; - emit datasourceSignal(event); + emit datasourceSignal(event); // --> WorkspaceController::processDatasourceEvent() } void DatasourceController::OnExpandField() @@ -213,9 +230,19 @@ void DatasourceController::OnExpandField() SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); for (int i=0; isize(); i++) { SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i); + std::string name(_studyEditor->getName(soFieldseries)); + if (soFieldseries->_is_nil() || name == "MEDCalc") + return; // First retrieve the fieldseries id associated to this study object - long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,OBJECT_ID); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soFieldseries->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(FIELD_SERIES_ID, PT_INTEGER)) + return; + } + long fieldseriesId = aParam->GetInt(FIELD_SERIES_ID); STDLOG("Expand the field timeseries "<newObject(soFieldseries); std::string label("it="); label += ToString(fieldHandler.iteration); _studyEditor->setName(soField,label.c_str()); - _studyEditor->setParameterInt(soField, OBJECT_ID, fieldHandler.id); - _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,false); + _studyEditor->setParameterInt(soField, FIELD_ID, fieldHandler.id); + _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,false); } } _salomeModule->updateObjBrowser(true); @@ -261,8 +288,17 @@ void DatasourceController::OnUseInWorkspace() { // <<< SALOMEDS::SObject_var soField = listOfSObject->at(0); - - bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE); + std::string name(_studyEditor->getName(soField)); + if (soField->_is_nil() || name == "MEDCalc") + return; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soField->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN)) + return; + } + bool isInWorkspace = aParam->GetBool(IS_IN_WORKSPACE); if ( isInWorkspace ) { QMessageBox::warning(_salomeModule->getApp()->desktop(), tr("Operation not allowed"), @@ -270,7 +306,9 @@ void DatasourceController::OnUseInWorkspace() { return; } - int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID); + if (! aParam->IsSet(FIELD_ID, PT_INTEGER)) + return; + int fieldId = aParam->GetInt(FIELD_ID); // If fieldId equals -1, then it means that it is not a field // managed by the MED module, and we stop this function process. @@ -307,9 +345,9 @@ void DatasourceController::OnUseInWorkspace() { dataObject->setFieldHandler(*fieldHandler); event->objectdata = dataObject; event->objectalias = alias; - emit datasourceSignal(event); + emit datasourceSignal(event); // --> WorkspaceController::processDatasourceEvent() // Tag the item to prevent double import - // _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true); + // _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true); // Tag the field as persistent on the server. It means that a // saving of the workspace will save at least this field (maybe it // should be an option?) @@ -320,10 +358,20 @@ void DatasourceController::OnUseInWorkspace() { // each item, we just import the whole set of items. for (int i=0; isize(); i++) { SALOMEDS::SObject_var soField = listOfSObject->at(i); - - bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE); + if (soField->_is_nil()) + continue; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeParameter_var aParam; + if ( soField->FindAttribute(anAttr,"AttributeParameter") ) { + aParam = SALOMEDS::AttributeParameter::_narrow(anAttr); + if (! aParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN)) + return; + } + bool isInWorkspace = aParam->GetBool(IS_IN_WORKSPACE); if ( !isInWorkspace ) { - int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID); + if (! aParam->IsSet(FIELD_ID, PT_INTEGER)) + continue; + int fieldId = aParam->GetInt(FIELD_ID); MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); DatasourceEvent* event = new DatasourceEvent(); @@ -331,11 +379,11 @@ void DatasourceController::OnUseInWorkspace() { XmedDataObject* dataObject = new XmedDataObject(); dataObject->setFieldHandler(*fieldHandler); event->objectdata = dataObject; - emit datasourceSignal(event); + emit datasourceSignal(event); // --> WorkspaceController::processDatasourceEvent() // Note that this signal is processed by the WorkspaceController // Tag the item to prevent double import - // _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true); + // _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true); // Tag the field as persistent on the server. It means that a // saving of the workspace will save at least this field (maybe it // should be an option?)