# 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
# ===========
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 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);
+
};
};
#define IS_IN_WORKSPACE "isInWorkspace"
#define SOURCE_ID "sourceId"
#define MESH_ID "meshId"
-//#define FIELD_SERIES_ID "fieldSeriesId"
+#define FIELD_SERIES_ID "fieldSeriesId"
#define FIELD_ID "fieldId"
#define PRESENTATION_ID "presentationId"
#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
// 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
soFieldseries->SetAttrString("AttributePixMap", "ICO_DATASOURCE_FIELD");
anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- //aParam->SetInt(FIELD_SERIES_ID, fieldseriesHandler.id);
- aParam->SetInt(FIELD_ID, fieldseriesHandler.id);
+ aParam->SetInt(FIELD_SERIES_ID, fieldseriesHandler.id);
+ //aParam->SetInt(FIELD_ID, fieldseriesHandler.id);
aParam->SetBool(IS_IN_WORKSPACE, false);
useCaseBuilder->AppendTo(soFieldseries->GetFather(), soFieldseries);
}
}
- result = MED_ORB::OP_OK;
- return result;
+ return MED_ORB::OP_OK;
}
MED_ORB::status
// 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->SetBool(IS_PRESENTATION, true);
aParam->SetInt(PRESENTATION_ID, presentationId);
- result = MED_ORB::OP_OK;
- return result;
+ return MED_ORB::OP_OK;
}
MED_ORB::status
// 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;
-
SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder();
}
}
}
+
+ 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*
//bool isPresentation = false;
int sourceId = -1;
int meshId = -1;
- //int fieldSeriesId = -1;
+ int fieldSeriesId = -1;
int fieldId = -1;
int presentationId = -1;
if (aSObj->FindAttribute(anAttribute, "AttributeParameter")) {
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_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))
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 (fieldSeriesId > -1)
+ oss << "Field series id: " << fieldSeriesId << std::endl;
if (fieldId > -1)
oss << "Field id: " << fieldId << std::endl;
//oss << "Is presentation: " << isPresentation << std::endl;
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 isPublished,
#include "MEDPresentation.hxx"
#include "MEDPresentationException.hxx"
#include "MEDCouplingRefCountObject.hxx"
-#include <iostream>
+#include "Basics_Utils.hxx"
+#include "PyInterp_Utils.h"
+
+#include <sstream>
MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name)
- : _fieldHandlerId(fieldHandlerId), _pipeline(0), _display(0), _properties()
+ : _fieldHandlerId(fieldHandlerId), _pipeline(0), _display(0), _properties(),
+ _renderViewPyId(GeneratePythonId())
{
MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
MEDCALC::FieldHandler* fieldHandler = dataManager->getFieldHandler(fieldHandlerId);
MEDPresentation::~MEDPresentation()
{
- std::cout << "###TODO#### ~MEDPresentation: clear pipeline\n";
- std::cout << "###TODO#### ~MEDPresentation: clear display\n";
+ 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
}
void
-MEDPresentation::pushInternal(PyObject* obj, PyObject* disp)
+MEDPresentation::pushPyObjects(PyObjectId obj, PyObjectId disp)
{
_pipeline.push_back(obj);
_display.push_back(disp);
}
+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)
{
return (*it).second;
}
else {
- std::cerr << "getProperty(): no property named " << propName << std::endl;
+ STDLOG("MEDPresentation::getProperty(): no property named " + propName);
return std::string();
}
}
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
{
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());
+}
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, const std::string& name);
std::string getRenderViewCommand(MEDCALC::MEDPresentationViewMode viewMode) const;
virtual void internalGeneratePipeline() = 0;
PyObject* getPythonObjectFromMain(const char* var) const;
- void pushInternal(PyObject* obj, PyObject* disp = NULL);
+ 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 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;
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_Release(_gil_state);
+// 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);
}
void
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_Release(_gil_state);
+// 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);
}
void
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;
if (presentation)
delete presentation;
_presentations.erase(presentationID);
+
+ std::stringstream sstm;
+ sstm << "Presentation " << presentationID << " has been removed.\n";
+ STDLOG(sstm.str());
+
return true;
}
-MEDPresentation::TypeID
-MEDPresentationManager_i::_getActivePresentationId() const
+CORBA::Boolean
+MEDPresentationManager_i::activateView(MEDPresentation::TypeID presentationID)
{
- // :TODO:
+ 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;
- return -1;
+ 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 presentationID, const MEDCALC::ScalarMapParameters&);
- MEDCALC_EXPORT void updateContour(MEDPresentation::TypeID presentationID, const MEDCALC::ContourParameters&);
- MEDCALC_EXPORT void updateVectorField(MEDPresentation::TypeID presentationID, const MEDCALC::VectorFieldParameters&);
- MEDCALC_EXPORT void updateSlices(MEDPresentation::TypeID presentationID, const MEDCALC::SlicesParameters&);
- MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters&);
- MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters&);
+ 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 presentationID);
+ MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID);
+
+ MEDCALC_EXPORT CORBA::Boolean activateView(MEDPresentation::TypeID);
+
+ MEDCALC_EXPORT MEDCALC::MEDPresentationViewMode getPresentationViewMode(MEDPresentation::TypeID);
private:
MEDPresentationManager_i();
void _updatePresentation(MEDPresentation::TypeID presentationID, PresentationParameters params);
MEDPresentation* _getPresentation(MEDPresentation::TypeID) const;
- MEDPresentation::TypeID _getActivePresentationId() const;
private :
MEDPresentation::TypeID
MEDPresentationManager_i::_makePresentation(PresentationParameters params)
{
- // Replace = Remove then add
- if (params.viewMode == MEDCALC::VIEW_MODE_REPLACE) {
- MEDPresentation::TypeID currentPresentationId = _getActivePresentationId();
- if (currentPresentationId > -1)
- removePresentation(currentPresentationId);
- }
-
// Create a new presentation instance
PresentationType* presentation = NULL;
try {
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_Release(_gil_state);
+// 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);
}
void
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;
- std::string cmd = std::string("import pvsimple as pvs;");
- cmd += getRenderViewCommand(_params.viewMode); // define __view1
+ 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());
- 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();");
+ pushAndExecPyLine( "import pvsimple as pvs;");
+ pushAndExecPyLine( getRenderViewCommand(_params.viewMode) ); // define __viewXXX
- cmd += getResetCameraCommand();
+ oss_v << "__view" << _renderViewPyId; std::string view(oss_v.str());
- //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);
+ 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();");
- PyGILState_Release(_gil_state);
+ // Retrieve Python object for internal storage:
+ 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));
}
void
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_Release(_gil_state);
+// 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);
}
void
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_Release(_gil_state);
+// 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);
}
void
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,FIELD_SERIES_ID);
- long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_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
#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());
#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>
#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>
static const int OPTIONS_VIEW_MODE_ID = 943;
static const int OPTIONS_VIEW_MODE_REPLACE_ID = 944;
static const int OPTIONS_VIEW_MODE_NEW_LAYOUT_ID = 946;
static const int OPTIONS_VIEW_MODE_SPLIT_VIEW_ID = 947;
-PresentationController::PresentationController(MEDModule* salomeModule)
+PresentationController::PresentationController(MEDModule* salomeModule) :
+ _salomeModule(salomeModule),
+ _studyEditor(salomeModule->getStudyEditor())
{
STDLOG("Creating a PresentationController");
- _salomeModule = salomeModule;
- _studyEditor = _salomeModule->getStudyEditor();
_widgetPresentationParameters = new WidgetPresentationParameters();
_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
// 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,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.
- 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)
{
_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);
}
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:
private:
MEDModule* _salomeModule;
SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule
+
QDockWidget *_dockWidget;
WidgetPresentationParameters* _widgetPresentationParameters;
};
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();
};
#include <QObject>
-class WidgetPresentationParameters : public QWidget
+class MEDCALCGUI_DIALOGS_EXPORT WidgetPresentationParameters : public QWidget
{
Q_OBJECT