+/*! Dump the data model in the python script. */
+bool ATOMICGUI_DataModel::dumpPython( const QString& theURL,
+ CAM_Study* theStudy,
+ bool isMultiFile,
+ QStringList& theListOfFiles ) {
+ QString aScript = "from AtomicPy import *\n";
+ QString aPrefix = "";
+ if(isMultiFile) {
+ aScript += "def RebuildData(theStudy):\n";
+ aPrefix = " ";
+ }
+
+ for ( int i = 0; i < myMolecules.count(); i++ ) {
+ aScript += aPrefix + QString("mol_%1 = AtomicMolecule('").arg(i) + myMolecules[ i ].name()+"')\n";
+ for ( int j = 0; j < myMolecules[ i ].count(); j++ ) {
+ aScript += aPrefix + QString("mol_%1.addAtom('").arg(i) + myMolecules[ i ].atomName( j );
+ aScript += QString("', %1, %2, %3)\n").arg(myMolecules[ i ].atomX( j )).arg(myMolecules[ i ].atomY( j )).arg(myMolecules[ i ].atomZ( j ));
+ }
+ }
+
+ if(isMultiFile) {
+ aScript += aPrefix+"pass\n";
+ }
+
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>( theStudy );
+ if(!study)
+ return false;
+
+ std::string aTmpDir = study->GetTmpDir( theURL.toLatin1().constData(), isMultiFile );
+ std::string aFile = aTmpDir + "atomic_dump.tmp";
+
+ std::ofstream outfile(aFile.c_str());
+ outfile.write (aScript.toLatin1().data(),aScript.size());
+ outfile.close();
+
+ theListOfFiles.append(aTmpDir.c_str());
+ theListOfFiles.append("atomic_dump.tmp");
+
+ return true;
+}