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 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);
+
};
};
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*
MED::DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isPublished,
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,
static int GeneratePythonId();
+ virtual MEDCALC::MEDPresentationViewMode getViewMode() = 0;
+
private:
std::string getFieldTypeString(MEDCoupling::TypeOfField fieldType) const;
virtual ~MEDPresentationContour() {}
void updatePipeline(const MEDCALC::ContourParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
protected:
virtual void internalGeneratePipeline();
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;
}
return true;
}
-MEDPresentation::TypeID
-MEDPresentationManager_i::_getActivePresentationId() const
+MEDCALC::MEDPresentationViewMode
+MEDPresentationManager_i::getPresentationViewMode(MEDPresentation::TypeID presentationID)
{
- // :TODO:
-
- return -1;
+ 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 presentationID);
+ 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 {
virtual ~MEDPresentationPointSprite() {}
void updatePipeline(const MEDCALC::PointSpriteParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
protected:
virtual void internalGeneratePipeline();
virtual ~MEDPresentationScalarMap() {}
void updatePipeline(const MEDCALC::ScalarMapParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
protected:
virtual void internalGeneratePipeline();
virtual ~MEDPresentationSlices() {}
void updatePipeline(const MEDCALC::SlicesParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
protected:
virtual void internalGeneratePipeline();
virtual ~MEDPresentationVectorField() {}
void updatePipeline(const MEDCALC::VectorFieldParameters& params);
+ MEDCALC::MEDPresentationViewMode getViewMode() { return _params.viewMode; }
protected:
virtual void internalGeneratePipeline();
#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;
_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);
}