1 // Copyright (C) 2010-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Adrien Bruneton (CEA)
23 #include "PVGUI_DataModel.h"
24 #include "PVGUI_Module.h"
27 #include <LightApp_Study.h>
28 #include <CAM_DataObject.h>
32 #include <QTextStream>
34 PVGUI_DataModel::PVGUI_DataModel( PVGUI_Module* theModule ):
35 LightApp_DataModel(theModule)
38 PVGUI_DataModel::~PVGUI_DataModel()
41 bool PVGUI_DataModel::dumpPython( const QString& path, CAM_Study* std,
42 bool isMultiFile, QStringList& listOfFiles)
45 LightApp_Study* study = dynamic_cast<LightApp_Study*>( std );
49 std::string aTmpDir = study->GetTmpDir( path.toLatin1().constData(), isMultiFile );
50 std::string aFile = aTmpDir + "paravis_dump.tmp";
52 listOfFiles.append(aTmpDir.c_str());
53 listOfFiles.append("paravis_dump.tmp");
55 QFile file(aFile.c_str());
56 if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
59 PVGUI_Module * mod = (PVGUI_Module *) getModule();
60 QString trace(mod->getTraceString());
65 abuffer.push_back(QString("def RebuildData( theStudy ):"));
66 QStringList lst(trace.split("\n"));
67 foreach(QString elem, lst)
69 QString s = " " + elem;
72 abuffer.push_back(QString(" pass"));
73 trace = abuffer.join("\n");
75 QTextStream out(&file);
76 out << trace.toStdString().c_str() << "\n";
83 /*-----------------------------------------------------------------------------------------*/
84 bool PVGUI_DataModel::open( const QString& theName, CAM_Study* theStudy, QStringList theList) {
85 bool res = LightApp_DataModel::open(theName, theStudy, theList);
86 publishComponent(theStudy);
90 /*-----------------------------------------------------------------------------------------*/
91 bool PVGUI_DataModel::create( CAM_Study* theStudy) {
92 bool res = LightApp_DataModel::create(theStudy);
93 publishComponent(theStudy);
96 /*-----------------------------------------------------------------------------------------*/
97 void PVGUI_DataModel::publishComponent( CAM_Study* theStudy ) {
98 LightApp_Study* study = dynamic_cast<LightApp_Study*>( theStudy );
99 CAM_ModuleObject *aModelRoot = dynamic_cast<CAM_ModuleObject*>( root());
100 if( study && aModelRoot == NULL ) {
101 aModelRoot = createModuleObject( theStudy->root() );
102 aModelRoot->setDataModel( this );