// MEDPresentationColorMap colorMap;
// };
+ typedef sequence<long> PresentationsList;
+
/* Functions */
interface MEDPresentationManager : SALOME::GenericObj
string getParavisDump(in long presId);
// MEDPresentationViewMode getPresentationViewMode(in long presId);
+
+ PresentationsList getAllPresentations();
};
};
in long presentationId)
raises (SALOME::SALOME_Exception);
+ // Get all presentations in study:
+ PresentationsList getStudyPresentations(in SALOMEDS::Study study)
+ raises (SALOME::SALOME_Exception);
};
};
return MED_ORB::OP_OK;
}
+MED_ORB::PresentationsList*
+MED::getStudyPresentations(SALOMEDS::Study_ptr study)
+{
+ // 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;
+
+ CORBA::ULong size = presList->length();
+ presList->length(size+1);
+ (*presList)[size] = attrParam->GetInt(PRESENTATION_ID);
+ }
+ }
+ return presList;
+}
+
+
MED_ORB::PresentationsList*
MED::getSiblingPresentations(SALOMEDS::Study_ptr study, CORBA::Long presentationId)
{
MED_ORB::PresentationsList* getSiblingPresentations(SALOMEDS::Study_ptr study,
CORBA::Long presentationId);
+ // Get all presentations registered in the study
+ MED_ORB::PresentationsList* getStudyPresentations(SALOMEDS::Study_ptr study);
+
/*! Dump the study as a Python file */
virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isPublished,
throw KERNEL::createSalomeException("getParavisDump(): presentation not found!!");
}
+MEDCALC::PresentationsList*
+MEDPresentationManager_i::getAllPresentations()
+{
+ MEDCALC::PresentationsList* presList = new MEDCALC::PresentationsList;
+ presList->length(_presentations.size());
+ std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator it;
+ int i;
+ for (i = 0, it = _presentations.begin(); it != _presentations.end(); ++it, ++i)
+ (*presList)[i] = it->first;
+ return presList;
+}
MEDCALC_EXPORT CORBA::Long getActiveViewPythonId();
// MEDCALC_EXPORT MEDCALC::MEDPresentationViewMode getPresentationViewMode(MEDPresentation::TypeID);
MEDCALC_EXPORT char* getParavisDump(MEDPresentation::TypeID presentationID);
+ MEDCALC_EXPORT MEDCALC::PresentationsList* getAllPresentations();
private:
MEDPresentationManager_i();
if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
updateTreeViewWithNewPresentation(event->dataId, event->presentationId);
// Deal with replace mode: presentations with invalid IDs have to be removed:
- std::map<int, MEDWidgetHelper *>::iterator it;
- std::vector<int> to_del;
- for (it = _presHelperMap.begin(); it != _presHelperMap.end(); ++it)
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
+ _PTR(Study) studyDS = study->studyDS();
+
+ MEDCALC::PresentationsList * lstManager = _presManager->getAllPresentations();
+ MED_ORB::PresentationsList * lstModule = _salomeModule->engine()->getStudyPresentations(_CAST(Study, studyDS)->GetStudy());
+ // The IDs not in the intersection needs deletion:
+ CORBA::Long * last = lstManager->get_buffer() + lstManager->length();
+ for (unsigned i = 0; i < lstModule->length(); i++)
{
- try {
- // TODO: not the best way to test for presentation existence at the engine level?
- _presManager->getPresentationStringProperty((*it).first, MEDPresentation::PROP_NAME.c_str());
- }
- catch(...){
- to_del.push_back((*it).first);
- delete((*it).second);
- (*it).second = 0;
- }
- }
- std::vector<int>::const_iterator it2;
- for (it2 = to_del.begin(); it2 != to_del.end(); ++it2)
- {
- updateTreeViewForPresentationRemoval(*it2);
- _presHelperMap.erase(*it2);
+ CORBA::Long * ptr = std::find(lstManager->get_buffer(), last, (*lstModule)[i]);
+ if (ptr == last)
+ {
+ STDLOG("Removing pres " << (*lstModule)[i] << " from OB.");
+ // Presentation in module but not in manager anymore: to be deleted from OB:
+ updateTreeViewForPresentationRemoval((*lstModule)[i]);
+ }
}
}
else if ( event->type == MEDCALC::EVENT_REMOVE_PRESENTATION ) {