From: Cédric Aguerre Date: Fri, 29 Jan 2016 08:41:33 +0000 (+0100) Subject: [MEDCalc] add icons and menu for presentations X-Git-Tag: V8_1_0a1~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c55144bfb0c9d1d77af03ad9d0c34e18781a0532;p=modules%2Fmed.git [MEDCalc] add icons and menu for presentations --- diff --git a/src/MEDCalc/gui/DatasourceController.cxx b/src/MEDCalc/gui/DatasourceController.cxx index 636c4d95b..f7a96890b 100644 --- a/src/MEDCalc/gui/DatasourceController.cxx +++ b/src/MEDCalc/gui/DatasourceController.cxx @@ -53,12 +53,12 @@ // Datasource controller // ============================================================== // -//DatasourceController::DatasourceController(StandardApp_Module * salomeModule) -DatasourceController::DatasourceController(MEDModule * salomeModule) +//DatasourceController::DatasourceController(StandardApp_Module* salomeModule) +DatasourceController::DatasourceController(MEDModule* salomeModule) { STDLOG("Creating a DatasourceController"); _salomeModule = salomeModule; - _studyEditor = new SALOME_AppStudyEditor(_salomeModule->getApp()); + _studyEditor = _salomeModule->getStudyEditor(); _dlgChangeUnderlyingMesh = new DlgChangeUnderlyingMesh(_studyEditor); connect(_dlgChangeUnderlyingMesh,SIGNAL(inputValidated()), @@ -72,7 +72,6 @@ DatasourceController::DatasourceController(MEDModule * salomeModule) DatasourceController::~DatasourceController() { STDLOG("Deleting the DatasourceController"); - delete _studyEditor; } void DatasourceController::createActions() { @@ -103,6 +102,8 @@ void DatasourceController::createActions() { actionId = _salomeModule->createStandardAction(label,this, SLOT(OnAddImagesource()),icon,tooltip); // _salomeModule->addActionInToolbar(actionId); _salomeModule->createTool(actionId, toolbarId); + _salomeModule->action(actionId)->setIconVisibleInMenu(true); + _salomeModule->createMenu(actionId, menuId, 20); // // Actions for popup menu only @@ -113,37 +114,6 @@ void DatasourceController::createActions() { actionId = _salomeModule->createStandardAction(label,this,SLOT(OnExpandField()),icon); _salomeModule->addActionInPopupMenu(actionId); - // Create a view submenu with usual visualization functions - label = tr("LAB_VISUALIZE_SCALARMAP"); - icon = tr("ICO_DATASOURCE_VIEW"); - actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeScalarMap()),icon); - _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); - - label = tr("LAB_VISUALIZE_CONTOUR"); - icon = tr("ICO_DATASOURCE_VIEW"); - actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeContour()),icon); - _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); - - label = tr("LAB_VISUALIZE_VECTORFIELD"); - icon = tr("ICO_DATASOURCE_VIEW"); - actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeVectorField()),icon); - _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); - - label = tr("LAB_VISUALIZE_SLICES"); - icon = tr("ICO_DATASOURCE_VIEW"); - actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeSlices()),icon); - _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); - - label = tr("LAB_VISUALIZE_DEFLECTIONSHAPE"); - icon = tr("ICO_DATASOURCE_VIEW"); - actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizeDeflectionShape()),icon); - _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); - - label = tr("LAB_VISUALIZE_POINTSPRITE"); - icon = tr("ICO_DATASOURCE_VIEW"); - actionId = _salomeModule->createStandardAction(label,this,SLOT(OnVisualizePointSprite()),icon); - _salomeModule->addActionInPopupMenu(actionId, tr("LAB_VISUALIZE")); - // Use in workspace label = tr("LAB_USE_IN_WORKSPACE"); icon = tr("ICO_DATASOURCE_USE"); @@ -197,27 +167,6 @@ DatasourceController::updateTreeViewWithNewDatasource(const MEDCALC::DatasourceH _salomeModule->getApp()->updateObjectBrowser(true); } -void -DatasourceController::updateTreeViewWithNewPresentation(long fieldId, long presentationId) -{ - if (presentationId < 0) { - std::cerr << "Unknown presentation\n"; - return; - } - - std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name"); - name = tr(name.c_str()).toStdString(); - std::string label = tr("ICO_MED_PRESENTATION").toStdString(); - - SalomeApp_Study* study = dynamic_cast(_salomeModule->application()->activeStudy()); - _PTR(Study) studyDS = study->studyDS(); - - _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str()); - - // update Object browser - _salomeModule->getApp()->updateObjectBrowser(true); -} - void DatasourceController::OnAddDatasource() { // Dialog to get the filename where the input data are read from @@ -291,7 +240,7 @@ void DatasourceController::OnExpandField() _studyEditor->updateActiveStudy(); // Get the selected objects in the study (SObject) - SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects(); + SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); for (int i=0; isize(); i++) { SALOMEDS::SObject_var soFieldseries = listOfSObject->at(i); @@ -308,7 +257,7 @@ void DatasourceController::OnExpandField() // contextual menu if the selected object is not conform // Then retrieve the list of fields in this timeseries - MEDCALC::FieldHandlerList * fieldHandlerList = + MEDCALC::FieldHandlerList* fieldHandlerList = MEDFactoryClient::getDataManager()->getFieldListInFieldseries(fieldseriesId); // Finally, create an entry for each of the field @@ -324,71 +273,12 @@ void DatasourceController::OnExpandField() _salomeModule->updateObjBrowser(true); } -void DatasourceController::visualize(DatasourceEvent::EventType eventType) { - // We need a _studyEditor updated on the active study - _studyEditor->updateActiveStudy(); - - // Get the selected objects in the study (SObject) - SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects(); - - // For each object, emit a signal to the workspace to request a - // visualisation using the tui command (so that the user can see how - // to make a view of an object from the tui console). - for (int i=0; isize(); i++) { - SALOMEDS::SObject_var soField = listOfSObject->at(i); - int fieldId = _studyEditor->getParameterInt(soField,OBJECT_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 ) - continue; - - MEDCALC::FieldHandler * fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); - if (! fieldHandler) { - QMessageBox::warning(_salomeModule->getApp()->desktop(), - tr("Operation not allowed"), - tr("No field is defined")); - return; - } - - DatasourceEvent * event = new DatasourceEvent(); - event->eventtype = eventType; - XmedDataObject * dataObject = new XmedDataObject(); - dataObject->setFieldHandler(*fieldHandler); - event->objectdata = dataObject; - emit datasourceSignal(event); - } -} - -void DatasourceController::OnVisualizeScalarMap() { - this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP); -} - -void DatasourceController::OnVisualizeContour() { - this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_CONTOUR); -} - -void DatasourceController::OnVisualizeVectorField() { - this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD); -} - -void DatasourceController::OnVisualizeSlices() { - this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_SLICES); -} - -void DatasourceController::OnVisualizeDeflectionShape() { - this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE); -} - -void DatasourceController::OnVisualizePointSprite() { - this->visualize(DatasourceEvent::EVENT_VIEW_OBJECT_POINT_SPRITE); -} - void DatasourceController::OnUseInWorkspace() { // We need a studyEditor updated on the active study _studyEditor->updateActiveStudy(); // Get the selected objects in the study (SObject) - SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects(); + SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); if ( listOfSObject->size() == 1 ) { // In this case we ask the name of the variable for the python // console @@ -421,7 +311,7 @@ void DatasourceController::OnUseInWorkspace() { return; } - MEDCALC::FieldHandler * fieldHandler = + MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); if (! fieldHandler) { @@ -441,9 +331,9 @@ void DatasourceController::OnUseInWorkspace() { } alias = dialog.getAlias(); - DatasourceEvent * event = new DatasourceEvent(); + DatasourceEvent* event = new DatasourceEvent(); event->eventtype = DatasourceEvent::EVENT_USE_OBJECT; - XmedDataObject * dataObject = new XmedDataObject(); + XmedDataObject* dataObject = new XmedDataObject(); dataObject->setFieldHandler(*fieldHandler); event->objectdata = dataObject; event->objectalias = alias; @@ -464,11 +354,11 @@ void DatasourceController::OnUseInWorkspace() { bool isInWorkspace = _studyEditor->getParameterBool(soField,OBJECT_IS_IN_WORKSPACE); if ( !isInWorkspace ) { int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID); - MEDCALC::FieldHandler * fieldHandler = + MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); - DatasourceEvent * event = new DatasourceEvent(); + DatasourceEvent* event = new DatasourceEvent(); event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT; - XmedDataObject * dataObject = new XmedDataObject(); + XmedDataObject* dataObject = new XmedDataObject(); dataObject->setFieldHandler(*fieldHandler); event->objectdata = dataObject; emit datasourceSignal(event); @@ -496,7 +386,7 @@ void DatasourceController::OnChangeUnderlyingMesh() { // Get the selected objects in the study (SObject). In cas of a // multiple selection, we consider only the first item. At least one // item must be selected. - SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects(); + SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); if ( listOfSObject->size() > 0 ) { SALOMEDS::SObject_var soField = listOfSObject->at(0); int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID); @@ -514,11 +404,11 @@ void DatasourceController::OnChangeUnderlyingMeshInputValidated() { int meshId = _dlgChangeUnderlyingMesh->getMeshId(); STDLOG("meshId = " << ToString(meshId)); int fieldId = _dlgChangeUnderlyingMesh->getFieldId(); - MEDCALC::FieldHandler * fieldHandler = + MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); // We don't modify the original field but create first a duplicate - MEDCALC::FieldHandler * duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler); + MEDCALC::FieldHandler* duplicate = MEDFactoryClient::getCalculator()->dup(*fieldHandler); MEDFactoryClient::getDataManager()->changeUnderlyingMesh(duplicate->id, meshId); // Request once more the duplicate to update the meta-data on this @@ -528,9 +418,9 @@ void DatasourceController::OnChangeUnderlyingMeshInputValidated() { // >>> // WARN: the following is a temporary code for test purpose // Automatically add in ws - DatasourceEvent * event = new DatasourceEvent(); + DatasourceEvent* event = new DatasourceEvent(); event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT; - XmedDataObject * dataObject = new XmedDataObject(); + XmedDataObject* dataObject = new XmedDataObject(); dataObject->setFieldHandler(*duplicate); event->objectdata = dataObject; emit datasourceSignal(event); @@ -547,7 +437,7 @@ void DatasourceController::OnInterpolateField() { // Get the selected objects in the study (SObject). In case of a // multiple selection, we consider only the first item. At least one // item must be selected. - SALOME_StudyEditor::SObjectList * listOfSObject = _studyEditor->getSelectedObjects(); + SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); if ( listOfSObject->size() > 0 ) { SALOMEDS::SObject_var soField = listOfSObject->at(0); int fieldId = _studyEditor->getParameterInt(soField,OBJECT_ID); @@ -603,9 +493,9 @@ void DatasourceController::OnInterpolateFieldInputValidated() { // >>> // WARN: the following is a temporary code for test purpose // Automatically add in ws - DatasourceEvent * event = new DatasourceEvent(); + DatasourceEvent* event = new DatasourceEvent(); event->eventtype = DatasourceEvent::EVENT_IMPORT_OBJECT; - XmedDataObject * dataObject = new XmedDataObject(); + XmedDataObject* dataObject = new XmedDataObject(); dataObject->setFieldHandler(*result); event->objectdata = dataObject; emit datasourceSignal(event); @@ -622,7 +512,4 @@ DatasourceController::processWorkspaceEvent(const MEDCALC::MedEvent* event) MEDCALC::DatasourceHandler* datasourceHandler = MEDFactoryClient::getDataManager()->getDatasourceHandler(event->filename); this->updateTreeViewWithNewDatasource(datasourceHandler); } - else if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) { - this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId); - } } diff --git a/src/MEDCalc/gui/DatasourceController.hxx b/src/MEDCalc/gui/DatasourceController.hxx index 69b9f8cb6..b2097e38c 100644 --- a/src/MEDCalc/gui/DatasourceController.hxx +++ b/src/MEDCalc/gui/DatasourceController.hxx @@ -67,7 +67,7 @@ typedef struct { EVENT_ADD_PRESENTATION }; int eventtype; - XmedDataObject * objectdata; + XmedDataObject* objectdata; QString objectalias; } DatasourceEvent; @@ -82,7 +82,7 @@ class MEDCALCGUI_EXPORT DatasourceController: public QObject { Q_OBJECT public: - DatasourceController(MEDModule * salomeModule); + DatasourceController(MEDModule* salomeModule); ~DatasourceController(); void createActions(); @@ -91,37 +91,29 @@ public slots: // Callback connected to dialog box validation signals void OnChangeUnderlyingMeshInputValidated(); void OnInterpolateFieldInputValidated(); - void processWorkspaceEvent(const MEDCALC::MedEvent * event); + void processWorkspaceEvent(const MEDCALC::MedEvent* event); signals: - void datasourceSignal(const DatasourceEvent * event); + void datasourceSignal(const DatasourceEvent* event); protected slots: void OnAddDatasource(); void OnAddImagesource(); void OnExpandField(); - void OnVisualizeScalarMap(); - void OnVisualizeContour(); - void OnVisualizeVectorField(); - void OnVisualizeSlices(); - void OnVisualizeDeflectionShape(); - void OnVisualizePointSprite(); void OnUseInWorkspace(); void OnChangeUnderlyingMesh(); void OnInterpolateField(); private: - void visualize(DatasourceEvent::EventType); void addDatasource(const char* filename); void updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler*); - void updateTreeViewWithNewPresentation(long fieldId, long presentationId); private: MEDModule* _salomeModule; - SALOME_AppStudyEditor * _studyEditor; + SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule - DlgChangeUnderlyingMesh * _dlgChangeUnderlyingMesh; - DlgInterpolateField * _dlgInterpolateField; + DlgChangeUnderlyingMesh* _dlgChangeUnderlyingMesh; + DlgInterpolateField* _dlgInterpolateField; }; diff --git a/src/MEDCalc/gui/MEDModule.cxx b/src/MEDCalc/gui/MEDModule.cxx index 50c7a4203..7b9fccbb3 100644 --- a/src/MEDCalc/gui/MEDModule.cxx +++ b/src/MEDCalc/gui/MEDModule.cxx @@ -38,7 +38,7 @@ MED_ORB::MED_Gen_var MEDModule::myEngine; MEDModule::MEDModule() : - SalomeApp_Module("MED") + SalomeApp_Module("MED"), _studyEditor(0), _datasourceController(0), _workspaceController(0), _presentationController(0) { // Note also that we can't use the getApp() function here because // the initialize(...) function has not been called yet. @@ -48,7 +48,14 @@ MEDModule::MEDModule() : MEDModule::~MEDModule() { - // nothing to do + if (_studyEditor) + delete _studyEditor; + if (_datasourceController) + delete _datasourceController; + //if (_workspaceController) + // delete _workspaceController; + if (_presentationController) + delete _presentationController; } MED_ORB::MED_Gen_var @@ -169,17 +176,24 @@ MEDModule::deactivateModule( SUIT_Study* theStudy ) */ void MEDModule::createModuleWidgets() { + _studyEditor = new SALOME_AppStudyEditor(getApp()); _datasourceController = new DatasourceController(this); _workspaceController = new WorkspaceController(this); _xmedDataModel = new XmedDataModel(); _workspaceController->setDataModel(_xmedDataModel); _presentationController = new PresentationController(this); - connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent *)), - _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent *))); + connect(_datasourceController, SIGNAL(datasourceSignal(const DatasourceEvent*)), + _workspaceController, SLOT(processDatasourceEvent(const DatasourceEvent*))); - connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent *)), - _datasourceController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent *))); + connect(_presentationController, SIGNAL(presentationSignal(const PresentationEvent*)), + _workspaceController, SLOT(processPresentationEvent(const PresentationEvent*))); + + connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)), + _datasourceController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*))); + + connect(_workspaceController, SIGNAL(workspaceSignal(const MEDCALC::MedEvent*)), + _presentationController, SLOT(processWorkspaceEvent(const MEDCALC::MedEvent*))); } void @@ -191,7 +205,7 @@ MEDModule::createModuleActions() { int MEDModule::createStandardAction(const QString& label, - QObject * slotobject, + QObject* slotobject, const char* slotmember, const QString& iconName, const QString& tooltip) diff --git a/src/MEDCalc/gui/MEDModule.hxx b/src/MEDCalc/gui/MEDModule.hxx index 8f39391ca..508253dcd 100644 --- a/src/MEDCalc/gui/MEDModule.hxx +++ b/src/MEDCalc/gui/MEDModule.hxx @@ -25,6 +25,7 @@ #include "MEDCALCGUI.hxx" #include +#include #include "WorkspaceController.hxx" #include "XmedDataModel.hxx" @@ -54,26 +55,30 @@ public: static MED_ORB::MED_Gen_var engine(); - virtual void initialize( CAM_Application* app ); - virtual QString engineIOR() const; + virtual void initialize(CAM_Application* app); + virtual QString engineIOR() const; - virtual QString iconName() const; + virtual QString iconName() const; - virtual void windows( QMap& theMap ) const; - virtual void viewManagers( QStringList& theList ) const; + virtual void windows(QMap& theMap) const; + virtual void viewManagers(QStringList& theList) const; int createStandardAction(const QString& label, - QObject * slotobject, + QObject* slotobject, const char* slotmember, const QString& iconName, const QString& tooltip=QString()); - void addActionInPopupMenu(int actionId,const QString& menus="",const QString& rule="client='ObjectBrowser'"); + void addActionInPopupMenu(int actionId, + const QString& menus="", + const QString& rule="client='ObjectBrowser'"); MEDCALC::MEDPresentationViewMode getSelectedViewMode(); + inline SALOME_AppStudyEditor* getStudyEditor() { return _studyEditor; } + public slots: - virtual bool activateModule( SUIT_Study* theStudy ); - virtual bool deactivateModule( SUIT_Study* theStudy ); + virtual bool activateModule(SUIT_Study* theStudy); + virtual bool deactivateModule(SUIT_Study* theStudy); private: void createModuleWidgets(); @@ -81,10 +86,11 @@ private: static void init(); private: - DatasourceController * _datasourceController; - WorkspaceController * _workspaceController; - XmedDataModel * _xmedDataModel; - PresentationController * _presentationController; + SALOME_AppStudyEditor* _studyEditor; + DatasourceController* _datasourceController; + WorkspaceController* _workspaceController; + XmedDataModel* _xmedDataModel; + PresentationController* _presentationController; static MED_ORB::MED_Gen_var myEngine; }; diff --git a/src/MEDCalc/gui/MED_images.ts b/src/MEDCalc/gui/MED_images.ts index 86476bca1..3f7fcf1e0 100644 --- a/src/MEDCalc/gui/MED_images.ts +++ b/src/MEDCalc/gui/MED_images.ts @@ -3,10 +3,6 @@ @default - - ICO_MED_PRESENTATION - pqAppIcon16.png - ICO_IMPORT_MED datasource_add.png @@ -43,10 +39,6 @@ ICO_DATASOURCE_USE datasource_use.png - - ICO_DATASOURCE_VIEW - datasource_view.png - ICO_FOLDER folder.png @@ -71,5 +63,53 @@ ICO_WORKSPACE_SAVE workspace_save.png + + ICO_PRESENTATION_SCALAR_MAP + scalarmap24.png + + + ICO_PRESENTATION_CONTOUR + pqIsosurface24.png + + + ICO_PRESENTATION_VECTOR_FIELD + pqGlyph24.png + + + ICO_PRESENTATION_SLICES + pqSlice24.png + + + ICO_PRESENTATION_DEFLECTION_SHAPE + pqWarp24.png + + + ICO_PRESENTATION_POINT_SPRITE + pqNodeMapData24.png + + + ICO_MEDPresentationScalarMap + scalarmap16.png + + + ICO_MEDPresentationContour + pqIsosurface16.png + + + ICO_MEDPresentationVectorField + pqGlyph16.png + + + ICO_MEDPresentationSlices + pqSlice16.png + + + ICO_MEDPresentationDeflectionShape + pqWarp16.png + + + ICO_MEDPresentationPointSprite + pqNodeMapData16.png + diff --git a/src/MEDCalc/gui/MED_msg_en.ts b/src/MEDCalc/gui/MED_msg_en.ts index a1c303a63..8a6d8934e 100644 --- a/src/MEDCalc/gui/MED_msg_en.ts +++ b/src/MEDCalc/gui/MED_msg_en.ts @@ -35,62 +35,109 @@ TIP_VIEW_MODE_SPLIT_VIEW Split - - - DatasourceController - - LAB_ADD_DATA_SOURCE - Add Data Source + LAB_PRESENTATION_SCALAR_MAP + Scalar map - - TIP_ADD_DATA_SOURCE - Add a file data source (file providing med data) + TIP_PRESENTATION_SCALAR_MAP + Scalar map - - LAB_ADD_IMAGE_SOURCE - Add Image Source + LAB_PRESENTATION_CONTOUR + Contour - - TIP_ADD_IMAGE_SOURCE - Create a Data Source from an image file + TIP_PRESENTATION_CONTOUR + Contour - - LAB_EXPAND_FIELD - Expand field timeseries + LAB_PRESENTATION_VECTOR_FIELD + Vector field + + + TIP_PRESENTATION_VECTOR_FIELD + Vector field + + + LAB_PRESENTATION_SLICES + Slices + + + TIP_PRESENTATION_SLICES + Slices + + + LAB_PRESENTATION_DEFLECTION_SHAPE + Deflection shape + + + TIP_PRESENTATION_DEFLECTION_SHAPE + Deflection shape + + + LAB_PRESENTATION_POINT_SPRITE + Point sprite + + + TIP_PRESENTATION_POINT_SPRITE + Point sprite + + + MENU_PRESENTATIONS + Presentations - LAB_VISUALIZE_SCALARMAP + MEDPresentationScalarMap Scalar map - LAB_VISUALIZE_CONTOUR + MEDPresentationContour Contour - LAB_VISUALIZE_VECTORFIELD + MEDPresentationVectorField Vector field - LAB_VISUALIZE_SLICES + MEDPresentationSlices Slices - LAB_VISUALIZE_DEFLECTIONSHAPE + MEDPresentationDeflectionShape Deflection shape - LAB_VISUALIZE_POINTSPRITE + MEDPresentationPointSprite Point sprite + + + DatasourceController + + + LAB_ADD_DATA_SOURCE + Add Data Source + - - LAB_VISUALIZE - Visualize + + TIP_ADD_DATA_SOURCE + Add a file data source (file providing med data) + + + + LAB_ADD_IMAGE_SOURCE + Add Image Source + + + + TIP_ADD_IMAGE_SOURCE + Create a Data Source from an image file + + + + LAB_EXPAND_FIELD + Expand field timeseries diff --git a/src/MEDCalc/gui/MED_msg_fr.ts b/src/MEDCalc/gui/MED_msg_fr.ts index 812cfaeb2..290fe00fb 100644 --- a/src/MEDCalc/gui/MED_msg_fr.ts +++ b/src/MEDCalc/gui/MED_msg_fr.ts @@ -35,66 +35,113 @@ TIP_VIEW_MODE_SPLIT_VIEW Scinder - - - DatasourceController - MEDPresentationScalarMap + LAB_PRESENTATION_SCALAR_MAP Carte scalaire - - LAB_ADD_DATA_SOURCE - Importer des données MED + TIP_PRESENTATION_SCALAR_MAP + Carte scalaire - - TIP_ADD_DATA_SOURCE - Ajouter des données par import de fichiers MED + LAB_PRESENTATION_CONTOUR + Contour - - LAB_ADD_IMAGE_SOURCE - Ajouter une image + TIP_PRESENTATION_CONTOUR + Contour - - TIP_ADD_IMAGE_SOURCE - Ajouter des données par import d'un fichier image + LAB_PRESENTATION_VECTOR_FIELD + Champ de vecteurs - - LAB_EXPAND_FIELD - Étendre les series temporelles du champ + TIP_PRESENTATION_VECTOR_FIELD + Champ de vecteurs - LAB_VISUALIZE_SCALARMAP + LAB_PRESENTATION_SLICES + Coupes + + + TIP_PRESENTATION_SLICES + Coupes + + + LAB_PRESENTATION_DEFLECTION_SHAPE + Déformée + + + TIP_PRESENTATION_DEFLECTION_SHAPE + Déformée + + + LAB_PRESENTATION_POINT_SPRITE + Point sprite + + + TIP_PRESENTATION_POINT_SPRITE + Point sprite + + + MENU_PRESENTATIONS + Présentations + + + MEDPresentationScalarMap Carte scalaire - LAB_VISUALIZE_CONTOUR + MEDPresentationContour Contour - LAB_VISUALIZE_VECTORFIELD + MEDPresentationVectorField Champ de vecteurs - LAB_VISUALIZE_SLICES + MEDPresentationSlices Coupes - LAB_VISUALIZE_DEFLECTIONSHAPE + MEDPresentationDeflectionShape Déformée - LAB_VISUALIZE_POINTSPRITE + MEDPresentationPointSprite Point sprite + + + DatasourceController + + MEDPresentationScalarMap + Carte scalaire + + + + LAB_ADD_DATA_SOURCE + Importer des données MED + - - LAB_VISUALIZE - Visualiser + + TIP_ADD_DATA_SOURCE + Ajouter des données par import de fichiers MED + + + + LAB_ADD_IMAGE_SOURCE + Ajouter une image + + + + TIP_ADD_IMAGE_SOURCE + Ajouter des données par import d'un fichier image + + + + LAB_EXPAND_FIELD + Étendre les series temporelles du champ diff --git a/src/MEDCalc/gui/PresentationController.cxx b/src/MEDCalc/gui/PresentationController.cxx index 0e0bf8441..ea2aa5752 100644 --- a/src/MEDCalc/gui/PresentationController.cxx +++ b/src/MEDCalc/gui/PresentationController.cxx @@ -18,9 +18,21 @@ // #include "PresentationController.hxx" +#include "DatasourceConstants.hxx" #include "MEDModule.hxx" #include "Basics_Utils.hxx" #include "QtxActionGroup.h" +#include "MEDFactoryClient.hxx" + +#include +#include +#include + +#include +#include + +#include +#include static const int OPTIONS_VIEW_MODE_ID = 943; static const int OPTIONS_VIEW_MODE_REPLACE_ID = 944; @@ -32,6 +44,7 @@ PresentationController::PresentationController(MEDModule* salomeModule) { STDLOG("Creating a PresentationController"); _salomeModule = salomeModule; + _studyEditor = _salomeModule->getStudyEditor(); } PresentationController::~PresentationController() @@ -45,6 +58,9 @@ PresentationController::createActions() STDLOG("Creating PresentationController actions"); int toolbarId = _salomeModule->createTool("View Mode", "PresentationToolbar"); + int presentationMenuId = _salomeModule->createMenu(tr("MENU_PRESENTATIONS"), -1, 1); + + // View Mode QtxActionGroup* ag = _salomeModule->createActionGroup(OPTIONS_VIEW_MODE_ID, true); ag->setText("View mode"); ag->setUsesDropDown(true); @@ -76,7 +92,55 @@ PresentationController::createActions() _salomeModule->createTool(OPTIONS_VIEW_MODE_ID, toolbarId); + // Presentations + label = tr("LAB_PRESENTATION_SCALAR_MAP"); + tooltip = tr("TIP_PRESENTATION_SCALAR_MAP"); + QString icon = tr("ICO_PRESENTATION_SCALAR_MAP"); + int actionId; + actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeScalarMap()),icon,tooltip); + _salomeModule->createTool(actionId, toolbarId); + _salomeModule->action(actionId)->setIconVisibleInMenu(true); + _salomeModule->createMenu(actionId, presentationMenuId); + + label = tr("LAB_PRESENTATION_CONTOUR"); + tooltip = tr("TIP_PRESENTATION_CONTOUR"); + icon = tr("ICO_PRESENTATION_CONTOUR"); + actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeContour()),icon,tooltip); + _salomeModule->createTool(actionId, toolbarId); + _salomeModule->action(actionId)->setIconVisibleInMenu(true); + _salomeModule->createMenu(actionId, presentationMenuId); + + label = tr("LAB_PRESENTATION_VECTOR_FIELD"); + tooltip = tr("TIP_PRESENTATION_VECTOR_FIELD"); + icon = tr("ICO_PRESENTATION_VECTOR_FIELD"); + actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeVectorField()),icon,tooltip); + _salomeModule->createTool(actionId, toolbarId); + _salomeModule->action(actionId)->setIconVisibleInMenu(true); + _salomeModule->createMenu(actionId, presentationMenuId); + + label = tr("LAB_PRESENTATION_SLICES"); + tooltip = tr("TIP_PRESENTATION_SLICES"); + icon = tr("ICO_PRESENTATION_SLICES"); + actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeSlices()),icon,tooltip); + _salomeModule->createTool(actionId, toolbarId); + _salomeModule->action(actionId)->setIconVisibleInMenu(true); + _salomeModule->createMenu(actionId, presentationMenuId); + label = tr("LAB_PRESENTATION_DEFLECTION_SHAPE"); + tooltip = tr("TIP_PRESENTATION_DEFLECTION_SHAPE"); + icon = tr("ICO_PRESENTATION_DEFLECTION_SHAPE"); + actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizeDeflectionShape()),icon,tooltip); + _salomeModule->createTool(actionId, toolbarId); + _salomeModule->action(actionId)->setIconVisibleInMenu(true); + _salomeModule->createMenu(actionId, presentationMenuId); + + label = tr("LAB_PRESENTATION_POINT_SPRITE"); + tooltip = tr("TIP_PRESENTATION_POINT_SPRITE"); + icon = tr("ICO_PRESENTATION_POINT_SPRITE"); + actionId = _salomeModule->createStandardAction(label,this, SLOT(OnVisualizePointSprite()),icon,tooltip); + _salomeModule->createTool(actionId, toolbarId); + _salomeModule->action(actionId)->setIconVisibleInMenu(true); + _salomeModule->createMenu(actionId, presentationMenuId); } MEDCALC::MEDPresentationViewMode @@ -95,3 +159,106 @@ PresentationController::getSelectedViewMode() return MEDCALC::VIEW_MODE_SPLIT_VIEW; } } + +void +PresentationController::visualize(PresentationEvent::EventType eventType) +{ + // We need a _studyEditor updated on the active study + _studyEditor->updateActiveStudy(); + + // Get the selected objects in the study (SObject) + SALOME_StudyEditor::SObjectList* listOfSObject = _studyEditor->getSelectedObjects(); + + // For each object, emit a signal to the workspace to request a + // visualisation using the tui command (so that the user can see how + // to make a view of an object from the tui console). + for (int i=0; isize(); i++) { + SALOMEDS::SObject_var soField = listOfSObject->at(i); + int fieldId = _studyEditor->getParameterInt(soField,OBJECT_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 ) + continue; + + MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldId); + if (! fieldHandler) { + QMessageBox::warning(_salomeModule->getApp()->desktop(), + tr("Operation not allowed"), + tr("No field is defined")); + return; + } + + PresentationEvent* event = new PresentationEvent(); + event->eventtype = eventType; + XmedDataObject* dataObject = new XmedDataObject(); + dataObject->setFieldHandler(*fieldHandler); + event->objectdata = dataObject; + emit presentationSignal(event); + } +} + +void +PresentationController::OnVisualizeScalarMap() +{ + this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP); +} + +void +PresentationController::OnVisualizeContour() +{ + this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_CONTOUR); +} + +void +PresentationController::OnVisualizeVectorField() +{ + this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD); +} + +void +PresentationController::OnVisualizeSlices() +{ + this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_SLICES); +} + +void +PresentationController::OnVisualizeDeflectionShape() +{ + this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE); +} + +void +PresentationController::OnVisualizePointSprite() +{ + this->visualize(PresentationEvent::EVENT_VIEW_OBJECT_POINT_SPRITE); +} + +void +PresentationController::updateTreeViewWithNewPresentation(long fieldId, long presentationId) +{ + if (presentationId < 0) { + std::cerr << "Unknown presentation\n"; + return; + } + + std::string name = MEDFactoryClient::getPresentationManager()->getPresentationProperty(presentationId, "name"); + std::string icon = std::string("ICO_") + name; + name = tr(name.c_str()).toStdString(); + std::string label = tr(icon.c_str()).toStdString(); + + SalomeApp_Study* study = dynamic_cast(_salomeModule->application()->activeStudy()); + _PTR(Study) studyDS = study->studyDS(); + + _salomeModule->engine()->registerPresentation(_CAST(Study, studyDS)->GetStudy(), fieldId, name.c_str(), label.c_str()); + + // update Object browser + _salomeModule->getApp()->updateObjectBrowser(true); +} + +void +PresentationController::processWorkspaceEvent(const MEDCALC::MedEvent* event) +{ + if ( event->type == MEDCALC::EVENT_ADD_PRESENTATION ) { + this->updateTreeViewWithNewPresentation(event->dataId, event->presentationId); + } +} diff --git a/src/MEDCalc/gui/PresentationController.hxx b/src/MEDCalc/gui/PresentationController.hxx index fbd90737f..f48f8e77b 100644 --- a/src/MEDCalc/gui/PresentationController.hxx +++ b/src/MEDCalc/gui/PresentationController.hxx @@ -23,8 +23,27 @@ #include #include "MEDCALCGUI.hxx" +#include "MEDEventListener_i.hxx" #include #include CORBA_SERVER_HEADER(MEDPresentationManager) +#include CORBA_CLIENT_HEADER(MEDDataManager) + +#include "XmedDataModel.hxx" +#include + +typedef struct { + enum EventType { + EVENT_VIEW_OBJECT_CONTOUR, + EVENT_VIEW_OBJECT_DEFLECTION_SHAPE, + EVENT_VIEW_OBJECT_POINT_SPRITE, + EVENT_VIEW_OBJECT_SCALAR_MAP, + EVENT_VIEW_OBJECT_SLICES, + EVENT_VIEW_OBJECT_VECTOR_FIELD + }; + int eventtype; + XmedDataObject* objectdata; + QString objectalias; +} PresentationEvent; class MEDModule; @@ -39,8 +58,25 @@ public: MEDCALC::MEDPresentationViewMode getSelectedViewMode(); +signals: + void presentationSignal(const PresentationEvent* event); + +protected slots: + void OnVisualizeScalarMap(); + void OnVisualizeContour(); + void OnVisualizeVectorField(); + void OnVisualizeSlices(); + void OnVisualizeDeflectionShape(); + void OnVisualizePointSprite(); + void processWorkspaceEvent(const MEDCALC::MedEvent* event); + +private: + void visualize(PresentationEvent::EventType); + void updateTreeViewWithNewPresentation(long fieldId, long presentationId); + private: MEDModule* _salomeModule; + SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule }; diff --git a/src/MEDCalc/gui/WorkspaceController.cxx b/src/MEDCalc/gui/WorkspaceController.cxx index 0fc4f443f..3137c82d2 100644 --- a/src/MEDCalc/gui/WorkspaceController.cxx +++ b/src/MEDCalc/gui/WorkspaceController.cxx @@ -40,8 +40,8 @@ * and containing a tree view for rendering a hierarchical data * model. This datamodel contains the objects used in the workspace. */ -//WorkspaceController::WorkspaceController(StandardApp_Module * salomeModule) -WorkspaceController::WorkspaceController(MEDModule * salomeModule) +//WorkspaceController::WorkspaceController(StandardApp_Module* salomeModule) +WorkspaceController::WorkspaceController(MEDModule* salomeModule) : TreeGuiManager(salomeModule->getApp(), "Workspace") { _salomeModule = salomeModule; @@ -67,8 +67,8 @@ WorkspaceController::WorkspaceController(MEDModule * salomeModule) // with other parts of the application, in particular the python // console that could retrieve this IOR using the // getEventListenerIOR() function of the MEDDataManager. - SalomeApp_Application * salomeApp = salomeModule->getApp(); - const char * medEventListenerIOR = + SalomeApp_Application* salomeApp = salomeModule->getApp(); + const char* medEventListenerIOR = salomeApp->orb()->object_to_string(medEventListenerServant); MEDFactoryClient::getDataManager()->setEventListenerIOR(medEventListenerIOR); @@ -178,7 +178,7 @@ void WorkspaceController::_importItemList(QStringList itemNameIdList) { * console (see _importItemList). */ void WorkspaceController::_importItem(QString itemNameId) { - XmedDataModel * dataModel = (XmedDataModel *)this->getDataModel(); + XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel(); if ( dataModel == NULL ) { LOG("No data model associated to this tree view"); return; @@ -186,8 +186,8 @@ void WorkspaceController::_importItem(QString itemNameId) { // We can request the dataModel to obtain the dataObject associated // to this item (iteNameId is a TreeView id, Qt stuff only). - XmedDataObject * dataObject = - (XmedDataObject *)dataModel->getDataObject(QS2S(itemNameId)); + XmedDataObject* dataObject = + (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId)); if ( dataObject == NULL ) { LOG("WorkspaceController: WARN! No data object associated to the item "<getFieldHandler(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); STDLOG("Field: mesh="<meshname<<" name="<fieldname); // Finally, we can import the field @@ -211,14 +211,14 @@ void WorkspaceController::_importItem(QString itemNameId) { * options or simply specify the alias (i.e. the name of the python * variable). */ -void WorkspaceController::_importFieldIntoConsole(MEDCALC::FieldHandler * fieldHandler, +void WorkspaceController::_importFieldIntoConsole(MEDCALC::FieldHandler* fieldHandler, bool askForOptions, - const char * alias) + const char* alias) { STDLOG("alias="<fieldname); } @@ -260,11 +260,11 @@ void WorkspaceController::_importFieldIntoConsole(MEDCALC::FieldHandler * fieldH * emitted from the MEDEventListener. It processes events coming from * the python console. */ -void WorkspaceController::processMedEvent(const MEDCALC::MedEvent * event) { +void WorkspaceController::processMedEvent(const MEDCALC::MedEvent* event) { STDLOG("WorkspaceController::processMedEvent"); STDLOG("dataId :"<dataId); - XmedDataModel * dataModel = (XmedDataModel *)this->getDataModel(); + XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel(); if ( dataModel == NULL ) { STDLOG("No data model associated to this tree view"); return; @@ -275,16 +275,16 @@ void WorkspaceController::processMedEvent(const MEDCALC::MedEvent * event) { } else if ( event->type == MEDCALC::EVENT_PUT_IN_WORKSPACE ) { STDLOG("add new field"); - MEDCALC::FieldHandler * fieldHandler = + MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(event->dataId); - XmedDataObject * dataObject = (XmedDataObject *)dataModel->newDataObject(); + XmedDataObject* dataObject = (XmedDataObject*)dataModel->newDataObject(); dataObject->setFieldHandler(*fieldHandler); this->getDataTreeModel()->addData(dataObject); } else if ( event->type == MEDCALC::EVENT_REMOVE_FROM_WORKSPACE ) { STDLOG("remove field"); - std::map::iterator itr = dataModel->begin(); + std::map::iterator itr = dataModel->begin(); for ( ; itr != dataModel->end(); ++itr) { XmedDataObject* obj = dynamic_cast(itr->second); if (obj->getFieldHandler()->id == event->dataId) { @@ -297,7 +297,7 @@ void WorkspaceController::processMedEvent(const MEDCALC::MedEvent * event) { } else if ( event->type == MEDCALC::EVENT_CLEAN_WORKSPACE ) { STDLOG("clean workspace"); - std::map::iterator itr = dataModel->begin(); + std::map::iterator itr = dataModel->begin(); for ( ; itr != dataModel->end(); ++itr) { XmedDataObject* obj = dynamic_cast(itr->second); std::string itemNameId = obj->getNameId(); @@ -319,7 +319,7 @@ void WorkspaceController::processMedEvent(const MEDCALC::MedEvent * event) { * name is requested to the user using a file chooser dialog box */ void WorkspaceController::_saveItemList(QStringList itemNameIdList) { - XmedDataProcessor * dataProcessor = new XmedDataProcessor(this->getDataModel()); + XmedDataProcessor* dataProcessor = new XmedDataProcessor(this->getDataModel()); dataProcessor->process(itemNameIdList); MEDCALC::FieldIdList_var fieldIdList = dataProcessor->getResultingFieldIdList(); delete dataProcessor; @@ -341,7 +341,7 @@ void WorkspaceController::_saveItemList(QStringList itemNameIdList) { * This function remove the selected item from workspace. */ void WorkspaceController::_removeItemList(QStringList itemNameIdList) { - XmedDataModel * dataModel = (XmedDataModel *)this->getDataModel(); + XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel(); if ( dataModel == NULL ) { LOG("No data model associated to this tree view"); return; @@ -352,8 +352,8 @@ void WorkspaceController::_removeItemList(QStringList itemNameIdList) { // We can request the dataModel to obtain the dataObject associated // to this item (iteNameId is a TreeView id, Qt stuff only). - XmedDataObject * dataObject = - (XmedDataObject *)dataModel->getDataObject(QS2S(itemNameId)); + XmedDataObject* dataObject = + (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId)); if ( dataObject == NULL ) { LOG("WorkspaceController: WARN! No data object associated to the item "<getFieldHandler(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); STDLOG("Field: mesh="<meshname<<" name="<fieldname); // Remove the field variable from console @@ -382,7 +382,7 @@ void WorkspaceController::_removeItemList(QStringList itemNameIdList) { * scalar map of the first item to start the job. */ void WorkspaceController::_exportItemList(QStringList itemNameIdList) { - XmedDataProcessor * dataProcessor = new XmedDataProcessor(this->getDataModel()); + XmedDataProcessor* dataProcessor = new XmedDataProcessor(this->getDataModel()); dataProcessor->process(itemNameIdList); MEDCALC::FieldIdList_var fieldIdList = dataProcessor->getResultingFieldIdList(); delete dataProcessor; @@ -390,24 +390,24 @@ void WorkspaceController::_exportItemList(QStringList itemNameIdList) { // _GBO_ We use a temporary file to proceed with this export to // paravis. I'm sure it could be better in a futur version or when I // will get a better understanding of paravis API. - const char * tmpfilename = "/tmp/medcalc_export2paravis.med"; + const char* tmpfilename = "/tmp/medcalc_export2paravis.med"; MEDFactoryClient::getDataManager()->saveFields(tmpfilename, fieldIdList); // We import the whole file but create a scalar map for the first // selected field only (it's just an export to continue the job in // paravis) - XmedDataModel * dataModel = (XmedDataModel *)this->getDataModel(); + XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel(); if ( dataModel == NULL ) { STDLOG("No data model associated to this tree view"); return; } QString itemNameId = itemNameIdList[0]; - XmedDataObject * dataObject = (XmedDataObject *)dataModel->getDataObject(QS2S(itemNameId)); + XmedDataObject* dataObject = (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId)); if ( dataObject == NULL ) { LOG("WorkspaceController: WARN! No data object associated to the item "<getFieldHandler(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); QStringList commands; /* commands+=QString("from xmed.driver_pvis import pvis_scalarmap"); @@ -434,7 +434,7 @@ void WorkspaceController::_viewItemList(QStringList itemNameIdList) { // __GBO__: In this version, we consider only the first field in the selection QString itemNameId = itemNameIdList[0]; - XmedDataModel * dataModel = (XmedDataModel *)this->getDataModel(); + XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel(); if ( dataModel == NULL ) { LOG("No data model associated to this tree view"); return; @@ -442,8 +442,8 @@ void WorkspaceController::_viewItemList(QStringList itemNameIdList) { // We can request the dataModel to obtain the dataObject associated // to this item (iteNameId is a TreeView id, Qt stuff only). - XmedDataObject * dataObject = - (XmedDataObject *)dataModel->getDataObject(QS2S(itemNameId)); + XmedDataObject* dataObject = + (XmedDataObject*)dataModel->getDataObject(QS2S(itemNameId)); if ( dataObject == NULL ) { LOG("WorkspaceController: WARN! No data object associated to the item "<getFieldHandler(); + MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); // And finally, we can create the set of medcalc instructions to // generate the scalar map on this field. @@ -477,8 +477,8 @@ WorkspaceController::_getViewMode() { * DatasourceController. The connection between the datasource signal * and this slot is realized by the main class MEDModule. */ -void WorkspaceController::processDatasourceEvent(const DatasourceEvent * event) { - XmedDataModel * dataModel = (XmedDataModel *)this->getDataModel(); +void WorkspaceController::processDatasourceEvent(const DatasourceEvent* event) { + XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel(); if ( dataModel == NULL ) { STDLOG("No data model associated to this tree view"); return; @@ -491,7 +491,7 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent * event) // options such that "change the underlying mesh". // <<< - XmedDataObject * dataObject = event->objectdata; + XmedDataObject* dataObject = event->objectdata; if ( event->eventtype == DatasourceEvent::EVENT_IMPORT_OBJECT ) { std::cout << "IMPORT object in workspace: " << dataObject->toString() << std::endl; @@ -516,62 +516,86 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent * event) askForOptions, QCHARSTAR(event->objectalias)); } - else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { + else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) { + QStringList commands; + commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias); + _consoleDriver->exec(commands); + } + else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) { + QStringList commands; + commands += QString("medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias); + _consoleDriver->exec(commands); + } + else { + STDLOG("The event "<eventtype<<" is not implemented yet"); + } +} +/** + * This slot can process the event coming from the + * DatasourceController. The connection between the datasource signal + * and this slot is realized by the main class MEDModule. + */ +void WorkspaceController::processPresentationEvent(const PresentationEvent* event) { + XmedDataModel* dataModel = (XmedDataModel*)this->getDataModel(); + if ( dataModel == NULL ) { + STDLOG("No data model associated to this tree view"); + return; + } + + // >>> + // __GBO__ To know what to do we should test the type, because the + // object could be a mesh, a timeseries or a single field. We test + // here the case of a single field. Moreover, there could have + // options such that "change the underlying mesh". + // <<< + + XmedDataObject* dataObject = event->objectdata; + + if ( event->eventtype == PresentationEvent::EVENT_VIEW_OBJECT_SCALAR_MAP ) { QString viewMode = _getViewMode(); MEDCALC::FieldHandler* fieldHandler = dataObject->getFieldHandler(); QStringList commands; commands += QString("medcalc.MakeScalarMap(accessField(%1), %2)").arg(fieldHandler->id).arg(viewMode); _consoleDriver->exec(commands); } - else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_CONTOUR ) { + 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); _consoleDriver->exec(commands); } - else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_VECTOR_FIELD ) { + 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); _consoleDriver->exec(commands); } - else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_SLICES ) { + 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); _consoleDriver->exec(commands); } - else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_DEFLECTION_SHAPE ) { + 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); _consoleDriver->exec(commands); } - else if ( event->eventtype == DatasourceEvent::EVENT_VIEW_OBJECT_POINT_SPRITE ) { + 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); _consoleDriver->exec(commands); } - else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) { - QStringList commands; - commands += QString("medcalc.LoadDataSource('%1')").arg(event->objectalias); - _consoleDriver->exec(commands); - } - else if ( event->eventtype == DatasourceEvent::EVENT_ADD_IMAGE_AS_DATASOURCE ) { - QStringList commands; - commands += QString("medcalc.LoadImageAsDataSource('%1')").arg(event->objectalias); - _consoleDriver->exec(commands); - } else { STDLOG("The event "<eventtype<<" is not implemented yet"); } - } void WorkspaceController::OnSaveWorkspace() { diff --git a/src/MEDCalc/gui/WorkspaceController.hxx b/src/MEDCalc/gui/WorkspaceController.hxx index 969fab86a..876ae6eab 100644 --- a/src/MEDCalc/gui/WorkspaceController.hxx +++ b/src/MEDCalc/gui/WorkspaceController.hxx @@ -26,6 +26,7 @@ #include "MEDEventListener_i.hxx" #include "XmedConsoleDriver.hxx" #include "DatasourceController.hxx" +#include "PresentationController.hxx" #include "MEDCALCGUI.hxx" #include @@ -46,7 +47,7 @@ class MEDCALCGUI_EXPORT WorkspaceController: public TreeGuiManager { Q_OBJECT public: - WorkspaceController(MEDModule * salomeModule); + WorkspaceController(MEDModule* salomeModule); ~WorkspaceController(); void createActions(); @@ -56,20 +57,21 @@ public slots: void processItemList(QStringList itemNameIdList, int actionId); // Internal slots - void processMedEvent(const MEDCALC::MedEvent * event); - void processDatasourceEvent(const DatasourceEvent * event); + void processMedEvent(const MEDCALC::MedEvent* event); + void processDatasourceEvent(const DatasourceEvent* event); + void processPresentationEvent(const PresentationEvent* event); void OnSaveWorkspace(); void OnCleanWorkspace(); signals: - void workspaceSignal(const MEDCALC::MedEvent * event); + void workspaceSignal(const MEDCALC::MedEvent* event); private: void _importItem(QString itemNameId); void _importItemList(QStringList itemNameIdList); - void _importFieldIntoConsole(MEDCALC::FieldHandler * fieldHandler, + void _importFieldIntoConsole(MEDCALC::FieldHandler* fieldHandler, bool askForOptions, - const char * alias=NULL); + const char* alias=NULL); void _exportItemList(QStringList itemNameIdList); void _saveItemList(QStringList itemNameIdList); @@ -78,9 +80,9 @@ private: QString _getViewMode(); private: - XmedConsoleDriver * _consoleDriver; - MEDModule * _salomeModule; - MEDEventListener_i * _medEventListener; + XmedConsoleDriver* _consoleDriver; + MEDModule* _salomeModule; + MEDEventListener_i* _medEventListener; // This structure is intended to memorized in a bundle the whole set // of integers identifying the actions of the popup menu associated diff --git a/src/MEDCalc/res/CMakeLists.txt b/src/MEDCalc/res/CMakeLists.txt index fb78aa13c..c46ae2bbb 100644 --- a/src/MEDCalc/res/CMakeLists.txt +++ b/src/MEDCalc/res/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2015 CEA/DEN, EDF R&D +# Copyright (C) 2007-2016 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -18,6 +18,7 @@ # ADD_SUBDIRECTORY(testfiles) +ADD_SUBDIRECTORY(presentations) SET(MED_RESOURCES_FILES datasource_add.png diff --git a/src/MEDCalc/res/presentations/CMakeLists.txt b/src/MEDCalc/res/presentations/CMakeLists.txt new file mode 100644 index 000000000..b5ca40881 --- /dev/null +++ b/src/MEDCalc/res/presentations/CMakeLists.txt @@ -0,0 +1,34 @@ +# Copyright (C) 2016 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +SET(MED_RESOURCES_FILES + pqGlyph16.png + pqGlyph24.png + pqIsosurface16.png + pqIsosurface24.png + pqNodeMapData16.png + pqNodeMapData24.png + pqSlice16.png + pqSlice24.png + pqWarp16.png + pqWarp24.png + scalarmap16.png + scalarmap24.png + ) +INSTALL(FILES ${MED_RESOURCES_FILES} DESTINATION ${SALOME_MED_INSTALL_RES_DATA}) diff --git a/src/MEDCalc/res/presentations/pqGlyph16.png b/src/MEDCalc/res/presentations/pqGlyph16.png new file mode 100644 index 000000000..ff441b0a4 Binary files /dev/null and b/src/MEDCalc/res/presentations/pqGlyph16.png differ diff --git a/src/MEDCalc/res/presentations/pqGlyph24.png b/src/MEDCalc/res/presentations/pqGlyph24.png new file mode 100644 index 000000000..68e6766d5 Binary files /dev/null and b/src/MEDCalc/res/presentations/pqGlyph24.png differ diff --git a/src/MEDCalc/res/presentations/pqIsosurface16.png b/src/MEDCalc/res/presentations/pqIsosurface16.png new file mode 100644 index 000000000..40b7908ef Binary files /dev/null and b/src/MEDCalc/res/presentations/pqIsosurface16.png differ diff --git a/src/MEDCalc/res/presentations/pqIsosurface24.png b/src/MEDCalc/res/presentations/pqIsosurface24.png new file mode 100644 index 000000000..825222cf6 Binary files /dev/null and b/src/MEDCalc/res/presentations/pqIsosurface24.png differ diff --git a/src/MEDCalc/res/presentations/pqNodeMapData16.png b/src/MEDCalc/res/presentations/pqNodeMapData16.png new file mode 100644 index 000000000..4cb32e427 Binary files /dev/null and b/src/MEDCalc/res/presentations/pqNodeMapData16.png differ diff --git a/src/MEDCalc/res/presentations/pqNodeMapData24.png b/src/MEDCalc/res/presentations/pqNodeMapData24.png new file mode 100644 index 000000000..3b797831c Binary files /dev/null and b/src/MEDCalc/res/presentations/pqNodeMapData24.png differ diff --git a/src/MEDCalc/res/presentations/pqSlice16.png b/src/MEDCalc/res/presentations/pqSlice16.png new file mode 100644 index 000000000..5b1f1cc65 Binary files /dev/null and b/src/MEDCalc/res/presentations/pqSlice16.png differ diff --git a/src/MEDCalc/res/presentations/pqSlice24.png b/src/MEDCalc/res/presentations/pqSlice24.png new file mode 100644 index 000000000..070ce3bda Binary files /dev/null and b/src/MEDCalc/res/presentations/pqSlice24.png differ diff --git a/src/MEDCalc/res/presentations/pqWarp16.png b/src/MEDCalc/res/presentations/pqWarp16.png new file mode 100644 index 000000000..b27599a22 Binary files /dev/null and b/src/MEDCalc/res/presentations/pqWarp16.png differ diff --git a/src/MEDCalc/res/presentations/pqWarp24.png b/src/MEDCalc/res/presentations/pqWarp24.png new file mode 100644 index 000000000..b7227d48c Binary files /dev/null and b/src/MEDCalc/res/presentations/pqWarp24.png differ diff --git a/src/MEDCalc/res/presentations/scalarmap16.png b/src/MEDCalc/res/presentations/scalarmap16.png new file mode 100644 index 000000000..aa7d554ac Binary files /dev/null and b/src/MEDCalc/res/presentations/scalarmap16.png differ diff --git a/src/MEDCalc/res/presentations/scalarmap24.png b/src/MEDCalc/res/presentations/scalarmap24.png new file mode 100644 index 000000000..7132ece51 Binary files /dev/null and b/src/MEDCalc/res/presentations/scalarmap24.png differ