EVENT_CLEAN_WORKSPACE,
EVENT_ADD_DATASOURCE,
EVENT_ADD_PRESENTATION,
+ EVENT_REMOVE_PRESENTATION,
EVENT_UNKNOWN
};
void updateDeflectionShape(in long presId, in DeflectionShapeParameters params);
void updatePointSprite(in long presId, in PointSpriteParameters params);
+ boolean removePresentation(in long presId);
+
};
};
in string label,
in long presentationId)
raises (SALOME::SALOME_Exception);
+
+ status unregisterPresentation(in SALOMEDS::Study study,
+ in long presentationId)
+ raises (SALOME::SALOME_Exception);
};
};
return result;
}
+MED_ORB::status
+MED::unregisterPresentation(SALOMEDS::Study_ptr study,
+ 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;
+
+ 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);
+ }
+ }
+ }
+}
+
Engines::TMPFile*
MED::DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isPublished,
const char* label,
CORBA::Long presentationId);
+ MED_ORB::status unregisterPresentation(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 "MEDCouplingRefCountObject.hxx"
#include <iostream>
-MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, std::string name)
+MEDPresentation::MEDPresentation(MEDPresentation::TypeID fieldHandlerId, const std::string& name)
: _fieldHandlerId(fieldHandlerId), _pipeline(0), _display(0), _properties()
{
MEDCALC::MEDDataManager_ptr dataManager(MEDFactoryClient::getDataManager());
setProperty("name", name);
}
+MEDPresentation::~MEDPresentation()
+{
+ std::cout << "###TODO#### ~MEDPresentation: clear pipeline\n";
+ std::cout << "###TODO#### ~MEDPresentation: clear display\n";
+}
+
void
MEDPresentation::generatePipeline()
{
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;
protected:
- 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 pushInternal(PyObject* obj, PyObject* disp = NULL);
MEDPresentation::TypeID getID() const { return _fieldHandlerId; }
MEDPresentation::TypeID _fieldHandlerId;
///! Pipeline elements
- std::vector< PyObject * > _pipeline;
+ std::vector<PyObject*> _pipeline;
///! Corresponding display object, if any:
- std::vector< PyObject * > _display;
+ std::vector<PyObject*> _display;
///! Presentation properties <key,value>
std::map<std::string, std::string> _properties;
{
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);
+ return true;
+}
+
+MEDPresentation::TypeID
+MEDPresentationManager_i::_getActivePresentationId() const
+{
+ // :TODO:
+
+ return -1;
+}
MEDCALC_EXPORT void updateDeflectionShape(MEDPresentation::TypeID presentationID, const MEDCALC::DeflectionShapeParameters&);
MEDCALC_EXPORT void updatePointSprite(MEDPresentation::TypeID presentationID, const MEDCALC::PointSpriteParameters&);
+ MEDCALC_EXPORT CORBA::Boolean removePresentation(MEDPresentation::TypeID presentationID);
+
private:
MEDPresentationManager_i();
virtual ~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 {
_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);
+}
+
void
PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event)
{
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
private:
void visualize(PresentationEvent::EventType);
void updateTreeViewWithNewPresentation(long, long);
+ void updateTreeViewForPresentationRemoval(long);
std::string _getIconName(const std::string&);
private:
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
}
}
from medpresentation import MakeSlices
from medpresentation import MakeDeflectionShape
from medpresentation import MakePointSprite
+from medpresentation import RemovePresentation
# Console commands
import medconsole
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)
+#
import medcalc
import MEDCALC
-from medcalc.medevents import notifyGui_addPresentation
+from medcalc.medevents import notifyGui_addPresentation, notifyGui_removePresentation
__manager = medcalc.medcorba.factory.getPresentationManager()
notifyGui_addPresentation(proxy.id, presentation_id)
return presentation_id
#
+
+def RemovePresentation(presentation_id):
+ ok = __manager.removePresentation(presentation_id)
+ if ok:
+ notifyGui_removePresentation(presentation_id)
+#