STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
SET(${PROJECT_NAME_UC}_MAJOR_VERSION 7)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 4)
-SET(${PROJECT_NAME_UC}_PATCH_VERSION 1)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 5)
+SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
SET(${PROJECT_NAME_UC}_VERSION
${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
-SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
+SET(${PROJECT_NAME_UC}_VERSION_DEV 0)
# Find KERNEL
# ===========
#include "CAF_Tools.h"
#include "CAF_Application.h"
-#include <Basics_OCCTVersion.hxx>
-
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <SUIT_Application.h>
#include "DDS_KeyWords.h"
-#include <Basics_OCCTVersion.hxx>
-
#include <LDOMString.hxx>
#include <LDOMParser.hxx>
#include "LightApp_WgViewModel.h"
#include "LightApp_FullScreenHelper.h"
-
#include <GUI_version.h>
-#include <Basics_OCCTVersion.hxx>
#include <SALOME_Event.h>
int LightApp_Application::lastStudyId = 0;
-
// Markers used to parse array with dockable windows and toolbars state.
// For more details please see the qdockarealayout.cpp && qtoolbararealayout.cpp
// in the Qt source code.
#ifndef DISABLE_PYCONSOLE
if( pythonConsole() )
- pythonConsole()->getInterp()->initStudy();
+ getPyInterp()->initStudy();
#endif
}
#ifndef DISABLE_PYCONSOLE
if( pythonConsole() )
- pythonConsole()->getInterp()->initStudy();
+ getPyInterp()->initStudy();
#endif
emit studyOpened();
#ifndef DISABLE_PYCONSOLE
else if ( flag == WT_PyConsole )
{
- PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(),new LightApp_PyInterp());
+ PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
pyCons->setObjectName( "pythonConsole" );
pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
// update object browser
updateObjectBrowser();
}
+ else if ( message.toLower().startsWith( "activate_viewer" ) ) {
+ QString vtype = message.split( sectionSeparator ).last();
+ if ( !vtype.isEmpty() )
+ getViewManager( vtype, true );
+ }
else {
QStringList data = message.split( sectionSeparator );
if ( data.count() > 1 ) {
return result;
}
+#ifndef DISABLE_PYCONSOLE
+
+PyConsole_Interp* LightApp_Application::getPyInterp()
+{
+ static PyConsole_Interp* myInterp = 0;
+ if ( !myInterp )
+ myInterp = createPyInterp();
+ return myInterp;
+}
+
+PyConsole_Interp* LightApp_Application::createPyInterp()
+{
+ return new LightApp_PyInterp();
+}
+
+#endif // DISABLE_PYCONSOLE
class LogWindow;
#ifndef DISABLE_PYCONSOLE
class PyConsole_Console;
+class PyConsole_Interp;
#endif
class LightApp_WidgetContainer;
class LightApp_Preferences;
virtual bool checkExistingDoc();
+#ifndef DISABLE_PYCONSOLE
+ PyConsole_Interp* getPyInterp();
+#endif
+
signals:
void studyOpened();
void studySaved();
virtual QMap<int, QString> activateModuleActions() const;
virtual void moduleActionSelected( const int );
+#ifndef DISABLE_PYCONSOLE
+ virtual PyConsole_Interp* createPyInterp();
+#endif
+
protected slots:
virtual void onDesktopActivated();
virtual void onViewManagerRemoved( SUIT_ViewManager* );
class LightApp_PyInterp : public PyConsole_EnhInterp
{
+ friend class LightApp_Application;
+
public:
- LightApp_PyInterp();
virtual ~LightApp_PyInterp();
protected:
+ LightApp_PyInterp();
virtual void initPython();
};
Standard_EXPORT Standard_Boolean isComponentType(const char* ComponentDataType);
// Must be defined for using by NCollection for ceratin of data map
- friend Standard_Boolean IsEqual(const Handle(SALOME_InteractiveObject)& anIO1,
+ Standard_EXPORT friend Standard_Boolean IsEqual(const Handle(SALOME_InteractiveObject)& anIO1,
const Handle(SALOME_InteractiveObject)& anIO2);
protected:
#include "OCCViewer_ViewManager.h"
#include "OCCViewer_ClipPlaneInteractor.h"
+#include <Basics_OCCTVersion.hxx>
+
#include <V3d_View.hxx>
#include <Visual3d_View.hxx>
#include <Geom_Plane.hxx>
if ( !aPrs->IsEmpty() && !aPrs->IsInfinite() ) {
isFound = true;
double xmin, ymin, zmin, xmax, ymax, zmax;
+#if OCC_VERSION_LARGE > 0x06070100
+ Bnd_Box aBox = aPrs->MinMaxValues();
+ xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
+ ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
+ zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
+ xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
+ ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
+ zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
+#else
aPrs->MinMaxValues( xmin, ymin, zmin, xmax, ymax, zmax );
+#endif
aXMin = qMin( aXMin, xmin ); aXMax = qMax( aXMax, xmax );
aYMin = qMin( aYMin, ymin ); aYMax = qMax( aYMax, ymax );
aZMin = qMin( aZMin, zmin ); aZMax = qMax( aZMax, zmax );
#include "QtxAction.h"
#include "QtxIntSpinBox.h"
-#include <Basics_OCCTVersion.hxx>
-
#include <QCheckBox>
#include <QGroupBox>
#include <QLineEdit>
#include "ViewerData_AISShape.hxx"
+#include <Basics_OCCTVersion.hxx>
+
#include "QtxActionToolMgr.h"
#include "QtxBackgroundTool.h"
double aMaxSide = 0;
double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
+#if OCC_VERSION_LARGE > 0x06070100
+ Bnd_Box aBox = view3d->View()->MinMaxValues();
+ Xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
+ Ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
+ Zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
+ Xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
+ Ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
+ Zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
+#else
view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax );
+#endif
if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() &&
Xmax != RealLast() && Ymax != RealLast() && Zmax != RealLast() )
#include <V3d_View.hxx>
#include <AIS_Trihedron.hxx>
#include <AIS_InteractiveContext.hxx>
-#include <Basics_OCCTVersion.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
class QKeyEvent;
continue;
}
+#if OCC_VERSION_LARGE > 0x06070100
+ Bnd_Box aBox = aStructure->MinMaxValues();
+ aXmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
+ aYmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
+ aZmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
+ aXmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
+ aYmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
+ aZmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
+#else
aStructure->MinMaxValues( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
+#endif
// Infinite structures are skipped
Standard_Real aLIM = ShortRealLast() - 1.0;
<name>OCCViewer_AxialScaleDlg</name>
<message>
<source>DLG_SCALING</source>
- <translation>Axes scaling</translation>
+ <translation>Scaling</translation>
</message>
<message>
<source>LBL_X</source>
</message>
<message>
<source>MNU_SCALING</source>
- <translation>Changer l'échelle</translation>
+ <translation>Mise à l'échelle</translation>
</message>
<message>
<source>DSC_SCALING</source>
<name>OCCViewer_AxialScaleDlg</name>
<message>
<source>DLG_SCALING</source>
- <translation>Changer l'échelle des axes</translation>
+ <translation>Mise à l'échelle</translation>
</message>
<message>
<source>LBL_X</source>
</message>
<message>
<source>MNU_SCALING</source>
- <translation>軸のスケーリング</translation>
+ <translation>スケーリング</translation>
</message>
<message>
<source>DSC_SCALING</source>
<name>OCCViewer_AxialScaleDlg</name>
<message>
<source>DLG_SCALING</source>
- <translation>ã\82¹ã\82±ã\83¼ã\83«ã\81®å¤\89æ\9b´</translation>
+ <translation>ã\82¹ã\82±ã\83¼ã\83ªã\83³ã\82°</translation>
</message>
<message>
<source>LBL_X</source>
pipelineBrowserWidget = new pqPipelineBrowserWidget(desk);
pipelineBrowserWidget->hide();
- sourcesMenu = new QMenu(desk);
- pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
-
- filtersMenu = new QMenu(desk);
- pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
-
- macrosMenu = new QMenu(desk);
- pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
+// sourcesMenu = new QMenu(desk);
+// pqParaViewMenuBuilders::buildSourcesMenu(*sourcesMenu, desk);
+// filtersMenu = new QPVMenu(desk);
+// pqParaViewMenuBuilders::buildFiltersMenu(*filtersMenu, desk);
+// macrosMenu = new QMenu(desk);
+// pqParaViewMenuBuilders::buildMacrosMenu(*macrosMenu);
}
PVViewer_GUIElements * PVViewer_GUIElements::GetInstance(SUIT_Desktop* desk)
return theInstance;
}
-void PVViewer_GUIElements::updateSourcesMenu(QMenu *menu)
-{
- if (menu)
- {
- menu->clear();
- QList<QAction *> act_list = sourcesMenu->actions();
- foreach(QAction * a, act_list)
- {
- menu->addAction(a);
- }
- }
-}
-
-void PVViewer_GUIElements::updateFiltersMenu(QMenu *menu)
-{
- if (menu)
- {
- menu->clear();
- QList<QAction *> act_list = filtersMenu->actions();
- foreach(QAction * a, act_list)
- {
- menu->addAction(a);
- }
- }
-}
-
-void PVViewer_GUIElements::updateMacrosMenu(QMenu *menu)
-{
- if (menu)
- {
- menu->clear();
- QList<QAction *> act_list = macrosMenu->actions();
- foreach(QAction * a, act_list)
- {
- menu->addAction(a);
- }
- }
-}
+//void PVViewer_GUIElements::updateSourcesMenu(QMenu *menu)
+//{
+// if (menu)
+// {
+// menu->clear();
+// QList<QAction *> act_list = sourcesMenu->actions();
+// foreach(QAction * a, act_list)
+// {
+// menu->addAction(a);
+// }
+// }
+//}
+//
+//void PVViewer_GUIElements::updateFiltersMenu(QMenu *menu)
+//{
+// if (menu)
+// {
+// filtersMenu->linkToMenu(menu);
+// menu->clear();
+// QList<QAction *> act_list = filtersMenu->actions();
+// foreach(QAction * a, act_list)
+// {
+// menu->addAction(a);
+// }
+// }
+//}
+//
+//void PVViewer_GUIElements::updateMacrosMenu(QMenu *menu)
+//{
+// if (menu)
+// {
+// menu->clear();
+// QList<QAction *> act_list = macrosMenu->actions();
+// foreach(QAction * a, act_list)
+// {
+// menu->addAction(a);
+// }
+// }
+//}
void PVViewer_GUIElements::onEmulateApply()
/*!
* Some GUI elements of ParaView need to be instanciated in a proper order. This class
* holds all of them for the sake of clarity.
- * For example sources menu should be built *before* loading ParaView's configuration, so that the
- * list of sources gets properly populated.
*/
class PVVIEWER_EXPORT PVViewer_GUIElements: public QObject
{
pqPipelineBrowserWidget * getPipelineBrowserWidget() { return pipelineBrowserWidget; }
// Update the sources menu from what was built in private member 'sourcesMenu'
- void updateSourcesMenu(QMenu *);
- void updateFiltersMenu(QMenu *);
- void updateMacrosMenu(QMenu *);
+// void updateSourcesMenu(QMenu *);
+// void updateFiltersMenu(QMenu *);
+// void updateMacrosMenu(QMenu *);
public slots:
void onEmulateApply(); // better use the slot from PVViewer_ViewManager if you want to trigger "Apply"
ParaviewBehaviors->instanciateMinimalBehaviors(aDesktop);
}
-void PVViewer_ViewManager::ParaviewLoadConfigurations()
+void PVViewer_ViewManager::ParaviewLoadConfigurations(bool force)
{
- if (!ConfigLoaded)
+ if (!ConfigLoaded || force)
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
QString aPath = resMgr->stringValue("resources", "PVViewer", QString());
//! Initialize ParaView if not yet done (once per session)
static bool ParaviewInitApp(SUIT_Desktop* aDesktop, LogWindow * w);
static void ParaviewInitBehaviors(bool fullSetup=false, SUIT_Desktop* aDesktop=0);
- static void ParaviewLoadConfigurations();
+ static void ParaviewLoadConfigurations(bool force=false);
static void ParaviewCleanup();
//! Connect to the external PVServer, using the PARAVIS engine to launch it if it is not
#include "PVViewer_ViewWindow.h"
#include "PVViewer_ViewManager.h"
+#include "PVViewer_ViewModel.h"
#include "PVViewer_GUIElements.h"
#include <SUIT_ViewManager.h>
: SUIT_ViewWindow( theDesktop ), myPVMgr( 0 )
{
myModel = theModel;
+ setViewManager(myModel->getViewManager());
myPVMgr = qobject_cast<pqTabbedMultiViewWidget*>(pqApplicationCore::instance()->manager("MULTIVIEW_WIDGET"));
if (myPVMgr) {
myPVMgr->setParent( this );
PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* interp )
: QWidget( parent )
{
- // create python interpreter
- myInterp = interp;
- if ( !myInterp )
- myInterp = new PyConsole_Interp();
+ PyConsole_Interp* anInterp = interp ? interp : new PyConsole_Interp();
// initialize Python interpretator
- myInterp->initialize();
+ anInterp->initialize();
// create editor console
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setMargin( 0 );
- myEditor = new PyConsole_Editor( myInterp, this );
+ myEditor = new PyConsole_Editor( anInterp, this );
char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
if (synchronous && atoi(synchronous))
{
/**
* Protected constructor.
*/
-PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* i, PyConsole_Editor* e)
- : QWidget (parent), myEditor(e), myInterp(i)
+PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Interp* /*i*/, PyConsole_Editor* e )
+ : QWidget (parent), myEditor(e)
{}
/*!
{
}
+PyConsole_Interp* PyConsole_Console::getInterp() const
+{
+ return myEditor ? myEditor->getInterp() : 0;
+}
+
/*!
\brief Execute python command in the interpreter.
\param command string with command and arguments
* @param parent
* @param interp
*/
-PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp)
- : PyConsole_Console(parent, interp, 0)
+PyConsole_EnhConsole::PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp )
+ : PyConsole_Console( parent, interp, 0 )
{
- // create python interpreter
- myInterp = interp;
- if ( !myInterp )
- myInterp = new PyConsole_EnhInterp();
+ PyConsole_Interp* anInterp = interp ? interp : new PyConsole_EnhInterp();
// initialize Python interpretator
- myInterp->initialize();
+ anInterp->initialize();
// create editor console
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setMargin( 0 );
- myEditor = new PyConsole_EnhEditor( static_cast<PyConsole_EnhInterp*>(myInterp), this );
+ myEditor = new PyConsole_EnhEditor( anInterp, this );
char* synchronous = getenv("PYTHON_CONSOLE_SYNC");
if (synchronous && atoi(synchronous))
{
class PyConsole_Interp;
class PyConsole_Editor;
-class PyConsole_EnhInterp;
class PYCONSOLE_EXPORT PyConsole_Console : public QWidget, public SUIT_PopupClient
{
virtual ~PyConsole_Console();
//! \brief Get python interperter
- PyConsole_Interp* getInterp() { return myInterp; }
+ PyConsole_Interp* getInterp() const;
QFont font() const;
virtual void setFont( const QFont& );
PyConsole_Console( QWidget* parent, PyConsole_Interp*, PyConsole_Editor*);
-
- PyConsole_Interp* myInterp; //!< python interpreter
PyConsole_Editor* myEditor; //!< python console editor widget
QMap<int, QAction*> myActions; //!< menu actions list
};
Q_OBJECT
public:
- PyConsole_EnhConsole( QWidget* parent, PyConsole_EnhInterp* interp = 0);
+ PyConsole_EnhConsole( QWidget* parent, PyConsole_Interp* interp = 0 );
virtual ~PyConsole_EnhConsole() {}
};
/*!
\brief Destructor.
-
- Does nothing for the moment.
*/
PyConsole_Editor::~PyConsole_Editor()
{
- myInterp->destroy();
- delete myInterp;
myInterp = 0;
}
+/*!
+ \brief Get Python interpreter
+*/
+PyConsole_Interp* PyConsole_Editor::getInterp() const
+{
+ return myInterp;
+}
+
/*!
\brief Get synchronous mode flag value.
public:
PyConsole_Editor( PyConsole_Interp* theInterp, QWidget *theParent = 0 );
~PyConsole_Editor();
+
+ PyConsole_Interp* getInterp() const;
virtual void addText( const QString& str, const bool newBlock = false, const bool isError = false );
bool isCommand( const QString& str ) const;
* @param interp the interpreter linked to the editor
* @param parent parent widget
*/
-PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent) :
+PyConsole_EnhEditor::PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent) :
PyConsole_Editor(interp, parent),
_tab_mode(false),
_cursor_pos(-1),
setTextCursor(tc);
textCursor().deletePreviousChar();
// TODO: before wait for any TAB event to be completed
- static_cast<PyConsole_EnhInterp *>(myInterp)->clearCompletion();
+ if ( myInterp )
+ myInterp->clearCompletion();
}
_tab_mode = false;
}
_compl_before_point = QString("");
}
- return new CompletionCommand( static_cast<PyConsole_EnhInterp *>(myInterp), _compl_before_point,
- _compl_after_point, this, isSync() );
+ return new CompletionCommand( myInterp, _compl_before_point,
+ _compl_after_point, this, isSync() );
}
/**
* @param matches list of possible completions
* @param result return value
*/
-void PyConsole_EnhEditor::formatCompletion(const std::vector<QString> & matches, QString & result) const
+void PyConsole_EnhEditor::formatCompletion(const QStringList& matches, QString& result) const
{
int sz = matches.size();
*/
void PyConsole_EnhEditor::customEvent( QEvent* event )
{
- std::vector<QString> matches;
+ QStringList matches;
QString first_match, comple_text, doc, base;
QTextCursor cursor(textCursor());
QTextBlockFormat bf;
QTextCharFormat cf;
- PyConsole_EnhInterp * interp = static_cast<PyConsole_EnhInterp *>(myInterp);
int cursorPos;
switch( event->type() )
{
case PyInterp_Event::ES_TAB_COMPLETE_OK:
+ {
// Extract corresponding matches from the interpreter
- matches = interp->getLastMatches();
+ matches = getInterp()->getLastMatches();
+ doc = getInterp()->getDocStr();
if (matches.size() == 0)
- {
- // Completion successful but nothing returned.
- _tab_mode = false;
- _cursor_pos = -1;
- return;
- }
-
+ {
+ // Completion successful but nothing returned.
+ _tab_mode = false;
+ _cursor_pos = -1;
+ return;
+ }
+
// Only one match - complete directly and update doc string window
- doc = interp->getDocStr();
if (matches.size() == 1)
- {
- first_match = matches[0].mid(_compl_after_point.size());
- cursor.insertText(first_match);
- _tab_mode = false;
- if (doc == QString(""))
- emit updateDoc(formatDocHTML("(no documentation available)\n"));
- else
- emit updateDoc(formatDocHTML(doc));
- }
+ {
+ first_match = matches[0].mid(_compl_after_point.size());
+ cursor.insertText(first_match);
+ _tab_mode = false;
+ if (doc.isEmpty())
+ emit updateDoc(formatDocHTML("(no documentation available)\n"));
+ else
+ emit updateDoc(formatDocHTML(doc));
+ }
else
- {
- // Detect if there is a common base to all available completion
- // In this case append this base to the text already
- extractCommon(matches, base);
- first_match = base.mid(_compl_after_point.size());
- cursor.insertText(first_match);
-
- // If this happens to match exaclty the first completion
- // also provide doc
- if (base == matches[0])
- {
- doc = formatDocHTML(doc);
- emit updateDoc(doc);
- }
-
- // Print all matching completion in a "undo-able" block
- cursorPos = cursor.position();
- cursor.insertBlock();
- cursor.beginEditBlock();
-
- // Insert all matches
- QTextCharFormat cf;
- cf.setForeground(QBrush(Qt::darkGreen));
- cursor.setCharFormat(cf);
- formatCompletion(matches, comple_text);
- cursor.insertText(comple_text);
- cursor.endEditBlock();
-
- // Position cursor where it was before inserting the completion list:
- cursor.setPosition(cursorPos);
- setTextCursor(cursor);
- }
+ {
+ // Detect if there is a common base to all available completion
+ // In this case append this base to the text already
+ extractCommon(matches, base);
+ first_match = base.mid(_compl_after_point.size());
+ cursor.insertText(first_match);
+
+ // If this happens to match exaclty the first completion
+ // also provide doc
+ if (base == matches[0])
+ {
+ doc = formatDocHTML(doc);
+ emit updateDoc(doc);
+ }
+
+ // Print all matching completion in a "undo-able" block
+ cursorPos = cursor.position();
+ cursor.insertBlock();
+ cursor.beginEditBlock();
+
+ // Insert all matches
+ QTextCharFormat cf;
+ cf.setForeground(QBrush(Qt::darkGreen));
+ cursor.setCharFormat(cf);
+ formatCompletion(matches, comple_text);
+ cursor.insertText(comple_text);
+ cursor.endEditBlock();
+
+ // Position cursor where it was before inserting the completion list:
+ cursor.setPosition(cursorPos);
+ setTextCursor(cursor);
+ }
break;
+ }
case PyInterp_Event::ES_TAB_COMPLETE_ERR:
+ {
// Tab completion was unsuccessful, switch off mode:
_tab_mode = false;
_cursor_pos = -1;
break;
+ }
case PyInterp_Event::ES_OK:
case PyInterp_Event::ES_ERROR:
case PyInterp_Event::ES_INCOMPLETE:
+ {
// Before everything else, call super()
PyConsole_Editor::customEvent(event);
// If we are in multi_paste_mode, process the next item:
multiLineProcessNextLine();
break;
+ }
default:
+ {
PyConsole_Editor::customEvent( event );
break;
+ }
}
}
* @param matches
* @param result
*/
-void PyConsole_EnhEditor::extractCommon(const std::vector<QString> & matches, QString & result) const
+void PyConsole_EnhEditor::extractCommon(const QStringList& matches, QString& result) const
{
result = "";
int charIdx = 0;
#define PYCONSOLE_ENHEDITOR_H_
#include "PyConsole.h"
-
#include "PyConsole_Editor.h"
+
#include <QObject>
#include <queue>
-class PyConsole_EnhInterp;
-
/**
* Enhanced Python editor handling tab completion.
*/
Q_OBJECT;
public:
- PyConsole_EnhEditor(PyConsole_EnhInterp * interp, QWidget * parent=0);
+ PyConsole_EnhEditor(PyConsole_Interp* interp, QWidget* parent = 0);
virtual ~PyConsole_EnhEditor() {}
signals:
virtual void handleTab();
virtual void handleBackTab();
virtual void clearCompletion();
- virtual void formatCompletion(const std::vector<QString> & matches, QString & result) const;
+ virtual void formatCompletion(const QStringList& matches, QString& result) const;
virtual QString formatDocHTML(const QString & doc) const;
virtual void multilinePaste(const QString & s);
virtual void multiLineProcessNextLine();
private:
- void extractCommon(const std::vector<QString> & matches, QString & result) const;
+ void extractCommon(const QStringList& matches, QString& result) const;
};
const std::vector<QString> PyConsole_EnhInterp::PYTHON_KEYWORDS = \
std::vector<QString>(tmp_k, tmp_k+sizeof(tmp_k)/sizeof(tmp_k[0]));
+/*!
+ \brief Constructor
+*/
+PyConsole_EnhInterp::PyConsole_EnhInterp()
+ : PyConsole_Interp()
+{
+}
+
+/*!
+ \brief Destructor
+*/
+PyConsole_EnhInterp::~PyConsole_EnhInterp()
+{
+}
+
+QStringList PyConsole_EnhInterp::getLastMatches() const
+{
+ return _last_matches;
+}
+
+QString PyConsole_EnhInterp::getDocStr() const
+{
+ return _doc_str;
+}
+
/*!
\brief Run Python dir() command and saves the result internally in _lastPy
\param dirArgument Python expression to pass to the dir command. The parsing of what the
the user types "a_string_variable.rsp <TAB>", this is "rsp".
\return command exit status - 0 = success
*/
-int PyConsole_EnhInterp::runDirCommand(const QString & dirArgument, const QString & startMatch)
+int PyConsole_EnhInterp::runDirCommand(const QString& dirArgument, const QString& startMatch)
{
int ret;
std::vector<QString> v;
* @return -1 if the call to dir() or the parsing of the result failed, 0 otherwise.
*/
int PyConsole_EnhInterp::runDirAndExtract(const QString& dirArgument,
- const QString & startMatch, std::vector<QString> & result,
- bool discardSwig) const
+ const QString& startMatch,
+ QStringList& result,
+ bool discardSwig) const
{
QRegExp re("^[A-Z].+_[A-Z]+[a-z]+.+$"); // discard SWIG static method, e.g. MEDCouplingUMesh_Blabla
QString command("dir(" + dirArgument + ")");
*/
void PyConsole_EnhInterp::clearCompletion()
{
- _last_matches.resize(0);
- _doc_str = QString("");
+ _last_matches.clear();
+ _doc_str = "";
}
-
-
-
class PYCONSOLE_EXPORT PyConsole_EnhInterp: public PyConsole_Interp
{
public:
- PyConsole_EnhInterp()
- : PyConsole_Interp(), _last_matches(0), _doc_str("")
- {}
+ PyConsole_EnhInterp();
+ virtual ~PyConsole_EnhInterp();
- virtual ~PyConsole_EnhInterp() {}
-
- const std::vector<QString>& getLastMatches() const { return _last_matches; }
- const QString & getDocStr() const { return _doc_str; }
+ virtual QStringList getLastMatches() const;
+ virtual QString getDocStr() const;
virtual int runDirCommand(const QString& dirArgument, const QString& startMatch);
virtual void clearCompletion();
static const std::vector<QString> PYTHON_KEYWORDS;
/** Last computed matches */
- std::vector<QString> _last_matches;
+ QStringList _last_matches;
/** Doc string of the first match - when only one match it will be displayed by the Editor*/
QString _doc_str;
- virtual int runDirAndExtract(const QString& dirArgument, const QString & startMatch,
- std::vector<QString> & result, bool discardSwig=true) const;
-
+ virtual int runDirAndExtract(const QString& dirArgument, const QString& startMatch,
+ QStringList& result, bool discardSwig=true) const;
};
#endif /* PYCONSOLE_ENHINTERP_H_ */
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
// File : PyConsole_Interp.cxx
// Author : Nicolas REJNERI, Adrien BRUNETON
-// Module : SALOME
-//
+
#include "PyConsole_Interp.h"
/*!
Creates new python interpreter.
*/
PyConsole_Interp::PyConsole_Interp(): PyInterp_Interp()
-{}
+{
+}
/*!
\brief Destructor.
Does nothing for the moment.
*/
-PyConsole_Interp::~PyConsole_Interp() { }
+PyConsole_Interp::~PyConsole_Interp()
+{
+}
/*! Sets the variable "__IN_SALOME_GUI_CONSOLE" to True.
* This is not attached to a module (like salome_iapp.IN_SALOME_GUI_CONSOLE)
{
return PyRun_SimpleString("__builtins__.__IN_SALOME_GUI_CONSOLE=False");
}
+
+QStringList PyConsole_Interp::getLastMatches() const
+{
+ return QStringList();
+}
+
+QString PyConsole_Interp::getDocStr() const
+{
+ return QString();
+}
+
+int PyConsole_Interp::runDirCommand(const QString&, const QString& )
+{
+ return 0;
+}
+
+void PyConsole_Interp::clearCompletion()
+{
+}
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
// File : PyConsole_Interp.h
// Author : Nicolas REJNERI, Adrien BRUNETON
-// Module : SALOME
-//
+
#ifndef PYCONSOLE_INTERP_H
#define PYCONSOLE_INTERP_H
#include "PyConsole.h"
+#include "PyInterp_Interp.h" /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
-#include <PyInterp_Interp.h> /// !!! WARNING !!! THIS INCLUDE MUST BE VERY FIRST !!!
+#include <QStringList>
class PYCONSOLE_EXPORT PyConsole_Interp : public PyInterp_Interp
{
virtual int afterRun();
virtual int beforeRun();
+
+ virtual QStringList getLastMatches() const;
+ virtual QString getDocStr() const;
+
+ virtual int runDirCommand(const QString&, const QString&);
+ virtual void clearCompletion();
};
#endif // PYCONSOLE_INTERP_H
// Created on: 3 avr. 2013
#include "PyConsole_Request.h"
-
-#include "PyInterp_Event.h"
+#include "PyConsole_Interp.h"
#include "PyConsole_Event.h"
-#include "PyConsole_EnhInterp.h"
-#include "PyConsole_EnhEditor.h"
+#include "PyInterp_Event.h"
#include <QCoreApplication>
* @param sync
*/
ExecCommand::ExecCommand( PyInterp_Interp* theInterp,
- const QString& theCommand,
- PyConsole_Editor* theListener,
- bool sync )
- : PyInterp_LockRequest( theInterp, theListener, sync ),
- myCommand( theCommand ), myState( PyInterp_Event::ES_OK )
- {}
+ const QString& theCommand,
+ QObject* theListener,
+ bool theSync )
+ : PyInterp_LockRequest( theInterp, theListener, theSync ),
+ myCommand( theCommand ), myState( PyInterp_Event::ES_OK )
+{}
/**
* Execute the command by calling the run() method of the embedded interpreter.
void ExecCommand::execute()
{
if ( myCommand != "" )
- {
- int ret = getInterp()->run( myCommand.toUtf8().data() );
- if ( ret < 0 )
- myState = PyInterp_Event::ES_ERROR;
- else if ( ret > 0 )
- myState = PyInterp_Event::ES_INCOMPLETE;
- }
+ {
+ int ret = getInterp()->run( myCommand.toUtf8().data() );
+ if ( ret < 0 )
+ myState = PyInterp_Event::ES_ERROR;
+ else if ( ret > 0 )
+ myState = PyInterp_Event::ES_INCOMPLETE;
+ }
}
/**
\param theListener widget to get the notification messages
\param sync if True the request is processed synchronously
*/
-CompletionCommand::CompletionCommand( PyConsole_EnhInterp* theInterp,
- const QString& input,
- const QString& startMatch,
- PyConsole_EnhEditor* theListener,
- bool sync)
- : PyInterp_LockRequest( theInterp, theListener, sync ),
- _tabSuccess(false), _dirArg(input), _startMatch(startMatch)
+CompletionCommand::CompletionCommand( PyInterp_Interp* theInterp,
+ const QString& theInput,
+ const QString& theStartMatch,
+ QObject* theListener,
+ bool theSync )
+ : PyInterp_LockRequest( theInterp, theListener, theSync ),
+ _tabSuccess(false), _dirArg(theInput), _startMatch(theStartMatch)
{}
/**
*/
void CompletionCommand::execute()
{
- PyConsole_EnhInterp * interp = static_cast<PyConsole_EnhInterp *>(getInterp());
- int ret = interp->runDirCommand( _dirArg, _startMatch);
- if (ret == 0)
- _tabSuccess = true;
- else
- _tabSuccess = false;
+ int ret = static_cast<PyConsole_Interp*>(getInterp())->runDirCommand( _dirArg, _startMatch );
+ _tabSuccess = ret == 0;
}
/**
QEvent* CompletionCommand::createEvent()
{
int typ = _tabSuccess ? PyInterp_Event::ES_TAB_COMPLETE_OK : PyInterp_Event::ES_TAB_COMPLETE_ERR;
-
return new PyInterp_Event( typ, this);
}
-
-
-
#ifndef PYCONSOLE_REQUEST_H_
#define PYCONSOLE_REQUEST_H_
-#include "PyConsole.h"
#include "PyInterp_Request.h"
#include <vector>
#include <QEvent>
class PyInterp_Interp;
-class PyConsole_Editor;
/*!
\class ExecCommand
*/
ExecCommand( PyInterp_Interp* theInterp,
const QString& theCommand,
- PyConsole_Editor* theListener,
- bool sync = false );
+ QObject* theListener,
+ bool theSync = false );
protected:
/*!
int myState; //!< Python command execution status
};
-class PyConsole_EnhInterp;
-class PyConsole_EnhEditor;
-
class CompletionCommand : public PyInterp_LockRequest
{
public:
- CompletionCommand( PyConsole_EnhInterp* theInterp,
- const QString& input,
- const QString& startMatch,
- PyConsole_EnhEditor* theListener,
- bool sync = false );
+ CompletionCommand( PyInterp_Interp* theInterp,
+ const QString& theInput,
+ const QString& theStartMatch,
+ QObject* theListener,
+ bool theSync = false );
protected:
virtual void execute();
virtual QEvent* createEvent();
-
};
#endif /* PYCONSOLE_REQUEST_H_ */
if ( isClosed() )
r += createRegion( myPoints.last(), myPoints.first() );
- setMask( r );
-
+ if ( !r.isEmpty() )
+ setMask( r );
}
//#include "SALOMEDSClient.hxx"
//#include "SALOMEDS_StudyManager.hxx"
-#include <Basics_OCCTVersion.hxx>
#include <AIS_TypeOfIso.hxx>
#include <Precision.hxx>
</message>
<message>
<source>DSC_SVTK_SCALING</source>
- <translation>Scaling</translation>
+ <translation>Change scale of axes</translation>
</message>
<message>
<source>MNU_SVTK_SCALING</source>
<source>LBL_Z</source>
<translation>Z:</translation>
</message>
- <message>
- <source>MEN_SCALING</source>
- <translation>Scaling</translation>
- </message>
<message>
<source>DLG_TITLE</source>
<translation>Scaling</translation>
</message>
<message>
<source>DSC_SVTK_SCALING</source>
- <translation>Mise à l'échelle</translation>
+ <translation>Changer l'échelle des axes de coordonnées</translation>
</message>
<message>
<source>MNU_SVTK_SCALING</source>
<source>LBL_Z</source>
<translation>Z:</translation>
</message>
- <message>
- <source>MEN_SCALING</source>
- <translation>Echelle</translation>
- </message>
<message>
<source>DLG_TITLE</source>
<translation>Mise à l'échelle</translation>
</message>
<message>
<source>DSC_SVTK_SCALING</source>
- <translation>スケーリング</translation>
+ <translation>座標のスケールの軸を変更します。</translation>
</message>
<message>
<source>MNU_SVTK_SCALING</source>
<source>LBL_Z</source>
<translation>Z:</translation>
</message>
- <message>
- <source>MEN_SCALING</source>
- <translation>スケール</translation>
- </message>
<message>
<source>DLG_TITLE</source>
<translation>スケーリング</translation>
if ( a )
a->setEnabled( false );
}
+ else if ( message.toLower() == "connect_to_study" ) {
+ onLoadDoc();
+ }
LightApp_Application::onDesktopMessage( message );
}
#ifndef DISABLE_PYCONSOLE
else if ( flag == WT_PyConsole )
{
- PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), new SalomeApp_PyInterp() );
+ PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() );
pyCons->setObjectName( "pythonConsole" );
pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" ));
}
return result;
}
+
+
+#ifndef DISABLE_PYCONSOLE
+
+PyConsole_Interp* SalomeApp_Application::createPyInterp()
+{
+ return new SalomeApp_PyInterp();
+}
+
+#endif // DISABLE_PYCONSOLE
#ifndef DISABLE_PYCONSOLE
bool updateStudy();
+ virtual PyConsole_Interp* createPyInterp();
#endif
virtual void afterCloseDoc();
#ifndef DISABLE_PYCONSOLE
#include <PyConsole_Interp.h> // this include must be first (see PyInterp_base.h)!
- #include <PyConsole_Console.h>
#endif
#include "SalomeApp_DoubleSpinBox.h"
if( studyDS->IsString( aName ) )
{
#ifndef DISABLE_PYCONSOLE
- PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
PyLockWrapper aLock; // Acquire GIL
std::string command;
command = "import salome_notebook ; ";
#include "Utils_CorbaException.hxx"
#include "CASCatch.hxx"
-#include "Basics_OCCTVersion.hxx"
#include <OSD.hxx>
#ifndef DISABLE_PYCONSOLE
#include <PyConsole_Interp.h> //this include must be first (see PyInterp_base.h)!
- #include <PyConsole_Console.h>
#endif
#include "SalomeApp_IntSpinBox.h"
if( studyDS->IsString( aName ) )
{
#ifndef DISABLE_PYCONSOLE
- PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
PyLockWrapper aLock; // Acquire GIL
std::string command;
command = "import salome_notebook ; ";
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
PyLockWrapper aLock; // Acquire GIL
std::string command = "import salome_notebook ; ";
command += "salome_notebook.checkThisNoteBook(";
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
PyConsole_Console* pyConsole = app->pythonConsole();
- PyConsole_Interp* pyInterp = pyConsole->getInterp();
+ PyConsole_Interp* pyInterp = app->getPyInterp();
PyLockWrapper aLock; // Acquire GIL
std::string command = "import salome_notebook ; ";
command += "salome_notebook.checkThisNoteBook(";
class SalomeApp_PyInterp : public PyConsole_EnhInterp
{
+ friend class SalomeApp_Application;
+
public:
- SalomeApp_PyInterp();
virtual ~SalomeApp_PyInterp();
virtual void initPython();
virtual void closeContext();
protected:
+ SalomeApp_PyInterp();
virtual int beforeRun();
private:
#ifndef DISABLE_PYCONSOLE
#include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
- #include <PyConsole_Console.h>
#endif
#include "utilities.h"
desk->blockSignals( isBlocked );
#ifndef DISABLE_PYCONSOLE
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
- if( app->pythonConsole() )
- app->pythonConsole()->getInterp()->destroy();
+ app->getPyInterp()->destroy();
#endif
}
SALOMEDSClient_Study* aStudy = 0;
#include <SALOME_LifeCycleCORBA.hxx>
#include <SALOME_Event.h>
-#include <Basics_OCCTVersion.hxx>
-
#include <Container_init_python.hxx>
#include <ConnectionManager_i.hxx>
#include <RegistryService.hxx>
//when creating the root item).
if ( parent != NULL ) {
this->associateToModel(parent->associatedModel());
- }
+ }
}
TreeItem::~TreeItem()
folder = new TreeItem(folderNameId, folderColumnValues, this);
this->appendChild(folder);
}
-
+
// We create the relative path of the next iteration (delete the
// first folder path).
QStringList nextRelativePath;
for (int i = 1; i < relativePath.size(); ++i)
nextRelativePath << relativePath[i];
-
+
folder->appendChild(nameId, columnValues, nextRelativePath);
}
model->endInsertRows();
}
+/*!
+ * This removes the specified child to this item. This item is the
+ * direct parent of the specified child.
+ */
+void TreeItem::removeChild(TreeItem *item)
+{
+ TreeModel * model = this->associatedModel();
+
+ int position = this->childCount();
+ model->beginRemoveRows(this->modelIndex(), position, position);
+ _childItems.removeOne(item);
+ _childItemsMapById.remove(item->nameId());
+ _childItemsMapByLabel.remove(item->data(0).toString());
+ model->endRemoveRows();
+}
+
+void TreeItem::removeChild(DataObject * dataObject, const QStringList &relativePath) {
+ if ( relativePath.isEmpty() ) {
+ // It is a direct child => just remove it.
+ QString nameId = QString(dataObject->getNameId().c_str());
+ TreeItem * child = this->childById(nameId);
+ if (child != NULL)
+ this->removeChild(child);
+ return;
+ }
+
+ // The child is embedded in a sub-folder.
+ // We first check if the sub-folder already exist:
+ TreeItem * folder = this->childByLabel(relativePath[0]);
+ if ( folder == NULL )
+ return;
+
+ // Go down into subfolder, if any.
+ QStringList nextRelativePath;
+ for (int i = 1; i < relativePath.size(); ++i)
+ nextRelativePath << relativePath[i];
+
+ folder->removeChild(dataObject, nextRelativePath);
+
+ if (folder->childCount() == 0)
+ this->removeChild(folder);
+}
+
/*!
* The child() function returns the child that corresponds to the
* specified row number in the item's list of child items.
const QVector<QVariant> &columnValues,
const QStringList &relativePath=QStringList());
-
-
+ void removeChild(TreeItem * child);
+ void removeChild(DataObject * dataObject,
+ const QStringList &relativePath=QStringList());
+
TreeItem *child(int row);
TreeItem *childById(const QString &nameId);
TreeItem *childByLabel(const QString &label);
QVariant data(int column) const;
bool setData(int column, const QVariant &value);
-
private:
void initialize(const QString &nameId,
const QVector<QVariant> &columnValues,
// This part is a specific behavior to get a TreeModel that can
// organize itself the tree hierarchy using data provided in a
// filesystem-like format:
-//
+//
// data="a/b/c" ==> creation/filling of the hierarchy a->b->c
// The "folder" categories are unique whereas the leaves may exists
// in multiple instances.
rootItem->appendChild(dataObject, path);
return true;
}
+
+bool TreeModel::removeData(DataObject * dataObject) {
+ QStringList path = QString(dataObject->getPath().c_str()).split(DataObject::pathsep.c_str());
+ TreeItem * rootItem = this->getItem();
+ rootItem->removeChild(dataObject, path);
+ return true;
+}
// This part is a specific behavior to get a TreeModel that can
// organize itself the tree hierarchy using data provided in a
// filesystem-like format:
- //
+ //
// data="a/b/c" ==> creation/filling of the hierarchy a->b->c
// The "folder" categories are unique whereas the leaves may exists
// in multiple instances.
bool addData(DataObject * dataObject, const QStringList &path);
// TODO: We should implement the delete and the update fucntions
+ bool removeData(DataObject * dataObject);
// This part contains helper functions for general purposes
TreeItem * getRootItem();