EVENT_ADD_PRESENTATION,
EVENT_REMOVE_PRESENTATION,
EVENT_MODIFY_PRESENTATION,
+ EVENT_CHANGE_UNDERLYING_MESH,
+ EVENT_INTERPOLATE_FIELD,
EVENT_PLAY_TEST,
EVENT_QUIT_SALOME,
EVENT_ERROR,
void
ProcessingController::OnChangeUnderlyingMeshInputValidated()
{
+ STDLOG("Change Underlying Mesh");
int meshId = _dlgChangeUnderlyingMesh->getMeshId();
STDLOG("meshId = " << ToString(meshId));
int fieldId = _dlgChangeUnderlyingMesh->getFieldId();
- MEDCALC::FieldHandler* fieldHandler =
- MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
- // We don't modify the original field but create first a duplicate
- MEDCALC::FieldHandler* duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
- MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
-
- // Request once more the duplicate to update the meta-data on this
- // client side
- duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
-
- // >>>
- // WARN: the following is a temporary code for test purpose
- // Automatically add in ws
ProcessingEvent* event = new ProcessingEvent();
- event->eventtype = ProcessingEvent::EVENT_IMPORT_OBJECT;
- XmedDataObject* dataObject = new XmedDataObject();
- dataObject->setFieldHandler(*duplicate);
- event->objectdata = dataObject;
- emit processingSignal(event);
- // Note that this signal is processed by the WorkspaceController
+ event->eventtype = ProcessingEvent::EVENT_CHANGE_UNDERLYING_MESH;
+ event->fieldId = fieldId;
+ event->meshId = meshId;
+ emit processingSignal(event); // --> WorkspaceController::processProcessingEvent()
// Tag the item to prevent double import
//_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
void
ProcessingController::OnInterpolateFieldInputValidated()
{
+ STDLOG("Interpolate Field");
MEDCALC::InterpolationParameters params;
params.precision = _dlgInterpolateField->getPrecision();
STDLOG("precision = " << params.precision);
int meshId = _dlgInterpolateField->getMeshId();
STDLOG("meshId = " << ToString(meshId));
int fieldId = _dlgInterpolateField->getFieldId();
- MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
-
- // We don't modify the original field but create first a duplicate
- // MEDCALC::FieldHandler* duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler);
- //MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId);
- MEDCALC::FieldHandler* result = NULL;
- try {
- result = MEDFactoryClient::getDataManager()->interpolateField(fieldId, meshId, params);
- }
- catch(...) {
- STDLOG("Unable to process field interpolation; please check interpolation parameters");
- QMessageBox::critical(_salomeModule->getApp()->desktop(),
- tr("Operation failed"),
- tr("Unable to process field interpolation; please check interpolation parameters"));
- return;
- }
-
- // Request once more the duplicate to update the meta-data on this
- // client side
- // duplicate = MEDFactoryClient::getDataManager()->getFieldHandler(duplicate->id);
- // >>>
- // WARN: the following is a temporary code for test purpose
- // Automatically add in ws
ProcessingEvent* event = new ProcessingEvent();
- event->eventtype = ProcessingEvent::EVENT_IMPORT_OBJECT;
- XmedDataObject* dataObject = new XmedDataObject();
- dataObject->setFieldHandler(*result);
- event->objectdata = dataObject;
- emit processingSignal(event);
- // Note that this signal is processed by the WorkspaceController
+ event->eventtype = ProcessingEvent::EVENT_INTERPOLATE_FIELD;
+ event->fieldId = fieldId;
+ event->meshId = meshId;
+ event->interpParams = params;
+ emit processingSignal(event); // --> WorkspaceController::processProcessingEvent()
// // Tag the item to prevent double import
// //_studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
typedef struct {
enum EventType {
EVENT_IMPORT_OBJECT,
- EVENT_PROCESS_INTERPOLATE_FIELD,
- EVENT_PROCESS_CHANGE_UNDERLYING_MESH
+ EVENT_INTERPOLATE_FIELD,
+ EVENT_CHANGE_UNDERLYING_MESH
};
int eventtype;
- XmedDataObject* objectdata;
+ int fieldId;
+ int meshId;
+ MEDCALC::InterpolationParameters interpParams;
} ProcessingEvent;
class MEDModule;
else if ( event->type == MEDCALC::EVENT_MODIFY_PRESENTATION ) {
emit workspaceSignal(event); // forward to PresentationController
}
+ else if ( event->type == MEDCALC::EVENT_CHANGE_UNDERLYING_MESH
+ || event->type == MEDCALC::EVENT_INTERPOLATE_FIELD ) {
+ int fieldId = event->dataId;
+ MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
+ XmedDataObject* dataObject = new XmedDataObject();
+ dataObject->setFieldHandler(*fieldHandler);
+ std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
+ STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
+ // _GBO_ QUESTION: tag automatically the object as a peristant object ??
+ // We first add the data object to the internal data model
+ dataModel->addDataObject(dataObject);
+ // Then we request the tree view to consider this new object
+ this->getDataTreeModel()->addData(dataObject);
+ }
else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
emit workspaceSignal(event); // forward to TestController
}
return;
}
- // >>>
- // __GBO__ To know what to do we should test the type, because the
- // object could be a mesh, a timeseries or a single field. We test
- // here the case of a single field. Moreover, there could have
- // options such that "change the underlying mesh".
- // <<<
+ int fieldId = event->fieldId;
+ int meshId = event->meshId;
- XmedDataObject* dataObject = event->objectdata;
+ if ( event->eventtype == ProcessingEvent::EVENT_CHANGE_UNDERLYING_MESH ) {
+ QStringList commands;
+ commands += QString("result_id = medcalc.ChangeUnderlyingMesh(fieldId=%1,meshId=%2)").arg(fieldId).arg(meshId);
+ commands += QString("result_id");
+ _consoleDriver->exec(commands);
+ }
+ else if ( event->eventtype == ProcessingEvent::EVENT_INTERPOLATE_FIELD ) {
+ MEDCALC::InterpolationParameters params = event->interpParams;
+ QString method = QString(params.method);
+ QString nature = QString(params.nature);
+ QString intersectionType = QString(params.intersectionType);
- if ( event->eventtype == ProcessingEvent::EVENT_IMPORT_OBJECT ) {
- std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl;
- STDLOG("IMPORT object in workspace:\n"<<dataObject->toString());
- // _GBO_ QUESTION: tag automatically the object as a peristant object ??
- // We first add the data object to the internal data model
- dataModel->addDataObject(dataObject);
- // Then we request the tree view to consider this new object
- this->getDataTreeModel()->addData(dataObject);
+ QStringList commands;
+ commands += QString("result_id = medcalc.InterpolateField(fieldId=%1,meshId=%2,precision=%3,defaultValue=%4,reverse=%5,method='%6',nature='%7',intersectionType='%8')").arg(fieldId).arg(meshId).arg(params.precision).arg(params.defaultValue).arg(params.reverse).arg(method).arg(nature).arg(intersectionType);
+ commands += QString("result_id");
+ _consoleDriver->exec(commands);
}
}
medimages.py
medio.py
medpresentation.py
+ medprocessing.py
medtest.py
)
from medpresentation import ComputeCellAverageSize, GetDomainCenter, GetSliceOrigins, SelectSourceField
+# Processing
+from medprocessing import ChangeUnderlyingMesh
+from medprocessing import InterpolateField
+
# Console commands
import medconsole
def notifyGui_removePresentation(presId):
__notifyGui(MEDCALC.EVENT_REMOVE_PRESENTATION, presentationId=presId)
#
+def notifyGui_modifyPresentation(presId):
+ __notifyGui(MEDCALC.EVENT_MODIFY_PRESENTATION, presentationId=presId)
+
def notifyGui_playQtTestingScenario(filename):
__notifyGui(MEDCALC.EVENT_PLAY_TEST, filename=filename)
#
def notifyGui_termination():
__notifyGui(MEDCALC.EVENT_QUIT_SALOME)
-
+
def notifyGui_error(msg):
__notifyGui(MEDCALC.EVENT_ERROR, msg=msg)
-
-def notifyGui_modifyPresentation(presId):
- __notifyGui(MEDCALC.EVENT_MODIFY_PRESENTATION, presentationId=presId)
+
+def notifyGui_changeUnderlyingMesh(fieldId):
+ __notifyGui(MEDCALC.EVENT_CHANGE_UNDERLYING_MESH, dataId=fieldId)
+
+def notifyGui_interpolateField(fieldId):
+ __notifyGui(MEDCALC.EVENT_INTERPOLATE_FIELD, dataId=fieldId)
--- /dev/null
+# Copyright (C) 2011-2016 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import medcalc
+import MEDCALC
+import SALOME
+from medcalc.medevents import notifyGui_error
+
+
+def ChangeUnderlyingMesh(fieldId, meshId):
+ try:
+ dataManager = medcalc.medcorba.factory.getDataManager()
+ fieldHandler = dataManager.getFieldHandler(fieldId)
+
+ # We don't modify the original field but create first a duplicate
+ duplicate = medcalc.medcorba.factory.getCalculator().dup(fieldHandler)
+ dataManager.changeUnderlyingMesh(duplicate.id, meshId)
+
+ from medcalc.medevents import notifyGui_changeUnderlyingMesh
+ notifyGui_changeUnderlyingMesh(duplicate.id)
+ return duplicate.id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occured while changing underlying mesh:\n" + e.details.text)
+ raise Exception(e.details.text)
+#
+
+def InterpolateField(fieldId,
+ meshId,
+ precision,
+ defaultValue,
+ reverse,
+ method,
+ nature,
+ intersectionType
+ ):
+ params = MEDCALC.InterpolationParameters(precision, defaultValue, reverse, method, nature, intersectionType)
+ try:
+ dataManager = medcalc.medcorba.factory.getDataManager()
+ fieldHandler = dataManager.interpolateField(fieldId, meshId, params)
+ from medcalc.medevents import notifyGui_interpolateField
+ notifyGui_interpolateField(fieldHandler.id)
+ return fieldHandler.id
+ except SALOME.SALOME_Exception as e:
+ notifyGui_error("An error occured while interpolating field:\n" + e.details.text)
+ raise Exception(e.details.text)
+#