template<typename PresentationType, typename PresentationParameters>
MEDPresentation::TypeID
-MEDPresentationManager_i::_makePresentation(const PresentationParameters params, const MEDCALC::MEDPresentationViewMode viewMode)
+MEDPresentationManager_i::_makePresentation(const PresentationParameters params, const MEDCALC::ViewModeType viewMode)
{
int activeViewId = getActiveViewPythonId();
// Replace = Remove then add
+ std::vector<int> to_del;
if (viewMode == MEDCALC::VIEW_MODE_REPLACE)
{
- // Remove all presentations from this view:
+ // Prepare all presentations to be removed from this view:
std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator it;
- std::vector<int> to_del;
for (it = _presentations.begin(); it != _presentations.end(); ++it)
{
int viewId2 = (*it).second->getPyViewID();
if (viewId2 == activeViewId)
to_del.push_back((*it).first);
}
- for (std::vector<int>::const_iterator it2 = to_del.begin(); it2 != to_del.end(); ++it2)
- removePresentation(*it2);
}
// Create a new presentation instance
STDLOG("Generated presentation ID: " << newID);
try {
presentation = new PresentationType(params, viewMode); // on stack or on heap?? heap for now
+ presentation->initFieldMeshInfos();
// In replace or overlap mode we force the display in the active view:
if(activeViewId != -1 && (viewMode == MEDCALC::VIEW_MODE_REPLACE || viewMode == MEDCALC::VIEW_MODE_OVERLAP))
presentation->setPyViewID(activeViewId);
_presentations.insert( std::pair<MEDPresentation::TypeID, MEDPresentation *>(newID, presentation) );
presentation->generatePipeline();
+
+ // If generatePipeline didn't throw, we can actually remove presentations to be deleted:
+ STDLOG("About to remove all presentations from view " << activeViewId);
+ for (std::vector<int>::const_iterator it2 = to_del.begin(); it2 != to_del.end(); ++it2)
+ removePresentation(*it2);
+
// Make the view holding the newly created presentation the active one:
activateView(newID);
return newID;