status registerPresentation(in SALOMEDS::Study study,
in long fieldId,
in string name,
- in string label)
+ in string label,
+ in long presentationId)
raises (SALOME::SALOME_Exception);
};
};
// This constant strings are used to specify an attribute name for
// AttributeParameter attributes associated to a SObject
-#define OBJECT_ID "objectid"
-#define OBJECT_IS_IN_WORKSPACE "isInWorkspace"
+#define IS_IN_WORKSPACE "isInWorkspace"
+#define SOURCE_ID "sourceId"
+#define MESH_ID "meshId"
+//#define FIELD_SERIES_ID "fieldSeriesId"
+#define FIELD_ID "fieldId"
+#define PRESENTATION_ID "presentationId"
+#define IS_PRESENTATION "isPresentation"
+
static const int NB_TYPE_OF_FIELDS = 4;
static const char* mapTypeOfFieldLabel[NB_TYPE_OF_FIELDS] =
{"ON_CELLS", "ON_NODES", "ON_GAUSS_PT", "ON_GAUSS_NE" };
-
-
-// Used by presentations
-#define FIELD_ID "fieldid"
-#define IS_PRESENTATION "ispresentation"
#include <SALOMEDS_SObject.hxx>
#include <Utils_ExceptHandlers.hxx>
+#include <SalomeApp_Application.h>
#include <string>
+#include <sstream>
/*!
\brief Constructor
soDatasource->SetAttrString("AttributePixMap", "ICO_DATASOURCE");
anAttr = studyBuilder->FindOrCreateAttribute(soDatasource, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetInt(OBJECT_ID, datasourceHandler.id);
+ aParam->SetInt(SOURCE_ID, datasourceHandler.id);
useCaseBuilder->AppendTo(soDatasource->GetFather(), soDatasource);
// We can add the meshes as children of the datasource
soMesh->SetAttrString("AttributePixMap", "ICO_DATASOURCE_MESH");
anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetInt(OBJECT_ID, meshHandler.id);
- anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter");
- aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false);
+ aParam->SetInt(MESH_ID, meshHandler.id);
+ aParam->SetBool(IS_IN_WORKSPACE, false);
useCaseBuilder->AppendTo(soMesh->GetFather(), soMesh);
// We add the field timeseries defined on this mesh, as children of the mesh SObject
soFieldseries->SetAttrString("AttributePixMap", "ICO_DATASOURCE_FIELD");
anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetInt(OBJECT_ID, fieldseriesHandler.id);
- anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter");
- aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false);
+ //aParam->SetInt(FIELD_SERIES_ID, fieldseriesHandler.id);
+ aParam->SetInt(FIELD_ID, fieldseriesHandler.id);
+ aParam->SetBool(IS_IN_WORKSPACE, false);
useCaseBuilder->AppendTo(soFieldseries->GetFather(), soFieldseries);
soFieldseries->UnRegister();
MED::registerPresentation(SALOMEDS::Study_ptr study,
CORBA::Long fieldId,
const char* name,
- const char* label)
+ const char* label,
+ CORBA::Long presentationId)
{
// set exception handler to catch unexpected CORBA exceptions
Unexpect aCatch(SALOME_SalomeException);
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
aParam->SetInt(FIELD_ID, fieldId);
aParam->SetBool(IS_PRESENTATION, true);
+ aParam->SetInt(PRESENTATION_ID, presentationId);
result = MED_ORB::OP_OK;
return result;
return aStreamFile._retn();
}
+CORBA::Boolean
+MED::hasObjectInfo()
+{
+ return true;
+}
+
+char*
+MED::getObjectInfo(CORBA::Long studyId, const char* entry)
+{
+ SALOME_NamingService* nameService = SalomeApp_Application::namingService();
+ CORBA::Object_var aSMObject = nameService->Resolve( "/myStudyManager" );
+ SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow( aSMObject );
+ SALOMEDS::Study_var aStudy = aStudyManager->GetStudyByID( studyId );
+ SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( entry );
+ SALOMEDS::SObject_var aResultSObj;
+ if (aSObj->ReferencedObject(aResultSObj))
+ aSObj = aResultSObj;
+
+ if (aSObj->_is_nil())
+ return CORBA::string_dup("unknown");
+
+ SALOMEDS::GenericAttribute_var anAttribute;
+
+ std::string name("unknown");
+ if (aSObj->FindAttribute(anAttribute, "AttributeName")) {
+ SALOMEDS::AttributeName_var attrName = SALOMEDS::AttributeName::_narrow(anAttribute);
+ name = std::string(attrName->Value());
+ }
+
+ bool isInWorkspace = false;
+ //bool isPresentation = false;
+ int sourceId = -1;
+ int meshId = -1;
+ //int fieldSeriesId = -1;
+ int fieldId = -1;
+ int presentationId = -1;
+ if (aSObj->FindAttribute(anAttribute, "AttributeParameter")) {
+ SALOMEDS::AttributeParameter_var attrParam = SALOMEDS::AttributeParameter::_narrow(anAttribute);
+ if (attrParam->IsSet(IS_IN_WORKSPACE, PT_BOOLEAN))
+ isInWorkspace = attrParam->GetBool(IS_IN_WORKSPACE);
+ //if (attrParam->IsSet(IS_PRESENTATION, PT_BOOLEAN))
+ // isPresentation = attrParam->GetBool(IS_PRESENTATION);
+ if (attrParam->IsSet(SOURCE_ID, PT_INTEGER))
+ sourceId = attrParam->GetInt(SOURCE_ID);
+ if (attrParam->IsSet(MESH_ID, PT_INTEGER))
+ meshId = attrParam->GetInt(MESH_ID);
+ //if (attrParam->IsSet(FIELD_SERIES_ID, PT_INTEGER))
+ // fieldSeriesId = attrParam->GetInt(FIELD_SERIES_ID);
+ if (attrParam->IsSet(FIELD_ID, PT_INTEGER))
+ fieldId = attrParam->GetInt(FIELD_ID);
+ if (attrParam->IsSet(PRESENTATION_ID, PT_INTEGER))
+ presentationId = attrParam->GetInt(PRESENTATION_ID);
+ }
+
+ if (!aSObj->_is_nil() )
+ aSObj->UnRegister();
+
+ std::ostringstream oss;
+ if (sourceId > -1)
+ oss << "Source id: " << sourceId << std::endl;
+ if (meshId > -1)
+ oss << "Mesh id: " << meshId << std::endl;
+ //if (fieldSeriesId > -1)
+ // oss << "Field series id: " << fieldSeriesId << std::endl;
+ if (fieldId > -1)
+ oss << "Field id: " << fieldId << std::endl;
+ //oss << "Is presentation: " << isPresentation << std::endl;
+ if (presentationId > -1)
+ oss << "Presentation id: " << presentationId << std::endl;
+ oss << "Is in workspace: " << isInWorkspace << std::endl;
+
+ return CORBA::string_dup(oss.str().c_str());
+}
+
extern "C"
{
/*!
MED_ORB::status registerPresentation(SALOMEDS::Study_ptr study,
CORBA::Long fieldId,
const char* name,
- const char* label);
+ const char* label,
+ CORBA::Long presentationId);
/*! Dump the study as a Python file */
virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
+ // For tooltips
+ virtual CORBA::Boolean hasObjectInfo();
+ virtual char* getObjectInfo(CORBA::Long studyId, const char* entry);
+
private:
std::map<long, std::string> _fieldSeriesEntries;
};
SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i);
// First retrieve the fieldseries id associated to this study object
- long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,OBJECT_ID);
+ //long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_SERIES_ID);
+ long fieldseriesId = _studyEditor->getParameterInt(soFieldseries,FIELD_ID);
STDLOG("Expand the field timeseries "<<fieldseriesId);
// If fieldseriesId equals -1, then it means that it is not a
SALOMEDS::SObject_var soField = _studyEditor->newObject(soFieldseries);
std::string label("it="); label += ToString(fieldHandler.iteration);
_studyEditor->setName(soField,label.c_str());
- _studyEditor->setParameterInt(soField, OBJECT_ID, fieldHandler.id);
- _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,false);
+ _studyEditor->setParameterInt(soField, FIELD_ID, fieldHandler.id);
+ _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,false);
}
}
_salomeModule->updateObjBrowser(true);
SALOMEDS::SObject_var soField = listOfSObject->at(0);
- bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
+ bool isInWorkspace = _studyEditor->getParameterBool(soField,IS_IN_WORKSPACE);
if ( isInWorkspace ) {
QMessageBox::warning(_salomeModule->getApp()->desktop(),
tr("Operation not allowed"),
return;
}
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
// If fieldId equals -1, then it means that it is not a field
// managed by the MED module, and we stop this function process.
event->objectalias = alias;
emit datasourceSignal(event);
// Tag the item to prevent double import
- // _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
+ // _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true);
// Tag the field as persistent on the server. It means that a
// saving of the workspace will save at least this field (maybe it
// should be an option?)
for (int i=0; i<listOfSObject->size(); i++) {
SALOMEDS::SObject_var soField = listOfSObject->at(i);
- bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE);
+ bool isInWorkspace = _studyEditor->getParameterBool(soField,IS_IN_WORKSPACE);
if ( !isInWorkspace ) {
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
MEDCALC::FieldHandler* fieldHandler =
MEDFactoryClient::getDataManager()->getFieldHandler(fieldId);
DatasourceEvent* event = new DatasourceEvent();
// Note that this signal is processed by the WorkspaceController
// Tag the item to prevent double import
- // _studyEditor->setParameterBool(soField,OBJECT_IS_IN_WORKSPACE,true);
+ // _studyEditor->setParameterBool(soField,IS_IN_WORKSPACE,true);
// Tag the field as persistent on the server. It means that a
// saving of the workspace will save at least this field (maybe it
// should be an option?)
// to make a view of an object from the tui console).
for (int i=0; i<listOfSObject->size(); i++) {
SALOMEDS::SObject_var soField = listOfSObject->at(i);
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
// If fieldId equals -1, then it means that it is not a field
// managed by the MED module, and we stop this function process.
if ( fieldId < 0 )
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(_salomeModule->application()->activeStudy());
_PTR(Study) studyDS = study->studyDS();
- _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str());
+ _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str(), presentationId);
// update Object browser
_salomeModule->getApp()->updateObjectBrowser(true);
SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
if ( listOfSObject->size() > 0 ) {
SALOMEDS::SObject_var soField = listOfSObject->at(0);
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ //int fieldId = _studyEditor->getParameterInt(soField,FIELD_SERIES_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
// _GBO_ : the dialog should not be modal, so that we can choose a
// mesh in the browser. Then we have to emit a signal from the
// dialog.accept, connected to a slot of the DatasourceControler
SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects();
if ( listOfSObject->size() > 0 ) {
SALOMEDS::SObject_var soField = listOfSObject->at(0);
- int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID);
+ int fieldId = _studyEditor->getParameterInt(soField,FIELD_ID);
// _GBO_ : the dialog should not be modal, so that we can choose a
// mesh in the browser. Then we have to emit a signal from the
// dialog.accept, connected to a slot of the DatasourceControler
}
else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) {
QStringList commands;
- commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id = medcalc.LoadDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) {
QStringList commands;
- commands += QString("medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id = medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias);
+ commands += QString("source_id");
_consoleDriver->exec(commands);
}
else {
QString colorMap = _getColorMap();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
+ commands += QString("presentation_id = medcalc.MakeScalarMap(accessField(%1), %2, colorMap=%3)").arg(fieldHandler->id).arg(viewMode).arg(colorMap);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakeContour(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakeVectorField(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SLICES ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakeSlices(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakeDeflectionShape(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) {
QString viewMode = _getViewMode();
MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler();
QStringList commands;
- commands += QString("medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id = medcalc.MakePointSprite(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode);
+ commands += QString("presentation_id");
_consoleDriver->exec(commands);
}
else {
SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
// _GBO_ TODO: we should test here if it is a mesh (attribute in
// the sobject)
- _meshId = _studyEditor->getParameterInt(soMesh,OBJECT_ID);
+ _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
const char * meshname = _studyEditor->getName(soMesh);
this->ui.txtMesh->setText(QString(meshname));
}
SALOMEDS::SObject_var soMesh = listOfSObject->at(0);
// _GBO_ TODO: we should test here if it is a mesh (attribute in
// the sobject)
- _meshId = _studyEditor->getParameterInt(soMesh,OBJECT_ID);
+ _meshId = _studyEditor->getParameterInt(soMesh,MESH_ID);
const char * meshname = _studyEditor->getName(soMesh);
this->ui.txtMesh->setText(QString(meshname));
}
def notifyGui_cleanWorkspace():
__notifyGui(MEDCALC.EVENT_CLEAN_WORKSPACE)
#
-def notifyGui_addDatasource(filename):
- __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, filename=filename)
+def notifyGui_addDatasource(handlerId, filename):
+ __notifyGui(MEDCALC.EVENT_ADD_DATASOURCE, dataId=handlerId, filename=filename)
#
def notifyGui_addPresentation(fieldId, presId):
__notifyGui(MEDCALC.EVENT_ADD_PRESENTATION, dataId=fieldId, presentationId=presId)
def LoadDataSource(filename):
dataManager = medcalc.medcorba.factory.getDataManager()
- dataManager.loadDatasource(filename)
+ handler = dataManager.loadDatasource(filename)
from medcalc.medevents import notifyGui_addDatasource
- notifyGui_addDatasource(filename)
+ notifyGui_addDatasource(handler.id, filename)
+ return handler.id
#
def LoadImageAsDataSource(filename):
from medimages import FieldBuilder
builder = FieldBuilder()
builder.image2med(filename, medfilename)
- LoadDataSource(medfilename)
+ return LoadDataSource(medfilename)
#
params = MEDCALC.ScalarMapParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap)
presentation_id = __manager.makeScalarMap(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakeContour(proxy,
params = MEDCALC.ContourParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap, nbContours)
presentation_id = __manager.makeContour(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakeVectorField(proxy,
params = MEDCALC.VectorFieldParameters(proxy.id, viewMode)
presentation_id = __manager.makeVectorField(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakeSlices(proxy,
params = MEDCALC.SlicesParameters(proxy.id, viewMode, orientation, nbSlices)
presentation_id = __manager.makeSlices(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakeDeflectionShape(proxy,
params = MEDCALC.DeflectionShapeParameters(proxy.id, viewMode)
presentation_id = __manager.makeDeflectionShape(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#
def MakePointSprite(proxy,
params = MEDCALC.PointSpriteParameters(proxy.id, viewMode, displayedInfo, scalarBarRange, colorMap)
presentation_id = __manager.makePointSprite(params)
notifyGui_addPresentation(proxy.id, presentation_id)
+ return presentation_id
#