// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef _MED_PRESENTATION_MANAGER_I_TPP_
-#define _MED_PRESENTATION_MANAGER_I_TPP_
+#ifndef _MED_PRESENTATION_MANAGER_I_TXX_
+#define _MED_PRESENTATION_MANAGER_I_TXX_
+
+#include <Basics_Utils.hxx>
template<typename PresentationType, typename PresentationParameters>
MEDPresentation::TypeID
-MEDPresentationManager_i::_makePresentation(PresentationParameters params)
+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)
+ {
+ // Prepare all presentations to be removed from this view:
+ std::map<MEDPresentation::TypeID, MEDPresentation*>::const_iterator it;
+ for (it = _presentations.begin(); it != _presentations.end(); ++it)
+ {
+ int viewId2 = (*it).second->getPyViewID();
+ if (viewId2 == activeViewId)
+ to_del.push_back((*it).first);
+ }
+ }
+
// Create a new presentation instance
PresentationType* presentation = NULL;
+ MEDPresentation::TypeID newID = MEDPresentationManager_i::GenerateID();
+ STDLOG("Generated presentation ID: " << newID);
try {
- presentation = new PresentationType(params); // on stack or on heap?? stack for now
+ 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);
+ else
+ presentation->setPyViewID(newID); // ensures a new ID for the view
}
catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
+ STDLOG("Error: " << e.what());
return -1;
}
- MEDPresentation::TypeID newID = MEDPresentationManager_i::GenerateID();
_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;
}
-#endif // _MED_PRESENTATION_MANAGER_I_TPP_
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentationManager_i::_updatePresentation(MEDPresentation::TypeID presentationID, const PresentationParameters params)
+{
+ MEDPresentation* presentation = _getPresentation(presentationID);
+ if (!presentation) {
+ std::cerr << "_updatePresentation(): presentation not found!!" << std::endl;
+ return;
+ }
+
+ presentation->updatePipeline<PresentationType>(params);
+}
+
+template<typename PresentationType, typename PresentationParameters>
+void
+MEDPresentationManager_i::_getParameters(MEDPresentation::TypeID presentationID, PresentationParameters & params) const
+{
+ MEDPresentation* presentation = _getPresentation(presentationID);
+ if (!presentation) {
+ std::cerr << "_getParameters(): presentation not found!!" << std::endl;
+ return;
+ }
+
+ presentation->getParameters<PresentationType>(params);
+}
+
+
+#endif // _MED_PRESENTATION_MANAGER_I_TXX_