msgstr "Version 2.0.0"
msgid "INF_COPYRIGHT"
-msgstr " "
+msgstr ""
msgid "INF_LICENSE"
msgstr " "
/*!
- Creates not existing config files.
+ Set default directory for config files.
*/
-bool QAD_Config::createConfigFile( bool overwrite )
+void QAD_Config::setDefaultConfigDir()
{
- bool ret=true;
-
#ifdef DEF_WINDOWS
setConfigDir(QDir(prgDir.absPath()));
#else
- setConfigDir(QDir(QDir::home().absPath() + "/." + tr("MEN_APPNAME") ));
+ QString vers = tr("INF_VERSION");
+ int first_dot = vers.find('.');
+ int blanc_before = vers.findRev(' ', first_dot) + 1;
+ int blanc_after = vers.find(' ', first_dot);
+ if (blanc_after == -1) blanc_after = vers.length();
+ int vers_len = blanc_after - blanc_before;
+ vers.truncate(blanc_after);
+ QString vers_nb = vers.right(vers_len);
+ setConfigDir(QDir(QDir::home().absPath() + "/." + tr("MEN_APPNAME") + "_" + vers_nb));
#endif
+}
+
+/*!
+ Creates not existing config files.
+*/
+bool QAD_Config::createConfigFile( bool overwrite )
+{
+ bool ret = true;
+
+ setDefaultConfigDir();
// Create config directory:
if(!configDir.exists()) {
*/
bool QAD_Config::readConfigFile()
{
-#ifdef DEF_WINDOWS
- setConfigDir(QDir(prgDir.absPath()));
-#else
- setConfigDir(QDir(QDir::home().absPath() + "/." + tr("MEN_APPNAME") ));
-#endif
+ setDefaultConfigDir();
QString configPath;
configPath = configDir.absPath() + "/" + tr("MEN_APPNAME") + ".conf";
/** Gets directory of KERNEL_ROOT. */
QDir getPrgDir() const { return prgDir; }
+ void setDefaultConfigDir();
bool createConfigFile( bool overwrite=false );
bool readConfigFile();
void QAD_FileDlg::accept()
{
// mySelectedFile = QFileDialog::selectedFile().simplifyWhiteSpace(); //VSR- 06/12/02
- mySelectedFile = QFileDialog::selectedFile(); //VSR+ 06/12/02
- addExtension();
+ if ( mode() != ExistingFiles ) {
+ mySelectedFile = QFileDialog::selectedFile(); //VSR+ 06/12/02
+ addExtension();
+ }
// mySelectedFile = mySelectedFile.simplifyWhiteSpace(); //VSR- 06/12/02
/* Qt 2.2.2 BUG: accept() is called twice if you validate
if ( myValidator )
{
if ( isOpenDlg() )
- return myValidator->canOpen( selectedFile() );
+ if ( mode() == ExistingFiles ) {
+ QStringList fileNames = selectedFiles();
+ for ( int i = 0; i < fileNames.count(); i++ ) {
+ if ( !myValidator->canOpen( fileNames[i] ) )
+ return false;
+ }
+ return true;
+ }
+ else {
+ return myValidator->canOpen( selectedFile() );
+ }
else
return myValidator->canSave( selectedFile() );
}
else {
if ( QFileInfo( fi.dirPath() ).exists() ) {
setDir( fi.dirPath() );
+ setSelection( path );
return true;
}
}
*/
QString QAD_FileDlg::getFileName( QWidget* parent,
const QString& initial,
- const QStringList& filters,
- const QString& caption,
- bool open,
+ const QStringList& filters,
+ const QString& caption,
+ bool open,
bool showQuickDir,
QAD_FileValidator* validator )
{
return filename;
}
+
+/*!
+ Returns the list of files to be opened [ static ]
+*/
+QStringList QAD_FileDlg::getOpenFileNames( QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption,
+ bool showQuickDir,
+ QAD_FileValidator* validator )
+{
+ QAD_FileDlg* fd = new QAD_FileDlg( parent, true, showQuickDir, true );
+ fd->setMode( ExistingFiles );
+ 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();
+ QStringList filenames = fd->selectedFiles();
+ delete fd;
+ qApp->processEvents();
+ return filenames;
+}
+
/*!
Existing directory selection dialog [ static ]
*/
return dirname;
}
+
bool open,
bool showQuickDir = true,
QAD_FileValidator* validator = 0);
+ static QStringList getOpenFileNames( QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption,
+ bool showQuickDir = true,
+ QAD_FileValidator* validator = 0);
static QString getExistingDirectory ( QWidget* parent,
const QString& initial,
const QString& caption,
- <prefix>_ROOT_DIR/share/salome/resources directory
- SALOME_<prefix>Resources env.var directory ( or directory list )
- ${HOME}/.salome/resources directory
- - KERNEL_ROOT_DIR/share/salome/resources directory
+ - ${SALOME_SITE_DIR}/share/${SALOME_SITE_NAME}/resources directory (for SALOME-based applications)
+ - ${KERNEL_ROOT_DIR}/share/salome/resources directory
*/
QString QAD_ResourceMgr::collectDirs( const QString& prefix ) const
{
dirList.append( dirList.isEmpty() ? dir : ( QString( SEPARATOR ) + dir ) );
}
}
-
+ // Try ${SALOME_SITE_DIR}/share/${SALOME_SITE_NAME}/resources directory
+ cenv = getenv( "SALOME_SITE_DIR" );
+ if ( cenv ) {
+ dir.sprintf( "%s", cenv );
+ if ( !dir.isEmpty() ) {
+ dir = QAD_Tools::addSlash(dir) ;
+ dir = dir + "share" ;
+ dir = QAD_Tools::addSlash(dir) ;
+ cenv = getenv( "SALOME_SITE_NAME" );
+ if ( cenv )
+ dir = dir + cenv ;
+ else
+ dir = dir + "salome" ;
+ dir = QAD_Tools::addSlash(dir) ;
+ dir = dir + "resources" ;
+ dir = QAD_Tools::addSlash(dir) ;
+ dirList.append( dirList.isEmpty() ? dir : ( QString( SEPARATOR ) + dir ) );
+ }
+ }
// Try ${KERNEL_ROOT_DIR}/share/salome/resources directory
cenv = getenv( "KERNEL_ROOT_DIR" );
if ( cenv ) {
// Module : SALOME
// $Header$
-using namespace std;
#include <Python.h>
-#include <vtkRenderer.h>
-#include <vtkRenderWindowInteractor.h>
#include <vtkPythonUtil.h>
+
#include <vtkVersion.h>
-#include "utilities.h"
-#include "QAD_Study.h"
-#include "QAD_RightFrame.h"
+#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+
#include "QAD_Application.h"
#include "QAD_Desktop.h"
+#include "QAD_Study.h"
+#include "QAD_RightFrame.h"
+
#include "VTKViewer_ViewFrame.h"
+#include "VTKViewer_RenderWindow.h"
+#include "VTKViewer_RenderWindowInteractor.h"
-extern "C"
-{
- static PyObject * libSalomePy_getRenderer(PyObject *self, PyObject *args);
+#include "utilities.h"
+
+using namespace std;
+
+
+PyObject* GetPyClass(const char* theClassName){
+ static PyObject *aVTKModule = NULL;
+ if(!aVTKModule){
+ if (VTK_MAJOR_VERSION > 3)
+ aVTKModule = PyImport_ImportModule("libvtkRenderingPython");
+ else
+ aVTKModule = PyImport_ImportModule("libVTKGraphicsPython");
+ if(PyErr_Occurred()){
+ PyErr_Print();
+ return NULL;
+ }
+ }
+ PyObject* aVTKDict = PyModule_GetDict(aVTKModule);
+ char* aClassName = const_cast<char*>(theClassName);
+ PyObject* aPyClass = PyDict_GetItemString(aVTKDict,aClassName);
+ //Py_DECREF(aVTKModule);
+ return aPyClass;
+}
+
+
+VTKViewer_ViewFrame* GetVTKViewFrame(){
+ QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
+ QAD_StudyFrame* aStudyFrame = aStudy->getActiveStudyFrame();
+ QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
+ return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
}
-static PyObject *libSalomePy_getRenderer(PyObject *self, PyObject *args)
+
+extern "C" PyObject *libSalomePy_getRenderer(PyObject *self, PyObject *args)
{
- if (!PyArg_ParseTuple(args, ":getRenderer"))
- return NULL;
- // exemple retournant systematiquement Py_None
- Py_INCREF(Py_None);
- return Py_None;
+ if(VTKViewer_ViewFrame* aVTKViewFrame = GetVTKViewFrame()){
+ PyObject* aPyClass = GetPyClass("vtkRenderer");
+ vtkRenderer* aVTKObject = aVTKViewFrame->getRenderer();
+ return PyVTKObject_New(aPyClass,aVTKObject);
+ }
+ return NULL;
+}
+
+
+extern "C" PyObject *libSalomePy_getRenderWindow(PyObject *self, PyObject *args)
+{
+ if(VTKViewer_ViewFrame* aVTKViewFrame = GetVTKViewFrame()){
+ PyObject* aPyClass = GetPyClass("vtkRenderWindow");
+ vtkRenderWindow* aVTKObject = aVTKViewFrame->getRW()->getRenderWindow();
+ return PyVTKObject_New(aPyClass,aVTKObject);
+ }
+ return NULL;
}
+
+extern "C" PyObject *libSalomePy_getRenderWindowInteractor(PyObject *self, PyObject *args)
+{
+ if(VTKViewer_ViewFrame* aVTKViewFrame = GetVTKViewFrame()){
+ PyObject* aPyClass = GetPyClass("vtkRenderWindowInteractor");
+ vtkRenderWindowInteractor* aVTKObject = aVTKViewFrame->getRWInteractor();
+ return PyVTKObject_New(aPyClass,aVTKObject);
+ }
+ return NULL;
+}
+
+
static PyMethodDef Module_Methods[] =
{
- {"getRenderer", libSalomePy_getRenderer, METH_VARARGS},
+ {"getRenderer",libSalomePy_getRenderer,METH_NOARGS},
+ {"getRenderWindow",libSalomePy_getRenderWindow,METH_NOARGS},
+ {"getRenderWindowInteractor",libSalomePy_getRenderWindow,METH_NOARGS},
{NULL, NULL}
};
-extern "C" { void initlibSalomePy();}
-void initlibSalomePy()
+extern "C" void initlibSalomePy()
{
- PyObject *m, *d, *c, *md, *obj, *vtkclass;
-
static char modulename[] = "libSalomePy";
- MESSAGE("---");
- m = Py_InitModule(modulename, Module_Methods);
- MESSAGE("---");
- d = PyModule_GetDict(m);
- MESSAGE("---");
- // DANGEROUS : if (!d) Py_FatalError("can't get dictionary for module SalomePy!");
- if (PyErr_Occurred())
- {
- MESSAGE("---");
- return;
- }
-
- if (VTK_MAJOR_VERSION > 3)
- m=PyImport_ImportModule("libvtkRenderingPython"); // import module if not already imported (new ref)
- else
- m=PyImport_ImportModule("libVTKGraphicsPython"); // import module if not already imported (new ref)
-
- MESSAGE("---");
-
- if (PyErr_Occurred())
- {
- PyErr_Print();
- MESSAGE("---");
- return;
- }
-
- if ( m ) {
- md = PyModule_GetDict(m); // dict of libvtkGraphicsPython (borrowed ref ; not decref)
- MESSAGE("---");
-
- vtkclass=PyDict_GetItemString(md,"vtkRenderer"); // (borrowed ref ; not decref)
- Py_DECREF(m); // no more need of m
- MESSAGE("---");
+ PyObject* aModule = Py_InitModule(modulename, Module_Methods);
+ PyObject* aDict = PyModule_GetDict(aModule);
+ if(PyErr_Occurred()){
+ PyErr_Print();
+ return;
}
-//NRI
- //san:T3.13 - move getRenderer() implementation here
- //vtkRenderer *renderer = SALOMEGUI_Swig::getRenderer();
- QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
- int nbStudyFrames = myStudy->getStudyFramesCount();
- vtkRenderer *renderer = NULL;
- int viewId = -1;
- if (viewId == -1) // find the first frame with VTK viewer & get renderer
- {
- int i=0;
- for(i=0; i<nbStudyFrames; i++)
- {
- if ( myStudy->getStudyFrame(i)->getTypeView() == VIEW_VTK )
- {
- renderer = ((VTKViewer_ViewFrame*)myStudy->getStudyFrame(i)->getRightFrame()->getViewFrame())->getRenderer();
- break;
- }
- }
- }
- else // get the VTK renderer of a given frame
- {
- SCRUTE(viewId);
- if ((viewId >=0) && (viewId <nbStudyFrames))
- renderer = ((VTKViewer_ViewFrame*)myStudy->getStudyFrame(viewId)->getRightFrame()->getViewFrame())->getRenderer();
- }
- if (renderer == NULL) MESSAGE("No VTK Renderer available !");
- //san:T3.13 - move getRenderer() implementation here
-
- MESSAGE("---");
- obj = PyVTKObject_New(vtkclass,renderer); // (new ref)
- MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp
- PyDict_SetItemString(d,"renderer",obj); // (add a ref to obj ; has to be decref)
- MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp
- Py_DECREF(obj); // only one ref is sufficient
- MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp
-//NRI
-
-// vtkclass=PyDict_GetItemString(md,"vtkRenderWindowInteractor"); // (borrowed ref ; not decref)
-// Py_DECREF(m); // no more need of m
-// MESSAGE("---");
-// vtkRenderWindowInteractor *RWInteractor = SALOMEGUI_Swig::getRWInteractor();
-// MESSAGE("---");
-// obj = PyVTKObject_New(vtkclass,RWInteractor); // (new ref)
-// MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp
-// PyDict_SetItemString(d,"interactor",obj); // (add a ref to obj ; has to be decref)
-// MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp
-// Py_DECREF(obj); // only one ref is sufficient
-// MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp
+ PyObject* anObj = libSalomePy_getRenderer(NULL,NULL);
+ PyDict_SetItemString(aDict,"renderer",anObj);
+ Py_DECREF(anObj);
}
-
-
QString & theObject )
{
MESSAGE("SALOME_PYQT_GUI::DefinePopup");
- //theContext = "";
- //theObject = "";
- //theParent = "";
+ theContext = "";
+ theObject = "";
+ theParent = "";
PyLockWrapper aLock = interp->GetLockWrapper();
using namespace std;
#include "SalomePyQt.hxx"
+#include <qapplication.h>
+
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Study.h"
#include "QAD_FileDlg.h"
+#include "QAD_ViewFrame.h"
+#include "QAD_RightFrame.h"
+#include "QAD_Tools.h"
#include "QAD_Config.h"
#include "QAD_Settings.h"
return QAD_FileDlg::getFileName(parent, initial, filters, caption, open);
}
+QStringList SalomePyQt::getOpenFileNames(QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption)
+{
+ return QAD_FileDlg::getOpenFileNames(parent, initial, filters, caption);
+}
+
QString SalomePyQt::getExistingDirectory(QWidget* parent,
const QString& initial,
const QString& caption)
void SalomePyQt::helpContext(const QString& source, const QString& context) {
//QAD_Application::getDesktop()->helpContext(source, context);
}
+
+bool SalomePyQt::dumpView(const QString& filename)
+{
+ QAD_Study* activeStudy = QAD_Application::getDesktop()->getActiveApp()->getActiveStudy();
+ if ( !activeStudy )
+ return false;
+ QAD_ViewFrame* activeViewFrame = activeStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
+ if ( !activeViewFrame )
+ return false;
+ if ( !activeViewFrame->getViewWidget() )
+ return false;
+
+ qApp->processEvents();
+ QPixmap px = QPixmap::grabWindow( activeViewFrame->getViewWidget()->winId() );
+ if ( !filename.isNull() ) {
+ QString fmt = QAD_Tools::getFileExtensionFromPath( filename ).upper();
+ if ( fmt.isEmpty() )
+ fmt = QString( "PNG" ); // default format
+ if ( fmt == "JPG" )
+ fmt = "JPEG";
+ bool bOk = px.save( filename, fmt.latin1() );
+ return bOk;
+ }
+ return false;
+}
static void updateObjBrowser( int studyId, bool updateSelection);
- static void addStringSetting(QString _name, QString _value, bool _autoValue);
- static void addIntSetting(QString _name, int _value, bool _autoValue);
- static void addDoubleSetting(QString _name, double _value, bool _autoValue);
- static bool removeSettings(QString name);
- static QString getSetting(QString name);
-
- static QString getFileName(QWidget* parent,
- const QString& initial,
- const QStringList& filters,
- const QString& caption,
- bool open);
- static QString getExistingDirectory(QWidget* parent,
- const QString& initial,
- const QString& caption);
- static void helpContext(const QString& source, const QString& context);
+ static void addStringSetting(QString _name, QString _value, bool _autoValue);
+ static void addIntSetting(QString _name, int _value, bool _autoValue);
+ static void addDoubleSetting(QString _name, double _value, bool _autoValue);
+ static bool removeSettings(QString name);
+ static QString getSetting(QString name);
+
+ static QString getFileName(QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption,
+ bool open);
+ static QStringList getOpenFileNames(QWidget* parent,
+ const QString& initial,
+ const QStringList& filters,
+ const QString& caption);
+ static QString getExistingDirectory(QWidget* parent,
+ const QString& initial,
+ const QString& caption);
+ static void helpContext(const QString& source, const QString& context);
+ static bool dumpView(const QString& filename);
};
#endif
static void addDoubleSetting(QString, double, bool);
static QString getFileName(QWidget*, const QString&, const QStringList&, const QString&, bool);
+ static QStringList getOpenFileNames(QWidget*, const QString&, const QStringList&, const QString&);
static QString getExistingDirectory(QWidget*, const QString&, const QString&);
static void helpContext(const QString&, const QString&);
+ static bool dumpView(const QString&);
};
if len(aListOfOpenStudies) == 0 :
myStudy = myStudyManager.NewStudy("Study1")
else:
- myStudy = aListOfOpenStudies[0]
+ myStudyName = aListOfOpenStudies[0]
+ myStudy = myStudyManager.GetStudyByName(myStudyName)
myStudyName = myStudy._get_Name()
_argc = argc ;
_argv = argv ;
_NS = 0 ;
-} ;
+}
//=============================================================================
}
aCatch.Deactivate();
- QString confMsg = "Settings create $HOME/." + QObject::tr("MEN_APPNAME") + "/" + QObject::tr("MEN_APPNAME") + ".conf";
- MESSAGE (confMsg )
+ QString confMsg = "Settings create "
+ + QAD_CONFIG->getConfigDir().absPath() + "/" + QObject::tr("MEN_APPNAME") + ".conf";
+ MESSAGE (confMsg);
QAD_CONFIG->createConfigFile(true);
}
-} ;
+}
//=============================================================================
/*! setNamingService
}
}
//aCatch.Deactivate();
- QString confMsg = "Settings create $HOME/."
- + QObject::tr("MEN_APPNAME") + "/" + QObject::tr("MEN_APPNAME") + ".conf";
- MESSAGE (confMsg );
+ QString confMsg = "Settings create "
+ + QAD_CONFIG->getConfigDir().absPath() + "/" + QObject::tr("MEN_APPNAME") + ".conf";
+ MESSAGE (confMsg);
QAD_CONFIG->createConfigFile(true);
}
//orb->shutdown(0);