CMAKE_DEPENDENT_OPTION(SALOME_USE_SALOMEOBJECT "Enable Salome Object (Mandatory in classic configurations)" ON
"SALOME_LIGHT_ONLY" ON)
-OPTION(SALOME_USE_SINGLE_DESKTOP "Enable multiple document interface" ON)
MARK_AS_ADVANCED(SALOME_LIGHT_ONLY SALOME_USE_VTKVIEWER SALOME_USE_GRAPHICSVIEW SALOME_USE_PVVIEWER)
MARK_AS_ADVANCED(SALOME_USE_SALOMEOBJECT SALOME_USE_OCCVIEWER SALOME_USE_GLVIEWER SALOME_USE_PLOT2DVIEWER)
MARK_AS_ADVANCED(SALOME_USE_PYCONSOLE SALOME_USE_QXGRAPHVIEWER SALOME_USE_PYVIEWER)
-MARK_AS_ADVANCED(SALOME_USE_SINGLE_DESKTOP)
# Prerequisites
# =============
ADD_DEFINITIONS(-DWITH_SALOMEDS_OBSERVER)
ENDIF()
-# Single-study GUI
-IF(SALOME_USE_SINGLE_DESKTOP)
- ADD_DEFINITIONS(-DSINGLE_DESKTOP)
-ENDIF()
-
# OCCT
FIND_PACKAGE(SalomeCAS REQUIRED)
SET(SALOME_USE_PYVIEWER @SALOME_USE_PYVIEWER@)
SET(SALOME_USE_PYCONSOLE @SALOME_USE_PYCONSOLE@)
SET(SALOME_USE_SALOMEOBJECT @SALOME_USE_SALOMEOBJECT@)
-SET(SALOME_USE_SINGLE_DESKTOP @SALOME_USE_SINGLE_DESKTOP@)
SET(SALOME_GUI_USE_OBSERVERS @SALOME_GUI_USE_OBSERVERS@)
SET(SALOME_GUI_USE_OPENGL2 @SALOME_GUI_USE_OPENGL2@)
IF(SALOME_GUI_LIGHT_ONLY)
LIST(APPEND GUI_DEFINITIONS "-DGUI_DISABLE_CORBA")
ENDIF()
-IF(SALOME_USE_SINGLE_DESKTOP)
- LIST(APPEND GUI_DEFINITIONS "-DSINGLE_DESKTOP")
-ENDIF()
IF(SALOME_GUI_USE_OBSERVERS)
LIST(APPEND GUI_DEFINITIONS "-DWITH_SALOMEDS_OBSERVER")
ENDIF()
useCaseBuilder->UnRegister();
\endcode
-\section use_case_compatibility Remark about compatibility with existing studies
+\section use_case_compatibility Remark about compatibility with existing study
If you decide to switch your module to the use case builder approach to provide
customization for the data tree representation, you must take care of compatibility
with existing SALOME studies. Basically it means that you have to add
-a simple code to \c Load() (and \c LoadASCII() if necessary) method
+a simple code to \c Load() method
of your module, which adds tree node attributes to all data entities
in the data tree of your module. The simplest way to do
this is to iterate through all data items and recursively add them to
{
if ( CORBA::is_nil( where ) ) return; // bad parent
- SALOMEDS::Study_var study = where->GetStudy(); // study
+ SALOMEDS::Study_var study = GUI::getStudyServant(); // study
SALOMEDS::StudyBuilder_var studyBuilder = study->NewBuilder(); // study builder
SALOMEDS::UseCaseBuilder_var useCaseBuilder = study->GetUseCaseBuilder(); // use case builder
SALOMEDS::SComponent_var father = where->GetFatherComponent(); // father component
The example of usage:
\code
# update Object browser contents
-salome.sg.updateObjBrowser(True)
-
-# get the active study ID
-studyId = salome.sg.getActiveStudyId()
+salome.sg.updateObjBrowser()
# get the active study name
studyName = salome.sg.getActiveStudyName()
import salome
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
# Create the objects
Vx = geompy.MakeVectorDXDYDZ(10, 0, 0)
def trihedron(context):
import GEOM
from salome.geom import geomBuilder
- geompy = geomBuilder.New(salome.myStudy)
+ geompy = geomBuilder.New()
# Intialize the geompy factory with the active study
activeStudy = context.study
- geompy.init_geom(activeStudy)
+ geompy.init_geom()
# Create the objects
Vx = geompy.MakeVectorDXDYDZ(10, 0, 0)
Vy = geompy.MakeVectorDXDYDZ(0, 10, 0)
{
CAM_DataModel* dm = (CAM_DataModel*)dModel;
- if ( isSaved() ) // need to load data model from an exisitng file?
+ if ( isSaved() ) // need to load data model from an existing file?
openDataModel( studyName(), dm );
else // no, just need to update data model's connection to study tree
//(some application may want to show model's root in a study tree even if a model is empty)
import libSALOME_Swig
SalomeGUI = libSALOME_Swig.SALOMEGUI_Swig()
-#
-# ==================================================================
-# General helper function for GUI programming actions
-# ==================================================================
-#
-# Get the active study
-#
-def getActiveStudy():
- """
- This returns a study object that corresponds to the active
- study. The active study is a GUI concept: it's the study currently
- active on the desktop.
- """
- studyId = sgPyQt.getStudyId()
- study = services.getStudyManager().GetStudyByID( studyId )
- return study
-
#
# ==================================================================
# Functions to manipulate the objects in the browser (generic)
'''
sobj = None
entry = None
- study = getActiveStudy()
+ study = salome.myStudy
if SalomeGUI.SelectedCount() == 1:
# We only considere the first element of the list. If you need
# something else, create another function in your own context.
'''
sobj, entry = getSObjectSelected()
if ( sobj ):
- study = getActiveStudy()
+ study = salome.myStudy
builder = study.NewBuilder()
builder.RemoveObject( sobj )
- SalomeGUI.updateObjBrowser(True)
+ SalomeGUI.updateObjBrowser()
pass
#
#
# Definitions:
-# - the SObject is an item in the active study (Study Object).
+# - the SObject is an item in the study (Study Object).
# - the entry is the identifier of an item.
# - the object (geom object or smesh object) is a CORBA servant
# embedded in the SALOME component container and with a reference in
// Author: Guillaume Boulant (EDF/R&D)
#include "SALOME_AppStudyEditor.hxx"
+#include "SALOME_GuiServices.hxx"
#include <SalomeApp_Study.h>
#include <SALOME_ListIO.hxx>
: SALOME_StudyEditor()
{
_salomeApp = salomeApp;
- updateActiveStudy();
-}
-
-/**
- * This updates the editor with the current active study. If the
- * active study id is identical to the study id currently associated
- * to this object, then no update is performed.
- */
-int SALOME_AppStudyEditor::updateActiveStudy() {
- int activeStudyId = SALOME_AppStudyEditor::getActiveStudyId(_salomeApp);
- if ( activeStudyId != this->getStudyId() ) {
- this->setStudyById(activeStudyId);
- }
- return activeStudyId;
-}
-
-// GUI context only
-int SALOME_AppStudyEditor::getActiveStudyId(SalomeApp_Application * salomeApp) {
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*> (salomeApp->activeStudy());
- _PTR(Study) aCStudy = appStudy->studyDS();
- int studyId = aCStudy->StudyId();
- return studyId;
}
SALOMEDS::SObject_ptr SALOME_AppStudyEditor::IObjectToSObject(const Handle(SALOME_InteractiveObject)& iobject) {
if (!iobject.IsNull()) {
if (iobject->hasEntry()) {
- SALOMEDS::SObject_var sobject = _study->FindObjectID(iobject->getEntry());
+ SALOMEDS::SObject_var sobject = GUI::getStudyServant()->FindObjectID(iobject->getEntry());
return sobject._retn();
}
}
class SALOMEGUIHELPERS_EXPORT SALOME_AppStudyEditor: public SALOME_StudyEditor {
public:
SALOME_AppStudyEditor(SalomeApp_Application * salomeApp);
- int updateActiveStudy();
SALOMEDS::SObject_ptr IObjectToSObject(const Handle(SALOME_InteractiveObject)& iobject);
SALOME_StudyEditor::SObjectList * getSelectedObjects();
- static int getActiveStudyId(SalomeApp_Application * salomeApp);
-
private:
SalomeApp_Application * _salomeApp;
// SALOME application using the resourceMgr() method:
//
- /**
- * This returns the current active study id if an active study is
- * defined in the SALOME session, returns -1 otherwise. Note that
- * the active study doesn't make sense outside of the GUI SALOME
- * process, i.e. the SALOME_SessionServer embedding the
- * SalomeApp_Application.
- */
- int getActiveStudyId() {
- SALOME::Session_var aSession = KERNEL::getSalomeSession();
- if ( CORBA::is_nil(aSession) ) {
- INFOS("ERR: can't request for active study because the session is NULL");
- return -1;
- }
- return aSession->GetActiveStudyId();
- }
-
/**
* This returns the current active study if an active study is
* defined in the SALOME session, returns null otherwise.
*/
- SALOMEDS::Study_ptr getActiveStudy() {
- return KERNEL::getStudyById(getActiveStudyId());
+ SALOMEDS::Study_ptr getStudyServant() {
+ return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
}
-
// __GBO__ Question: what is the difference between a
// SALOMEDS::Study and a SalomeApp_Study?
SalomeApp_Study* getSalomeAppActiveStudy() {
// retrieve the SALOMEDS::Study servant first and the to
// request this servant to get the SObject given its entry.
//
- _PTR(Study) studyClient = appStudy->studyDS();
- SALOMEDS::Study_var study = KERNEL::getStudyManager()->GetStudyByID(studyClient->StudyId());
- SALOMEDS::SObject_ptr sobject = study->FindObjectID(iobject->getEntry());
+ SALOMEDS::SObject_ptr sobject = KERNEL::getStudyServant()->FindObjectID(iobject->getEntry());
return sobject;
}
}
// depends of the SALOME module technical choices). In general, on
// of the attribute of a SObject is a CORBA servant that handles the
// data to work with
- SALOMEGUIHELPERS_EXPORT SALOMEDS::Study_ptr getActiveStudy();
- SALOMEGUIHELPERS_EXPORT int getActiveStudyId();
+ SALOMEGUIHELPERS_EXPORT SALOMEDS::Study_ptr getStudyServant();
// Another way to get the active study (to be converted in
// SALOMEDS::Study):
#include "StandardApp_Module.hxx"
+#include "SALOME_GuiServices.hxx"
+
#include <SUIT_Desktop.h>
#include <SUIT_Study.h>
#include <SalomeApp_Application.h>
setToolShown( true );
if ( this->createStudyComponentAtActivation() ) {
- this->createStudyComponent(theStudy);
+ this->createStudyComponent();
}
return bOk;
* the module. This component is associated to the engine (return by
* getEngine()) if the engine is a SALOMEDS::Driver.
*/
-void StandardApp_Module::createStudyComponent(SUIT_Study* theStudy) {
+void StandardApp_Module::createStudyComponent() {
- SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
- CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
- SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(theStudy->id());
+ SALOMEDS::Study_var aDSStudy = GUI::getStudyServant();
SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent(QCHARSTAR(moduleName()));
if (aFather->_is_nil())
virtual void createModuleActions();
/* Use this to create a root entry in the study for this module */
- void createStudyComponent(SUIT_Study*);
+ void createStudyComponent();
/* Implement this to say if study component entry should be created
at activation step */
virtual bool createStudyComponentAtActivation();
"....................",
"...................."};
-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.
}
}
-/*!
- \return last global id of study
-*/
-int LightApp_Application::studyId()
-{
- return LightApp_Application::lastStudyId;
-}
-
/*!Create new instance of LightApp_Application.*/
extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
{
desktop()->statusBar()->showMessage( "" );
LightApp_EventFilter::Init();
+
+ onNewDoc();
}
/*!Closeapplication.*/
*/
void LightApp_Application::onNewDoc()
{
-#ifdef SINGLE_DESKTOP
if ( !checkExistingDoc() )
return;
-#endif
//asl: fix for 0020515
saveDockWindowsState();
{
SUIT_Study* study = activeStudy();
-#ifdef SINGLE_DESKTOP
if ( !checkExistingDoc() )
return;
-#endif
CAM_Application::onOpenDoc();
*/
bool LightApp_Application::onOpenDoc( const QString& aName )
{
-#ifdef SINGLE_DESKTOP
if ( !checkExistingDoc() )
return false;
-#endif
saveDockWindowsState();
/*!
Gets window.
\param flag - key for window
- \param studyId - study id
Flag used how identificator of window in windows list.
*/
-QWidget* LightApp_Application::getWindow( const int flag, const int )
+QWidget* LightApp_Application::getWindow( const int flag)
{
QWidget* wid = dockWindow( flag );
if ( !wid )
*/
SUIT_Study* LightApp_Application::createNewStudy()
{
- LightApp_Application::lastStudyId++;
-
LightApp_Study* aStudy = new LightApp_Study( this );
// Set up processing of major study-related events
{
bool result = true;
if( activeStudy() ) {
- int answer = SUIT_MessageBox::question( desktop(),
- tr( "APPCLOSE_CAPTION" ),
- tr( "STUDYCLOSE_DESCRIPTION" ),
- tr( "APPCLOSE_SAVE" ),
- tr( "APPCLOSE_CLOSE" ),
- tr( "APPCLOSE_CANCEL" ), 0 );
+ int answer = !activeStudy()->isModified() ? 1 :
+ SUIT_MessageBox::question( desktop(),
+ tr( "APPCLOSE_CAPTION" ),
+ tr( "STUDYCLOSE_DESCRIPTION" ),
+ tr( "APPCLOSE_SAVE" ),
+ tr( "APPCLOSE_CLOSE" ),
+ tr( "APPCLOSE_CANCEL" ), 0 );
if(answer == 0) {
if ( activeStudy()->isSaved() ) {
onSaveDoc();
closeDoc( false );
} else if ( onSaveAsDoc() ) {
- if( !closeDoc( false ) ) {
- result = false;
+ if( !closeDoc( false ) ) {
+ result = false;
}
} else {
result = false;
virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w );
virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* );
- QWidget* getWindow( const int, const int = -1 );
+ QWidget* getWindow( const int );
QWidget* dockWindow( const int ) const;
void removeDockWindow( const int );
void insertDockWindow( const int, QWidget* );
void setDefaultStudyName( const QString& theName );
- static int studyId();
-
virtual bool event( QEvent* );
virtual bool checkDataObject( LightApp_DataObject* theObj );
virtual void onWindowActivated( SUIT_ViewWindow* theViewWindow );
void onNewWindow();
- void onModuleActivation( const QString& );
+ virtual void onModuleActivation( const QString& );
void onCloseView( SUIT_ViewManager* );
virtual void onStudyCreated( SUIT_Study* );
static LightApp_Preferences* _prefs_;
- static int lastStudyId;
QStringList myUserWmTypes;
};
*/
bool LightApp_Study::createDocument( const QString& theStr )
{
- setStudyName( QString( "Study%1" ).arg( LightApp_Application::studyId() ) );
-
// create myRoot
setRoot( new LightApp_RootObject( this ) );
</message>
<message>
<source>STUDYCLOSE_DESCRIPTION</source>
- <translation>You already have an active study in your session. It has to be closed before working with another study.</translation>
+ <translation>The current study has unsaved changes. Would you like to save before closing it?</translation>
</message>
<message>
<source>APPCLOSE_SAVE</source>
- <translation>&Save && Close</translation>
+ <translation>&Yes</translation>
</message>
<message>
<source>APPCLOSE_CLOSE</source>
- <translation>Close &w/o saving</translation>
+ <translation>&No</translation>
</message>
<message>
<source>APPCLOSE_CANCEL</source>
</message>
<message>
<source>STUDYCLOSE_DESCRIPTION</source>
- <translation>Une étude est déjà ouverte. Elle doit être fermée avant d'en ouvrir une autre.</translation>
+ <translation>Une étude a des modifications non enregistrées. Voulez-vous les sauvegarder avant de fermer?</translation>
</message>
<message>
<source>APPCLOSE_SAVE</source>
- <translation>&Sauvegarder && Fermer</translation>
+ <translation>&Oui</translation>
</message>
<message>
<source>APPCLOSE_CLOSE</source>
- <translation>&Fermer sans sauvegarder</translation>
+ <translation>&Non</translation>
</message>
<message>
<source>APPCLOSE_CANCEL</source>
</message>
<message>
<source>STUDYCLOSE_DESCRIPTION</source>
- <translation>既存のスタディを閉じる必要があります。閉じますか?
-</translation>
+ <translation type="unfinished">The current study has unsaved changes. Would you like to save before closing it?</translation>
</message>
<message>
<source>APPCLOSE_SAVE</source>
- <translation>保存して閉じる(&S)</translation>
+ <translation>はい(&Y)</translation>
</message>
<message>
<source>APPCLOSE_CLOSE</source>
- <translation>保存せずに閉じる(&C)</translation>
+ <translation>いいえ(&N)</translation>
</message>
<message>
<source>APPCLOSE_CANCEL</source>
SALOME GUI modules.
*/
-PyModuleHelper::InterpMap PyModuleHelper::myInterpMap;
LightApp_Module* PyModuleHelper::myInitModule = 0;
/*!
/*!
\brief Initialize python subinterpreter (one per study).
\internal
- \param studyId study ID
*/
-void PyModuleHelper::initInterp( int studyId )
+void PyModuleHelper::initInterp()
{
FuncMsg fmsg( "--- PyModuleHelper::initInterp()" );
- // check study Id
- if ( !studyId ) {
- // Error! Study Id must not be 0!
- myInterp = 0;
- return;
- }
-
QMutexLocker ml( &myInitMutex );
- // try to find the subinterpreter
- if ( myInterpMap.contains( studyId ) ) {
- // found!
- myInterp = myInterpMap[ studyId ];
- return;
- }
-
myInterp = new SALOME_PYQT_PyInterp();
myInterp->initialize();
- myInterpMap[ studyId ] = myInterp;
#ifndef GUI_DISABLE_CORBA
if ( !SUIT_PYTHON::initialized ) {
}
// ... then call a method
int embedded = 1;
- PyObjWrapper aRes( PyObject_CallMethod( aMod, (char*)"salome_init", (char*)"ii", studyId, embedded ) );
+ PyObjWrapper aRes( PyObject_CallMethod( aMod, (char*)"salome_init", (char*)"i", embedded ) );
if ( !aRes ) {
// Error!
PyErr_Print();
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( app->activeStudy() );
if ( !aStudy )
return;
- int aStudyId = aStudy ? aStudy->id() : 0;
// initialize Python subinterpreter (on per study) and put it in <myInterp> variable
- initInterp( aStudyId );
+ initInterp();
if ( !myInterp )
return; // Error
// get study Id
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( study );
- int aStudyId = aStudy ? aStudy->id() : 0;
+ if ( !aStudy )
+ return;
// initialize Python subinterpreter (on per study) and put it in <myInterp> variable
- initInterp( aStudyId );
+ initInterp();
if ( !myInterp ) {
myLastActivateStatus = false;
return; // Error
// get study Id
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( study );
- int aStudyId = aStudy ? aStudy->id() : 0;
+ if ( !aStudy )
+ return;
// initialize Python subinterpreter (on per study) and put it in <myInterp> variable
- initInterp( aStudyId );
+ initInterp();
if ( !myInterp ) {
myLastActivateStatus = false;
return; // Error
// Get study Id
// get study Id
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( theStudy );
- int aStudyId = aStudy ? aStudy->id() : 0;
+ if ( !aStudy )
+ return;
// check that Python subinterpreter is initialized and Python module is imported
if ( !myInterp || !myPyModule ) {
}
// then call Python module's deactivate() method
if ( PyObject_HasAttrString( myPyModule , (char*)"closeStudy" ) ) {
- PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"closeStudy", (char*)"i", aStudyId ) );
+ PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"closeStudy", (char*)"i" ) );
if( !res ) {
PyErr_Print();
}
// get study Id
LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( study );
- int id = aStudy ? aStudy->id() : 0;
-
- fmsg.message( QString( "study id = %1" ).arg( id ) );
+ if ( !aStudy )
+ return;
// initialize Python subinterpreter (on per study) and put it in <myInterp> variable
- initInterp( id );
+ initInterp();
if ( !myInterp )
return; // Error
// call Python module's activeStudyChanged() method
if ( PyObject_HasAttrString( myPyModule, (char*)"activeStudyChanged" ) ) {
- PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"activeStudyChanged", (char*)"i", id ) );
+ PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"activeStudyChanged", (char*)"i" ) );
if( !res ) {
PyErr_Print();
}
class XmlHandler;
class InitLocker;
- typedef QMap<int, PyInterp_Interp*> InterpMap;
-
- static InterpMap myInterpMap; //!< study to Python subinterpreter map
static LightApp_Module* myInitModule; //!< Python GUI being initialized (not zero only during the initialization)
LightApp_Module* myModule; //!< GUI module
void onObjectBrowserClicked(SUIT_DataObject*, int);
private:
- void initInterp( int );
+ void initInterp();
void importModule();
void setWorkSpace();
return ProcessEvent( new TGetObjectBrowserEvent() );
}
-/*!
- \fn int SalomePyQt::getStudyId();
- \brief Get active study's identifier.
- \return active study ID or 0 if there is no active study
-*/
-
-class TGetStudyIdEvent: public SALOME_Event
-{
-public:
- typedef int TResult;
- TResult myResult;
- TGetStudyIdEvent() : myResult( 0 ) {}
- virtual void Execute()
- {
- if ( LightApp_Study* aStudy = getActiveStudy() ) {
- myResult = aStudy->id();
- }
- }
-};
-int SalomePyQt::getStudyId()
-{
- return ProcessEvent( new TGetStudyIdEvent() );
-}
-
/*!
\fn SALOME_Selection* SalomePyQt::getSelection();
\brief Get the selection object for the current study.
}
/*!
- \brief Update an Object Browser of the specified (by identifier) study.
-
- If \a studyId <= 0 the active study's object browser is updated.
- The \a updateSelection parameter is obsolete and currently is not used.
- This parameter will be removed in future, so try to avoid its usage in
- your code.
-
- \brief studyId study identifier
- \brief updateSelection update selection flag (not used)
- \sa getActiveStudy()
+ \brief Update an Object Browser of the study.
*/
-void SalomePyQt::updateObjBrowser( const int studyId, bool updateSelection )
+void SalomePyQt::updateObjBrowser()
{
class TEvent: public SALOME_Event
{
- int myStudyId;
- bool myUpdateSelection;
public:
- TEvent( const int studyId, bool updateSelection )
- : myStudyId( studyId ), myUpdateSelection( updateSelection ) {}
+ TEvent() {}
virtual void Execute()
{
if ( SUIT_Session::session() ) {
- if ( getActiveStudy() && myStudyId <= 0 )
- myStudyId = getActiveStudy()->id();
- if ( myStudyId > 0 ) {
+ if ( getActiveStudy() ) {
QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
QList<SUIT_Application*>::Iterator it;
for( it = apps.begin(); it != apps.end(); ++it ) {
LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( *it );
- if ( anApp && anApp->activeStudy() && anApp->activeStudy()->id() == myStudyId ) {
+ if ( anApp && anApp->activeStudy() ) {
anApp->updateObjectBrowser();
return;
}
}
}
};
- ProcessVoidEvent( new TEvent( studyId, updateSelection ) );
+ ProcessVoidEvent( new TEvent() );
}
static void disableSelector();
static SALOME_Selection* getSelection();
static void setSelection( const QStringList& );
- static int getStudyId();
static void putInfo( const QString&, const int = 0 );
static const QString getActiveComponent();
static PyObject* getActivePythonModule();
static bool activateModule( const QString& );
- static void updateObjBrowser( const int = 0, bool = true );
+ static void updateObjBrowser();
static bool isModified();
static void setModified( bool );
static void enableSelector() /ReleaseGIL/ ;
static void disableSelector() /ReleaseGIL/ ;
static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ;
- static void setSelection( const QStringList& ) /ReleaseGIL/ ;
- static int getStudyId() /ReleaseGIL/ ;
static void putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ;
static const QString getActiveComponent() /ReleaseGIL/ ;
static SIP_PYOBJECT getActivePythonModule() /ReleaseGIL/ ;
static bool activateModule( const QString& ) /ReleaseGIL/ ;
- static void updateObjBrowser( const int = 0, bool = true ) /ReleaseGIL/ ;
+ static void updateObjBrowser() /ReleaseGIL/ ;
static bool isModified() /ReleaseGIL/ ;
static void setModified( bool ) /ReleaseGIL/ ;
This module provides an access to the SALOME GUI implementing set of functions
which can be used from Python. This module is implemented using SWIG wrappings
for some GUI functionality:
- - getActiveStudyId(), getActiveStudyName() : get active study identifier and name
+ - getActiveStudyName() : get active study name
- updateObjBrowser() : update contents of the Object Browser
- SelectedCount() : get number of currently selected items
- getSelected() : get entry of the speicified selected item
/*!
\brief Update active study's Object Browser.
- \param updateSelection this parameter is obsolete
*/
-void SALOMEGUI_Swig::updateObjBrowser( bool /*updateSelection*/ )
+void SALOMEGUI_Swig::updateObjBrowser()
{
class TEvent: public SALOME_Event
{
ProcessVoidEvent( new TEvent() );
}
-/*!
- \fn int SALOMEGUI_Swig::getActiveStudyId()
- \brief Get active study identifier
- \return active study's ID or 0 if there is no active study
-*/
-
-class TGetActiveStudyIdEvent: public SALOME_Event
-{
-public:
- typedef int TResult;
- TResult myResult;
- TGetActiveStudyIdEvent() : myResult( 0 ) {}
- virtual void Execute()
- {
- if ( LightApp_Study* aStudy = getActiveStudy() ) {
- myResult = aStudy->id();
- }
- }
-};
-int SALOMEGUI_Swig::getActiveStudyId()
-{
- return ProcessEvent( new TGetActiveStudyIdEvent() );
-}
-
/*!
\fn const char* SALOMEGUI_Swig::getActiveStudyName()
\brief Get active study name
bool hasDesktop();
- void updateObjBrowser( bool );
+ void updateObjBrowser();
- int getActiveStudyId();
const char* getActiveStudyName();
const char* getComponentName( const char* );
bool hasDesktop();
/* update object browser*/
- void updateObjBrowser(bool);
+ void updateObjBrowser();
/* get active study */
- int getActiveStudyId();
const char *getActiveStudyName();
/* get component name/username */
ARealTable.SetTitle("Very useful data")
# >>> Updating Object Browser ================================================
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# ============================================================================
myBuilder.Addreference(myRefObject,myObject3);
# >>> Updating Object Browser ================================================
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# ============================================================================
ACmt.SetValue("Just a comment")
# >>> Updating Object Browser ================================================
-salome.sg.updateObjBrowser(True)
+salome.sg.updateObjBrowser()
# ============================================================================
#include <SALOME_InteractiveObject.hxx>
#include <SALOME_ListIO.hxx>
-// Temporarily commented to avoid awful dependecy on SALOMEDS
-// TODO: better mechanism of storing display/erse status in a study
-// should be provided...
-//#include <Utils_ORB_INIT.hxx>
-//#include <Utils_SINGLETON.hxx>
-//#include <SALOME_ModuleCatalog_impl.hxx>
-//#include <SALOME_NamingService.hxx>
-
-//#include "SALOMEDSClient.hxx"
-//#include "SALOMEDS_StudyManager.hxx"
-
#include <AIS_TypeOfIso.hxx>
#include <Precision.hxx>
#include <algorithm>
-// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
-// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from
-// SALOMEDS::StudyManager - no linkage with SalomeApp.
-
-// Temporarily commented to avoid awful dependecy on SALOMEDS
-// TODO: better mechanism of storing display/erse status in a study
-// should be provided...
-//static _PTR(Study) getStudyDS()
-//{
-// SALOMEDSClient_Study* aStudy = NULL;
-// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
-
- // get id of SUIT_Study, if it's a SalomeApp_Study, it will return
- // id of its underlying SALOMEDS::Study
-// SUIT_Application* app = SUIT_Session::session()->activeApplication();
-// if ( !app ) return _PTR(Study)(aStudy);
-// SUIT_Study* stud = app->activeStudy();
-// if ( !stud ) return _PTR(Study)(aStudy);
-// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
- // get SALOMEDS_Study with this id from StudyMgr
-// return aMgr->GetStudyByID( id );
-//}
-
/*!
Constructor
\param DisplayTrihedron - is trihedron displayed
if ( !anOCCPrs || anOCCPrs->IsNull() )
return;
- // get SALOMEDS Study
- // Temporarily commented to avoid awful dependecy on SALOMEDS
- // TODO: better mechanism of storing display/erse status in a study
- // should be provided...
- // _PTR(Study) study(getStudyDS());
-
// get context
Handle (AIS_InteractiveContext) ic = getAISContext();
// Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() );
//if ( !anObj.IsNull() && anObj->hasEntry() )
//{
- // if ( study )
- // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this );
+ // ToolsGUI::SetVisibility( anObj->getEntry(), true, this );
//}
// Deactivate object if necessary
if ( !anOCCPrs || anOCCPrs->IsNull() )
return;
- // get SALOMEDS Study
- // Temporarily commented to avoid awful dependecy on SALOMEDS
- // TODO: better mechanism of storing display/erse status in a study
- // should be provided...
- // _PTR(Study) study(getStudyDS());
-
// get context
Handle(AIS_InteractiveContext) ic = getAISContext();
// Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() );
// if ( !anObj.IsNull() && anObj->hasEntry() )
// {
- // if ( study )
- // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this );
+ // ToolsGUI::SetVisibility( anObj->getEntry(), true, this );
// }
//}
}
*/
void SOCC_Viewer::EraseAll( SALOME_Displayer* d, const bool forced )
{
- // get SALOMEDS Study
- // Temporarily commented to avoid awful dependecy on SALOMEDS
- // TODO: better mechanism of storing display/erse status in a study
- // should be provided...
- // _PTR(Study) study(getStudyDS());
-
// get context
Handle(AIS_InteractiveContext) ic = getAISContext();
// Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() );
// if ( !anObj.IsNull() && anObj->hasEntry() ) {
- // if ( study )
- // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this );
+ // ToolsGUI::SetVisibility( anObj->getEntry(), true, this );
// }
//}
}
#include <qwt_plot_curve.h>
#include <stdlib.h>
-//ASL: Temporary commented in order to avoir dependency on SALOMEDS
-
-//#include "SALOMEDSClient.hxx"
-//#include "SALOMEDS_StudyManager.hxx"
-
-// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
-// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from
-// SALOMEDS::StudyManager - no linkage with SalomeApp.
-
-/*static _PTR(Study) getStudyDS()
-{
- SALOMEDSClient_Study* aStudy = NULL;
- _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
-
- // get id of SUIT_Study, if it's a SalomeApp_Study, it will return
- // id of its underlying SALOMEDS::Study
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( !app ) return _PTR(Study)(aStudy);
- SUIT_Study* stud = app->activeStudy();
- if ( !stud ) return _PTR(Study)(aStudy);
- const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
- // get SALOMEDS_Study with this id from StudyMgr
- return aMgr->GetStudyByID( id );
-} */
-
/*!
Constructor
*/
resMgr->loadPixmap( "STD", tr( "ICON_FILE_NEW" ) ),
tr( "MEN_DESK_FILE_NEW" ), tr( "PRP_DESK_FILE_NEW" ),
Qt::CTRL+Qt::Key_N, desk, false, this, SLOT( onNewDoc() ) );
+ //no need at this action for mono-study application because study is always exists
+ action( FileNewId )->setVisible( false );
createAction( FileOpenId, tr( "TOT_DESK_FILE_OPEN" ),
resMgr->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
// post closing actions
afterCloseDoc();
- int aNbStudies = 0;
- QList<SUIT_Application*> apps = SUIT_Session::session()->applications();
- for ( int i = 0; i < apps.count(); i++ )
- aNbStudies += apps.at( i )->getNbStudies();
-
// reload study from the file
res = useFile( studyName ) && activeStudy();
// if reloading is failed, close the desktop
- if ( aNbStudies && !res )
+ if ( activeStudy() && !res )
closeApplication();
else
{
// VSR: Uncomment below line to allow texture background support in VTK viewer
#define VTK_ENABLE_TEXTURED_BACKGROUND
-
-// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
-// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from
-// SALOMEDS::StudyManager - no linkage with SalomeApp.
-
-// Temporarily commented to avoid awful dependecy on SALOMEDS
-// TODO: better mechanism of storing display/erse status in a study
-// should be provided...
-//static _PTR(Study) getStudyDS()
-//{
-// SALOMEDSClient_Study* aStudy = NULL;
-// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
- // get id of SUIT_Study, if it's a SalomeApp_Study, it will return
- // id of its underlying SALOMEDS::Study
-// SUIT_Application* app = SUIT_Session::session()->activeApplication();
-// if ( !app ) return _PTR(Study)(aStudy);
-// SUIT_Study* stud = app->activeStudy();
-// if ( !stud ) return _PTR(Study)(aStudy);
-// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
- // get SALOMEDS_Study with this id from StudyMgr
-// return aMgr->GetStudyByID( id );
-//}
-
/*!
Constructor
*/
if(aPrs->IsNull())
return;
if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
- // get SALOMEDS Study
- // Temporarily commented to avoid awful dependecy on SALOMEDS
- // TODO: better mechanism of storing display/erse status in a study
- // should be provided...
- // _PTR(Study) aStudy(getStudyDS());
anActorCollection->InitTraversal();
while(vtkActor* anActor = anActorCollection->GetNextActor()){
if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
// TODO: better mechanism of storing display/erse status in a study
// should be provided...
//Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
- //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
- // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this);
+ //if(!anObj.IsNull() && anObj->hasEntry()){
+ // ToolsGUI::SetVisibility(anObj->getEntry(),true,this);
//}
// just display the object
QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
if(aPrs->IsNull())
return;
if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
- // get SALOMEDS Study
- // Temporarily commented to avoid awful dependecy on SALOMEDS
- // TODO: better mechanism of storing display/erase status in a study
- // should be provided...
- //_PTR(Study) aStudy(getStudyDS());
anActorCollection->InitTraversal();
while(vtkActor* anActor = anActorCollection->GetNextActor())
if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
// TODO: better mechanism of storing display/erase status in a study
// should be provided...
//Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
- //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
- // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
+ //if(!anObj.IsNull() && anObj->hasEntry()){
+ // ToolsGUI::SetVisibility(anObj->getEntry(),false,this);
//}
// just display the object
QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
*/
void SVTK_Viewer::EraseAll( SALOME_Displayer* d, const bool forced )
{
- // Temporarily commented to avoid awful dependecy on SALOMEDS
- // TODO: better mechanism of storing display/erse status in a study
- // should be provided...
- //_PTR(Study) aStudy(getStudyDS());
QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
// TODO: better mechanism of storing display/erse status in a study
// should be provided...
//Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
- //if(!anObj.IsNull() && anObj->hasEntry() && aStudy)
- // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
+ //if(!anObj.IsNull() && anObj->hasEntry())
+ // ToolsGUI::SetVisibility(anObj->getEntry(),false,this);
if(forced){
if(SVTK_Renderer* aRnd = aView->GetRenderer())
aRnd->RemoveActor(anAct);
QString hdffile;
QStringList pyfiles;
- QString loadStudy;
for (int i = 1; i < qApp->arguments().size(); i++) {
QRegExp rxs ("--study-hdf=(.+)");
SALOME_EventFilter::Init();
setProperty("open_study_from_command_line", true);
- if ( !hdffile.isEmpty() ) // open hdf file given as parameter
+ if ( !hdffile.isEmpty() ) // open hdf file given as parameter
onOpenDoc( hdffile );
- else if ( pyfiles.count() > 0 ) // create new study
- onNewDoc();
- else if (!loadStudy.isEmpty()) {// load study by name
- if (onLoadDoc(loadStudy))
- updateObjectBrowser(true);
- }
setProperty("open_study_from_command_line", QVariant());
#ifndef DISABLE_PYCONSOLE
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
PyConsole_Console* pyConsole = pythonConsole();
if ( appStudy && pyConsole ) {
- _PTR(Study) aStudy = appStudy->studyDS();
- if ( !aStudy->GetProperties()->IsLocked() ) {
+ if ( !getStudy()->GetProperties()->IsLocked() ) {
// pyfiles[j] is a dictionary: {"/absolute/path/to/script.py": [script_args]}
// Path is absolute, script has .py extension
for (uint j = 0; j < pyfiles.count(); j++ ) {
createAction( ConnectId, tr( "TOT_DESK_CONNECT_STUDY" ), QIcon(),
tr( "MEN_DESK_CONNECT" ), tr( "PRP_DESK_CONNECT" ),
Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
+ //no need at this action for mono-study application because study is always exists
+ action( ConnectId )->setVisible( false );
createAction( DisconnectId, tr( "TOT_DESK_DISCONNECT_STUDY" ), QIcon(),
tr( "MEN_DESK_DISCONNECT" ), tr( "PRP_DESK_DISCONNECT" ),
Qt::CTRL+Qt::Key_U, desk, false, this, SLOT( onUnloadDoc() ) );
+ //no need at this action for mono-study application because study is always exists
+ action( DisconnectId )->setVisible( false );
int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
{
QString studyName;
- std::vector<std::string> List = studyMgr()->GetOpenStudies();
-
// rnv: According to the single-study approach on the server side
// can be only one study. So if it is exists connect to them,
// overwise show warning message: "No active study on the server"
return;
*/
- if(List.size() <= 0) {
+ if(!activeStudy()) {
SUIT_MessageBox::warning( desktop(),
QObject::tr("WRN_WARNING"),
QObject::tr("WRN_NO_STUDY_ON SERV") );
return;
}
- studyName = List[0].c_str();
+ studyName = activeStudy()->studyName();
#ifndef WIN32
// this code replaces marker of windows drive and path become invalid therefore
/*!SLOT. Load document with \a aName.*/
bool SalomeApp_Application::onLoadDoc( const QString& aName )
{
-#ifdef SINGLE_DESKTOP
if ( !LightApp_Application::closeDoc() )
return false;
-#endif
+
bool res = true;
if ( !activeStudy() ) {
// if no study - load in current desktop
/*!SLOT. Parse message for desktop.*/
void SalomeApp_Application::onDesktopMessage( const QString& message )
{
- if (message.indexOf("studyCreated:") == 0) {
- // Enable 'Connect' action
- updateCommandsStatus();
+ if (message.indexOf("studyCreated") == 0) {
+ if (!activeStudy()) {
+ onNewDoc();
+ updateCommandsStatus();
+ }
}
- else if (message.indexOf("studyClosed:") == 0) {
- /* message also contains ID of the closed study,
- but as soon as SALOME is mono-study application for the moment,
- this ID is not needed now.*/
- //long aStudyId = message.section(':', 1).toLong();
+ if (message.indexOf("studyCleared") == 0) {
// Disconnect GUI from active study, because it was closed on DS side.
- closeActiveDoc( false );
- // Disable 'Connect' action
- QAction* a = action( ConnectId );
- if ( a )
- a->setEnabled( false );
+ if (activeStudy()) {
+ closeActiveDoc( false );
+ // Disable 'Connect' action
+ QAction* a = action( ConnectId );
+ if ( a )
+ a->setEnabled( false );
+ }
}
else if ( message.toLower() == "connect_to_study" ) {
onLoadDoc();
}
+ if (message.indexOf("studyNameChanged") == 0) {
+ updateDesktopTitle();
+ }
LightApp_Application::onDesktopMessage( message );
}
+/*!On module activation action.*/
+void SalomeApp_Application::onModuleActivation( const QString& modName )
+{
+ if (!activeStudy() && !modName.isEmpty())
+ getStudy()->Init();
+
+ LightApp_Application::onModuleActivation( modName );
+}
+
/*!SLOT. Copy objects to study maneger from selection maneger..*/
void SalomeApp_Application::onCopy()
{
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
if(study == NULL) return;
- _PTR(Study) stdDS = study->studyDS();
+ _PTR(Study) stdDS = getStudy();
if(!stdDS) return;
SALOME_ListIteratorOfListIO it( list );
{
_PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
try {
- studyMgr()->Copy(so);
+ stdDS->Copy(so);
onSelectionChanged();
}
catch(...) {
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
if(study == NULL) return;
- _PTR(Study) stdDS = study->studyDS();
+ _PTR(Study) stdDS = getStudy();
if(!stdDS) return;
if ( stdDS->GetProperties()->IsLocked() ) {
{
_PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
try {
- studyMgr()->Paste(so);
+ stdDS->Paste(so);
updateObjectBrowser( true );
updateActions(); //SRN: BugID IPAL9377, case 3
}
/*! Check if the study is locked */
void SalomeApp_Application::onCloseDoc( bool ask )
{
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
-
- if (study != NULL) {
- _PTR(Study) stdDS = study->studyDS();
- if(stdDS && stdDS->IsStudyLocked()) {
- if ( SUIT_MessageBox::question( desktop(),
- QObject::tr( "WRN_WARNING" ),
- QObject::tr( "CLOSE_LOCKED_STUDY" ),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::No) == SUIT_MessageBox::No ) return;
+ if(getStudy()->IsStudyLocked()) {
+ if ( SUIT_MessageBox::question( desktop(),
+ QObject::tr( "WRN_WARNING" ),
+ QObject::tr( "CLOSE_LOCKED_STUDY" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::No) == SUIT_MessageBox::No ) return;
- }
}
LightApp_Application::onCloseDoc( ask );
+
+ // reinitialize study to have empty data
+ getStudy()->Init();
}
/*!Sets enable or disable some actions on selection changed.*/
canPaste = m->canPaste();
}
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
- if (study) {
- _PTR(Study) stdDS = study->studyDS();
+ SALOME_ListIteratorOfListIO it ( list );
- if (stdDS) {
- SALOME_ListIteratorOfListIO it ( list );
+ if (it.More() && list.Extent() == 1) {
+ _PTR(SObject) so = getStudy()->FindObjectID(it.Value()->getEntry());
- if (it.More() && list.Extent() == 1) {
- _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
-
- if ( so ) {
- canCopy = canCopy || studyMgr()->CanCopy(so);
- canPaste = canPaste || studyMgr()->CanPaste(so);
- }
- }
+ if ( so ) {
+ canCopy = canCopy || getStudy()->CanCopy(so);
+ canPaste = canPaste || getStudy()->CanPaste(so);
}
}
if( aList.IsEmpty() )
return;
- SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
- _PTR(Study) aStudyDS = aStudy->studyDS();
+ _PTR(Study) aStudyDS = getStudy();
_PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder();
_PTR(SObject) anObj;
// Connect study menu
a = action( ConnectId );
if( a )
- a->setEnabled( !activeStudy() && studyMgr()->GetOpenStudies().size() > 0 );
+ a->setEnabled( !activeStudy() );
// Disconnect study menu
a = action( DisconnectId );
{
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
if ( !appStudy ) return;
- _PTR(Study) aStudy = appStudy->studyDS();
QStringList aFilters;
aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
/*!Private SLOT. On load script.*/
void SalomeApp_Application::onLoadScript( )
{
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
- if ( appStudy ) {
- _PTR(Study) aStudy = appStudy->studyDS();
- if ( aStudy->GetProperties()->IsLocked() ) {
- SUIT_MessageBox::warning( desktop(),
- QObject::tr("WRN_WARNING"),
- QObject::tr("WRN_STUDY_LOCKED") );
- return;
- }
+ if ( getStudy()->GetProperties()->IsLocked() ) {
+ SUIT_MessageBox::warning( desktop(),
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("WRN_STUDY_LOCKED") );
+ return;
}
QStringList filtersList;
}
else if ( flag == WT_NoteBook )
{
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
- if ( appStudy ) {
- _PTR(Study) aStudy = appStudy->studyDS();
- setNoteBook( new SalomeApp_NoteBook( desktop(), aStudy ) );
- //to receive signal in NoteBook that it's variable was modified
- connect( this, SIGNAL( notebookVarUpdated( QString ) ),
- getNoteBook(), SLOT( onVarUpdate( QString ) ) );
- }
+ setNoteBook( new SalomeApp_NoteBook( desktop() ) );
+ //to receive signal in NoteBook that it's variable was modified
+ connect( this, SIGNAL( notebookVarUpdated( QString ) ),
+ getNoteBook(), SLOT( onVarUpdate( QString ) ) );
+
wid = getNoteBook();
wid->setObjectName( "noteBook" );
}
{
QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
if ( !sName.isEmpty() ) {
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
- if ( study ) {
- _PTR(Study) stdDS = study->studyDS();
- if(stdDS) {
- if ( stdDS->GetProperties()->IsLocked() ) {
- aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
- } else {
- aTitle += QString( " - [%1]" ).arg( sName );
- }
- }
+ if ( getStudy()->GetProperties()->IsLocked() ) {
+ aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
+ } else {
+ aTitle += QString( " - [%1]" ).arg( sName );
}
}
}
QStringList buttons;
QMap<int, int> choices;
int idx = 0;
- buttons << tr ("APPCLOSE_SAVE"); // Save & Close
+ buttons << tr ("APPCLOSE_SAVE"); // Save & Clear
choices.insert( idx++, CloseSave ); // ...
- buttons << tr ("APPCLOSE_CLOSE"); // Close w/o saving
+ buttons << tr ("APPCLOSE_CLOSE"); // Clear w/o saving
choices.insert( idx++, CloseDiscard ); // ...
if ( myIsCloseFromExit ) {
buttons << tr ("APPCLOSE_UNLOAD_SAVE"); // Save & Disconnect
buttons << tr ("APPCLOSE_CANCEL"); // Cancel
choices.insert( idx++, CloseCancel ); // ...
+ if( !activeStudy()->isModified() )
+ return CloseCancel;
int answer = SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ),
tr( "APPCLOSE_DESCRIPTION" ), buttons, 0 );
return choices[answer];
if ( QFileInfo( aName ).exists() ) {
if ( choice == OpenNew ) { // The document isn't already open.
bool exist = false;
- std::vector<std::string> lst = studyMgr()->GetOpenStudies();
- for ( uint i = 0; i < lst.size() && !exist; i++ ) {
- if ( aName == QString( lst[i].c_str() ) )
- exist = true;
- }
- // The document already exists in the study manager.
+ if ( aName == getStudy()->Name().c_str() )
+ exist = true;
+ // The document already exists in the study.
// Do you want to reload it?
if ( exist ) {
int answer = SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYEXIST" ).arg( aName ),
{
case OpenRefresh:
{
- _PTR(Study) aStudy = studyMgr()->GetStudyByName( aName.toStdString() );
- if ( aStudy )
- {
- studyMgr()->Close( aStudy );
- choice = OpenNew;
- }
+ choice = OpenNew;
}
default:
res = LightApp_Application::openAction( choice, aName );
return _orb;
}
-/*!Create and return SALOMEDS_StudyManager.*/
-SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
+/*!Create and return SALOMEDS_Study.*/
+_PTR(Study) SalomeApp_Application::getStudy()
{
- static _PTR(StudyManager) _sm;
- if(!_sm) _sm = ClientFactory::StudyManager();
- return _sm.get();
+ static _PTR(Study) _study;
+ if(!_study) {
+ CORBA::Object_var aSObject = namingService()->Resolve("/Study");
+ SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(aSObject);
+ _study = ClientFactory::Study(aStudy);
+ }
+ return _study;
}
/*!Create and return SALOME_NamingService.*/
// isInvalidRefs will be true, if at least one of selected objects is invalid reference
bool isInvalidRefs = false;
- SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
- if ( aStudy ) {
- _PTR(Study) aStudyDS = aStudy->studyDS();
- _PTR(SObject) anObj;
- for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() )
+ _PTR(SObject) anObj;
+ for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() )
+ {
+ if( it.Value()->hasEntry() )
{
- if( it.Value()->hasEntry() )
- {
- _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
- while( aRefObj && aRefObj->ReferencedObject( anObj ) )
- aRefObj = anObj;
+ _PTR(SObject) aSObject = getStudy()->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
+ while( aRefObj && aRefObj->ReferencedObject( anObj ) )
+ aRefObj = anObj;
- if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
- isInvalidRefs = true;
- }
+ if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
+ isInvalidRefs = true;
}
+ }
- // Add "Delete reference" item to popup
- if ( isInvalidRefs )
- {
- thePopup->addSeparator();
- thePopup->addAction( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) );
- return;
- }
+ // Add "Delete reference" item to popup
+ if ( isInvalidRefs )
+ {
+ thePopup->addSeparator();
+ thePopup->addAction( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) );
+ return;
+ }
- // "Activate module" item should appear only if it's necessary
- if ( aList.Extent() == 1 ) {
- aList.Clear();
- mgr->selectedObjects( aList );
-
- Handle(SALOME_InteractiveObject) aIObj = aList.First();
-
- // add extra popup menu (defined in XML)
- if ( myExtActions.size() > 0 ) {
- // Use only first selected object
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
- if ( study ) {
- _PTR(Study) stdDS = study->studyDS();
- if ( stdDS ) {
- _PTR(SObject) aSO = stdDS->FindObjectID( aIObj->getEntry() );
- if ( aSO ) {
- _PTR( GenericAttribute ) anAttr;
- std::string auid = "AttributeUserID";
- auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID);
- if ( aSO->FindAttribute( anAttr, auid ) ) {
- _PTR(AttributeUserID) aAttrID = anAttr;
- QString aId = aAttrID->Value().c_str();
- if ( myExtActions.contains( aId ) ) {
- thePopup->addAction(myExtActions[aId]);
- }
- }
- }
+ // "Activate module" item should appear only if it's necessary
+ if ( aList.Extent() == 1 ) {
+ aList.Clear();
+ mgr->selectedObjects( aList );
+
+ Handle(SALOME_InteractiveObject) aIObj = aList.First();
+
+ // add extra popup menu (defined in XML)
+ if ( myExtActions.size() > 0 ) {
+ // Use only first selected object
+ _PTR(SObject) aSO = getStudy()->FindObjectID( aIObj->getEntry() );
+ if ( aSO ) {
+ _PTR( GenericAttribute ) anAttr;
+ std::string auid = "AttributeUserID";
+ auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID);
+ if ( aSO->FindAttribute( anAttr, auid ) ) {
+ _PTR(AttributeUserID) aAttrID = anAttr;
+ QString aId = aAttrID->Value().c_str();
+ if ( myExtActions.contains( aId ) ) {
+ thePopup->addAction(myExtActions[aId]);
}
}
}
+ }
- // check if item is a "GUI state" item (also a first level object)
- QString entry( aIObj->getEntry() );
- if ( !entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) {
- QString aModuleName( aIObj->getComponentDataType() );
- QString aModuleTitle = moduleTitle( aModuleName );
- CAM_Module* currentModule = activeModule();
- if ( ( !currentModule || currentModule->moduleName() != aModuleTitle ) && !aModuleTitle.isEmpty() )
- thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) );
- }
+ // check if item is a "GUI state" item (also a first level object)
+ QString entry( aIObj->getEntry() );
+ if ( !entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) {
+ QString aModuleName( aIObj->getComponentDataType() );
+ QString aModuleTitle = moduleTitle( aModuleName );
+ CAM_Module* currentModule = activeModule();
+ if ( ( !currentModule || currentModule->moduleName() != aModuleTitle ) && !aModuleTitle.isEmpty() )
+ thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) );
}
}
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
if ( study )
{
- _PTR(Study) stdDS = study->studyDS();
- if( stdDS )
+ for ( _PTR(SComponentIterator) it ( getStudy()->NewComponentIterator() ); it->More(); it->Next() )
{
- for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
- {
- _PTR(SComponent) aComponent ( it->Value() );
+ _PTR(SComponent) aComponent ( it->Value() );
#ifndef WITH_SALOMEDS_OBSERVER
- // with GUI observers this check is not needed anymore
- if ( aComponent->ComponentDataType() == study->getVisualComponentName().toLatin1().constData() )
- continue; // skip the magic "Interface Applicative" component
+ // with GUI observers this check is not needed anymore
+ if ( aComponent->ComponentDataType() == study->getVisualComponentName().toLatin1().constData() )
+ continue; // skip the magic "Interface Applicative" component
#endif
- if ( !objectBrowser() )
- getWindow( WT_ObjectBrowser );
- const bool isAutoUpdate = objectBrowser()->autoUpdate();
- objectBrowser()->setAutoUpdate( false );
- SalomeApp_DataModel::synchronize( aComponent, study );
- objectBrowser()->setAutoUpdate( isAutoUpdate );
- }
+ if ( !objectBrowser() )
+ getWindow( WT_ObjectBrowser );
+ const bool isAutoUpdate = objectBrowser()->autoUpdate();
+ objectBrowser()->setAutoUpdate( false );
+ SalomeApp_DataModel::synchronize( aComponent, study );
+ objectBrowser()->setAutoUpdate( isAutoUpdate );
}
}
myNoteBook->setIsDumpedStudySaved( study->isSaved() );
myNoteBook->setDumpedStudyName( study->studyName() );
- _PTR(Study) studyDS = study->studyDS();
-
// get unique temporary directory name
QString aTmpDir = QString::fromStdString( SALOMEDS_Tool::GetTmpDir() );
if( aTmpDir.isEmpty() )
int savePoint;
_PTR(AttributeParameter) ap;
_PTR(IParameters) ip = ClientFactory::getIParameters(ap);
- if(ip->isDumpPython(studyDS)) ip->setDumpPython(studyDS); //Unset DumpPython flag.
+ if(ip->isDumpPython()) ip->setDumpPython(); //Unset DumpPython flag.
if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method
- ip->setDumpPython(studyDS);
+ ip->setDumpPython();
savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point
}
- bool ok = studyDS->DumpStudy( aTmpDir.toStdString(), aScriptName.toStdString(), toPublish, isMultiFile );
+ bool ok = getStudy()->DumpStudy( aTmpDir.toStdString(), aScriptName.toStdString(), toPublish, isMultiFile );
if ( toSaveGUI )
study->removeSavePoint(savePoint); //SRN: remove the created temporary save point.
{
bool ok = true;
- // create a new study
- onNewDoc();
-
// get active application
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
if( SalomeApp_Study* newStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) )
{
#ifndef DISABLE_PYCONSOLE
- _PTR(Study) aStudyDS = newStudy->studyDS();
if ( app->getNoteBook() )
- app->getNoteBook()->Init( aStudyDS );
+ app->getNoteBook()->Init();
newStudy->updateFromNotebook(theStudyName, theIsStudySaved);
newStudy->Modified();
updateDesktopTitle();
*/
bool SalomeApp_Application::checkExistingDoc()
{
- bool result = LightApp_Application::checkExistingDoc();
- if ( result && !activeStudy() ) {
- SALOMEDSClient_StudyManager* aMgr = studyMgr();
- if ( aMgr ) {
- std::vector<std::string> List = studyMgr()->GetOpenStudies();
- if( List.size() > 0 ) {
- SUIT_MessageBox::critical( desktop(), tr( "WRN_WARNING" ), tr( "ERR_ACTIVEDOC_LOAD" ));
- result = false;
- }
- }
- }
- return result;
+ return LightApp_Application::checkExistingDoc();
}
virtual bool checkExistingDoc();
static CORBA::ORB_var orb();
- static SALOMEDSClient_StudyManager* studyMgr();
+ static _PTR(Study) getStudy();
static SALOME_NamingService* namingService();
static SALOME_LifeCycleCORBA* lcc();
void onStudyOpened( SUIT_Study* );
void onDesktopMessage( const QString& );
+ virtual void onModuleActivation( const QString& );
+
protected:
virtual void createActions();
virtual SUIT_Study* createNewStudy();
if ( anId.isEmpty() )
return true; // Probably nothing to load
- _PTR(Study) aStudy ( aDoc->studyDS() ); // shared_ptr cannot be used here
- _PTR(SComponent) aSComp ( aStudy->FindComponentID( std::string( anId.toLatin1() ) ) );
+ _PTR(SComponent) aSComp ( SalomeApp_Application::getStudy()->FindComponentID( std::string( anId.toLatin1() ) ) );
if ( aSComp )
updateTree( aSComp, aDoc );
studyRoot = dynamic_cast<LightApp_RootObject*>( aSStudy->root() );
QString anId = getRootEntry( aSStudy );
if ( !anId.isEmpty() ){ // if nothing is published in the study for this module -> do nothing
- _PTR(Study) aStudy ( aSStudy->studyDS() );
- sobj = aStudy->FindComponentID( std::string( anId.toLatin1() ) );
+ sobj = SalomeApp_Application::getStudy()->FindComponentID( std::string( anId.toLatin1() ) );
}
}
}
if ( studyRoot ) {
aSStudy = dynamic_cast<SalomeApp_Study*>( studyRoot->study() ); // <study> value should not change here theoretically, but just to make sure
if ( aSStudy ) {
- _PTR(Study) aStudy ( aSStudy->studyDS() );
// modelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon
- sobj = aStudy->FindComponentID( std::string( modelRoot->entry().toLatin1() ) );
+ sobj = SalomeApp_Application::getStudy()->FindComponentID( std::string( modelRoot->entry().toLatin1() ) );
}
}
}
if ( !CORBA::is_nil(aComponent) && aComponent->hasObjectInfo() ) {
LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() );
if ( aRoot && aRoot->study() ) {
- CORBA::String_var data = aComponent->getObjectInfo( aRoot->study()->id(), entry().toLatin1().constData());
+ CORBA::String_var data = aComponent->getObjectInfo( entry().toLatin1().constData());
QString objInfo = data.in();
QStringList l;
l << name();
bool ok = false;
// tmp??
- _PTR(UseCaseBuilder) aUseCaseBuilder = myObject->GetStudy()->GetUseCaseBuilder();
+ _PTR(UseCaseBuilder) aUseCaseBuilder = SalomeApp_Application::getStudy()->GetUseCaseBuilder();
if (aUseCaseBuilder->IsUseCaseNode(myObject)) {
ok = aUseCaseBuilder->HasChildren(myObject);
// TODO: check name as below?
}
else {
- _PTR(ChildIterator) it ( myObject->GetStudy()->NewChildIterator( myObject ) );
+ _PTR(ChildIterator) it ( SalomeApp_Application::getStudy()->NewChildIterator( myObject ) );
for ( ; it->More() && !ok; it->Next() ) {
_PTR(SObject) obj = it->Value();
if ( obj ) {
QString aStrings = fromUtf8( str );
//Special case to show NoteBook variables in the "Value" column of the OB
- if ( LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root() ) )
+ bool ok = false;
+ QStringList aSectionList = aStrings.split( "|" );
+ if ( !aSectionList.isEmpty() )
{
- if ( SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( aRoot->study() ) )
+ QString aLastSection = aSectionList.last();
+ QStringList aStringList = aLastSection.split( ":" );
+ if ( !aStringList.isEmpty() )
{
- _PTR(Study) studyDS( aStudy->studyDS() );
-
- bool ok = false;
- QStringList aSectionList = aStrings.split( "|" );
- if ( !aSectionList.isEmpty() )
+ ok = true;
+ for ( int i = 0, n = aStringList.size(); i < n; i++ )
{
- QString aLastSection = aSectionList.last();
- QStringList aStringList = aLastSection.split( ":" );
- if ( !aStringList.isEmpty() )
- {
- ok = true;
- for ( int i = 0, n = aStringList.size(); i < n; i++ )
- {
- QString aStr = aStringList[i];
- if ( studyDS->IsVariable( aStr.toStdString() ) )
- val.append( aStr + ", " );
- }
-
- if ( !val.isEmpty() )
- val.remove( val.length() - 2, 2 );
- }
+ QString aStr = aStringList[i];
+ if ( SalomeApp_Application::getStudy()->IsVariable( aStr.toStdString() ) )
+ val.append( aStr + ", " );
}
- if( !ok )
- val = aStrings;
+
+ if ( !val.isEmpty() )
+ val.remove( val.length() - 2, 2 );
}
}
+ if( !ok )
+ val = aStrings;
}
else if ( obj->FindAttribute( attr, "AttributeInteger" ) )
{
value = 0;
if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) )
{
- if( SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) )
- {
- _PTR(Study) studyDS = study->studyDS();
+ _PTR(Study) studyDS = SalomeApp_Application::getStudy();
- std::string aName = name.toStdString();
- if( studyDS->IsVariable( aName ) )
+ std::string aName = name.toStdString();
+ if( studyDS->IsVariable( aName ) )
+ {
+ if( studyDS->IsReal( aName ) || studyDS->IsInteger( aName ) || studyDS->IsString( aName ) )
{
- if( studyDS->IsReal( aName ) || studyDS->IsInteger( aName ) || studyDS->IsString( aName ) )
+ if( studyDS->IsString( aName ) )
{
- if( studyDS->IsString( aName ) )
- {
#ifndef DISABLE_PYCONSOLE
- PyConsole_Interp* pyInterp = app->getPyInterp();
- PyLockWrapper aLock; // Acquire GIL
- std::string command;
- command = "import salome_notebook ; ";
- command += "salome_notebook.notebook.setAsReal(\"";
- command += aName;
- command += "\")";
- bool aResult;
- aResult = pyInterp->run(command.c_str());
- if(aResult)
- {
- return IncorrectType;
- }
+ PyConsole_Interp* pyInterp = app->getPyInterp();
+ PyLockWrapper aLock; // Acquire GIL
+ std::string command;
+ command = "import salome_notebook ; ";
+ command += "salome_notebook.notebook.setAsReal(\"";
+ command += aName;
+ command += "\")";
+ bool aResult;
+ aResult = pyInterp->run(command.c_str());
+ if(aResult)
+ {
+ return IncorrectType;
+ }
#endif
- }
- value = studyDS->GetReal( aName );
- return Found;
}
- return IncorrectType;
+ value = studyDS->GetReal( aName );
+ return Found;
}
+ return IncorrectType;
}
}
return NotFound;
{
SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
- if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy()))
+ if (CORBA::is_nil(theComponent))
return aStreamFile._retn();
- const int studyId = theComponent->GetStudy()->StudyId();
-
// Get a temporary directory to store a file
//std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
- if (myMap.count(studyId)) {
- std::string componentName (theComponent->ComponentDataType());
-
- // Error somewhere outside - Save() called with
- // wrong SComponent instance
- if ( myComponentName != componentName )
- return aStreamFile._retn();
+ std::string componentName (theComponent->ComponentDataType());
- const ListOfFiles& listOfFiles = myMap[studyId];
+ // Error somewhere outside - Save() called with
+ // wrong SComponent instance
+ if ( myComponentName != componentName )
+ return aStreamFile._retn();
- // listOfFiles must contain temporary directory name in its first item
- // and names of files (relatively the temporary directory) in the others
- const int n = listOfFiles.size() - 1;
+ // listOfFiles must contain temporary directory name in its first item
+ // and names of files (relatively the temporary directory) in the others
+ const int n = myListOfFiles.size() - 1;
- if (n > 0) { // there are some files, containing persistent data of the component
- std::string aTmpDir = listOfFiles[0];
+ if (n > 0) { // there are some files, containing persistent data of the component
+ std::string aTmpDir = myListOfFiles[0];
- // Create a list to store names of created files
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(n);
- for (int i = 0; i < n; i++)
- aSeq[i] = CORBA::string_dup(listOfFiles[i + 1].c_str());
+ // Create a list to store names of created files
+ ListOfFiles aSeq;
+ aSeq.reserve(n);
+ for (int i = 0; i < n; i++)
+ aSeq.push_back(CORBA::string_dup(myListOfFiles[i + 1].c_str()));
- // Convert a file to the byte stream
- aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), isMultiFile);
+ // Convert a file to the byte stream
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq, isMultiFile);
- // Remove the files and tmp directory, created by the component storage procedure
- if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
- }
+ // Remove the files and tmp directory, created by the component storage procedure
+ if (!isMultiFile) SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq, true);
}
return aStreamFile._retn();
bool isMultiFile)
{
std::cout << "SalomeApp_Engine_i::Load() isMultiFile = " << isMultiFile << std::endl;
- if (CORBA::is_nil(theComponent) || CORBA::is_nil(theComponent->GetStudy()))
+ if (CORBA::is_nil(theComponent))
return false;
// Error somewhere outside - Load() called with
if ( myComponentName != componentName )
return false;
- const int studyId = theComponent->GetStudy()->StudyId();
-
// Create a temporary directory for the component's data files
std::string aTmpDir = isMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
// Convert the byte stream theStream to a files and place them in the tmp directory.
// The files and temporary directory must be deleted by the component loading procedure.
- SALOMEDS::ListOfFileNames_var aSeq =
+ ListOfFiles aSeq =
SALOMEDS_Tool::PutStreamToFiles(theFile, aTmpDir.c_str(), isMultiFile);
// Store list of file names to be used by the component loading procedure
- const int n = aSeq->length() + 1;
+ const int n = aSeq.size() + 1;
ListOfFiles listOfFiles (n);
listOfFiles[0] = aTmpDir;
for (int i = 1; i < n; i++)
listOfFiles[i] = std::string(aSeq[i - 1]);
- SetListOfFiles(listOfFiles, studyId);
+ SetListOfFiles(listOfFiles);
return true;
}
-SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles (const int theStudyId)
+SalomeApp_Engine_i::ListOfFiles SalomeApp_Engine_i::GetListOfFiles()
{
- ListOfFiles aListOfFiles;
-
- if (myMap.find(theStudyId) != myMap.end())
- {
- aListOfFiles = myMap[theStudyId];
- }
-
- return aListOfFiles;
+ return myListOfFiles;
}
-void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles,
- const int theStudyId)
+void SalomeApp_Engine_i::SetListOfFiles (const ListOfFiles& theListOfFiles)
{
- myMap[theStudyId] = theListOfFiles;
+ myListOfFiles = theListOfFiles;
}
/*!
* DumpPython implementation for light modules
*/
-Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
- CORBA::Boolean isMultiFile,
- CORBA::Boolean& isValidScript)
+Engines::TMPFile* SalomeApp_Engine_i::DumpPython(CORBA::Boolean isPublished,
+ CORBA::Boolean isMultiFile,
+ CORBA::Boolean& isValidScript)
{
MESSAGE("SalomeApp_Engine_i::DumpPython(): myComponentName = "<<
myComponentName << ", this = " << this);
aStreamFile[0] = '\0';
isValidScript = true;
- if (CORBA::is_nil(theStudy))
- return aStreamFile._retn();
-
- SALOMEDS::Study_var studyDS = SALOMEDS::Study::_narrow( theStudy );
- const int studyId = studyDS->StudyId();
-
- if (!myMap.count(studyId))
- return aStreamFile._retn();
-
- ListOfFiles listOfFiles = myMap[studyId];
-
// listOfFiles must contain temporary directory name in its first item
// and names of files (relatively the temporary directory) in the others
- if ( listOfFiles.size() < 2 )
+ if ( myListOfFiles.size() < 2 )
return aStreamFile._retn();
// there are some files, containing persistent data of the component
- QString aTmpPath( listOfFiles.front().c_str() );
+ QString aTmpPath( myListOfFiles.front().c_str() );
QDir aTmpDir( aTmpPath );
if ( !aTmpDir.exists() )
return aStreamFile._retn();
QStringList aFilePaths;
QList<qint64> aFileSizes;
qint64 aBuffSize = 0;
- ListOfFiles::const_iterator aFIt = listOfFiles.begin();
- ListOfFiles::const_iterator aFEnd = listOfFiles.end();
+ ListOfFiles::const_iterator aFIt = myListOfFiles.begin();
+ ListOfFiles::const_iterator aFEnd = myListOfFiles.end();
aFIt++;
for (; aFIt != aFEnd; aFIt++){
QString aFileName( (*aFIt).c_str() );
const char* theURL,
bool isMultiFile );
- virtual Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy,
- CORBA::Boolean isPublished,
+ virtual Engines::TMPFile* DumpPython(CORBA::Boolean isPublished,
CORBA::Boolean isMultiFile,
CORBA::Boolean& isValidScript);
public:
typedef std::vector<std::string> ListOfFiles;
- ListOfFiles GetListOfFiles (const int theStudyId);
- void SetListOfFiles (const ListOfFiles& theListOfFiles,
- const int theStudyId);
+ ListOfFiles GetListOfFiles ();
+ void SetListOfFiles (const ListOfFiles& theListOfFiles);
static std::string EngineIORForComponent( const char* theComponentName,
bool toCreate );
char* IORToLocalPersistentID( SALOMEDS::SObject_ptr, const char*, CORBA::Boolean, CORBA::Boolean ) {return 0;}
char* LocalPersistentIDToIOR( SALOMEDS::SObject_ptr, const char*, CORBA::Boolean, CORBA::Boolean ) {return 0;}
bool CanPublishInStudy( CORBA::Object_ptr ) {return 0;}
- SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr, CORBA::Object_ptr, const char* ) throw (SALOME::SALOME_Exception) {return 0;}
+ SALOMEDS::SObject_ptr PublishInStudy( SALOMEDS::SObject_ptr, CORBA::Object_ptr, const char* ) throw (SALOME::SALOME_Exception) {return 0;}
CORBA::Boolean CanCopy( SALOMEDS::SObject_ptr ) {return 0;}
SALOMEDS::TMPFile* CopyFrom( SALOMEDS::SObject_ptr, CORBA::Long& ) {return 0;}
CORBA::Boolean CanPaste( const char*, CORBA::Long ) {return 0;}
static PortableServer::POA_var poa();
static SALOME_NamingService* namingService();
private:
- typedef std::map<int, ListOfFiles> MapOfListOfFiles;
- MapOfListOfFiles myMap;
+ ListOfFiles myListOfFiles;
std::string myComponentName;
};
value = 0;
if( SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() ) )
{
- if( SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() ) )
- {
- _PTR(Study) studyDS = study->studyDS();
+ _PTR(Study) studyDS = SalomeApp_Application::getStudy();
- std::string aName = name.toStdString();
- if( studyDS->IsVariable( aName ) )
+ std::string aName = name.toStdString();
+ if( studyDS->IsVariable( aName ) )
+ {
+ if( studyDS->IsInteger( aName ) || studyDS->IsString( aName ) )
{
- if( studyDS->IsInteger( aName ) || studyDS->IsString( aName ) )
+ if( studyDS->IsString( aName ) )
{
- if( studyDS->IsString( aName ) )
- {
#ifndef DISABLE_PYCONSOLE
- PyConsole_Interp* pyInterp = app->getPyInterp();
- PyLockWrapper aLock; // Acquire GIL
- std::string command;
- command = "import salome_notebook ; ";
- command += "salome_notebook.notebook.setAsInteger(\"";
- command += aName;
- command += "\")";
- bool aResult;
- aResult = pyInterp->run(command.c_str());
- if(aResult)
- {
- return IncorrectType;
- }
+ PyConsole_Interp* pyInterp = app->getPyInterp();
+ PyLockWrapper aLock; // Acquire GIL
+ std::string command;
+ command = "import salome_notebook ; ";
+ command += "salome_notebook.notebook.setAsInteger(\"";
+ command += aName;
+ command += "\")";
+ bool aResult;
+ aResult = pyInterp->run(command.c_str());
+ if(aResult)
+ {
+ return IncorrectType;
+ }
#endif
- }
- value = studyDS->GetInteger( aName );
- return Found;
}
- return IncorrectType;
+ value = studyDS->GetInteger( aName );
+ return Found;
}
+ return IncorrectType;
}
}
return NotFound;
* Purpose : Add variables in the table from theStudy
*/
//============================================================================
-void NoteBook_Table::Init(_PTR(Study) theStudy)
+void NoteBook_Table::Init()
{
isProcessItemChangedSignal = false;
myVariableMap.clear();
//Add all variables into the table
- std::vector<std::string> aVariables = theStudy->GetVariableNames();
+ std::vector<std::string> aVariables = SalomeApp_Application::getStudy()->GetVariableNames();
for(int iVar = 0; iVar < aVariables.size(); iVar++ ) {
AddRow(QString(aVariables[iVar].c_str()),
- Variable2String(aVariables[iVar],theStudy));
+ Variable2String(aVariables[iVar]));
}
//Add empty row
isProcessItemChangedSignal = true;
ResetMaps();
-
- myStudy = theStudy;
}
//============================================================================
* Purpose : Convert variable values to QString
*/
//============================================================================
-QString NoteBook_Table::Variable2String(const std::string& theVarName,
- _PTR(Study) theStudy)
+QString NoteBook_Table::Variable2String(const std::string& theVarName)
{
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
QString aResult;
- if( theStudy->IsReal(theVarName) )
- aResult = QString::number(theStudy->GetReal(theVarName));
- else if( theStudy->IsInteger(theVarName) )
- aResult = QString::number(theStudy->GetInteger(theVarName));
- else if( theStudy->IsBoolean(theVarName) )
- aResult = theStudy->GetBoolean(theVarName) ? QString("True") : QString("False");
- else if( theStudy->IsString(theVarName) )
- aResult = theStudy->GetString(theVarName).c_str();
+ if( aStudy->IsReal(theVarName) )
+ aResult = QString::number(aStudy->GetReal(theVarName));
+ else if( aStudy->IsInteger(theVarName) )
+ aResult = QString::number(aStudy->GetInteger(theVarName));
+ else if( aStudy->IsBoolean(theVarName) )
+ aResult = aStudy->GetBoolean(theVarName) ? QString("True") : QString("False");
+ else if( aStudy->IsString(theVarName) )
+ aResult = aStudy->GetString(theVarName).c_str();
return aResult;
}
if( myVariableMap.contains( anIndex ) )
{
const NoteBoox_Variable& aVariable = myVariableMap[ anIndex ];
- if( !aVariable.Name.isEmpty() && myStudy->IsVariableUsed( std::string( aVariable.Name.toLatin1().constData() ) ) )
+ if( !aVariable.Name.isEmpty() && SalomeApp_Application::getStudy()->IsVariableUsed( std::string( aVariable.Name.toLatin1().constData() ) ) )
{
if( QMessageBox::warning( parentWidget(), tr( "WARNING" ),
tr( "RENAME_VARIABLE_IS_USED" ).arg( aVariable.Name ),
//============================================================================
void NoteBook_Table::RemoveSelected()
{
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
isProcessItemChangedSignal = false;
QList<QTableWidgetItem*> aSelectedItems = selectedItems();
if( !(aSelectedItems.size() > 0)) {
else {
int nRow = row(aSelectedItems[i]);
- if( myStudy->IsVariableUsed( std::string( aRow->GetName().toLatin1().constData() ) ) )
+ if( aStudy->IsVariableUsed( std::string( aRow->GetName().toLatin1().constData() ) ) )
{
if( QMessageBox::warning( parentWidget(), tr( "WARNING" ),
tr( "REMOVE_VARIABLE_IS_USED" ).arg( aRow->GetName() ),
myVariableMap.remove( index );
removeRow(nRow);
myRows.removeAt(nRow);
- if(myStudy->IsVariable(aVarName.toLatin1().constData()))
+ if(aStudy->IsVariable(aVarName.toLatin1().constData()))
removedFromStudy = true;
}
}
* Purpose : Constructor
*/
//============================================================================
-SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent, _PTR(Study) theStudy):
- QWidget(parent),
- myStudy(theStudy)
+SalomeApp_NoteBook::SalomeApp_NoteBook(QWidget * parent):
+ QWidget(parent)
{
setObjectName("SalomeApp_NoteBook");
setWindowTitle(tr("NOTEBOOK_TITLE"));
connect( myUpdateStudyBtn, SIGNAL(clicked()), this, SLOT(onUpdateStudy()) );
connect( myRemoveButton, SIGNAL(clicked()), this, SLOT(onRemove()));
- myTable->Init(myStudy);
+ myTable->Init();
myDumpedStudyScript = "";
myIsDumpedStudySaved = false;
* Purpose : init variable table
*/
//============================================================================
-void SalomeApp_NoteBook::Init(_PTR(Study) theStudy){
- if(myStudy!= theStudy)
- myStudy = theStudy;
- myTable->Init(myStudy);
+void SalomeApp_NoteBook::Init(){
+ myTable->Init();
}
//============================================================================
void SalomeApp_NoteBook::onVarUpdate(QString theVarName)
{
- myTable->Init(myStudy);
+ myTable->Init();
}
//============================================================================
SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_DATA" ) );
return;
}
+ _PTR(Study) aStudy = SalomeApp_Application::getStudy();
double aDVal;
int anIVal;
if( aVariableMapRef.contains( anIndex ) )
{
QString aRemovedVariable = aVariableMapRef[ anIndex ].Name;
- myStudy->RemoveVariable( std::string( aRemovedVariable.toLatin1().constData() ) );
+ aStudy->RemoveVariable( std::string( aRemovedVariable.toLatin1().constData() ) );
}
}
if( !aNameRef.isEmpty() && !aValueRef.isEmpty() && aNameRef != aName )
{
- myStudy->RenameVariable( std::string( aNameRef.toLatin1().constData() ),
- std::string( aName.toLatin1().constData() ) );
+ aStudy->RenameVariable( std::string( aNameRef.toLatin1().constData() ),
+ std::string( aName.toLatin1().constData() ) );
}
}
if( NoteBook_TableRow::IsIntegerValue(aValue,&anIVal) )
- myStudy->SetInteger(std::string(aName.toLatin1().constData()),anIVal);
+ aStudy->SetInteger(std::string(aName.toLatin1().constData()),anIVal);
else if( NoteBook_TableRow::IsRealValue(aValue,&aDVal) )
- myStudy->SetReal(std::string(aName.toLatin1().constData()),aDVal);
+ aStudy->SetReal(std::string(aName.toLatin1().constData()),aDVal);
else if( NoteBook_TableRow::IsBooleanValue(aValue,&aBVal) )
- myStudy->SetBoolean(std::string(aName.toLatin1().constData()),aBVal);
+ aStudy->SetBoolean(std::string(aName.toLatin1().constData()),aBVal);
else
- myStudy->SetString(std::string(aName.toLatin1().constData()),aValue.toStdString());
+ aStudy->SetString(std::string(aName.toLatin1().constData()),aValue.toStdString());
}
}
myTable->ResetMaps();
if(app)
app->updateActions();
- myStudy->Modified();
+ aStudy->Modified();
}
//============================================================================
NoteBook_Table(QWidget * parent = 0);
virtual ~NoteBook_Table();
- void Init(_PTR(Study) theStudy);
- static QString Variable2String(const std::string& theVarName,
- _PTR(Study) theStudy);
+ void Init();
+ static QString Variable2String(const std::string& theVarName);
bool IsValid() const;
QList<int> myRemovedRows;
VariableMap myVariableMapRef;
VariableMap myVariableMap;
-
- _PTR(Study) myStudy;
};
class SALOMEAPP_EXPORT SalomeApp_NoteBook : public QWidget
{
Q_OBJECT
public:
- SalomeApp_NoteBook(QWidget * parent , _PTR(Study) theStudy);
+ SalomeApp_NoteBook(QWidget * parent);
virtual ~SalomeApp_NoteBook();
- void Init(_PTR(Study) theStudy);
+ void Init();
QString getDumpedStudyName() { return myDumpedStudyName; }
void setDumpedStudyName(QString theName) { myDumpedStudyName = theName; }
QPushButton* myRemoveButton;
QPushButton* myUpdateStudyBtn;
- _PTR(Study) myStudy;
QString myDumpedStudyScript; // path to script of dumped study
QString myDumpedStudyName;
bool myIsDumpedStudySaved;
int ret = simpleRun( "import salome", false );
if ( ret )
return ret;
- ret = simpleRun( "salome.salome_init(0,1)", false );
+ ret = simpleRun( "salome.salome_init(1)", false );
if ( ret )
return ret;
}
public:
- Observer_i(_PTR(Study) aStudyDS, SalomeApp_Study* aStudy):QObject(aStudy)
+ Observer_i( SalomeApp_Study* aStudy):QObject(aStudy)
{
- myStudyDS=aStudyDS;
myStudy=aStudy;
fillEntryMap();
}
switch(event) {
case 1:
{ //Add sobject
- _PTR(SObject) aSObj = myStudyDS->FindObjectID(theID);
+ _PTR(SObject) aSObj = SalomeApp_Application::getStudy()->FindObjectID(theID);
_PTR(SComponent) aSComp = aSObj->GetFatherComponent();
if (!aSComp || aSComp->IsNull()) {
}
// Mantis issue 0020136: Drag&Drop in OB
- _PTR(UseCaseBuilder) aUseCaseBuilder = myStudyDS->GetUseCaseBuilder();
+ _PTR(UseCaseBuilder) aUseCaseBuilder = SalomeApp_Application::getStudy()->GetUseCaseBuilder();
if (aUseCaseBuilder->IsUseCaseNode(aSComp)) { // BEGIN: work with tree nodes structure
if (!aUseCaseBuilder->IsUseCaseNode(aSObj)) {
// tree node is not yet set, it is a normal situation
}
private:
- _PTR(Study) myStudyDS;
SalomeApp_Study* myStudy;
EntryMap entry2SuitObject;
};
SalomeApp_Study::SalomeApp_Study( SUIT_Application* app )
: LightApp_Study( app ), myObserver( 0 )
{
+ myStudyDS = SalomeApp_Application::getStudy();
}
/*!
}
#endif
-/*!
- Gets study id.
-*/
-int SalomeApp_Study::id() const
-{
- int id = -1;
- if ( studyDS() )
- id = studyDS()->StudyId();
- return id;
-}
-
/*!
Get study name.
*/
// it can be changed outside of GUI
// TEMPORARILY SOLUTION: better to be implemented with help of SALOMEDS observers
if ( studyDS() ) {
- QString newName = QString::fromUtf8(studyDS()->Name().c_str());
+ QString newName = QString::fromUtf8(studyDS()->URL().c_str());
if ( LightApp_Study::studyName() != newName ) {
SalomeApp_Study* that = const_cast<SalomeApp_Study*>( this );
that->setStudyName( newName );
{
MESSAGE( "createDocument" );
- // initialize myStudyDS, read HDF file
- QString aName = newStudyName();
-
- _PTR(Study) study;
- bool showError = !application()->property("open_study_from_command_line").isValid() ||
- !application()->property("open_study_from_command_line").toBool();
- try {
- study = _PTR(Study)( SalomeApp_Application::studyMgr()->NewStudy( aName.toUtf8().data() ) );
- }
- catch(const SALOME_Exception& ex) {
- application()->putInfo(tr(ex.what()));
- if ( showError )
- SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
- tr("ERR_ERROR"), tr(ex.what()));
- return false;
- }
- catch(...) {
- application()->putInfo(tr("CREATE_DOCUMENT_PROBLEM"));
- if ( showError )
- SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
- tr("ERR_ERROR"), tr("CREATE_DOCUMENT_PROBLEM"));
- return false;
- }
-
- if ( !study )
- return false;
-
- setStudyDS( study );
- setStudyName( aName );
+ setStudyName( QString::fromUtf8(myStudyDS->URL().c_str()) );
// create myRoot
SalomeApp_RootObject* aRoot=new SalomeApp_RootObject( this );
bool aRet = CAM_Study::createDocument( theStr );
#ifdef WITH_SALOMEDS_OBSERVER
- myObserver = new Observer_i(myStudyDS,this);
+ myObserver = new Observer_i(this);
//attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
{
MESSAGE( "openDocument" );
- // initialize myStudyDS, read HDF file
- _PTR(Study) study;
- bool showError = !application()->property("open_study_from_command_line").isValid() ||
+ // read HDF file
+ bool res = false;
+ bool showError = !application()->property("open_study_from_command_line").isValid() ||
!application()->property("open_study_from_command_line").toBool();
try {
- study = _PTR(Study) ( SalomeApp_Application::studyMgr()->Open( theFileName.toUtf8().data() ) );
+ res = myStudyDS->Open( theFileName.toUtf8().data() );
}
catch(const SALOME_Exception& ex) {
application()->putInfo(tr(ex.what()));
SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(),
tr("ERR_ERROR"), tr(ex.what()));
return false;
- }
+ }
catch(...) {
application()->putInfo(tr("OPEN_DOCUMENT_PROBLEM"));
if ( showError )
return false;
}
- if ( !study )
+ if ( !res)
return false;
- setStudyDS( study );
-
setRoot( new SalomeApp_RootObject( this ) ); // create myRoot
// update loaded data models: call open() and update() on them.
#ifdef WITH_SALOMEDS_OBSERVER
dynamic_cast<SalomeApp_RootObject*>( root() )->setToSynchronize(false);
- myObserver = new Observer_i(myStudyDS,this);
+ myObserver = new Observer_i(this);
//attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
- bool res = CAM_Study::openDocument( theFileName );
+ res = CAM_Study::openDocument( theFileName );
emit opened( this );
- study->IsSaved(true);
+ myStudyDS->IsSaved(true);
bool restore = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", true );
if ( restore ) {
}
/*!
- Connects GUI study to SALOMEDS one already loaded into StudyManager
+ Connects GUI study to SALOMEDS one
\param theStudyName - name of study
*/
bool SalomeApp_Study::loadDocument( const QString& theStudyName )
{
MESSAGE( "loadDocument" );
- // obtain myStudyDS from StudyManager
- _PTR(Study) study ( SalomeApp_Application::studyMgr()->GetStudyByName( theStudyName.toUtf8().data() ) );
- if ( !study )
- return false;
-
- setStudyDS( study );
-
setRoot( new SalomeApp_RootObject( this ) ); // create myRoot
//SRN: BugID IPAL9021, put there the same code as in a method openDocument
#ifdef WITH_SALOMEDS_OBSERVER
dynamic_cast<SalomeApp_RootObject*>( root() )->setToSynchronize(false);
- myObserver = new Observer_i(myStudyDS,this);
+ myObserver = new Observer_i(this);
//attach an observer to the study with notification of modifications
myStudyDS->attach(myObserver->_this(),true);
#endif
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
- bool res = (isAscii ?
- SalomeApp_Application::studyMgr()->SaveAsASCII( theFileName.toUtf8().data(), studyDS(), isMultiFile ) :
- SalomeApp_Application::studyMgr()->SaveAs ( theFileName.toUtf8().data(), studyDS(), isMultiFile ))
+ bool res = studyDS()->SaveAs( theFileName.toUtf8().data(), isMultiFile, isAscii )
&& CAM_Study::saveDocumentAs( theFileName );
res = res && saveStudyData(theFileName);
bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
- bool res = (isAscii ?
- SalomeApp_Application::studyMgr()->SaveASCII( studyDS(), isMultiFile ) :
- SalomeApp_Application::studyMgr()->Save ( studyDS(), isMultiFile )) && CAM_Study::saveDocument();
+ bool res = studyDS()->Save( isMultiFile, isAscii ) && CAM_Study::saveDocument();
res = res && saveStudyData(studyName());
if ( res )
LightApp_Study::closeDocument(permanently);
// close SALOMEDS document
- _PTR(Study) studyPtr = studyDS();
- if ( studyPtr )
- {
- if ( myObserver )
- myStudyDS->detach( myObserver->_this() );
- if ( permanently ) {
- SUIT_Desktop* desk = SUIT_Session::session()->activeApplication()->desktop();
- bool isBlocked = desk->signalsBlocked();
- desk->blockSignals( true );
- SalomeApp_Application::studyMgr()->Close( studyPtr );
- desk->blockSignals( isBlocked );
+ if ( myObserver )
+ myStudyDS->detach( myObserver->_this() );
+ if ( permanently ) {
+ SUIT_Desktop* desk = SUIT_Session::session()->activeApplication()->desktop();
+ bool isBlocked = desk->signalsBlocked();
+ desk->blockSignals( true );
+ myStudyDS->Clear();
+ desk->blockSignals( isBlocked );
#ifndef DISABLE_PYCONSOLE
- SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
- app->getPyInterp()->destroy();
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( application() );
+ app->getPyInterp()->destroy();
#endif
- }
- SALOMEDSClient_Study* aStudy = 0;
- setStudyDS( _PTR(Study)(aStudy) );
}
}
int savePoint;
_PTR(AttributeParameter) ap;
_PTR(IParameters) ip = ClientFactory::getIParameters(ap);
- _PTR(Study) aStudy = studyDS();
- if( ip->isDumpPython( aStudy ) )
- ip->setDumpPython( aStudy ); //Unset DumpPython flag.
+ if( ip->isDumpPython() )
+ ip->setDumpPython(); //Unset DumpPython flag.
if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method
- ip->setDumpPython( aStudy );
+ ip->setDumpPython();
//SRN: create a temporary save point
savePoint = SalomeApp_VisualState(
dynamic_cast<SalomeApp_Application*>( application() ) ).storeState();
// Now dump SALOMEDS part that also involves SalomeApp_Engine in case if
// any light module is present in the current configuration
QFileInfo aFileInfo( theFileName );
- bool res = aStudy->DumpStudy( aFileInfo.absolutePath().toUtf8().data(),
- aFileInfo.baseName().toUtf8().data(),
- toPublish,
- isMultiFile);
+ bool res = myStudyDS->DumpStudy( aFileInfo.absolutePath().toUtf8().data(),
+ aFileInfo.baseName().toUtf8().data(),
+ toPublish,
+ isMultiFile);
if ( toSaveGUI )
removeSavePoint( savePoint ); //SRN: remove the created temporary save point.
*/
void SalomeApp_Study::Modified()
{
- if(_PTR(Study) aStudy = studyDS())
- aStudy->Modified();
+ myStudyDS->Modified();
LightApp_Study::Modified();
}
return true;
}
-/*!
- Set studyDS.
-*/
-void SalomeApp_Study::setStudyDS( const _PTR(Study)& s )
-{
- myStudyDS = s;
-}
-
/*!
Virtual method re-implemented from LightApp_Study in order to create
the module object connected to SALOMEDS - SalomeApp_ModuleObject.
}
if ( !res ){
- _PTR(Study) aStudy = studyDS();
- if ( !aStudy )
- return res;
-
- _PTR(SComponent) aComp = aStudy->FindComponent(
+ _PTR(SComponent) aComp = myStudyDS->FindComponent(
theDataModel->module()->name().toStdString() );
if ( !aComp )
return res;
// 1. aModule == 0 means that this is a light module (no CORBA enigine)
if (!aModule) {
// Check SComponent existance
- _PTR(Study) aStudy = studyDS();
- if (!aStudy)
- return;
std::string aCompDataType = dm->module()->name().toStdString();
- _PTR(SComponent) aComp = aStudy->FindComponent(aCompDataType);
+ _PTR(SComponent) aComp = myStudyDS->FindComponent(aCompDataType);
if (!aComp) {
// Create SComponent
- _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+ _PTR(StudyBuilder) aBuilder = myStudyDS->NewBuilder();
aComp = aBuilder->NewComponent(aCompDataType);
aBuilder->SetName(aComp, dm->module()->moduleName().toStdString());
QString anIconName = dm->module()->iconName();
SalomeApp_DataModel::synchronize( aComp, this );
}
else {
- _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
+ _PTR(StudyBuilder) aBuilder = myStudyDS->NewBuilder();
aBuilder->SetName(aComp, dm->module()->moduleName().toStdString());
QString anIconName = dm->module()->iconName();
if (!anIconName.isEmpty()) {
// SalomeApp_DataModel* aDM = (SalomeApp_DataModel*)(dm);
SalomeApp_Module* aModule = dynamic_cast<SalomeApp_Module*>( dm->module() );
- _PTR(Study) aStudy = studyDS(); // shared_ptr cannot be used here
_PTR(SComponent) aSComp;
QString anEngine;
// 1. aModule == 0 means that this is a light module (no CORBA enigine)
// Issue 21377 - using separate engine for each type of light module
std::string aCompDataType = dm->module()->name().toStdString();
anEngine = SalomeApp_Engine_i::EngineIORForComponent( aCompDataType.c_str(), true ).c_str();
- aSComp = aStudy->FindComponent( aCompDataType );
+ aSComp = myStudyDS->FindComponent( aCompDataType );
}
else {
SalomeApp_DataModel* aDM = dynamic_cast<SalomeApp_DataModel*>( dm );
anEngine = aDM->getModule()->engineIOR();
if ( anEngine.isEmpty() )
return false;
- aSComp = aStudy->FindComponentID( std::string( anId.toLatin1() ) );
+ aSComp = myStudyDS->FindComponentID( std::string( anId.toLatin1() ) );
}
}
if ( aSComp ) {
- _PTR(StudyBuilder) aBuilder( aStudy->NewBuilder() );
+ _PTR(StudyBuilder) aBuilder( myStudyDS->NewBuilder() );
if ( aBuilder ) {
try {
aBuilder->LoadWith( aSComp, std::string( anEngine.toLatin1() ) );
return false;
}
-/*!
- Create new study name.
-*/
-QString SalomeApp_Study::newStudyName() const
-{
- std::vector<std::string> studies = SalomeApp_Application::studyMgr()->GetOpenStudies();
- QString prefix( "Study%1" ), newName, curName;
- int i = 1, j, n = studies.size();
- while ( newName.isEmpty() ){
- curName = prefix.arg( i );
- for ( j = 0 ; j < n; j++ ){
- if ( !strcmp( studies[j].c_str(), curName.toLatin1() ) )
- break;
- }
- if ( j == n )
- newName = curName;
- else
- i++;
- }
- return newName;
-}
-
/*!
Note that this method does not create or activate SalomeApp_Engine_i instance,
therefore it can be called safely for any kind of module, but for full
// Issue 21377 - using separate engine for each type of light module
SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false );
if (aDefaultEngine)
- return aDefaultEngine->GetListOfFiles(id());
+ return aDefaultEngine->GetListOfFiles();
std::vector<std::string> aListOfFiles;
return aListOfFiles;
// Issue 21377 - using separate engine for each type of light module
SalomeApp_Engine_i* aDefaultEngine = SalomeApp_Engine_i::GetInstance( theModuleName, false );
if (aDefaultEngine)
- aDefaultEngine->SetListOfFiles(theListOfFiles, id());
+ aDefaultEngine->SetListOfFiles(theListOfFiles);
}
/*!
if (isMultiFile)
return;
- std::vector<std::string> aListOfFiles = GetListOfFiles( theModuleName );
+ SALOMEDS_Tool::ListOfFiles aListOfFiles = GetListOfFiles( theModuleName );
if (aListOfFiles.size() > 0) {
std::string aTmpDir = aListOfFiles[0];
const int n = aListOfFiles.size() - 1;
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(n);
+ std::vector<std::string> aSeq;
+ aSeq.reserve(n);
for (int i = 0; i < n; i++)
- aSeq[i] = CORBA::string_dup(aListOfFiles[i + 1].c_str());
+ aSeq.push_back(CORBA::string_dup(aListOfFiles[i + 1].c_str()));
- SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
+ SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq, true);
}
}
void SalomeApp_Study::updateFromNotebook( const QString& theFileName, bool isSaved )
{
setStudyName(theFileName);
- studyDS()->Name(theFileName.toStdString());
+ studyDS()->URL(theFileName.toStdString());
setIsSaved( isSaved );
}
#endif
SalomeApp_Study( SUIT_Application* );
virtual ~SalomeApp_Study();
- virtual int id() const;
virtual QString studyName() const;
virtual bool createDocument( const QString& );
protected:
virtual void dataModelInserted( const CAM_DataModel* );
virtual bool openDataModel( const QString&, CAM_DataModel* );
- void setStudyDS(const _PTR(Study)& s );
+
virtual CAM_ModuleObject* createModuleObject( LightApp_DataModel* theDataModel,
SUIT_DataObject* theParent ) const;
protected slots:
void onNoteBookVarUpdate( QString theVarName );
#endif
-private:
- QString newStudyName() const;
-
private:
_PTR(Study) myStudyDS;
Observer_i* myObserver;
// Author : Roman NIKOLAEV
#include "SalomeApp_StudyPropertiesDlg.h"
+#include "SalomeApp_Application.h"
#include "SalomeApp_Study.h"
#include "SUIT_Session.h"
setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint );
- // Display study properties
- SalomeApp_Study* study =
- dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
- if (study)
- myStudyDoc = study->studyDS();
-
//Author
QLabel* authorLbl = new QLabel(tr("PRP_AUTHOR"),this);
myAuthor = new QLineEdit(this);
*/
void SalomeApp_StudyPropertiesDlg::initData()
{
- bool hasData = (myStudyDoc != NULL);
+ bool hasData = (SalomeApp_Application::getStudy() != NULL);
_PTR(AttributeStudyProperties) propAttr;
if (hasData)
- propAttr = myStudyDoc->GetProperties();
+ propAttr = SalomeApp_Application::getStudy()->GetProperties();
hasData = hasData && propAttr;
if (hasData) {
*/
void SalomeApp_StudyPropertiesDlg::clickOnOk()
{
- _PTR(AttributeStudyProperties) propAttr = myStudyDoc->GetProperties();
+ _PTR(AttributeStudyProperties) propAttr = SalomeApp_Application::getStudy()->GetProperties();
//Firstly, store locked flag
if(propAttr) {
bool bLocked = myLocked->isChecked();
void initData();
private:
- _PTR(Study) myStudyDoc;
bool myIsChanged;
QLineEdit* myAuthor;
QLabel* myDate;
#include "LightApp_DataOwner.h"
#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
/*!
Constructor.
{
const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*> ( sOwner );
- SalomeApp_Study* aDoc = getStudy();
- if (owner && aDoc && aDoc->studyDS())
+ if (owner)
+ {
+ QString entry = owner->entry();
+
+ _PTR(SObject) aSObj( SalomeApp_Application::getStudy()->FindObjectID( entry.toStdString() ) );
+ if (aSObj)
{
- _PTR(Study) aStudy = aDoc->studyDS();
- QString entry = owner->entry();
-
- _PTR(SObject) aSObj( aStudy->FindObjectID( entry.toStdString() ) );
- if (aSObj)
- {
- _PTR(SComponent) aComponent(aSObj->GetFatherComponent());
- if ( aComponent && (aComponent->ComponentDataType() == myKind.toStdString()) )
- return true;
- }
+ _PTR(SComponent) aComponent(aSObj->GetFatherComponent());
+ if ( aComponent && (aComponent->ComponentDataType() == myKind.toStdString()) )
+ return true;
}
+ }
return false;
}
from qtsalome import *
def minmax(context):
- # get context study, studyId, salomeGui
+ # get context study, salomeGui
study = context.study
- studyId = context.studyId
sg = context.sg
from minmax_ui import Ui_Dialog
import salome
import SMESH
from salome.smesh import smeshBuilder
- smesh = smeshBuilder.New(salome.myStudy)
+ smesh = smeshBuilder.New()
controls_dict = {
"Aspect Ratio 3D" : SMESH.FT_AspectRatio3D,
try:
import GEOM
from salome.geom import geomBuilder
- geompy = geomBuilder.New(salome.myStudy)
+ geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
- smesh = smeshBuilder.New(salome.myStudy)
+ smesh = smeshBuilder.New()
except:
DEMO_IS_ACTIVATED = False
from salome.geom import geomBuilder
# Intialize the geompy factory with the active study
- activeStudy = context.study
- geompy = geomBuilder.New(activeStudy)
+ geompy = geomBuilder.New()
# Create the objects
Vx = geompy.MakeVectorDXDYDZ(10, 0, 0)
from salome.geom import geomBuilder
# Intialize the geompy factory with the active study
- activeStudy = context.study
- geompy = geomBuilder.New(activeStudy)
+ geompy = geomBuilder.New()
# Create the objects
Vx = geompy.MakeVectorDXDYDZ(10, 0, 0)
def tube_shapewithgui(context):
global tubebuilder, xalome, dialog
- activeStudy = context.study
# Get the parameter values from a gui dialog box. If the dialog is
# closed using the Ok button, then the data are requested from the
dialog.exec_()
if dialog.wasOk():
radius, length, width = dialog.getData()
- shape = tubebuilder.createGeometry(activeStudy, radius, length, width)
- entry = xalome.addToStudy(activeStudy, shape, "Tube" )
+ shape = tubebuilder.createGeometry(radius, length, width)
+ entry = xalome.addToStudy(shape, "Tube" )
xalome.displayShape(entry)
#
def tube_meshwithgui(context):
global tube, dialog
- activeStudy = context.study
# Get the parameter values from a gui dialog box. If the dialog is
# closed using the Ok button, then the data are requested from the
dialog.exec_()
if dialog.wasOk():
radius, length, width = dialog.getData()
- mesh = tubebuilder.createModel(activeStudy, radius, length, width)
+ mesh = tubebuilder.createModel(radius, length, width)
salome_pluginsmanager.AddFunction('DEMO/Tube mesh from parameters',
dialogWithApply.setData(tubebuilder.DEFAULT_RADIUS,
tubebuilder.DEFAULT_LENGTH,
tubebuilder.DEFAULT_WIDTH)
- activeStudy = None
previewShapeEntry = None
DEFAULT_FOLDER_NAME="TubeList"
def acceptCallback():
"""Action to be done when click on Ok"""
global tubebuilder, xalome
- global dialogWithApply, activeStudy
+ global dialogWithApply
global previewShapeEntry, deletePreviewShape
global DEFAULT_FOLDER_NAME,DEFAULT_SHAPE_NAME
deletePreviewShape()
radius, length, width = dialogWithApply.getData()
- shape = tubebuilder.createGeometry(activeStudy, radius, length, width)
- entry = xalome.addToStudy(activeStudy, shape, DEFAULT_SHAPE_NAME, DEFAULT_FOLDER_NAME)
+ shape = tubebuilder.createGeometry(radius, length, width)
+ entry = xalome.addToStudy(shape, DEFAULT_SHAPE_NAME, DEFAULT_FOLDER_NAME)
xalome.displayShape(entry)
def rejectCallback():
def applyCallback():
"""Action to be done when click on Apply"""
global tubebuilder, xalome
- global dialogWithApply, activeStudy
+ global dialogWithApply
global previewShapeEntry, deletePreviewShape
global PREVIEW_COLOR, DEFAULT_SHAPE_NAME, DEFAULT_FOLDER_NAME, PREVIEW_SHAPE_NAME
# Then we can create the new shape with the new parameter values
radius, length, width = dialogWithApply.getData()
- shape = tubebuilder.createGeometry(activeStudy, radius, length, width)
+ shape = tubebuilder.createGeometry(radius, length, width)
# We apply a specific color on the shape for the preview state
shape.SetColor(PREVIEW_COLOR)
- previewShapeEntry = xalome.addToStudy(activeStudy, shape, PREVIEW_SHAPE_NAME, DEFAULT_FOLDER_NAME )
+ previewShapeEntry = xalome.addToStudy(shape, PREVIEW_SHAPE_NAME, DEFAULT_FOLDER_NAME )
xalome.displayShape(previewShapeEntry)
def deletePreviewShape():
"""This delete the shape currently being displayed as a preview"""
- global activeStudy, previewShapeEntry, xsalome
- xalome.deleteShape(activeStudy,previewShapeEntry)
+ global previewShapeEntry, xsalome
+ xalome.deleteShape(previewShapeEntry)
previewShapeEntry = None
# Connection of callback functions to the dialog butoon click signals
required callback functions to be associated to the button
signals.
"""
- global dialogWithApply, activeStudy
- activeStudy = context.study
+ global dialogWithApply
dialogWithApply.open()
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
# Create the objects
Vx = geompy.MakeVectorDXDYDZ(10, 0, 0)
from salome.geom import geomtools
-def createGeometry(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH):
+def createGeometry(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH):
'''
This function creates the geometry on the specified study and with
given parameters.
'''
print "TUBE: creating the geometry ..."
- studyId = study._get_StudyId()
- geompy = geomtools.getGeompy(studyId)
+ geompy = geomtools.getGeompy()
radius_ext = radius
radius_int = radius_ext - width
Tube = geompy.MakeCut(CylinderExt, CylinderInt)
return Tube
-def createGeometryWithPartition(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH):
+def createGeometryWithPartition(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH, width=DEFAULT_WIDTH):
'''
This function create the geometrical shape with a partition so
that the hexaedric algorithm could be used for meshing.
'''
- shape = createGeometry(study,radius,length,width)
+ shape = createGeometry(radius,length,width)
# We have to create a partition so that we can use an hexaedric
# meshing algorithm.
- studyId = study._get_StudyId()
- geompy = geomtools.getGeompy(studyId)
+ geompy = geomtools.getGeompy()
print "TUBE: creating a partition ..."
toolPlane = geompy.MakeFaceHW(2.1*length,2.1*radius,3)
entry = geompy.addToStudy( partition, "TubeWithPartition" )
return partition
-def createMesh(study, shape):
- '''This function creates the mesh of the specified shape on the specified study'''
+def createMesh(shape):
+ '''This function creates the mesh of the specified shape on the current study'''
print "TUBE: creating the mesh ..."
import SMESH
from salome.smesh import smeshBuilder
- smesh = smeshBuilder.New(study)
+ smesh = smeshBuilder.New()
mesh = smesh.Mesh(shape)
Regular_1D = mesh.Segment()
smesh.SetName(Nb_Segments, 'Nb. Segments_1')
smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
- salome.sg.updateObjBrowser(False)
+ salome.sg.updateObjBrowser()
return mesh
-def createModel(study, radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH,width=DEFAULT_WIDTH):
+def createModel(radius=DEFAULT_RADIUS, length=DEFAULT_LENGTH,width=DEFAULT_WIDTH):
'''
This function create the geomtrical shape AND the associated mesh.
'''
# We first create a shape with a partition so that the hexaedric
# algorithm could be used.
- shape = createGeometryWithPartition(study,radius,length,width)
+ shape = createGeometryWithPartition(radius,length,width)
# Then the mesh can be defined and computed
- mesh = createMesh(study,shape)
+ mesh = createMesh(shape)
def exportModel(mesh, filename):
'''
#
def TEST_createGeometry():
salome.salome_init()
- theStudy=salome.myStudy
- createGeometry(theStudy)
+ createGeometry()
def TEST_createMesh():
salome.salome_init()
- theStudy=salome.myStudy
- shape = createGeometryWithPartition(theStudy)
- mesh = createMesh(theStudy, shape)
+ shape = createGeometryWithPartition()
+ mesh = createMesh(shape)
def TEST_createModel():
salome.salome_init()
- theStudy=salome.myStudy
- createModel(theStudy)
+ createModel()
def TEST_exportModel():
salome.salome_init()
- theStudy=salome.myStudy
- shape = createGeometryWithPartition(theStudy)
- mesh = createMesh(theStudy, shape)
+ shape = createGeometryWithPartition()
+ mesh = createMesh(shape)
exportModel(mesh,"tubemesh.med")
if __name__ == "__main__":
# Helper functions to add/remove a geometrical shape in/from the study
# ======================================================================
-def addToStudy(study,shape,shapeName,folderName=None):
+def addToStudy(shape,shapeName,folderName=None):
"""
Add a GEOM shape in the study. It returns the associated entry
that corresponds to the identifier of the entry in the study. This
created in the Geometry part of the study, and the shape study
object is stored in this folder of the study.
"""
- studyId = study._get_StudyId()
- geompy = geomtools.getGeompy(studyId)
+ geompy = geomtools.getGeompy()
if folderName is None:
# Insert the shape in the study by the standard way
# A folder name has been specified to embed this shape. Find
# or create a folder with this name in the Geometry study, and
# then store the shape in this folder.
- studyEditor = getStudyEditor(studyId)
+ studyEditor = getStudyEditor()
geomStudyFolder = studyEditor.findOrCreateComponent("GEOM")
shapeStudyFolder = studyEditor.findOrCreateItem(geomStudyFolder,folderName)
return entry
-def removeFromStudy(study,shapeStudyEntry):
+def removeFromStudy(shapeStudyEntry):
"""
This removes the specified entry from the study. Note that this
operation does not destroy the underlying GEOM object, neither
erase the drawing in the viewer.
The underlying GEOM object is returned (so that it can be destroyed)
"""
- studyId = study._get_StudyId()
shape = IDToObject(shapeStudyEntry)
studyObject = IDToSObject(shapeStudyEntry)
- studyEditor = getStudyEditor(studyId)
+ studyEditor = getStudyEditor()
studyEditor.removeItem(studyObject,True)
return shape
# Helper functions for a complete suppression of a shape from the
# SALOME session.
# ======================================================================
-def deleteShape(study,shapeStudyEntry):
+def deleteShape(shapeStudyEntry):
"""
This completly deletes a geom shape.
3. destroy the underlying geom object
"""
eraseShape(shapeStudyEntry)
- shape = removeFromStudy(study, shapeStudyEntry)
+ shape = removeFromStudy(shapeStudyEntry)
if shape is not None:
shape.Destroy()
"""
import salome
salome.salome_init()
- study = salome.myStudy
- studyId = salome.myStudyId
+ study = salome.myStudy
from salome.geom import geomtools
- geompy = geomtools.getGeompy(studyId)
+ geompy = geomtools.getGeompy()
# --------------------------------------------------
# Create a first shape (GEOM object)
# folder. A name must be specified. The register operation
# (addToStudy) returns an identifier of the entry in the study.
cylinderName = "cyl.r%s.l%s"%(radius,length)
- cylinderStudyEntry = addToStudy(study, cylinder, cylinderName)
+ cylinderStudyEntry = addToStudy(cylinder, cylinderName)
# Display the registered shape in a viewer
displayShape(cylinderStudyEntry)
radius = 10
sphere = geompy.MakeSphereR(radius)
sphereName = "sph.r%s"%radius
- sphereStudyEntry = addToStudy(study, sphere, sphereName)
+ sphereStudyEntry = addToStudy(sphere, sphereName)
displayShape(sphereStudyEntry)
# --------------------------------------------------
box = geompy.MakeBoxDXDYDZ(length,length,length)
boxName = "box.l%s"%length
folderName = "boxset"
- boxStudyEntry = addToStudy(study, box, boxName, folderName)
+ boxStudyEntry = addToStudy(box, boxName, folderName)
displayShape(boxStudyEntry,PreviewColor)
# --------------------------------------------------
# SALOME session (erase from viewer, remove from study and finnaly
# destroy the object). This is done by a simple call to
# deleteShape().
- deleteShape(study,cylinderStudyEntry)
+ deleteShape(cylinderStudyEntry)
# --------------------------------------------------
# At the end of the executioon of this test, you should have in
<source>WRN_FILE_NOT_EXIST</source>
<translation>The file %1 does not exist.</translation>
</message>
- <message>
- <source>ERR_ACTIVEDOC_LOAD</source>
- <translation>A study is already active in your session, but you are not connected to it. Use the Connect button to load it in the interface.</translation>
- </message>
<message>
<source>WRN_STUDY_LOCKED</source>
<translation>Study is locked.</translation>
</message>
<message>
<source>QUE_DOC_ALREADYEXIST</source>
- <translation>The document %1 already exists in study manager.
+ <translation>The document %1 already exists.
Do you want to reload it ?</translation>
</message>
<message>
<source>WRN_FILE_NOT_EXIST</source>
<translation>Le fichier %1 n'existe pas.</translation>
</message>
- <message>
- <source>ERR_ACTIVEDOC_LOAD</source>
- <translation>Une étude est déjà chargée dans votre session mais vous n'y êtes pas connectée. Utilisez le bouton "Connecter" pour charger l'étude dans l'interface.</translation>
- </message>
<message>
<source>WRN_STUDY_LOCKED</source>
<translation>L'étude est verrouillée</translation>
</message>
<message>
<source>QUE_DOC_ALREADYEXIST</source>
- <translation>Le document %1 existe déjà dans le gestionnaire d'études.
+ <translation>Le document %1 existe déjà.
Voulez-vous le recharger ?</translation>
</message>
<message>
<source>WRN_FILE_NOT_EXIST</source>
<translation>ファイル %1 は存在しません。</translation>
</message>
- <message>
- <source>ERR_ACTIVEDOC_LOAD</source>
- <translation>A study is already active in your session, but you are not connected to it. Use the Connect button to load it in the interface.
-スタディはあなたのセッション内ですでにアクティブになっていますが、接続できません。インターフェイス内でそれをロードするための接続用ボタンを使用してください。</translation>
- </message>
<message>
<source>WRN_STUDY_LOCKED</source>
<translation>スタディがロックされています</translation>
</message>
<message>
<source>QUE_DOC_ALREADYEXIST</source>
- <translation>ドキュメント %1 は研究のマネージャーに既に存在します。それを再読み込みしますか。</translation>
+ <translation>ドキュメント %1 はの存在。それを再読み込みしますか。</translation>
</message>
<message>
<source>MEN_RENAME_VS</source>
context attributes:
- sg : the SALOME Swig interface
- - studyId : the SALOME studyId that must be used to execute the plugin
- study : the SALOME study object that must be used to execute the plugin
"""
class Context:
def __init__(self,sgpyqt):
self.sg=sgpyqt
- self.studyId=salome.sg.getActiveStudyId()
- self.study= salome.myStudyManager.GetStudyByID(self.studyId)
+ self.study=salome.myStudy
def find_menu(smenu):
lmenus=smenu.split("|")
def importPlugins(self):
"""Execute the salome_plugins file that contains plugins definition """
- studyId=sg.getActiveStudyId()
- if studyId == 0:
- self.menu.clear()
- self.menu.menuAction().setVisible(False)
- return
- elif self.lasttime ==0 or salome.myStudy == None:
+ if self.lasttime ==0 or salome.myStudy == None:
salome.salome_init(embedded=1)
lasttime=0
SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance();
ASSERT( SINGLETON_<SALOME_NamingService>::IsAlreadyExisting() );
NS.init_orb( orb );
- CORBA::Object_var obj = NS.Resolve( "/myStudyManager" );
- SALOMEDS::StudyManager_var studyManager = SALOMEDS::StudyManager::_narrow( obj );
- if ( !CORBA::is_nil( studyManager ) ) {
- MESSAGE( "/myStudyManager is found" );
- studyManager->ping();
- MESSAGE( "StudyManager was activated" );
+ CORBA::Object_var obj = NS.Resolve( "/Study" );
+ SALOMEDS::Study_var study = SALOMEDS::Study::_narrow( obj );
+ if ( !CORBA::is_nil( study ) ) {
+ MESSAGE( "/Study is found" );
+ study->ping();
+ MESSAGE( "Study was activated" );
setStep( ++current * myAttempts );
break;
}
}
case 4: // Session
{
- NamingService_WaitForServerReadiness(_NS,"/myStudyManager");
+ NamingService_WaitForServerReadiness(_NS,"/Study");
std::string containerName = "/Containers/";
containerName = containerName + Kernel_Utils::GetHostname();
containerName = containerName + "/FactoryServer";
// counted objects, they will be deleted by the POA when they are no
// longer needed.
- ClientFactory::createStudyManager(_orb,_root_poa);
+ ClientFactory::createStudy(_orb,_root_poa);
}
catch(CORBA::SystemException&) {
INFOS( "Caught CORBA::SystemException." );
_argc = argc ;
_argv = argv ;
_isGUI = false ;
- _runningStudies= 0 ;
_orb = CORBA::ORB::_duplicate(orb) ;
_poa = PortableServer::POA::_duplicate(poa) ;
_GUIMutex = GUIMutex;
/*!
Send a SALOME::StatSession structure (see idl) to the client
- (number of running studies and presence of GUI)
+ (presence of GUI)
*/
/*class QtLock
{
{
// update Session state
_GUIMutex->lock();
+ int activeStudy = 0;
- _runningStudies = 0;
{
//QtLock lock;
_isGUI = SUIT_Session::session();
if ( _isGUI && SUIT_Session::session()->activeApplication() )
- _runningStudies = SUIT_Session::session()->activeApplication()->getNbStudies();
+ activeStudy = SUIT_Session::session()->activeApplication()->getNbStudies();
}
// getting stat info
- SALOME::StatSession_var myStats = new SALOME::StatSession ;
- if (_runningStudies)
+ SALOME::StatSession_var myStats = new SALOME::StatSession;
+ if (activeStudy)
myStats->state = SALOME::running ;
else if (_isShuttingDown)
myStats->state = SALOME::shutdown ;
else
myStats->state = SALOME::asleep ;
- myStats->runningStudies = _runningStudies ;
myStats->activeGUI = _isGUI ;
_GUIMutex->unlock();
return myStats._retn() ;
}
-CORBA::Long SALOME_Session_i::GetActiveStudyId()
-{
- long aStudyId=-1;
- if ( SUIT_Session::session() && SUIT_Session::session()->activeApplication() ) {
- if ( SUIT_Session::session()->activeApplication()->activeStudy() ) // mkr : IPAL12128
- aStudyId = SUIT_Session::session()->activeApplication()->activeStudy()->id();
- }
- return aStudyId;
-}
-
CORBA::Long SALOME_Session_i::getPID() {
return (CORBA::Long)
#ifndef WIN32
//! Unregister the servant from Naming Service
void NSunregister();
- CORBA::Long GetActiveStudyId();
-
void ping(){};
CORBA::Long getPID();
char* getHostname();
CORBA::Boolean _isGUI ;
QMutex* _GUIMutex ;
QWaitCondition* _GUILauncher;
- int _runningStudies ;
CORBA::ORB_var _orb;
PortableServer::POA_var _poa;
bool _isShuttingDown;
${CAS_KERNEL}
${KERNEL_SalomeIDLKernel}
${KERNEL_SALOMELocalTrace}
+ ${KERNEL_SalomeDSClient}
${KERNEL_SalomeNS}
${KERNEL_OpUtil}
+ ${KERNEL_SalomeKernelHelpers}
${OMNIORB_LIBRARIES}
qtx suit
)
// Author : Nicolas REJNERI
//
#include "ToolsGUI.h"
+#include <SALOMEDSClient_ClientFactory.hxx>
+#include <SALOME_KernelServices.hxx>
/*!
\class ToolsGUI
/*!
\brief Get visibility value of the "AttributeGraphic" attribute.
- \param theStudy study
\param theObj object
\param theId sub-object identifier
\return \c true if an object (sub-object) is visible
*/
-bool ToolsGUI::GetVisibility( _PTR(Study) theStudy,
- _PTR(SObject) theObj,
+bool ToolsGUI::GetVisibility( _PTR(SObject) theObj,
void* theId )
{
_PTR(GenericAttribute) anAttr;
/*!
\brief Set visibility value of the "AttributeGraphic" attribute.
- \param theStudy study
\param theObj object
\return theValue new visibility value
\param theId sub-object identifier
*/
-bool ToolsGUI::SetVisibility( _PTR(Study) theStudy,
- const char* theEntry,
+bool ToolsGUI::SetVisibility( const char* theEntry,
const bool theValue,
void* theId )
{
- _PTR(SObject) anObj ( theStudy->FindObjectID( theEntry ) );
+ _PTR(Study) aStudy = ClientFactory::Study(KERNEL::getStudyServant());
+ _PTR(SObject) anObj ( aStudy->FindObjectID( theEntry ) );
if ( anObj )
{
}
else if ( theValue )
{
- _PTR(StudyBuilder) aBuilder (theStudy->NewBuilder());
+ _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
_PTR(AttributeGraphic) anAttr (aBuilder->FindOrCreateAttribute(anObj, "AttributeGraphic"));
anAttr->SetVisibility( (unsigned long)theId, theValue );
}
class TOOLSGUI_EXPORT ToolsGUI
{
public :
- static bool GetVisibility( _PTR(Study) theStudy,
- _PTR(SObject) theObj,
+ static bool GetVisibility( _PTR(SObject) theObj,
void* theId );
- static bool SetVisibility( _PTR(Study) theStudy,
- const char* theEntry,
+ static bool SetVisibility( const char* theEntry,
const bool theValue,
void* theId );
};