SET(SalomeIDLMED_IDLSOURCES
MED_Gen.idl
+ MEDCommandsHistoryManager.idl
MEDCouplingCorbaServant.idl
ParaMEDCouplingCorbaServant.idl
MEDDataManager.idl
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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
+//
+
+#ifndef __MED_COMMANDS_HISTORY_MANAGER_IDL_
+#define __MED_COMMANDS_HISTORY_MANAGER_IDL_
+
+#include "SALOME_GenericObj.idl"
+
+module MEDCALC
+{
+
+ typedef sequence<string> CommandsList;
+
+ interface MEDCommandsHistoryManager : SALOME::GenericObj
+ {
+
+ void addCommand(in string command);
+ CommandsList getCommandsHistory();
+ void clearHistory();
+
+ };
+
+};
+
+#endif
#include "MEDDataManager.idl"
#include "MEDCalculator.idl"
#include "MEDPresentationManager.idl"
+#include "MEDCommandsHistoryManager.idl"
/*!
* This module contains the interface required for starting with MED
MEDCALC::MEDDataManager getDataManager();
MEDCALC::MEDCalculator getCalculator();
MEDCALC::MEDPresentationManager getPresentationManager();
+ MEDCALC::MEDCommandsHistoryManager getCommandsHistoryManager();
};
};
)
SET(COMMON_SOURCES
+ MEDCommandsHistoryManager_i.cxx
MEDFactoryClient.cxx
MEDDataManager_i.cxx
MEDCalculator_i.cxx
// nothing to do
}
+// Duplicate gui/DatasourceConstants
+#define OBJECT_ID "objectid"
+#define OBJECT_IS_IN_WORKSPACE "isInWorkspace"
+
// Duplicate gui/XmedDataModel
static const int NB_TYPE_OF_FIELDS = 4;
static const char* mapTypeOfFieldLabel[NB_TYPE_OF_FIELDS] =
soDatasource->SetAttrString("AttributePixMap", "ICO_DATASOURCE");
anAttr = studyBuilder->FindOrCreateAttribute(soDatasource, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetInt("objectid", datasourceHandler.id);
+ aParam->SetInt(OBJECT_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("objectid", meshHandler.id);
+ aParam->SetInt(OBJECT_ID, meshHandler.id);
anAttr = studyBuilder->FindOrCreateAttribute(soMesh, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetBool("isInWorkspace", false);
+ aParam->SetBool(OBJECT_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("objectid", fieldseriesHandler.id);
+ aParam->SetInt(OBJECT_ID, fieldseriesHandler.id);
anAttr = studyBuilder->FindOrCreateAttribute(soFieldseries, "AttributeParameter");
aParam = SALOMEDS::AttributeParameter::_narrow(anAttr);
- aParam->SetBool("isInWorkspace", false);
+ aParam->SetBool(OBJECT_IS_IN_WORKSPACE, false);
useCaseBuilder->AppendTo(soFieldseries->GetFather(), soFieldseries);
soFieldseries->UnRegister();
return MED_ORB::OP_ERROR ;
}
std::string entry = _fieldSeriesEntries[fieldId];
- //SALOMEDS::SObject_ptr soFieldseries = _studyEditor->findObject(entry.c_str());
SALOMEDS::SObject_var sobject = study->FindObjectID(entry.c_str());
SALOMEDS::SObject_ptr soFieldseries = sobject._retn();
return MED_ORB::OP_ERROR;
}
- //SALOMEDS::SObject_var soPresentation = _studyEditor->newObject(soFieldseries);
SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder();
SALOMEDS::SObject_var soPresentation = studyBuilder->NewObject(soFieldseries);
- //_studyEditor->setName(soPresentation, tr(name.c_str()).toStdString().c_str());
- //_studyEditor->setIcon(soPresentation, tr("ICO_MED_PRESENTATION").toStdString().c_str());
soPresentation->SetAttrString("AttributeName", name);
soPresentation->SetAttrString("AttributePixMap", label);
TCollection_AsciiString aScript;
- aScript += "dumping MED";
+ MEDCALC::CommandsList* history = MEDFactoryClient::getCommandsHistoryManager()->getCommandsHistory();
+ for (CORBA::ULong i = 0; i < history->length(); ++i) {
+ aScript += (*history)[i];
+ aScript += "\n";
+ }
int aLen = aScript.Length();
unsigned char* aBuffer = new unsigned char[aLen+1];
\param interfaceName SALOME component interface name
\return CORBA object identifier of the registered servant
*/
- //PortableServer::ObjectId* MEDEngine_factory( CORBA::ORB_ptr orb,
PortableServer::ObjectId* MEDEngine_factory(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId* contId,
--- /dev/null
+// Copyright (C) 2015 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
+//
+
+#include "MEDCommandsHistoryManager_i.hxx"
+
+MEDCommandsHistoryManager_i* MEDCommandsHistoryManager_i::_instance = NULL;
+
+MEDCommandsHistoryManager_i*
+MEDCommandsHistoryManager_i::getInstance()
+{
+ if (_instance == NULL)
+ _instance = new MEDCommandsHistoryManager_i();
+ return _instance;
+}
+
+MEDCommandsHistoryManager_i::MEDCommandsHistoryManager_i()
+ : _history(0)
+{
+ _history = new MEDCALC::CommandsList;
+}
+
+MEDCommandsHistoryManager_i::~MEDCommandsHistoryManager_i()
+{
+ for (CORBA::ULong i = 0; i < _history->length(); ++i) {
+ CORBA::string_free((*_history)[i]);
+ }
+ delete _history;
+}
+
+void
+MEDCommandsHistoryManager_i::addCommand(const char* command)
+{
+ CORBA::ULong size = _history->length();
+ _history->length(size+1);
+ (*_history)[size] = CORBA::string_dup(command);
+}
+
+MEDCALC::CommandsList*
+MEDCommandsHistoryManager_i::getCommandsHistory()
+{
+ return _history;
+}
+
+void
+MEDCommandsHistoryManager_i::clearHistory()
+{
+ _history->length(0);
+}
--- /dev/null
+// Copyright (C) 2015 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
+//
+
+#ifndef MED_COMMANDS_HISTORY_MANAGER_I_HXX
+#define MED_COMMANDS_HISTORY_MANAGER_I_HXX
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(MEDCommandsHistoryManager)
+#include "SALOME_GenericObj_i.hh"
+
+#include "MEDCALC.hxx"
+
+class MEDCALC_EXPORT MEDCommandsHistoryManager_i
+ : public POA_MEDCALC::MEDCommandsHistoryManager,
+ public SALOME::GenericObj_i
+{
+ public:
+ static MEDCommandsHistoryManager_i* getInstance();
+
+ void addCommand(const char* command);
+ MEDCALC::CommandsList* getCommandsHistory();
+ void clearHistory();
+
+ private:
+ MEDCommandsHistoryManager_i();
+ virtual ~MEDCommandsHistoryManager_i();
+
+ private:
+ static MEDCommandsHistoryManager_i* _instance;
+ MEDCALC::CommandsList* _history;
+};
+
+#endif
return presentationManager;
}
+ /*!
+ * This returns a singleton (static) instance of the MED commands history.
+ */
+ MEDCALC::MEDCommandsHistoryManager_ptr getCommandsHistoryManager() {
+ static MEDCALC::MEDCommandsHistoryManager_ptr commandsHistoryManager;
+ if(CORBA::is_nil(commandsHistoryManager)){
+ commandsHistoryManager = getFactory()->getCommandsHistoryManager();
+ }
+ return commandsHistoryManager;
+ }
+
}
#include CORBA_CLIENT_HEADER(MEDFactory)
#include CORBA_CLIENT_HEADER(MEDDataManager)
#include CORBA_CLIENT_HEADER(MEDCalculator)
+#include CORBA_CLIENT_HEADER(MEDPresentationManager)
+#include CORBA_CLIENT_HEADER(MEDCommandsHistoryManager)
#include "MEDCALC.hxx"
MEDCALC_EXPORT MEDCALC::MEDDataManager_ptr getDataManager();
MEDCALC_EXPORT MEDCALC::MEDCalculator_ptr getCalculator();
MEDCALC_EXPORT MEDCALC::MEDPresentationManager_ptr getPresentationManager();
+ MEDCALC_EXPORT MEDCALC::MEDCommandsHistoryManager_ptr getCommandsHistoryManager();
}
#endif // _MEDFACTORY_CLIENT_HXX_
#include "MEDFactory_i.hxx"
#include "utilities.h"
-#include <string>
-
#include "MEDDataManager_i.hxx"
#include "MEDCalculator_i.hxx"
#include "MEDPresentationManager_i.hxx"
-
-using namespace std;
+#include "MEDCommandsHistoryManager_i.hxx"
//=============================================================================
/*!
//=============================================================================
MEDFactory_i::MEDFactory_i(CORBA::ORB_ptr orb,
- PortableServer::POA_ptr poa,
- PortableServer::ObjectId * contId,
- const char *instanceName,
- const char *interfaceName) :
- Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId* contId,
+ const char* instanceName,
+ const char* interfaceName)
+ : Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
{
MESSAGE("activate object");
_thisObj = this ;
MEDFactory_i::~MEDFactory_i()
{
+ // nothing to do
}
-MEDCALC::MEDDataManager_ptr MEDFactory_i::getDataManager() {
- MEDDataManager_i * medDataManager = MEDDataManager_i::getInstance();
+MEDCALC::MEDDataManager_ptr
+MEDFactory_i::getDataManager()
+{
+ MEDDataManager_i* medDataManager = MEDDataManager_i::getInstance();
MEDCALC::MEDDataManager_ptr medDataManagerPtr = medDataManager->_this();
return medDataManagerPtr;
}
-MEDCALC::MEDCalculator_ptr MEDFactory_i::getCalculator() {
- MEDCalculator_i * medCalculator = MEDCalculator_i::getInstance();
+MEDCALC::MEDCalculator_ptr
+MEDFactory_i::getCalculator()
+{
+ MEDCalculator_i* medCalculator = MEDCalculator_i::getInstance();
MEDCALC::MEDCalculator_ptr medCalculatorPtr = medCalculator->_this();
return medCalculatorPtr;
}
-MEDCALC::MEDPresentationManager_ptr MEDFactory_i::getPresentationManager() {
- MEDPresentationManager_i * manager = MEDPresentationManager_i::getInstance();
+MEDCALC::MEDPresentationManager_ptr
+MEDFactory_i::getPresentationManager()
+{
+ MEDPresentationManager_i* manager = MEDPresentationManager_i::getInstance();
MEDCALC::MEDPresentationManager_ptr managerPtr = manager->_this();
return managerPtr;
}
+MEDCALC::MEDCommandsHistoryManager_ptr
+MEDFactory_i::getCommandsHistoryManager()
+{
+ MEDCommandsHistoryManager_i* manager = MEDCommandsHistoryManager_i::getInstance();
+ MEDCALC::MEDCommandsHistoryManager_ptr managerPtr = manager->_this();
+ return managerPtr;
+}
+
extern "C"
{
- PortableServer::ObjectId * MEDFactoryEngine_factory(
+ PortableServer::ObjectId* MEDFactoryEngine_factory(
CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
- PortableServer::ObjectId * contId,
- const char *instanceName,
- const char *interfaceName)
+ PortableServer::ObjectId* contId,
+ const char* instanceName,
+ const char* interfaceName)
{
MESSAGE("PortableServer::ObjectId * MEDEngine_factory()");
SCRUTE(interfaceName);
- MEDFactory_i * factory = new MEDFactory_i(orb, poa, contId,
- instanceName,
- interfaceName);
+ MEDFactory_i* factory = new MEDFactory_i(orb, poa, contId,
+ instanceName,
+ interfaceName);
return factory->getId() ;
}
}
#include CORBA_SERVER_HEADER(MEDDataManager)
#include CORBA_SERVER_HEADER(MEDCalculator)
#include CORBA_SERVER_HEADER(MEDPresentationManager)
+#include CORBA_SERVER_HEADER(MEDCommandsHistoryManager)
#include "SALOME_Component_i.hxx"
#include "MEDCALC.hxx"
{
public:
+
MEDFactory_i(CORBA::ORB_ptr orb,
PortableServer::POA_ptr poa,
PortableServer::ObjectId * contId,
MEDCALC::MEDDataManager_ptr getDataManager();
/*! Returns the singleton instance of the calculator */
MEDCALC::MEDCalculator_ptr getCalculator();
- /*! Returns the singleton instance of the prsentation manager */
+ /*! Returns the singleton instance of the presentation manager */
MEDCALC::MEDPresentationManager_ptr getPresentationManager();
-
+ /*! Returns the singleton instance of the commands history manager */
+ MEDCALC::MEDCommandsHistoryManager_ptr getCommandsHistoryManager();
};
extern "C"
#include "MEDEventListener_i.hxx"
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(MEDDataManager)
-//#include <StandardApp_Module.hxx>
+
#include <SalomeApp_Module.h>
#include <SALOME_AppStudyEditor.hxx>
#include <MEDPresentation.hxx>
Q_OBJECT
public:
- //DatasourceController(StandardApp_Module * salomeModule);
- //DatasourceController(SalomeApp_Module * salomeModule);
DatasourceController(MEDModule * salomeModule);
~DatasourceController();
void updateTreeViewWithNewPresentation(long fieldId, long presentationId);
private:
- //StandardApp_Module * _salomeModule;
MEDModule* _salomeModule;
SALOME_AppStudyEditor * _studyEditor;
// Initialize the python console. Note that this must be done at
// last because the setup will try to initiate a connection to the
// event listener.
- _consoleDriver = new XmedConsoleDriver(salomeApp);
+ _consoleDriver = new XmedConsoleDriver(salomeModule);
_consoleDriver->setup();
}
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(MEDDataManager)
-//#include <StandardApp_Module.hxx>
#include <SalomeApp_Module.h>
#include <vector>
Q_OBJECT
public:
- //WorkspaceController(StandardApp_Module * salomeModule);
WorkspaceController(MEDModule * salomeModule);
~WorkspaceController();
void workspaceSignal(const MEDCALC::MedEvent * event);
private:
- XmedConsoleDriver * _consoleDriver;
- //StandardApp_Module * _salomeModule;
- MEDModule * _salomeModule;
void _importItem(QString itemNameId);
void _importItemList(QStringList itemNameIdList);
void _importFieldIntoConsole(MEDCALC::FieldHandler * fieldHandler,
- bool askForOptions,
- const char * alias=NULL);
+ bool askForOptions,
+ const char * alias=NULL);
void _exportItemList(QStringList itemNameIdList);
void _saveItemList(QStringList itemNameIdList);
void _removeItemList(QStringList itemNameIdList);
void _viewItemList(QStringList itemNameIdList);
+private:
+ XmedConsoleDriver * _consoleDriver;
+ MEDModule * _salomeModule;
MEDEventListener_i * _medEventListener;
// This structure is intended to memorized in a bundle the whole set
#include "XmedConsoleDriver.hxx"
#include "Utils_SALOME_Exception.hxx"
+#include "MEDModule.hxx"
+#include "MEDCommandsHistoryManager_i.hxx"
+#include "MEDFactoryClient.hxx"
+#include CORBA_CLIENT_HEADER(MED_Gen)
+#include CORBA_CLIENT_HEADER(MEDCommandsHistoryManager)
-XmedConsoleDriver::XmedConsoleDriver(SalomeApp_Application * application) {
-
+XmedConsoleDriver::XmedConsoleDriver(MEDModule* salomeModule)
+{
+ _salomeModule = salomeModule;
bool forcePythonConsole = true;
- _pyConsole = application->pythonConsole(forcePythonConsole);
+ _pyConsole = _salomeModule->getApp()->pythonConsole(forcePythonConsole);
if ( !_pyConsole ) {
const char * msg = "The python console can't be obtained from the SALOME application";
throw SALOME_Exception(msg);
if ( !_importXmedDone ) {
QStringList commands;
- /*
- // First import xmed to initialize the main objects, in particular
- // the corba pointer to the event listener.
- commands+="import xmed";
- // Set the globals dictionnary so that the fields tools work properly.
- commands+="xmed.setConsoleGlobals(globals())";
- // Import the tools required for field operations
- commands+="from xmed import load, get, put, dup, ls, la, save, view, doc, wipe, remove, clean";
- // A last one to clear the console screen
- //commands+="wipe";
- */
#ifndef DISABLE_PVVIEWER
// start PVServer and show render view
commands+="import pvsimple as pvs";
* This function sends the specified list of commands to the console.
*/
void XmedConsoleDriver::exec(const QStringList& commands) {
+ MEDCALC::MEDCommandsHistoryManager_ptr history = MEDFactoryClient::getCommandsHistoryManager();
+
QStringListIterator it(commands);
+ int i = 0;
while (it.hasNext()) {
- _pyConsole->exec(it.next());
+ const QString& command = it.next();
+ _pyConsole->exec(command);
+ // store command in history
+ history->addCommand(command.toStdString().c_str());
}
- this->_history.append(commands);
}
#ifndef XMEDCONSOLEDRIVER_HXX
#define XMEDCONSOLEDRIVER_HXX
-#include <SalomeApp_Application.h>
+#include "MEDCALCGUI.hxx"
+
#include <PyConsole_Console.h>
#include <QStringList>
-#include "MEDCALCGUI.hxx"
-
-typedef QList<QStringList> CommandsHistory;
+class MEDModule;
class MEDCALCGUI_EXPORT XmedConsoleDriver {
public:
- XmedConsoleDriver(SalomeApp_Application * application);
+ XmedConsoleDriver(MEDModule* salomeModule);
void setup();
void exec(const QStringList& commands);
- inline const CommandsHistory& getHistory() { return _history; }
-
private:
+ MEDModule* _salomeModule;
PyConsole_Console * _pyConsole;
bool _importXmedDone;
- CommandsHistory _history;
};
#endif //XMEDCONSOLEDRIVER_HXX