EVENT_UPDATE_FIELD,
EVENT_CLEAN_WORKSPACE,
EVENT_ADD_DATASOURCE,
+ EVENT_ADD_PRESENTATION,
EVENT_UNKNOWN
};
struct MedEvent {
MedEventType type;
- long fieldid;
+ long dataId;
string filename;
};
long makeScalarMap(in ScalarMapParameters params);
void setPresentationProperty(in long presId, in string propName, in string propValue);
-
+ string getPresentationProperty(in long presId, in string propName);
+
};
};
}
return calculator;
}
+
+ /*!
+ * This returns a singleton (static) instance of the MED presentation manager.
+ */
+ MEDCALC::MEDPresentationManager_ptr getPresentationManager() {
+ static MEDCALC::MEDPresentationManager_ptr presentationManager;
+ if(CORBA::is_nil(presentationManager)){
+ presentationManager = getFactory()->getPresentationManager();
+ }
+ return presentationManager;
+ }
+
}
MEDCALC_EXPORT MEDCALC::MEDFactory_ptr getFactory();
MEDCALC_EXPORT MEDCALC::MEDDataManager_ptr getDataManager();
MEDCALC_EXPORT MEDCALC::MEDCalculator_ptr getCalculator();
+ MEDCALC_EXPORT MEDCALC::MEDPresentationManager_ptr getPresentationManager();
}
#endif // _MEDFACTORY_CLIENT_HXX_
_display.push_back(disp);
}
-void MEDPresentation::setProperty(const char * propName, const char * propValue)
+void MEDPresentation::setProperty(const std::string& propName, const std::string& propValue)
{
// LIMITED!!! For now switch the first display element to Wireframe
-
+ /*
PyLockWrapper lock;
PyObject_CallMethod(_display[0], (char*)"SetRepresentationType", (char*)"(s)", "Wireframe");
+ */
+
+ _properties[propName] = propValue;
+}
+
+const std::string
+MEDPresentation::getProperty(const std::string& propName)
+{
+ if (_properties.find(propName) != _properties.end()) {
+ return _properties[propName];
+ }
+ else {
+ std::cerr << "getProperty(): no property named " << propName << std::endl;
+ return std::string();
+ }
}
PyObject * MEDPresentation::getPythonObjectFromMain(const char * python_var)
#include CORBA_SERVER_HEADER(MEDPresentationManager)
#include <vector>
+#include <map>
#include <string>
class MEDCALC_EXPORT MEDPresentation
{
-public:
friend class MEDPresentationManager_i;
- MEDPresentation(MEDCALC::FieldHandler* fieldHdl):
- _fieldHandler(fieldHdl), _pipeline(0), _display(0)
- {}
+public:
+
virtual ~MEDPresentation() {}
- void setProperty(const char * propName, const char * propValue);
+ void setProperty(const std::string& propName, const std::string& propValue);
+ const std::string getProperty(const std::string& propName);
std::string getFieldTypeString();
protected:
+ MEDPresentation(MEDCALC::FieldHandler* fieldHdl):
+ _fieldHandler(fieldHdl), _pipeline(0), _display(0), _properties()
+ {}
+
void generatePipeline();
virtual void internalGeneratePipeline() = 0;
PyObject * getPythonObjectFromMain(const char * var);
///! Corresponding display object, if any:
std::vector< PyObject * > _display;
+
+ ///! Presentation properties <key,value>
+ std::map<std::string, std::string> _properties;
};
class MEDCALC_EXPORT MEDPresentationScalarMap : public MEDPresentation
#include <iostream>
void
-MEDPresentationManager_i::setPresentationProperty(TypeID presentationID, const char * propName, const char * propValue)
+MEDPresentationManager_i::setPresentationProperty(TypeID presentationID, const char * propName, const char * propValue)
{
if (_presentations.find(presentationID) != _presentations.end())
{
}
}
+char*
+MEDPresentationManager_i::getPresentationProperty(TypeID presentationID, const char* propName)
+{
+ if (_presentations.find(presentationID) != _presentations.end()) {
+ MEDPresentation* pres = _presentations[presentationID];
+ return (char*) pres->getProperty(propName).c_str();
+ }
+ else {
+ std::cerr << "getPresentationProperty(): presentation not found!!" << std::endl;
+ return (char*) "";
+ }
+}
+
TypeID
MEDPresentationManager_i::makeScalarMap(const MEDCALC::ScalarMapParameters& params)
{
#include "MEDCALC.hxx"
#include <vector>
+#include <string>
typedef ::CORBA::Long TypeID;
static MEDPresentationManager_i* getInstance();
TypeID makeScalarMap(const MEDCALC::ScalarMapParameters&);
- void setPresentationProperty(TypeID presentationID, const char * propName, const char * propValue);
+ void setPresentationProperty(TypeID presentationID, const char * propName, const char * propValue);
+ char* getPresentationProperty(TypeID presentationID, const char* propName);
private:
MEDPresentationManager_i();
_studyEditor->setIcon(soFieldseries,tr("ICO_DATASOURCE_FIELD").toStdString().c_str());
_studyEditor->setParameterInt(soFieldseries,OBJECT_ID,fieldseriesHandler.id);
_studyEditor->setParameterBool(soFieldseries,OBJECT_IS_IN_WORKSPACE,false);
+ //std::cout << "soFieldseries.GetIOR(): " << soFieldseries._retn()->GetIOR() << std::endl;
+ //std::cout << _studyEditor->findObject(soFieldseries._retn()->GetIOR())->GetIOR() << std::endl;
+ std::cout << "soFieldseries.GetName(): " << soFieldseries._retn()->GetName() << std::endl;
+
}
}
}
+void
+DatasourceController::updateTreeViewWithNewPresentation(long presentationId)
+{
+ if (presentationId < 0) {
+ return;
+ }
+
+ std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name");
+
+}
+
void DatasourceController::OnAddDatasource()
{
// Dialog to get the filename where the input data are read from
this->updateTreeViewWithNewDatasource(datasourceHandler);
_salomeModule->updateObjBrowser(true);
}
+ else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
+ this->updateTreeViewWithNewPresentation(event->dataId);
+ _salomeModule->updateObjBrowser(true);
+ }
}
#include CORBA_CLIENT_HEADER(MEDDataManager)
#include <StandardApp_Module.hxx>
#include <SALOME_AppStudyEditor.hxx>
+#include <MEDPresentation.hxx>
#include <map>
EVENT_VIEW_OBJECT_SCALAR_MAP,
// these ones forward actions to workspace (and then to python console)
EVENT_ADD_DATASOURCE,
- EVENT_ADD_IMAGE_AS_DATASOURCE
+ EVENT_ADD_IMAGE_AS_DATASOURCE,
+ EVENT_ADD_PRESENTATION
};
int eventtype;
XmedDataObject * objectdata;
void visualize(DatasourceEvent::EventType);
void addDatasource(const char* filename);
void updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler*);
+ void updateTreeViewWithNewPresentation(long presentationId);
private:
StandardApp_Module * _salomeModule;
}
void MEDEventListener_i::processMedEvent(const MEDCALC::MedEvent & event) {
- LOG("Start processing event for field id="<<event.fieldid);
+ LOG("Start processing event for field id="<<event.dataId);
// This function must be executed as fast as possible because the
// CORBA request is a synchronous call. Then we just emit a Qt
*/
void WorkspaceController::processMedEvent(const MEDCALC::MedEvent * event) {
STDLOG("WorkspaceController::processMedEvent");
- STDLOG("fieldid :"<<event->fieldid);
+ STDLOG("dataId :"<<event->dataId);
XmedDataModel * dataModel = (XmedDataModel *)this->getDataModel();
if ( dataModel == NULL ) {
else if ( event->type == MEDCALC::EVENT_PUT_IN_WORKSPACE ) {
STDLOG("add new field");
MEDCALC::FieldHandler * fieldHandler =
- MEDFactoryClient::getDataManager()->getFieldHandler(event->fieldid);
+ MEDFactoryClient::getDataManager()->getFieldHandler(event->dataId);
XmedDataObject * dataObject = (XmedDataObject *)dataModel->newDataObject();
dataObject->setFieldHandler(*fieldHandler);
std::map<string, DataObject *>::iterator itr = dataModel->begin();
for ( ; itr != dataModel->end(); ++itr) {
XmedDataObject* obj = dynamic_cast<XmedDataObject*>(itr->second);
- if (obj->getFieldHandler()->id == event->fieldid) {
+ if (obj->getFieldHandler()->id == event->dataId) {
std::string itemNameId = obj->getNameId();
this->getDataTreeModel()->removeData(obj);
dataModel->removeDataObject(itemNameId);
else if ( event->type == MEDCALC::EVENT_ADD_DATASOURCE ) {
emit workspaceSignal(event); // forward to DatasourceController
}
+ else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) {
+ emit workspaceSignal(event); // forward to DatasourceController
+ }
}
# that they could be used in another context than the FieldProxy instances
import MEDCALC
-def __notifyGui(type, fieldId=-1, filename=""):
- medEvent = MEDCALC.MedEvent(type, fieldId, filename)
+def __notifyGui(eventType, dataId=-1, filename=""):
+ medEvent = MEDCALC.MedEvent(eventType, dataId, filename)
if not eventListenerIsRunning(): return
# Notify the GUI of the update event
def notifyGui_addDatasource(filename):
__notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, -1, filename)
#
+def notifyGui_addPresentation(presentation_id):
+ __notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, presentation_id)
+#
import medcalc
import MEDCALC
+from medcalc.medevents import notifyGui_addPresentation
__manager = medcalc.medcorba.factory.getPresentationManager()
print "viewMode:", viewMode, " [", type(viewMode), "]"
params = MEDCALC.ScalarMapParameters(proxy.id, viewMode)
- __manager.makeScalarMap(params)
-
+ presentation_id = __manager.makeScalarMap(params)
+ notifyGui_addPresentation(presentation_id)
#
def MakeIsoSurface():