SALOMEGUI_NameDlg.h \
SALOMEGUI_SetValueDlg.h \
SALOMEGUI_SetupCurveDlg.h \
- SALOMEGUI_CloseDlg.h
+ SALOMEGUI_CloseDlg.h \
+ SALOMEGUI_AdvancedFileDlg.h
# .po files to transform in .qm
PO_FILES = \
SALOMEGUI_SetValueDlg.cxx \
SALOMEGUI_SetupCurveDlg.cxx \
SALOMEGUI_CloseDlg.cxx \
- SALOMEGUI_ActivateComponentDlg.cxx
+ SALOMEGUI_ActivateComponentDlg.cxx \
+ SALOMEGUI_AdvancedFileDlg.cxx
LIB_MOC = \
SALOMEGUI.h \
SALOMEGUI_Application.h \
SALOMEGUI_NameDlg.h \
SALOMEGUI_SetupCurveDlg.h \
SALOMEGUI_CloseDlg.h \
- SALOMEGUI_ActivateComponentDlg.h
+ SALOMEGUI_ActivateComponentDlg.h \
+ SALOMEGUI_AdvancedFileDlg.h
LIB_CLIENT_IDL = SALOMEDS.idl \
SALOMEDS_Attributes.idl \
SALOME_ModuleCatalog.idl \
#include "SALOMEGUI_AboutDlg.h"
#include "SALOMEGUI_ViewChoiceDlg.h"
#include "SALOMEGUI_SetValueDlg.h"
+#include "SALOMEGUI_AdvancedFileDlg.h"
#include "utilities.h"
#include "SALOMEGUI_CloseDlg.h"
this, SLOT( onSaveAsStudy() )));
fileSaveAsAction->addTo( &myFilePopup );
myStdActions.insert ( FileSaveAsId, fileSaveAsAction );
-
/* separator */
myFilePopup.insertSeparator();
+ /* dump study */
+ QActionP* fileDumpStudyAction = new QActionP( "", tr("MEN_DESK_FILE_DUMP_STUDY"), 0, this );
+ fileDumpStudyAction->setStatusTip ( tr("PRP_DESK_FILE_DUMP_STUDY") );
+ QAD_ASSERT ( connect( fileDumpStudyAction, SIGNAL( activated() ),
+ this, SLOT( onDumpStudy() )));
+ fileDumpStudyAction->addTo( &myFilePopup );
+ myStdActions.insert ( FileDumpStudyId, fileDumpStudyAction );
+
+ /* separator */
+ myFilePopup.insertSeparator();
+
// Study properties
QActionP* filePropsAction = new QActionP( "", QPixmap(), tr("MEN_DESK_FILE_PROPERTIES"), 0, this );
filePropsAction->setStatusTip ( tr("PRP_DESK_FILE_PROPERTIES") );
return true; /* saved ok */
}
+/*!
+ Dumps the active study to the python scripts
+*/
+bool QAD_Desktop::onDumpStudy()
+{
+ return onDumpStudy( myActiveStudy );
+}
+
+/*!
+ Dumps the given study to the python scripts
+*/
+bool QAD_Desktop::onDumpStudy( QAD_Study* study )
+{
+ if ( !study ) return true;
+
+ /* Select a path where to save the scrips and the base name of the sripts
+ */
+ QString aDir = QAD_Tools::getDirFromPath ( myActiveStudy->getPath(), false );
+ QStringList flt;
+ flt.append( "Python Files (*.py)" );
+ QFileInfo aFileInfo = SALOMEGUI_AdvancedFileDlg::getFileName(QAD_Application::getDesktop(),
+ aDir,flt,tr("INF_DESK_DUMP"), tr("Publish in study"), false);
+
+ QString aPath = aFileInfo.dirPath(true);
+ QString aBaseName = aFileInfo.baseName();
+
+ if ( aPath.isNull() || aPath.isEmpty() || aBaseName.isNull() || aBaseName.isEmpty() || !aFileInfo.dir(true).exists())
+ {
+ putInfo( tr("INF_CANCELLED") );
+ return false;
+ }
+
+ bool toPublished = SALOMEGUI_AdvancedFileDlg::IsChecked;
+
+ /* Dumping study
+ */
+ const QString aStudyTitle = study->getTitle();
+ putInfo ( tr("INF_DOC_DUMPING") + aStudyTitle );
+ if ( !study->getStudyDocument()->DumpStudy( aPath, aBaseName, toPublished ) ) {
+ /* can't save the file */
+ QAD_MessageBox::error1( this,
+ tr("ERR_ERROR"),
+ tr("ERR_DOC_CANTDUMP") + "\n" + aStudyTitle,
+ tr("BUT_OK") );
+ putInfo("");
+ return false; /* cannot dump */
+ }
+ putInfo ( tr("INF_DOC_DUMPED").arg( aStudyTitle ) + tr(" to %1_*.py").arg(aPath + "/" + aBaseName) );
+ return true; /* dumped ok */
+}
+
/*!
Closes the active study
*/
myStdActions.at( FileCloseId )->setEnabled ( myActiveStudy != NULL );
myStdActions.at( FileSaveId )->setEnabled ( myActiveStudy != NULL );
myStdActions.at( FileSaveAsId )->setEnabled ( myActiveStudy != NULL );
+ myStdActions.at( FileDumpStudyId )->setEnabled ( myActiveStudy != NULL );
myStdActions.at( FilePropsId )->setEnabled( myActiveStudy != NULL );
// myStdActions.at( HelpContentsId )->setEnabled ( myActiveApp != NULL );
// myStdActions.at( HelpSearchId )->setEnabled ( myActiveApp != NULL );
protected:
//NRI - unused - : enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ;
- enum { FileNewId = -1000, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId,
+ enum { FileNewId = -1000, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FileDumpStudyId, FilePropsId, FileExitId,
ViewStatusBarId,
SelectionPointId, SelectionEdgeId, SelectionCellId, SelectionActorId,
PrefViewerOCCId, PrefViewerVTKId, PrefGraphSupervisorId, PrefViewerPlot2dId,
virtual bool onSaveStudy(QAD_Study* doc);
virtual bool onSaveAsStudy();
virtual bool onSaveAsStudy(QAD_Study* doc);
+ virtual bool onDumpStudy();
+ virtual bool onDumpStudy(QAD_Study* doc);
virtual bool onCloseStudy();
virtual bool onCloseStudy(QAD_Study* doc);
//ask user to remove study from study manager permanently
msgid "INF_DESK_DOC_SAVE"
msgstr "Save study"
+#: QAD_Desktop.cxx:654
+msgid "INF_DESK_DUMP"
+msgstr "Dump study"
+
#: QAD_Desktop.cxx:465
msgid "QAD_Desktop::INF_DESK_EXIT"
msgstr "Exit"
msgid "QAD_Desktop::INF_DOC_SAVING"
msgstr "Saving study "
+#: QAD_Desktop.cxx:1987
+msgid "QAD_Desktop::INF_DOC_DUMPED"
+msgstr "Study %1 dumped"
+
+#: QAD_Desktop.cxx:1977
+msgid "QAD_Desktop::INF_DOC_DUMPING"
+msgstr "Dumping study "
+
#: QAD_Desktop.cxx:993
msgid "QAD_Desktop::INF_PARSE_ERROR"
msgstr "Parse error"
msgid "QAD_Desktop::MEN_DESK_FILE_SAVEAS"
msgstr "Save As ..."
+#: QAD_Desktop.cxx:608
+msgid "QAD_Desktop::MEN_DESK_FILE_DUMP_STUDY"
+msgstr "Dump Study ..."
+
#: QAD_Desktop.cxx:141
msgid "QAD_Desktop::MEN_DESK_HELP"
msgstr "&Help"
msgid "QAD_Desktop::PRP_DESK_FILE_SAVEAS"
msgstr "Saves the active study with a new name"
+#: QAD_Desktop.cxx:609
+msgid "QAD_Desktop::PRP_DESK_FILE_DUMP_STUDY"
+msgstr "Dumps the active study to the python scripts"
+
#: QAD_Desktop.cxx:3759
msgid "QAD_Desktop::PRP_DESK_FILE_IMPORT"
msgstr "Import file"
msgid "QAD_Desktop::ERR_DOC_CANTWRITE"
msgstr "Cannot save study"
+#: QAD_Desktop.cxx:683
+msgid "QAD_Desktop::ERR_DOC_CANTDUMP"
+msgstr "Cannot dump study"
+
#: QAD_Desktop.cxx:599
msgid "QAD_Desktop::ERR_DOC_UNKNOWNTYPE"
msgstr "Unknown study type"
--- /dev/null
+// SALOME SALOMEGUI : implementation of desktop and GUI kernel
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SALOMEGUI_AdvancedFileDlg.cxx
+// Author : Michael Zorin
+// Module : SALOME
+// $Header:
+
+#include <qapplication.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qstring.h>
+#include "QAD_Config.h"
+#include "SALOMEGUI_AdvancedFileDlg.h"
+
+using namespace std;
+
+bool SALOMEGUI_AdvancedFileDlg::IsChecked = false;
+
+/*!
+Constructor
+*/
+SALOMEGUI_AdvancedFileDlg::SALOMEGUI_AdvancedFileDlg( QWidget* parent, bool open, const QString& cbTitle, bool showQuickDir, bool modal ) :
+ QAD_FileDlg( parent, open, showQuickDir, modal )
+{
+ myCheckBox = new QCheckBox( cbTitle, this );
+ QLabel* label = new QLabel("", this);
+ label->setMaximumWidth(0);
+ QPushButton* pb = new QPushButton(this);
+ pb->setMaximumWidth(0);
+ addWidgets( label, myCheckBox, pb );
+ myCheckBox->setChecked(false);
+}
+
+/*!
+ Destructor
+*/
+SALOMEGUI_AdvancedFileDlg::~SALOMEGUI_AdvancedFileDlg()
+{
+}
+
+/*!
+ Processes selection : tries to set given path or filename as selection
+*/
+bool SALOMEGUI_AdvancedFileDlg::processPath( const QString& path )
+{
+ if ( !path.isNull() ) {
+ QFileInfo fi( path );
+ if ( fi.exists() ) {
+ if ( fi.isFile() )
+ setSelection( path );
+ else if ( fi.isDir() )
+ setDir( path );
+ return true;
+ }
+ else {
+ if ( QFileInfo( fi.dirPath() ).exists() ) {
+ setDir( fi.dirPath() );
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/*!
+ Returns the file name
+*/
+QString SALOMEGUI_AdvancedFileDlg::getFileName( QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption,
+ const QString& cbTitle,
+ bool open,
+ bool showQuickDir,
+ QAD_FileValidator* validator )
+{
+ SALOMEGUI_AdvancedFileDlg* fd = new SALOMEGUI_AdvancedFileDlg( parent, open, cbTitle, showQuickDir, true );
+ if ( !caption.isEmpty() )
+ fd->setCaption( caption );
+ if ( !initial.isEmpty() ) {
+ fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug
+ }
+ fd->setFilters( filters );
+ if ( validator )
+ fd->setValidator( validator );
+ fd->exec();
+ QString filename = fd->selectedFile();
+
+ SALOMEGUI_AdvancedFileDlg::IsChecked = fd->IsCBChecked();
+
+ delete fd;
+ qApp->processEvents();
+
+ return filename;
+}
+
+bool SALOMEGUI_AdvancedFileDlg::IsCBChecked()
+{
+ return myCheckBox->isChecked();
+}
--- /dev/null
+// SALOME SALOMEGUI : implementation of desktop and GUI kernel
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SALOMEGUI_AdvancedFileDlg.h
+// Author : Michael Zorin
+// Module : SALOME
+// $Header:
+
+#ifndef SALOMEGUI_AdvancedFileDlg_H
+#define SALOMEGUI_AdvancedFileDlg_H
+
+#include "QAD_FileDlg.h"
+#include <qcheckbox.h>
+
+class SALOMEGUI_AdvancedFileDlg : public QAD_FileDlg
+{
+ Q_OBJECT
+
+public:
+ SALOMEGUI_AdvancedFileDlg( QWidget* parent, bool open, const QString& cbTitle, bool showQuickDir = true, bool modal = true );
+ ~SALOMEGUI_AdvancedFileDlg();
+
+public:
+ static bool IsChecked;
+ static QString getFileName( QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption,
+ const QString& cbTitle,
+ bool open,
+ bool showQuickDir = true,
+ QAD_FileValidator* validator = 0);
+
+private:
+ QCheckBox* myCheckBox;
+ bool IsCBChecked();
+ bool processPath( const QString& path );
+
+};
+
+#endif // SALOMEGUI_AdvancedFileDlg_H