# Ensure a proper linker behavior:
CMAKE_POLICY(SET CMP0003 NEW)
+IF(WIN32)
+ CMAKE_POLICY(SET CMP0020 OLD) # disable automatic linking to qtmain.lib
+ENDIF(WIN32)
# Versioning
# ===========
FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
ELSE()
FIND_PACKAGE(SalomeQt5 REQUIRED)
- ENDIF()
+ ENDIF()
ENDIF(SALOME_BUILD_GUI)
IF(SALOME_MED_ENABLE_PYTHON)
LIST(APPEND _${PROJECT_NAME}_exposed_targets paramedcouplingcorba paramedmemcompo)
ENDIF()
-LIST(APPEND _${PROJECT_NAME}_exposed_targets
+LIST(APPEND _${PROJECT_NAME}_exposed_targets
medcouplingcorba medcouplingclient medcalculator MEDFactoryEngine)
IF(SALOME_MED_ENABLE_PYTHON)
LIST(APPEND _${PROJECT_NAME}_exposed_targets medcalculatorspython)
# Build variables that will be expanded when configuring Salome<MODULE>Config.cmake:
IF(NOT SALOME_GUI_BUILD_WITH_QT5)
- SALOME_CONFIGURE_PREPARE(MEDCoupling Qt4 MPI omniORB CppUnit Graphviz Doxygen Sphinx
- PThread Python)
- ELSE()
- SALOME_CONFIGURE_PREPARE(MEDCoupling Qt5 MPI omniORB CppUnit Graphviz Doxygen Sphinx
- PThread Python)
+ SALOME_CONFIGURE_PREPARE(MEDCoupling Qt4 MPI omniORB CppUnit Graphviz Doxygen Sphinx
+ PThread Python)
+ ELSE()
+ SALOME_CONFIGURE_PREPARE(MEDCoupling Qt5 MPI omniORB CppUnit Graphviz Doxygen Sphinx
+ PThread Python)
ENDIF()
CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in
INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX
KERNEL_ROOT_DIR GUI_ROOT_DIR MEDCOUPLING_ROOT_DIR QT_ROOT_DIR MPI_ROOT_DIR
- OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR
+ OMNIORB_ROOT_DIR PTHREAD_ROOT_DIR SWIG_ROOT_DIR PYTHON_ROOT_DIR CPPUNIT_ROOT_DIR
GRAPHVIZ_ROOT_DIR DOXYGEN_ROOT_DIR SPHINX_ROOT_DIR)
WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
# Install the export set for use with the install-tree
INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}"
FILE ${PROJECT_NAME}Targets.cmake)
+
+# Application tests
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test
+ RENAME CTestTestfile.cmake)
-# Copyright (C) 2015-2016 CEA/DEN, EDF R&D
+# Copyright (C) 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
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-SET(SALOME_TEST_DRIVER "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver.py")
-SET(SALOME_TEST_DRIVER_GUI "$ENV{ABSOLUTE_APPLI_PATH}/bin/salome/appliskel/salome_test_driver_gui.py")
+SET(COMPONENT_NAME MEDCALC)
+SET(TIMEOUT 300)
+
+SUBDIRS(MEDCalculator)
SUBDIRS(MEDCalc)
EVENT_CLEAN_WORKSPACE,
EVENT_ADD_DATASOURCE,
EVENT_ADD_PRESENTATION,
+ EVENT_REMOVE_PRESENTATION,
EVENT_PLAY_TEST,
EVENT_QUIT_SALOME,
EVENT_UNKNOWN
void setPresentationProperty(in long presId, in string propName, in string propValue);
string getPresentationProperty(in long presId, in string propName);
+ void updateScalarMap(in long presId, in ScalarMapParameters params);
+ void updateContour(in long presId, in ContourParameters params);
+ void updateVectorField(in long presId, in VectorFieldParameters params);
+ void updateSlices(in long presId, in SlicesParameters params);
+ void updateDeflectionShape(in long presId, in DeflectionShapeParameters params);
+ void updatePointSprite(in long presId, in PointSpriteParameters params);
+
+ boolean removePresentation(in long presId);
+
+ // Helper functions to keep GUI sync
+ boolean activateView(in long presentationId);
+
+ MEDPresentationViewMode getPresentationViewMode(in long presId);
};
};
OP_ERROR //!< ERROR: other problems
};
+ typedef sequence<long> PresentationsList;
+
interface
MED_Gen : Engines::EngineComponent
{
status registerPresentation(in SALOMEDS::Study study,
in long fieldId,
in string name,
- in string label)
+ in string label,
+ in long presentationId)
+ raises (SALOME::SALOME_Exception);
+
+ status unregisterPresentation(in SALOMEDS::Study study,
+ in long presentationId)
raises (SALOME::SALOME_Exception);
+
+ PresentationsList getSiblingPresentations(in SALOMEDS::Study study,
+ in long presentationId)
+ raises (SALOME::SALOME_Exception);
+
};
};
IF(SALOME_BUILD_GUI)
ADD_SUBDIRECTORY(gui)
- IF(SALOME_MED_WITH_QTTESTING)
+ IF(SALOME_MED_WITH_QTTESTING)
ADD_SUBDIRECTORY(test)
ENDIF()
-
+
ENDIF()
IF(SALOME_MED_ENABLE_PYTHON)
// This constant strings are used to specify an attribute name for
// AttributeParameter attributes associated to a SObject
-#define OBJECT_ID "objectid"
-#define OBJECT_IS_IN_WORKSPACE "isInWorkspace"
+#define IS_IN_WORKSPACE "isInWorkspace"
+#define SOURCE_ID "sourceId"
+#define MESH_ID "meshId"
+#define FIELD_SERIES_ID "fieldSeriesId"
+#define FIELD_ID "fieldId"
+#define PRESENTATION_ID "presentationId"
+#define IS_PRESENTATION "isPresentation"
+
static const int NB_TYPE_OF_FIELDS = 4;
static const char* mapTypeOfFieldLabel[NB_TYPE_OF_FIELDS] =
{"ON_CELLS", "ON_NODES", "ON_GAUSS_PT", "ON_GAUSS_NE" };
-
-
-// Used by presentations
-#define FIELD_ID "fieldid"
-#define IS_PRESENTATION "ispresentation"
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
${PROJECT_BINARY_DIR}/idl
+ ${GUI_INCLUDE_DIRS} # For PyLockWrapper
)
SET(COMMON_SOURCES
${OMNIORB_LIBRARIES}
${PYTHON_LIBRARIES}
${MEDCoupling_medcoupling} ${MEDCoupling_medloader} ${MEDCoupling_medcouplingremapper}
+ ${GUI_PyInterp}
)
# This undefines the macros MIN and MAX which are specified in the windows headers
#include <SALOMEDS_SObject.hxx>
#include <Utils_ExceptHandlers.hxx>
+#include <SALOME_LifeCycleCORBA.hxx>
+#include <SALOME_NamingService.hxx>
#include <string>
+#include <sstream>
/*!
\brief Constructor
// set exception handler to catch unexpected CORBA exceptions
Unexpect aCatch(SALOME_SalomeException);
- // set result status to error initially
- MED_ORB::status result = MED_ORB::OP_ERROR;
-
// check if reference to study is valid
if (!CORBA::is_nil(study)) {
// get full object path
soDatasource->SetAttrString("AttributePixMap", "ICO_DATASOURCE");
anAttr = studyBuilder->FindOrCreateAttribute(soDatasource, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetInt(OBJECT_ID, datasourceHandler.id);
+ aParam->SetInt(SOURCE_ID, datasourceHandler.id);
useCaseBuilder->AppendTo(soDatasource->GetFather(), soDatasource);
// We can add the meshes as children of the datasource
soMesh->SetAttrString("AttributePixMap", "ICO_DATASOURCE_MESH");
anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetInt(OBJECT_ID, meshHandler.id);
- anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter");
- aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false);
+ aParam->SetInt(MESH_ID, meshHandler.id);
+ aParam->SetBool(IS_IN_WORKSPACE, false);
useCaseBuilder->AppendTo(soMesh->GetFather(), soMesh);
// We add the field timeseries defined on this mesh, as children of the mesh SObject
soFieldseries->SetAttrString("AttributePixMap", "ICO_DATASOURCE_FIELD");
anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetInt(OBJECT_ID, fieldseriesHandler.id);
- anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter");
- aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false);
+ aParam->SetInt(FIELD_SERIES_ID, fieldseriesHandler.id);
+ //aParam->SetInt(FIELD_ID, fieldseriesHandler.id);
+ aParam->SetBool(IS_IN_WORKSPACE, false);
useCaseBuilder->AppendTo(soFieldseries->GetFather(), soFieldseries);
soFieldseries->UnRegister();
}
}
- result = MED_ORB::OP_OK;
- return result;
+ return MED_ORB::OP_OK;
}
MED_ORB::status
MED::registerPresentation(SALOMEDS::Study_ptr study,
CORBA::Long fieldId,
const char* name,
- const char* label)
+ const char* label,
+ CORBA::Long presentationId)
{
// set exception handler to catch unexpected CORBA exceptions
Unexpect aCatch(SALOME_SalomeException);
- // set result status to error initially
- MED_ORB::status result = MED_ORB::OP_ERROR;
-
if (_fieldSeriesEntries.find(fieldId) == _fieldSeriesEntries.end()) {
std::cerr << "Field not found\n";
return MED_ORB::OP_ERROR ;
if (soFieldseries->IsNull()) {
std::cerr << "Entry not found\n";
- return MED_ORB::OP_ERROR;
+ return MED_ORB::OP_ERROR;
}
SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
aParam->SetInt(FIELD_ID, fieldId);
aParam->SetBool(IS_PRESENTATION, true);
+ aParam->SetInt(PRESENTATION_ID, presentationId);
- result = MED_ORB::OP_OK;
- return result;
+ return MED_ORB::OP_OK;
+}
+
+MED_ORB::status
+MED::unregisterPresentation(SALOMEDS::Study_ptr study,
+ CORBA::Long presentationId)
+{
+ // set exception handler to catch unexpected CORBA exceptions
+ Unexpect aCatch(SALOME_SalomeException);
+
+ SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
+
+ SALOMEDS::GenericAttribute_var anAttribute;
+ SALOMEDS::SComponent_var father = study->FindComponent("MED");
+ SALOMEDS::ChildIterator_var it = study->NewChildIterator(father);
+ for (it->InitEx(true); it->More(); it->Next()) {
+ SALOMEDS::SObject_var child(it->Value());
+
+ if (child->FindAttribute(anAttribute, "AttributeParameter")) {
+ SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+ if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+ continue;
+
+ if (presentationId == attrParam->GetInt(PRESENTATION_ID)) {
+ // remove object from study
+ studyBuilder->RemoveObjectWithChildren(child);
+ // remove object from use case tree
+ useCaseBuilder->Remove(child);
+ }
+ }
+ }
+
+ return MED_ORB::OP_OK;
+}
+
+MED_ORB::PresentationsList*
+MED::getSiblingPresentations(SALOMEDS::Study_ptr study, CORBA::Long presentationId)
+{
+ // set exception handler to catch unexpected CORBA exceptions
+ Unexpect aCatch(SALOME_SalomeException);
+
+ MED_ORB::PresentationsList* presList = new MED_ORB::PresentationsList;
+
+ SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
+ SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
+
+ SALOMEDS::GenericAttribute_var anAttribute;
+ SALOMEDS::SComponent_var father = study->FindComponent("MED");
+ SALOMEDS::ChildIterator_var it = study->NewChildIterator(father);
+ for (it->InitEx(true); it->More(); it->Next()) {
+ SALOMEDS::SObject_var child(it->Value());
+
+ if (child->FindAttribute(anAttribute, "AttributeParameter")) {
+ SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+ if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+ continue;
+
+ if (presentationId == attrParam->GetInt(PRESENTATION_ID)) {
+ // get siblings
+ SALOMEDS::ChildIterator_var siblItr = study->NewChildIterator(child->GetFather());
+ for (siblItr->InitEx(true); siblItr->More(); siblItr->Next()) {
+ SALOMEDS::SObject_var sibl(siblItr->Value());
+
+ if (sibl->FindAttribute(anAttribute, "AttributeParameter")) {
+ SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+ if (!attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN) || !attrParam->GetBool(IS_PRESENTATION) || !attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+ continue;
+
+ if (attrParam->GetInt(PRESENTATION_ID) != presentationId) {
+ CORBA::ULong size = presList->length();
+ presList->length(size+1);
+ (*presList)[size] = attrParam->GetInt(PRESENTATION_ID);
+ }
+ }
+ }
+ return presList;
+ }
+ }
+ }
+
+ return presList;
}
Engines::TMPFile*
return aStreamFile._retn();
}
+CORBA::Boolean
+MED::hasObjectInfo()
+{
+ return true;
+}
+
+char*
+MED::getObjectInfo(CORBA::Long studyId, const char* entry)
+{
+ SALOME_LifeCycleCORBA lcc;
+ CORBA::Object_var aSMObject = lcc.namingService()->Resolve( "/myStudyManager" );
+ SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
+ SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
+ SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( entry );
+ SALOMEDS::SObject_var aResultSObj;
+ if (aSObj->ReferencedObject(aResultSObj))
+ aSObj = aResultSObj;
+
+ if (aSObj->_is_nil())
+ return CORBA::string_dup("unknown");
+
+ SALOMEDS::GenericAttribute_var anAttribute;
+
+ std::string name("unknown");
+ if (aSObj->FindAttribute(anAttribute, "AttributeName")) {
+ SALOMEDS::AttributeName_var attrName = SALOMEDS::AttributeName::_narrow(anAttribute);
+ name = std::string(attrName->Value());
+ }
+
+ bool isInWorkspace = false;
+ //bool isPresentation = false;
+ int sourceId = -1;
+ int meshId = -1;
+ int fieldSeriesId = -1;
+ int fieldId = -1;
+ int presentationId = -1;
+ if (aSObj->FindAttribute(anAttribute, "AttributeParameter")) {
+ SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+ if (attrParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN))
+ isInWorkspace = attrParam->GetBool(IS_IN_WORKSPACE);
+ //if (attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN))
+ // isPresentation = attrParam->GetBool(IS_PRESENTATION);
+ if (attrParam->IsSet(SOURCE_ID, PT_INTEGER))
+ sourceId = attrParam->GetInt(SOURCE_ID);
+ if (attrParam->IsSet(MESH_ID, PT_INTEGER))
+ meshId = attrParam->GetInt(MESH_ID);
+ if (attrParam->IsSet(FIELD_SERIES_ID, PT_INTEGER))
+ fieldSeriesId = attrParam->GetInt(FIELD_SERIES_ID);
+ if (attrParam->IsSet(FIELD_ID, PT_INTEGER))
+ fieldId = attrParam->GetInt(FIELD_ID);
+ if (attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+ presentationId = attrParam->GetInt(PRESENTATION_ID);
+ }
+
+ if (!aSObj->_is_nil() )
+ aSObj->UnRegister();
+
+ std::ostringstream oss;
+ if (sourceId > -1)
+ oss << "Source id: " << sourceId << std::endl;
+ if (meshId > -1)
+ oss << "Mesh id: " << meshId << std::endl;
+ if (fieldSeriesId > -1)
+ oss << "Field series id: " << fieldSeriesId << std::endl;
+ if (fieldId > -1)
+ oss << "Field id: " << fieldId << std::endl;
+ //oss << "Is presentation: " << isPresentation << std::endl;
+ if (presentationId > -1)
+ oss << "Presentation id: " << presentationId << std::endl;
+ oss << "Is in workspace: " << isInWorkspace << std::endl;
+
+ return CORBA::string_dup(oss.str().c_str());
+}
+
extern "C"
{
/*!
MED_ORB::status registerPresentation(SALOMEDS::Study_ptr study,
CORBA::Long fieldId,
const char* name,
- const char* label);
+ const char* label,
+ CORBA::Long presentationId);
+
+ MED_ORB::status unregisterPresentation(SALOMEDS::Study_ptr study,
+ CORBA::Long presentationId);
+
+ // Caller owns the returned list, and is responsible for the list deletion.
+ MED_ORB::PresentationsList* getSiblingPresentations(SALOMEDS::Study_ptr study,
+ CORBA::Long presentationId);
/*! Dump the study as a Python file */
virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
+ // For tooltips
+ virtual CORBA::Boolean hasObjectInfo();
+ virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
+
private:
std::map<long, std::string> _fieldSeriesEntries;
};
#include "MEDPresentation.hxx"
#include "MEDPresentationException.hxx"
#include "MEDCouplingRefCountObject.hxx"
-#include <iostream>
+#include "Basics_Utils.hxx"
+#include "PyInterp_Utils.h"
-MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::string name)
- : _fieldHandlerId(fieldHandlerId), _pipeline(0), _display(0), _properties()
+#include <sstream>
+
+MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name)
+ : _fieldHandlerId(fieldHandlerId), _pipeline(0), _display(0), _properties(),
+ _renderViewPyId(GeneratePythonId())
{
MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
setProperty("name", name);
}
-void MEDPresentation::generatePipeline()
+MEDPresentation::~MEDPresentation()
+{
+ STDLOG("~MEDPresentation(): clear display");
+ {
+ PyLockWrapper lock;
+ std::ostringstream oss_o, oss_v, oss;
+ // Get top level object and display:
+ oss_o << "__obj" << _pipeline.front().first;
+ oss_v << "__view" << _renderViewPyId;
+ oss << "pvs.Hide(" << oss_o.str() << ", view=" << oss_v.str() << ");";
+ oss << "pvs.Render();";
+
+// std::cerr << oss.str() << std::endl;
+ PyRun_SimpleString(oss.str().c_str());
+ }
+}
+
+void
+MEDPresentation::generatePipeline()
{
// Might be more complicated in the future:
this->internalGeneratePipeline();
}
-void MEDPresentation::pushInternal(PyObject * obj, PyObject * disp)
+void
+MEDPresentation::pushPyObjects(PyObjectId obj, PyObjectId disp)
{
_pipeline.push_back(obj);
_display.push_back(disp);
}
-void MEDPresentation::setProperty(const std::string& propName, const std::string& propValue)
+void
+MEDPresentation::pushAndExecPyLine(const std::string & lin)
+{
+ // TODO: store internally for low level dump
+ PyLockWrapper lock;
+// std::cerr << lin << std::endl;
+ PyRun_SimpleString(lin.c_str());
+}
+
+void
+MEDPresentation::setProperty(const std::string& propName, const std::string& propValue)
{
// LIMITED!!! For now switch the first display element to Wireframe
/*
return (*it).second;
}
else {
- std::cerr << "getProperty(): no property named " << propName << std::endl;
+ STDLOG("MEDPresentation::getProperty(): no property named " + propName);
return std::string();
}
}
-PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var) const
+PyObject*
+MEDPresentation::getPythonObjectFromMain(const char* python_var) const
{
// TODO: improve to avoid getting dict at each call
return PyDict_GetItemString(global_dict, python_var);
}
-std::string MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const
+std::string
+MEDPresentation::getFieldTypeString(MEDCoupling::TypeOfField fieldType) const
{
switch(fieldType)
{
case MEDCoupling::ON_NODES:
return "POINTS";
default:
- std::cerr << "MEDPresentation::getFieldTypeString() -- Not implemented ! Gauss points?";
+ STDLOG("MEDPresentation::getFieldTypeString() -- Not implemented ! Gauss points?");
return "";
}
}
std::string
MEDPresentation::getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const
{
- std::string cmd = std::string("pvs._DisableFirstRenderCameraReset();");
+ std::ostringstream oss, oss2;
+ oss << "__view" << _renderViewPyId;
+ std::string view(oss.str());
+ oss2 << "pvs._DisableFirstRenderCameraReset();";
if (viewMode == MEDCALC::VIEW_MODE_OVERLAP) {
- cmd += std::string("__view1 = pvs.GetActiveViewOrCreate('RenderView');");
+ oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
} else if (viewMode == MEDCALC::VIEW_MODE_REPLACE) {
- cmd += std::string("__view1 = pvs.GetActiveViewOrCreate('RenderView');");
- cmd += std::string("pvs.active_objects.source and pvs.Hide(view=__view1);");
- cmd += std::string("pvs.Render();");
+ oss2 << view << " = pvs.GetActiveViewOrCreate('RenderView');";
+ oss2 << "pvs.active_objects.source and pvs.Hide(view=" << view << ");";
+ oss2 << "pvs.Render();";
} else if (viewMode == MEDCALC::VIEW_MODE_NEW_LAYOUT) {
- cmd += std::string("__layout1 = pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');");
- cmd += std::string("__view1 = pvs.CreateView('RenderView');");
+ oss2 << "__layout1 = pvs.servermanager.misc.ViewLayout(registrationGroup='layouts');";
+ oss2 << view << " = pvs.CreateView('RenderView');";
} else if (viewMode == MEDCALC::VIEW_MODE_SPLIT_VIEW) {
- cmd += std::string("__view1 = pvs.CreateView('RenderView');");
+ oss2 << view << " = pvs.CreateView('RenderView');";
}
- return cmd;
+ return oss2.str();
}
std::string
MEDPresentation::getResetCameraCommand() const
{
- return std::string("__view1.ResetCamera();");
+ std::ostringstream oss;
+ oss << "__view" << _renderViewPyId << ".ResetCamera();";
+ return oss.str();
}
-
std::string
MEDPresentation::getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const
{
- switch(colorMap) {
+ switch (colorMap) {
case MEDCALC::COLOR_MAP_BLUE_TO_RED_RAINBOW: return "Blue to Red Rainbow";
case MEDCALC::COLOR_MAP_COOL_TO_WARM: return "Cool to Warm";
}
}
+
+int
+MEDPresentation::GeneratePythonId()
+{
+ static int INIT_ID = 0;
+ return INIT_ID++;
+}
+
+void
+MEDPresentation::activateView() const
+{
+ PyLockWrapper lock;
+ std::ostringstream oss;
+ oss << "pvs.SetActiveView(__view" << _renderViewPyId << ");";
+ std::cerr << oss.str() << std::endl;
+ PyRun_SimpleString(oss.str().c_str());
+}
typedef ::CORBA::Long TypeID;
- virtual ~MEDPresentation() {}
+ virtual ~MEDPresentation();
void setProperty(const std::string& propName, const std::string& propValue);
const std::string getProperty(const std::string& propName) const;
+ void activateView() const;
+
protected:
+ typedef std::pair<int, PyObject *> PyObjectId;
- MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::string name);
+ MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name);
std::string getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const;
std::string getResetCameraCommand() const;
std::string getColorMapCommand(MEDCALC::MEDPresentationColorMap colorMap) const;
virtual void internalGeneratePipeline() = 0;
- PyObject * getPythonObjectFromMain(const char * var) const;
- void pushInternal(PyObject * obj, PyObject * disp = NULL);
+ PyObject* getPythonObjectFromMain(const char* var) const;
+ void pushPyObjects(PyObjectId obj, PyObjectId disp);
+ void pushAndExecPyLine(const std::string & lin);
MEDPresentation::TypeID getID() const { return _fieldHandlerId; }
+ long getPyViewID() const { return _renderViewPyId; }
+
+ static int GeneratePythonId();
+
+ virtual MEDCALC::MEDPresentationViewMode getViewMode() = 0;
private:
- void generatePipeline(); // reserved to friend class MEDPresentationManager
std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const;
-protected:
+ // The following functions are reserved to friend class MEDPresentationManager
+ void generatePipeline();
+
+ template<typename PresentationType, typename PresentationParameters>
+ void updatePipeline(PresentationParameters params);
+protected:
std::string _fileName;
std::string _fieldName;
std::string _fieldType;
-private:
+ ///! Identifier (in the Python dump) of the render view
+ int _renderViewPyId;
+private:
MEDPresentation::TypeID _fieldHandlerId;
///! Pipeline elements
- std::vector< PyObject * > _pipeline;
+ std::vector<PyObjectId> _pipeline;
///! Corresponding display object, if any:
- std::vector< PyObject * > _display;
+ std::vector<PyObjectId> _display;
///! Presentation properties <key,value>
std::map<std::string, std::string> _properties;
};
+#include "MEDPresentation.txx"
+
#endif /* SRC_MEDCALC_CMP_MEDPRESENTATION_HXX_ */
--- /dev/null
+// Copyright (C) 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
+//
+
+#ifndef _MED_PRESENTATION_TXX_
+#define _MED_PRESENTATION_TXX_
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentation::updatePipeline(PresentationParameters params)
+{
+ static_cast<PresentationType*>(this)->updatePipeline(params);
+}
+
+#endif // _MED_PRESENTATION_TXX_
void
MEDPresentationContour::internalGeneratePipeline()
{
- PyGILState_STATE _gil_state = PyGILState_Ensure();
-
- std::string cmd = std::string("import pvsimple as pvs;");
- cmd += getRenderViewCommand(_params.viewMode); // define __view1
-
- cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
- cmd += std::string("__isovolume1 = pvs.IsoVolume(Input=__obj1);");
- cmd += std::string("__disp1 = pvs.Show(__isovolume1, __view1);");
- cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
- cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
- cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
- cmd += std::string("pvs.Render();");
-
- cmd += getResetCameraCommand();
-
- //std::cerr << "Python command:" << std::endl;
- //std::cerr << cmd << std::endl;
- PyRun_SimpleString(cmd.c_str());
- // Retrieve Python object for internal storage:
- PyObject* obj = getPythonObjectFromMain("__isovolume1");
- PyObject* disp = getPythonObjectFromMain("__disp1");
- pushInternal(obj, disp);
+// PyGILState_STATE _gil_state = PyGILState_Ensure();
+//
+// std::string cmd = std::string("import pvsimple as pvs;");
+// cmd += getRenderViewCommand(_params.viewMode); // define __view1
+//
+// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
+// cmd += std::string("__isovolume1 = pvs.IsoVolume(Input=__obj1);");
+// cmd += std::string("__disp1 = pvs.Show(__isovolume1, __view1);");
+// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
+// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
+// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
+// cmd += std::string("pvs.Render();");
+//
+// cmd += getResetCameraCommand();
+//
+// //std::cerr << "Python command:" << std::endl;
+// //std::cerr << cmd << std::endl;
+// PyRun_SimpleString(cmd.c_str());
+// // Retrieve Python object for internal storage:
+// PyObject* obj = getPythonObjectFromMain("__isovolume1");
+// PyObject* disp = getPythonObjectFromMain("__disp1");
+// pushInternal(obj, disp);
+//
+// PyGILState_Release(_gil_state);
+}
- PyGILState_Release(_gil_state);
+void
+MEDPresentationContour::updatePipeline(const MEDCALC::ContourParameters& params)
+{
+ // :TODO:
}
{}
virtual ~MEDPresentationContour() {}
+ void updatePipeline(const MEDCALC::ContourParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
protected:
virtual void internalGeneratePipeline();
void
MEDPresentationDeflectionShape::internalGeneratePipeline()
{
- PyGILState_STATE _gil_state = PyGILState_Ensure();
-
- std::string cmd = std::string("import pvsimple as pvs;");
- cmd += getRenderViewCommand(_params.viewMode); // define __view1
-
- cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
- cmd += std::string("__warpByVector1 = pvs.WarpByVector(Input=__obj1);");
- cmd += std::string("__disp1 = pvs.Show(__warpByVector1, __view1);");
- cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
- cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
- cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
- cmd += std::string("pvs.Render();");
-
- cmd += getResetCameraCommand();
-
- //std::cerr << "Python command:" << std::endl;
- //std::cerr << cmd << std::endl;
- PyRun_SimpleString(cmd.c_str());
- // Retrieve Python object for internal storage:
- PyObject* obj = getPythonObjectFromMain("__warpByVector1");
- PyObject* disp = getPythonObjectFromMain("__disp1");
- pushInternal(obj, disp);
+// PyGILState_STATE _gil_state = PyGILState_Ensure();
+//
+// std::string cmd = std::string("import pvsimple as pvs;");
+// cmd += getRenderViewCommand(_params.viewMode); // define __view1
+//
+// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
+// cmd += std::string("__warpByVector1 = pvs.WarpByVector(Input=__obj1);");
+// cmd += std::string("__disp1 = pvs.Show(__warpByVector1, __view1);");
+// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
+// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
+// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
+// cmd += std::string("pvs.Render();");
+//
+// cmd += getResetCameraCommand();
+//
+// //std::cerr << "Python command:" << std::endl;
+// //std::cerr << cmd << std::endl;
+// PyRun_SimpleString(cmd.c_str());
+// // Retrieve Python object for internal storage:
+// PyObject* obj = getPythonObjectFromMain("__warpByVector1");
+// PyObject* disp = getPythonObjectFromMain("__disp1");
+// pushInternal(obj, disp);
+//
+// PyGILState_Release(_gil_state);
+}
- PyGILState_Release(_gil_state);
+void
+MEDPresentationDeflectionShape::updatePipeline(const MEDCALC::DeflectionShapeParameters& params)
+{
+ // :TODO:
}
{}
virtual ~MEDPresentationDeflectionShape() {}
+ void updatePipeline(const MEDCALC::DeflectionShapeParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
protected:
virtual void internalGeneratePipeline();
#include "MEDPresentationManager_i.hxx"
#include "MEDFactoryClient.hxx"
+#include "Basics_Utils.hxx"
// presentations
#include "MEDPresentationScalarMap.hxx"
#include "MEDPresentationPointSprite.hxx"
#include <iostream>
+#include <sstream>
MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL;
return START_ID;
}
+MEDPresentation*
+MEDPresentationManager_i::_getPresentation(MEDPresentation::TypeID presentationID) const
+{
+ std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
+ if (citr == _presentations.end())
+ return NULL;
+ return (*citr).second;
+}
+
void
-MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char * propName, const char * propValue)
+MEDPresentationManager_i::setPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName, const char* propValue)
{
- if (_presentations.find(presentationID) != _presentations.end())
- {
- MEDPresentation * pres(_presentations[presentationID]);
- pres->setProperty(propName, propValue);
- }
+ MEDPresentation* pres = _getPresentation(presentationID);
+ if (pres)
+ pres->setProperty(propName, propValue);
else
- {
- std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
- }
+ std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
}
char*
MEDPresentationManager_i::getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName)
{
- if (_presentations.find(presentationID) != _presentations.end()) {
- MEDPresentation* pres = _presentations[presentationID];
+ MEDPresentation* pres = _getPresentation(presentationID);
+ if (pres) {
return (char*) pres->getProperty(propName).c_str();
}
else {
{
return _makePresentation<MEDPresentationPointSprite>(params);
}
+
+void
+MEDPresentationManager_i::updateScalarMap(MEDPresentation::TypeID presentationID, const MEDCALC::ScalarMapParameters& params)
+{
+ return _updatePresentation<MEDPresentationScalarMap>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters& params)
+{
+ return _updatePresentation<MEDPresentationContour>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters& params)
+{
+ return _updatePresentation<MEDPresentationVectorField>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters& params)
+{
+ return _updatePresentation<MEDPresentationSlices>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters& params)
+{
+ return _updatePresentation<MEDPresentationDeflectionShape>(presentationID, params);
+}
+
+void
+MEDPresentationManager_i::updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters& params)
+{
+ return _updatePresentation<MEDPresentationPointSprite>(presentationID, params);
+}
+
+CORBA::Boolean
+MEDPresentationManager_i::removePresentation(MEDPresentation::TypeID presentationID)
+{
+ std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
+ if (citr == _presentations.end()) {
+ std::cerr << "removePresentation(): presentation not found!!" << std::endl;
+ return false;
+ }
+ MEDPresentation* presentation = (*citr).second;
+ if (presentation)
+ delete presentation;
+ _presentations.erase(presentationID);
+
+ std::stringstream sstm;
+ sstm << "Presentation " << presentationID << " has been removed.\n";
+ STDLOG(sstm.str());
+
+ return true;
+}
+
+CORBA::Boolean
+MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID)
+{
+ std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator citr = _presentations.find(presentationID);
+ if (citr == _presentations.end()) {
+ std::cerr << "getPresentationPyViewId(): presentation not found!!" << std::endl;
+ return false;
+ }
+ MEDPresentation* presentation = (*citr).second;
+
+ presentation->activateView();
+ return true;
+}
+
+MEDCALC::MEDPresentationViewMode
+MEDPresentationManager_i::getPresentationViewMode(MEDPresentation::TypeID presentationID)
+{
+ MEDPresentation* pres = _getPresentation(presentationID);
+ if (pres) {
+ return pres->getViewMode();
+ } else {
+ std::cerr << "setPresentationProperty(): presentation not found!!" << std::endl;
+ return MEDCALC::VIEW_MODE_DEFAULT;
+ }
+}
MEDCALC_EXPORT MEDPresentation::TypeID makeDeflectionShape(const MEDCALC::DeflectionShapeParameters&);
MEDCALC_EXPORT MEDPresentation::TypeID makePointSprite(const MEDCALC::PointSpriteParameters&);
- MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID presentationID, const char * propName, const char * propValue);
- MEDCALC_EXPORT char* getPresentationProperty(MEDPresentation::TypeID presentationID, const char* propName);
+ MEDCALC_EXPORT void setPresentationProperty(MEDPresentation::TypeID, const char* propName, const char* propValue);
+ MEDCALC_EXPORT char* getPresentationProperty(MEDPresentation::TypeID, const char* propName);
+
+ MEDCALC_EXPORT void updateScalarMap(MEDPresentation::TypeID, const MEDCALC::ScalarMapParameters&);
+ MEDCALC_EXPORT void updateContour(MEDPresentation::TypeID, const MEDCALC::ContourParameters&);
+ MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID, const MEDCALC::VectorFieldParameters&);
+ MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID, const MEDCALC::SlicesParameters&);
+ MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID, const MEDCALC::DeflectionShapeParameters&);
+ MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID, const MEDCALC::PointSpriteParameters&);
+
+ MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID);
+
+ MEDCALC_EXPORT CORBA::Boolean activateView(MEDPresentation::TypeID);
+
+ MEDCALC_EXPORT MEDCALC::MEDPresentationViewMode getPresentationViewMode(MEDPresentation::TypeID);
private:
MEDPresentationManager_i();
template<typename PresentationType, typename PresentationParameters>
MEDPresentation::TypeID _makePresentation(PresentationParameters params);
+ // Update presentation
+ template<typename PresentationType, typename PresentationParameters>
+ void _updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params);
+
+ MEDPresentation* _getPresentation(MEDPresentation::TypeID) const;
+
private :
// The MEDPresentationManager is a singleton, whose instance can be obtained
// using the getInstance static method.
- static MEDPresentationManager_i * _instance;
+ static MEDPresentationManager_i* _instance;
// Owns a list of MEDPresentation objects
- std::map< MEDPresentation::TypeID, MEDPresentation * > _presentations;
+ std::map<MEDPresentation::TypeID, MEDPresentation*> _presentations;
};
return newID;
}
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params)
+{
+ MEDPresentation* presentation = _getPresentation(presentationID);
+ if (!presentation) {
+ std::cerr << "_updatePresentation(): presentation not found!!" << std::endl;
+ return;
+ }
+
+ presentation->updatePipeline<PresentationType>(params);
+}
+
#endif // _MED_PRESENTATION_MANAGER_I_TXX_
void
MEDPresentationPointSprite::internalGeneratePipeline()
{
- PyGILState_STATE _gil_state = PyGILState_Ensure();
-
- std::string cmd = std::string("import pvsimple as pvs;");
- cmd += getRenderViewCommand(_params.viewMode); // define __view1
-
- cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
- cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);");
- cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
- cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
- cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
- cmd += std::string("__disp1.SetRepresentationType('Point Sprite');");
- cmd += std::string("pvs.Render();");
-
- cmd += getResetCameraCommand();
-
- //std::cerr << "Python command:" << std::endl;
- //std::cerr << cmd << std::endl;
- PyRun_SimpleString(cmd.c_str());
- // Retrieve Python object for internal storage:
- PyObject* obj = getPythonObjectFromMain("__obj1");
- PyObject* disp = getPythonObjectFromMain("__disp1");
- pushInternal(obj, disp);
+// PyGILState_STATE _gil_state = PyGILState_Ensure();
+//
+// std::string cmd = std::string("import pvsimple as pvs;");
+// cmd += getRenderViewCommand(_params.viewMode); // define __view1
+//
+// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
+// cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);");
+// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
+// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
+// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
+// cmd += std::string("__disp1.SetRepresentationType('Point Sprite');");
+// cmd += std::string("pvs.Render();");
+//
+// cmd += getResetCameraCommand();
+//
+// //std::cerr << "Python command:" << std::endl;
+// //std::cerr << cmd << std::endl;
+// PyRun_SimpleString(cmd.c_str());
+// // Retrieve Python object for internal storage:
+// PyObject* obj = getPythonObjectFromMain("__obj1");
+// PyObject* disp = getPythonObjectFromMain("__disp1");
+// pushInternal(obj, disp);
+//
+// PyGILState_Release(_gil_state);
+}
- PyGILState_Release(_gil_state);
+void
+MEDPresentationPointSprite::updatePipeline(const MEDCALC::PointSpriteParameters& params)
+{
+ // :TODO:
}
{}
virtual ~MEDPresentationPointSprite() {}
+ void updatePipeline(const MEDCALC::PointSpriteParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
protected:
virtual void internalGeneratePipeline();
//
#include "MEDPresentationScalarMap.hxx"
+#include "PyInterp_Utils.h"
+
+#include <sstream>
void
MEDPresentationScalarMap::internalGeneratePipeline()
{
- PyGILState_STATE _gil_state = PyGILState_Ensure();
+ PyLockWrapper lock;
+
+ int disp_id(GeneratePythonId());
+ int obj_id(disp_id);
+ std::ostringstream oss_o, oss_d, oss, oss_v;
+ oss_o << "__obj" << obj_id; std::string obj(oss_o.str());
+ oss_d << "__disp" << disp_id; std::string disp(oss_d.str());
- std::string cmd = std::string("import pvsimple as pvs;");
- cmd += getRenderViewCommand(_params.viewMode); // define __view1
+ pushAndExecPyLine( "import pvsimple as pvs;");
+ pushAndExecPyLine( getRenderViewCommand(_params.viewMode) ); // define __viewXXX
- cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
- cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);");
- cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
- cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
- cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
- cmd += std::string("__lut = pvs.GetColorTransferFunction('")+_fieldName+std::string("');");
- cmd += std::string("__lut.ApplyPreset('")+getColorMapCommand(_params.colorMap)+std::string("',True);");
- cmd += std::string("pvs.Render();");
+ oss_v << "__view" << _renderViewPyId; std::string view(oss_v.str());
- cmd += getResetCameraCommand();
+ oss << obj << " = pvs.MEDReader(FileName='" << _fileName << "');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << disp << " = pvs.Show(" << obj << ", " << view << ");";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << "pvs.ColorBy(" << disp << ", ('" << _fieldType << "', '" << _fieldName << "'));";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << disp << ".SetScalarBarVisibility(" << view << ", True);";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << disp << ".RescaleTransferFunctionToDataRangeOverTime();";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << "__lut = pvs.GetColorTransferFunction('" << _fieldName << "');";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ oss << "__lut.ApplyPreset('" << getColorMapCommand(_params.colorMap) << "',True);";
+ pushAndExecPyLine(oss.str()); oss.str("");
+ pushAndExecPyLine(getResetCameraCommand());
+ pushAndExecPyLine("pvs.Render();");
- //std::cerr << "Python command:" << std::endl;
- //std::cerr << cmd << std::endl;
- PyRun_SimpleString(cmd.c_str());
// Retrieve Python object for internal storage:
- PyObject* obj = getPythonObjectFromMain("__obj1");
- PyObject* disp = getPythonObjectFromMain("__disp1");
- pushInternal(obj, disp);
+ PyObject* p_obj = getPythonObjectFromMain(obj.c_str());
+ PyObject* p_disp = getPythonObjectFromMain(disp.c_str());
+ pushPyObjects(std::make_pair(obj_id, p_obj), std::make_pair(disp_id, p_disp));
+}
- PyGILState_Release(_gil_state);
+void
+MEDPresentationScalarMap::updatePipeline(const MEDCALC::ScalarMapParameters& params)
+{
+ // :TODO:
}
{}
virtual ~MEDPresentationScalarMap() {}
+ void updatePipeline(const MEDCALC::ScalarMapParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
protected:
virtual void internalGeneratePipeline();
void
MEDPresentationSlices::internalGeneratePipeline()
{
- PyGILState_STATE _gil_state = PyGILState_Ensure();
-
- std::string cmd = std::string("import pvsimple as pvs;");
- cmd += getRenderViewCommand(_params.viewMode); // define __view1
-
- cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
- cmd += std::string("__slice1 = pvs.Slice(Input=__obj1);");
- cmd += std::string("__disp1 = pvs.Show(__slice1, __view1);");
- cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
- cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
- cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
- cmd += std::string("pvs.Render();");
-
- cmd += getResetCameraCommand();
-
- //std::cerr << "Python command:" << std::endl;
- //std::cerr << cmd << std::endl;
- PyRun_SimpleString(cmd.c_str());
- // Retrieve Python object for internal storage:
- PyObject* obj = getPythonObjectFromMain("__slice1");
- PyObject* disp = getPythonObjectFromMain("__disp1");
- pushInternal(obj, disp);
+// PyGILState_STATE _gil_state = PyGILState_Ensure();
+//
+// std::string cmd = std::string("import pvsimple as pvs;");
+// cmd += getRenderViewCommand(_params.viewMode); // define __view1
+//
+// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
+// cmd += std::string("__slice1 = pvs.Slice(Input=__obj1);");
+// cmd += std::string("__disp1 = pvs.Show(__slice1, __view1);");
+// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
+// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
+// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
+// cmd += std::string("pvs.Render();");
+//
+// cmd += getResetCameraCommand();
+//
+// //std::cerr << "Python command:" << std::endl;
+// //std::cerr << cmd << std::endl;
+// PyRun_SimpleString(cmd.c_str());
+// // Retrieve Python object for internal storage:
+// PyObject* obj = getPythonObjectFromMain("__slice1");
+// PyObject* disp = getPythonObjectFromMain("__disp1");
+// pushInternal(obj, disp);
+//
+// PyGILState_Release(_gil_state);
+}
- PyGILState_Release(_gil_state);
+void
+MEDPresentationSlices::updatePipeline(const MEDCALC::SlicesParameters& params)
+{
+ // :TODO:
}
{}
virtual ~MEDPresentationSlices() {}
+ void updatePipeline(const MEDCALC::SlicesParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
protected:
virtual void internalGeneratePipeline();
void
MEDPresentationVectorField::internalGeneratePipeline()
{
- PyGILState_STATE _gil_state = PyGILState_Ensure();
-
- std::string cmd = std::string("import pvsimple as pvs;");
- cmd += getRenderViewCommand(_params.viewMode); // define __view1
-
- cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
- cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);");
- cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
- cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
- cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
- cmd += std::string("__disp1.SetRepresentationType('3D Glyphs');");
- cmd += std::string("pvs.Render();");
-
- cmd += getResetCameraCommand();
-
- //std::cerr << "Python command:" << std::endl;
- //std::cerr << cmd << std::endl;
- PyRun_SimpleString(cmd.c_str());
- // Retrieve Python object for internal storage:
- PyObject* obj = getPythonObjectFromMain("__obj1");
- PyObject* disp = getPythonObjectFromMain("__disp1");
- pushInternal(obj, disp);
+// PyGILState_STATE _gil_state = PyGILState_Ensure();
+//
+// std::string cmd = std::string("import pvsimple as pvs;");
+// cmd += getRenderViewCommand(_params.viewMode); // define __view1
+//
+// cmd += std::string("__obj1 = pvs.MEDReader(FileName='") + _fileName + std::string("');");
+// cmd += std::string("__disp1 = pvs.Show(__obj1, __view1);");
+// cmd += std::string("pvs.ColorBy(__disp1, ('") + _fieldType + std::string("', '") + _fieldName + std::string("'));");
+// cmd += std::string("__disp1.SetScalarBarVisibility(__view1, True);");
+// cmd += std::string("__disp1.RescaleTransferFunctionToDataRangeOverTime();");
+// cmd += std::string("__disp1.SetRepresentationType('3D Glyphs');");
+// cmd += std::string("pvs.Render();");
+//
+// cmd += getResetCameraCommand();
+//
+// //std::cerr << "Python command:" << std::endl;
+// //std::cerr << cmd << std::endl;
+// PyRun_SimpleString(cmd.c_str());
+// // Retrieve Python object for internal storage:
+// PyObject* obj = getPythonObjectFromMain("__obj1");
+// PyObject* disp = getPythonObjectFromMain("__disp1");
+// pushInternal(obj, disp);
+//
+// PyGILState_Release(_gil_state);
+}
- PyGILState_Release(_gil_state);
+void
+MEDPresentationVectorField::updatePipeline(const MEDCALC::VectorFieldParameters& params)
+{
+ // :TODO:
}
{}
virtual ~MEDPresentationVectorField() {}
+ void updatePipeline(const MEDCALC::VectorFieldParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
+
protected:
virtual void internalGeneratePipeline();
SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i);
// First retrieve the fieldseries id associated to this study object
- long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,OBJECT_ID);
+ long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_SERIES_ID);
+ //long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_ID);
STDLOG("Expand the field timeseries "<<fieldseriesId);
// If fieldseriesId equals -1, then it means that it is not a
SALOMEDS::SObject_var soField = _studyEditor->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);
SALOMEDS::SObject_var soField = listOfSObject->at(0);
- bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
+ bool isInWorkspace = _studyEditor->getParameterBool(soField,IS_IN_WORKSPACE);
if ( isInWorkspace ) {
QMessageBox::warning(_salomeModule->getApp()->desktop(),
tr("Operation not allowed"),
return;
}
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,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.
event->objectalias = alias;
emit datasourceSignal(event);
// 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?)
for (int i=0; i<listOfSObject->size(); i++) {
SALOMEDS::SObject_var soField = listOfSObject->at(i);
- bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
+ bool isInWorkspace = _studyEditor->getParameterBool(soField,IS_IN_WORKSPACE);
if ( !isInWorkspace ) {
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
MEDCALC::FieldHandler* fieldHandler =
MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
DatasourceEvent* event = new DatasourceEvent();
// 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?)
#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());
STDLOG(" - Presentation name: " + name);
+ // :TODO:
+ // get edited values from a popup widget
+ // get presentation
+ // call presentation edit function
+
}
void
#include <QModelIndex>
class SalomeApp_Application;
+class PVViewer_GUIElements;
+class MEDPresentationManager_i;
/*!
* This class defines the gui of the MED module.
virtual bool activateModule(SUIT_Study* theStudy);
virtual bool deactivateModule(SUIT_Study* theStudy);
virtual void onDblClick(const QModelIndex& index);
+ virtual void onClick(const QModelIndex& index);
+
+
private:
void createModuleWidgets();
void createModuleActions();
+ void initToolbars();
+ bool itemClickGeneric(const QModelIndex & index, std::string & name, int & fieldId, int & presId) const;
static void init();
XmedDataModel* _xmedDataModel;
PresentationController* _presentationController;
ProcessingController* _processingController;
+
+ PVViewer_GUIElements* _pvGuiElements;
+
+ static MED_ORB::MED_Gen_var _MED_engine;
+
+ // GUI needs to talk directly to the pres manager to activate a view, get some params, etc ...:
+ static MEDCALC::MEDPresentationManager_ptr _presManager;
+
#ifdef MED_HAS_QTTESTING
TestController * _testController;
#endif
- static MED_ORB::MED_Gen_var myEngine;
};
#endif
<source>ICO_MEDPresentationPointSprite_CLASSIC</source>
<translation>visu_points16.png</translation>
</message>
+ <message>
+ <source>ICO_DELETE_PRESENTATION</source>
+ <translation>close.png</translation>
+ </message>
</context>
</TS>
<source>TIP_PRESENTATION_POINT_SPRITE</source>
<translation>Point sprite</translation>
</message>
+ <message>
+ <source>LAB_DELETE_PRESENTATION</source>
+ <translation>Delete presentation</translation>
+ </message>
+ <message>
+ <source>TIP_DELETE_PRESENTATION</source>
+ <translation>Delete selected presentation</translation>
+ </message>
<message>
<source>MENU_PRESENTATIONS</source>
<translation>Presentations</translation>
<context>
<name>WidgetPresentationParameters</name>
<message>
- <source>LAB_FIELD</source>
- <translation>Field:</translation>
+ <source>LAB_DISP_COMP</source>
+ <translation>Displayed component:</translation>
</message>
<message>
<source>LAB_EUCLIDEAN_NORM</source>
<context>
<name>WidgetPresentationParameters</name>
<message>
- <source>LAB_FIELD</source>
- <translation>Champ :</translation>
+ <source>LAB_DISP_COMP</source>
+ <translation>Composante affichée :</translation>
</message>
<message>
<source>LAB_EUCLIDEAN_NORM</source>
#include "QtxActionGroup.h"
#include "QtxActionToolMgr.h"
#include "MEDFactoryClient.hxx"
+#include "MEDPresentationManager_i.hxx"
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <QMessageBox>
+#include <sstream>
-PresentationController::PresentationController(MEDModule* salomeModule)
+static const int OPTIONS_VIEW_MODE_ID = 943;
+static const int OPTIONS_VIEW_MODE_REPLACE_ID = 944;
+static const int OPTIONS_VIEW_MODE_OVERLAP_ID = 945;
+static const int OPTIONS_VIEW_MODE_NEW_LAYOUT_ID = 946;
+static const int OPTIONS_VIEW_MODE_SPLIT_VIEW_ID = 947;
+
+PresentationController::PresentationController(MEDModule* salomeModule) :
+ _salomeModule(salomeModule),
+ _studyEditor(salomeModule->getStudyEditor())
{
STDLOG("Creating a PresentationController");
- _salomeModule = salomeModule;
- _studyEditor = _salomeModule->getStudyEditor();
_widgetPresentationParameters = new WidgetPresentationParameters();
{
STDLOG("Creating PresentationController actions");
+ // View Mode
+ int viewModeToolbarId = _salomeModule->createTool("View Mode", "ViewModeToolbar");
+ QtxActionGroup* ag = _salomeModule->createActionGroup(OPTIONS_VIEW_MODE_ID, true);
+ ag->setText("View mode");
+ ag->setUsesDropDown(true);
+ QString label = tr("LAB_VIEW_MODE_REPLACE");
+ QString tooltip = tr("TIP_VIEW_MODE_REPLACE");
+ QAction* a = _salomeModule->createAction(OPTIONS_VIEW_MODE_REPLACE_ID,label,QIcon(),label,tooltip,0);
+ a->setCheckable(true);
+ a->setChecked(true);
+ ag->add(a);
+
+ label = tr("LAB_VIEW_MODE_OVERLAP");
+ tooltip = tr("TIP_VIEW_MODE_OVERLAP");
+ a = _salomeModule->createAction(OPTIONS_VIEW_MODE_OVERLAP_ID,label,QIcon(),label,tooltip,0);
+ a->setCheckable(true);
+ ag->add(a);
+
+ label = tr("LAB_VIEW_MODE_NEW_LAYOUT");
+ tooltip = tr("TIP_VIEW_MODE_NEW_LAYOUT");
+ a = _salomeModule->createAction(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID,label,QIcon(),label,tooltip,0);
+ a->setCheckable(true);
+ ag->add(a);
+
+ label = tr("LAB_VIEW_MODE_SPLIT_VIEW");
+ tooltip = tr("TIP_VIEW_MODE_SPLIT_VIEW");
+ a = _salomeModule->createAction(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID,label,QIcon(),label,tooltip,0);
+ a->setCheckable(true);
+ ag->add(a);
+
+ _salomeModule->createTool(OPTIONS_VIEW_MODE_ID, viewModeToolbarId);
+
+ // Presentations
int presentationToolbarId = _salomeModule->createTool("Presentations", "PresentationToolbar");
int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1);
- // Presentations
- QString label = tr("LAB_PRESENTATION_SCALAR_MAP");
- QString tooltip = tr("TIP_PRESENTATION_SCALAR_MAP");
+ label = tr("LAB_PRESENTATION_SCALAR_MAP");
+ tooltip = tr("TIP_PRESENTATION_SCALAR_MAP");
QString icon = tr(_getIconName("ICO_PRESENTATION_SCALAR_MAP").c_str());
int actionId;
actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeScalarMap()),icon,tooltip);
_salomeModule->createTool(actionId, presentationToolbarId);
_salomeModule->action(actionId)->setIconVisibleInMenu(true);
_salomeModule->createMenu(actionId, presentationMenuId);
+
+ label = tr("LAB_DELETE_PRESENTATION");
+ tooltip = tr("TIP_DELETE_PRESENTATION");
+ icon = tr(_getIconName("ICO_DELETE_PRESENTATION").c_str());
+ actionId = _salomeModule->createStandardAction(label,this, SLOT(OnDeletePresentation()),icon,tooltip);
+// _salomeModule->createTool(actionId, presentationToolbarId);
+// _salomeModule->action(actionId)->setIconVisibleInMenu(true);
+ _salomeModule->createMenu(actionId, presentationMenuId);
+
}
MEDCALC::MEDPresentationViewMode
PresentationController::getSelectedViewMode()
{
- return _widgetPresentationParameters->getViewMode();
+ if (_salomeModule->action(OPTIONS_VIEW_MODE_REPLACE_ID)->isChecked()) {
+ return MEDCALC::VIEW_MODE_REPLACE;
+ }
+ else if (_salomeModule->action(OPTIONS_VIEW_MODE_OVERLAP_ID)->isChecked()) {
+ return MEDCALC::VIEW_MODE_OVERLAP;
+ }
+ else if (_salomeModule->action(OPTIONS_VIEW_MODE_NEW_LAYOUT_ID)->isChecked()) {
+ return MEDCALC::VIEW_MODE_NEW_LAYOUT;
+ }
+ else if (_salomeModule->action(OPTIONS_VIEW_MODE_SPLIT_VIEW_ID)->isChecked()) {
+ return MEDCALC::VIEW_MODE_SPLIT_VIEW;
+ }
+ // Should not happen
+ STDLOG("Strange!! No matching view mode found - returning VIEW_MODE_REPLACE.");
+ return MEDCALC::VIEW_MODE_REPLACE;
}
MEDCALC::MEDPresentationColorMap
// to make a view of an object from the tui console).
for (int i=0; i<listOfSObject->size(); i++) {
SALOMEDS::SObject_var soField = listOfSObject->at(i);
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_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.
- if ( fieldId < 0 )
- continue;
+ int fieldId = -1;
+ try {
+ fieldId = _studyEditor->getParameterInt(soField,FIELD_ID); }
+ catch(...) { }
+ if (fieldId < 0) // is it a field serie ?
+ {
+ int fieldSeriesId = -1;
+ try {
+ fieldSeriesId = _studyEditor->getParameterInt(soField,FIELD_SERIES_ID); }
+ catch(...) { }
+ // If fieldId and fieldSeriesId equals -1, then it means that it is not a field
+ // managed by the MED module, and we stop this function process.
+ 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;
+ }
MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
if (! fieldHandler) {
this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE);
}
+void
+PresentationController::OnDeletePresentation()
+{
+ // We need a _studyEditor updated on the active study
+ _studyEditor->updateActiveStudy();
+
+ // Get the selected objects in the study (SObject)
+ SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
+
+ // For each object, emit a signal to the workspace to request pres deletion
+ for (int i=0; i<listOfSObject->size(); i++) {
+ SALOMEDS::SObject_var soPres = listOfSObject->at(i);
+ int presId = _studyEditor->getParameterInt(soPres,PRESENTATION_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.
+ if ( presId < 0 )
+ continue;
+
+ STDLOG("Requesting deletion of presentation: ")
+ std::ostringstream oss;
+ oss << presId;
+ STDLOG(" - Pres id: " + oss.str());
+
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION;
+ XmedDataObject* dataObject = new XmedDataObject();
+ dataObject->setPresentationId(presId);
+ event->objectdata = dataObject;
+ emit presentationSignal(event); // --> WorkspaceController::processPresentationEvent
+ }
+}
+
void
PresentationController::updateTreeViewWithNewPresentation(long fieldId, long presentationId)
{
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
_PTR(Study) studyDS = study->studyDS();
- _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str());
+ _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str(), presentationId);
+
+
+ MEDCALC::MEDPresentationViewMode viewMode = MEDFactoryClient::getPresentationManager()->getPresentationViewMode(presentationId);
+
+ // Remove sibling presentations if view mode is set to REPLACE
+ if (viewMode == MEDCALC::VIEW_MODE_REPLACE) {
+ MED_ORB::PresentationsList* presList = _salomeModule->engine()->getSiblingPresentations(_CAST(Study, studyDS)->GetStudy(), presentationId);
+ CORBA::ULong size = presList->length();
+
+ std::stringstream sstm;
+ sstm << "Removing sibling presentation(s): ";
+ for (int i = 0; i < size; ++i)
+ sstm << (*presList)[i] << " ";
+ STDLOG(sstm.str());
+
+ for (int i = 0; i < size; ++i) {
+ PresentationEvent* event = new PresentationEvent();
+ event->eventtype = PresentationEvent::EVENT_DELETE_PRESENTATION;
+ XmedDataObject* dataObject = new XmedDataObject();
+ dataObject->setPresentationId((*presList)[i]);
+ event->objectdata = dataObject;
+ emit presentationSignal(event); // --> WorkspaceController::processPresentationEvent
+ }
+
+ delete presList;
+ }
+
+ // update Object browser
+ _salomeModule->getApp()->updateObjectBrowser(true);
+}
+
+void
+PresentationController::updateTreeViewForPresentationRemoval(long presentationId)
+{
+ if (presentationId < 0) {
+ std::cerr << "Unknown presentation\n";
+ return;
+ }
+
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
+ _PTR(Study) studyDS = study->studyDS();
+
+ _salomeModule->engine()->unregisterPresentation(_CAST(Study, studyDS)->GetStudy(), presentationId);
// update Object browser
_salomeModule->getApp()->updateObjectBrowser(true);
if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
}
+ else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
+ this->updateTreeViewForPresentationRemoval(event->presentationId);
+ }
}
void
EVENT_VIEW_OBJECT_POINT_SPRITE,
EVENT_VIEW_OBJECT_SCALAR_MAP,
EVENT_VIEW_OBJECT_SLICES,
- EVENT_VIEW_OBJECT_VECTOR_FIELD
+ EVENT_VIEW_OBJECT_VECTOR_FIELD,
+ EVENT_DELETE_PRESENTATION
};
int eventtype;
XmedDataObject* objectdata;
void OnVisualizeSlices();
void OnVisualizeDeflectionShape();
void OnVisualizePointSprite();
+
+ void OnDeletePresentation();
+
void processWorkspaceEvent(const MEDCALC::MedEvent*);
private:
void visualize(PresentationEvent::EventType);
void updateTreeViewWithNewPresentation(long, long);
+ void updateTreeViewForPresentationRemoval(long);
std::string _getIconName(const std::string&);
private:
MEDModule* _salomeModule;
SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule
+
QDockWidget *_dockWidget;
WidgetPresentationParameters* _widgetPresentationParameters;
};
SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
if ( listOfSObject->size() > 0 ) {
SALOMEDS::SObject_var soField = listOfSObject->at(0);
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ //int fieldId = _studyEditor->getParameterInt(soField,FIELD_SERIES_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
// _GBO_ : the dialog should not be modal, so that we can choose a
// mesh in the browser. Then we have to emit a signal from the
// dialog.accept, connected to a slot of the DatasourceControler
SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
if ( listOfSObject->size() > 0 ) {
SALOMEDS::SObject_var soField = listOfSObject->at(0);
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
// _GBO_ : the dialog should not be modal, so that we can choose a
// mesh in the browser. Then we have to emit a signal from the
// dialog.accept, connected to a slot of the DatasourceControler
emit workspaceSignal(event); // forward to DatasourceController
}
else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
- emit workspaceSignal(event); // forward to DatasourceController
+ emit workspaceSignal(event); // forward to PresentationController
+ }
+ else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {
+ emit workspaceSignal(event); // forward to PresentationController
}
else if ( event->type == MEDCALC::EVENT_PLAY_TEST ) {
emit workspaceSignal(event); // forward to TestController
}
else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) {
QStringList commands;
- commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id = medcalc.LoadDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) {
QStringList commands;
- commands += QString("medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id = medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id");
_consoleDriver->exec(commands);
}
else {
QString colorMap = _getColorMap();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
+ commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
+ else if ( event->eventtype == PresentationEvent::EVENT_DELETE_PRESENTATION ) {
+ QStringList commands;
+ commands += QString("medcalc.RemovePresentation(%1)").arg(dataObject->getPresentationId());
+ _consoleDriver->exec(commands);
+ }
else {
STDLOG("The event "<<event->eventtype<<" is not implemented yet");
}
// =================================================================
//
-XmedDataObject::XmedDataObject() : DataObject() {
+XmedDataObject::XmedDataObject() : DataObject(), _presId(-1) {
}
/*! This function specified the localization of the object in the
return &_fieldHandler;
}
+void XmedDataObject::setPresentationId(int presId) {
+ _presId = presId;
+}
+
+int XmedDataObject::getPresentationId() const { return _presId; }
+
+
/*!
* This function implements the convention for displaying a fieldname
* characterized by its spatial discretisation type.
void setFieldHandler(MEDCALC::FieldHandler fieldHandler);
MEDCALC::FieldHandler * getFieldHandler();
+ void setPresentationId(int presId);
+ int getPresentationId() const;
+
private:
MEDCALC::FieldHandler _fieldHandler;
+ int _presId;
string _getTypedFieldLabel();
};
SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
// _GBO_ TODO: we should test here if it is a mesh (attribute in
// the sobject)
- _meshId = _studyEditor->getParameterInt(soMesh,OBJECT_ID);
+ _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
const char * meshname = _studyEditor->getName(soMesh);
this->ui.txtMesh->setText(QString(meshname));
}
SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
// _GBO_ TODO: we should test here if it is a mesh (attribute in
// the sobject)
- _meshId = _studyEditor->getParameterInt(soMesh,OBJECT_ID);
+ _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
const char * meshname = _studyEditor->getName(soMesh);
this->ui.txtMesh->setText(QString(meshname));
}
ui.setupUi(this); // To be done first
}
-MEDCALC::MEDPresentationViewMode
-WidgetPresentationParameters::getViewMode() {
- QString viewMode = this->ui.comboBoxViewMode->currentText();
- if (viewMode == tr("LAB_VIEW_MODE_REPLACE")) {
- return MEDCALC::VIEW_MODE_REPLACE;
- }
- else if (viewMode == tr("LAB_VIEW_MODE_OVERLAP")) {
- return MEDCALC::VIEW_MODE_OVERLAP;
- }
- else if (viewMode == tr("LAB_VIEW_MODE_NEW_LAYOUT")) {
- return MEDCALC::VIEW_MODE_NEW_LAYOUT;
- }
- else if (viewMode == tr("LAB_VIEW_MODE_SPLIT_VIEW")) {
- return MEDCALC::VIEW_MODE_SPLIT_VIEW;
- }
- // Should not happen
- STDLOG("Strange!! No matching view mode found - returning VIEW_MODE_REPLACE.");
- return MEDCALC::VIEW_MODE_REPLACE;
-}
-
std::string
WidgetPresentationParameters::getField()
{
#include <QObject>
-class WidgetPresentationParameters : public QWidget
+class MEDCALCGUI_DIALOGS_EXPORT WidgetPresentationParameters : public QWidget
{
Q_OBJECT
WidgetPresentationParameters(QWidget* parent = 0);
virtual ~WidgetPresentationParameters() {}
- MEDCALC::MEDPresentationViewMode getViewMode();
std::string getField();
std::string getScalarBarRange();
double getScalarBarTimestep();
<x>0</x>
<y>0</y>
<width>404</width>
- <height>230</height>
+ <height>200</height>
</rect>
</property>
<property name="minimumSize">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0">
+ <item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
- <string>LAB_FIELD</string>
+ <string>LAB_DISP_COMP</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="0" column="1">
<widget class="QComboBox" name="comboBoxField">
<item>
<property name="text">
</item>
</widget>
</item>
- <item row="5" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="labelTimeStep">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="4" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxTimeStep">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="6" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="labelMinVal">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="6" column="1">
+ <item row="5" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxMinVal">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="7" column="0">
+ <item row="6" column="0">
<widget class="QLabel" name="labelMaxVal">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="7" column="1">
+ <item row="6" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxMaxVal">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="8" column="0">
+ <item row="7" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>LAB_COLOR_MAP</string>
</property>
</widget>
</item>
- <item row="8" column="1">
+ <item row="7" column="1">
<widget class="QComboBox" name="comboBoxColorMap">
<item>
<property name="text">
</item>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>LAB_VIEW_MODE</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="comboBoxViewMode">
- <item>
- <property name="text">
- <string>LAB_VIEW_MODE_REPLACE</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>LAB_VIEW_MODE_OVERLAP</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>LAB_VIEW_MODE_NEW_LAYOUT</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>LAB_VIEW_MODE_SPLIT_VIEW</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="4" column="1">
+ <item row="3" column="1">
<widget class="QComboBox" name="comboBoxScalarBarRange">
<property name="enabled">
<bool>true</bool>
</item>
</widget>
</item>
- <item row="2" column="0">
+ <item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>LAB_SCALARBAR</string>
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="enabled">
<bool>true</bool>
)
# Install rules
-SALOME_INSTALL_SCRIPTS(test_qttesting.py ${SALOME_MED_INSTALL_TEST}/MEDCalc)
-SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${SALOME_MED_INSTALL_TEST}/MEDCalc)
+SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalc)
+
+SALOME_INSTALL_SCRIPTS(test_qttesting.py ${TEST_INSTALL_DIRECTORY})
+SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/medcalc_testutils.py ${TEST_INSTALL_DIRECTORY})
SALOME_INSTALL_SCRIPTS("${_test_scripts}" ${SALOME_INSTALL_PYTHON}/tests)
-
+
INSTALL(FILES ${_test_scenarii} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/scenarios)
INSTALL(FILES ${_test_baselines} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/baselines)
INSTALL(FILES ${_test_files} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}/tests/medfiles)
-INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${SALOME_MED_INSTALL_TEST}/MEDCalc RENAME CTestTestfile.cmake)
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${TEST_INSTALL_DIRECTORY}
+ RENAME CTestTestfile.cmake)
-# Copyright (C) 2015-2016 CEA/DEN, EDF R&D
+# Copyright (C) 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
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-SET(COMPONENT_NAME MEDCALC)
-SET(TIMEOUT 180) # the GUI needs to start - so let some time here!
+SET(TEST_NAMES
+ test_qttesting
+)
-ADD_TEST(MEDCalcQtTesting python test_qttesting.py)
-SET_TESTS_PROPERTIES(MEDCalcQtTesting PROPERTIES LABELS "${COMPONENT_NAME}")
+FOREACH(tfile ${TEST_NAMES})
+ SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ ADD_TEST(${TEST_NAME} python ${tfile}.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+ LABELS "${COMPONENT_NAME}"
+ TIMEOUT ${TIMEOUT}
+ )
+ENDFOREACH()
-# Copyright (C) 2011-2016 CEA/DEN, EDF R&D
+# Copyright (C) 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
unittest.TestCase.__init__(self, methodName=methodName)
self._tmpDir = ""
self._removeDir = True
-
+
def setUp(self):
import tempfile
self._tmpDir = tempfile.mkdtemp(prefix="med_gui_tests_")
unittest.TestCase.tearDown(self)
if self._removeDir:
shutil.rmtree(self._tmpDir, False)
-
+
def getTestName(self):
""" Return name of the test being currently executed. """
return self.id().split(".")[-1]
Assert if not matching. """
import filecmp
from medcalc_testutils import GetBaselineDir
-
+
base_pth = os.path.join(GetBaselineDir(), basename)
gen_path = os.path.join(self._tmpDir, basename)
print base_pth, gen_path
try:
ret = filecmp.cmp(base_pth, gen_path, shallow=False)
except OSError:
+ import traceback
+ traceback.print_exc()
ret = False
if not ret:
# Keep file if comparison fails
filedata = filedata.replace("/tmp/%s" % med_file, os.path.join(GetMEDFileDir(), med_file))
with open(scen_pth2,'w') as f:
f.write(filedata)
-
+
##
## Now the tests themselves
##
from medpresentation import MakeSlices
from medpresentation import MakeDeflectionShape
from medpresentation import MakePointSprite
+from medpresentation import RemovePresentation
# Console commands
import medconsole
def notifyGui_cleanWorkspace():
__notifyGui(MEDCALC.EVENT_CLEAN_WORKSPACE)
#
-def notifyGui_addDatasource(filename):
- __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, filename=filename)
+def notifyGui_addDatasource(handlerId, filename):
+ __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, dataId=handlerId, filename=filename)
#
def notifyGui_addPresentation(fieldId, presId):
__notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, dataId=fieldId, presentationId=presId)
#
+def notifyGui_removePresentation(presId):
+ __notifyGui(MEDCALC.EVENT_REMOVE_PRESENTATION, presentationId=presId)
+#
def notifyGui_playQtTestingScenario(filename):
__notifyGui(MEDCALC.EVENT_PLAY_TEST, filename=filename)
#
def notifyGui_termination():
__notifyGui(MEDCALC.EVENT_QUIT_SALOME)
-
def LoadDataSource(filename):
dataManager = medcalc.medcorba.factory.getDataManager()
- dataManager.loadDatasource(filename)
+ handler = dataManager.loadDatasource(filename)
from medcalc.medevents import notifyGui_addDatasource
- notifyGui_addDatasource(filename)
+ notifyGui_addDatasource(handler.id, filename)
+ return handler.id
#
def LoadImageAsDataSource(filename):
from medimages import FieldBuilder
builder = FieldBuilder()
builder.image2med(filename, medfilename)
- LoadDataSource(medfilename)
+ return LoadDataSource(medfilename)
#
import medcalc
import MEDCALC
-from medcalc.medevents import notifyGui_addPresentation
+from medcalc.medevents import notifyGui_addPresentation, notifyGui_removePresentation
__manager = medcalc.medcorba.factory.getPresentationManager()
params = MEDCALC.ScalarMapParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap)
presentation_id = __manager.makeScalarMap(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakeContour(proxy,
params = MEDCALC.ContourParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap, nbContours)
presentation_id = __manager.makeContour(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakeVectorField(proxy,
params = MEDCALC.VectorFieldParameters(proxy.id, viewMode)
presentation_id = __manager.makeVectorField(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakeSlices(proxy,
params = MEDCALC.SlicesParameters(proxy.id, viewMode, orientation, nbSlices)
presentation_id = __manager.makeSlices(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakeDeflectionShape(proxy,
params = MEDCALC.DeflectionShapeParameters(proxy.id, viewMode)
presentation_id = __manager.makeDeflectionShape(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakePointSprite(proxy,
params = MEDCALC.PointSpriteParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap)
presentation_id = __manager.makePointSprite(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
+#
+
+def RemovePresentation(presentation_id):
+ ok = __manager.removePresentation(presentation_id)
+ if ok:
+ notifyGui_removePresentation(presentation_id)
#
# Application tests
-SET(TEST_INSTALL_DIRECTORY ${SALOME_INSTALL_SCRIPT_SCRIPTS}/test/MEDCoupling/MEDCalculator)
+SET(TEST_INSTALL_DIRECTORY ${SALOME_MED_INSTALL_TEST}/MEDCalculator)
INSTALL(TARGETS TestMEDCalculator DESTINATION ${TEST_INSTALL_DIRECTORY})
INSTALL(FILES CTestTestfileInstall.cmake
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-ADD_TEST(TestMEDCalculator TestMEDCalculator)
-SET_TESTS_PROPERTIES(TestMEDCalculator PROPERTIES LABELS "${COMPONENT_NAME}")
+SET(TEST_NAMES
+ TestMEDCalculator
+)
+
+FOREACH(tfile ${TEST_NAMES})
+ SET(TEST_NAME ${COMPONENT_NAME}_${tfile})
+ ADD_TEST(${TEST_NAME} ${tfile})
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+ LABELS "${COMPONENT_NAME}"
+ TIMEOUT ${TIMEOUT}
+ )
+ENDFOREACH()