1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File: SalomeApp_Application.cxx
23 // Created: 10/22/2004 3:23:45 PM
24 // Author: Sergey LITONIN
26 #include "SalomeApp_PyInterp.h" // WARNING! This include must be the first!
27 #include "SalomeApp_Application.h"
28 #include "SalomeApp_Study.h"
29 #include "SalomeApp_DataModel.h"
30 #include "SalomeApp_DataObject.h"
31 #include "SalomeApp_VisualState.h"
32 #include "SalomeApp_StudyPropertiesDlg.h"
33 #include "SalomeApp_LoadStudiesDlg.h"
34 #include "SalomeApp_NoteBookDlg.h"
36 #include "SalomeApp_ExitDlg.h"
38 #include <LightApp_Application.h>
39 #include <LightApp_Preferences.h>
40 #include <LightApp_SelectionMgr.h>
41 #include <LightApp_NameDlg.h>
42 #include <LightApp_DataOwner.h>
44 #include <CAM_Module.h>
46 #include <SUIT_Tools.h>
47 #include <SUIT_Session.h>
48 #include <SUIT_Desktop.h>
49 #include <SUIT_DataBrowser.h>
50 #include <SUIT_FileDlg.h>
51 #include <SUIT_FileValidator.h>
52 #include <SUIT_MessageBox.h>
53 #include <SUIT_ResourceMgr.h>
54 #include <SUIT_TreeModel.h>
56 #include <QtxTreeView.h>
58 #include <SALOME_EventFilter.h>
60 // temporary commented
61 //#include <OB_ListItem.h>
63 #include <PyConsole_Console.h>
65 #include <Utils_ORB_INIT.hxx>
66 #include <Utils_SINGLETON.hxx>
67 #include <SALOME_LifeCycleCORBA.hxx>
69 #include <QApplication>
73 #include <QPushButton>
75 #include <QListWidget>
76 #include <QGridLayout>
79 #include <SALOMEDSClient_ClientFactory.hxx>
81 #include <SALOME_ListIteratorOfListIO.hxx>
82 #include <SALOME_ListIO.hxx>
84 #include <ToolsGUI_CatalogGeneratorDlg.h>
85 #include <ToolsGUI_RegWidget.h>
89 /*!Internal class that updates object browser item properties */
90 // temporary commented
91 /*class SalomeApp_Updater : public OB_Updater
94 SalomeApp_Updater() : OB_Updater(){};
95 virtual ~SalomeApp_Updater(){};
96 virtual void update( SUIT_DataObject* theObj, OB_ListItem* theItem );
99 void SalomeApp_Updater::update( SUIT_DataObject* theObj, OB_ListItem* theItem )
101 if( !theObj || !theItem )
104 SalomeApp_DataObject* SAObj = dynamic_cast<SalomeApp_DataObject*>( theObj );
108 _PTR(SObject) SObj = SAObj->object();
111 _PTR( GenericAttribute ) anAttr;
114 if ( SObj->FindAttribute( anAttr, "AttributeSelectable" ) )
116 _PTR(AttributeSelectable) aAttrSel = anAttr;
117 theItem->setSelectable( aAttrSel->IsSelectable() );
120 if ( SObj->FindAttribute(anAttr, "AttributeExpandable") )
122 _PTR(AttributeExpandable) aAttrExpand = anAttr;
123 theItem->setExpandable( aAttrExpand->IsExpandable() );
126 //this attribute is not supported in the version of SALOME 3.x
127 //if ( SObj->FindAttribute(anAttr, "AttributeOpened") )
129 // _PTR(AttributeOpened) aAttrOpen = anAttr;
130 // theItem->setOpen( aAttrOpen->IsOpened() );
134 /*!Create new instance of SalomeApp_Application.*/
135 extern "C" SALOMEAPP_EXPORT SUIT_Application* createApplication()
137 return new SalomeApp_Application();
141 SalomeApp_Application::SalomeApp_Application()
142 : LightApp_Application()
144 connect( desktop(), SIGNAL( message( const QString& ) ),
145 this, SLOT( onDesktopMessage( const QString& ) ) );
150 *\li Destroy event filter.
152 SalomeApp_Application::~SalomeApp_Application()
154 // Do not destroy. It's a singleton !
155 //SALOME_EventFilter::Destroy();
158 /*!Start application.*/
159 void SalomeApp_Application::start()
161 LightApp_Application::start();
163 SALOME_EventFilter::Init();
165 static bool isFirst = true;
172 for (int i = 1; i < qApp->argc(); i++) {
173 QRegExp rxs ("--study-hdf=(.+)");
174 if ( rxs.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxs.capturedTexts().count() > 1 ) {
175 QString file = rxs.capturedTexts()[1];
176 QFileInfo fi ( file );
177 QString extension = fi.suffix().toLower();
178 if ( extension == "hdf" && fi.exists() )
179 hdffile = fi.absoluteFilePath();
182 QRegExp rxp ("--pyscript=(.+)");
183 if ( rxp.indexIn( QString(qApp->argv()[i]) ) >= 0 && rxp.capturedTexts().count() > 1 ) {
184 QStringList files = rxp.capturedTexts()[1].split(",",QString::SkipEmptyParts);
190 if ( !hdffile.isEmpty() ) // open hdf file given as parameter
191 onOpenDoc( hdffile );
192 else if ( pyfiles.count() > 0 ) // create new study
195 // import/execute python scripts
196 if ( pyfiles.count() > 0 && activeStudy() ) {
197 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
199 _PTR(Study) aStudy = appStudy->studyDS();
200 if ( !aStudy->GetProperties()->IsLocked() ) {
201 for (uint j = 0; j < pyfiles.count(); j++ ) {
202 QFileInfo fi ( pyfiles[j] );
203 PyConsole_Console* pyConsole = pythonConsole();
205 QString extension = fi.suffix().toLower();
207 // execute python script
208 QString command = QString( "execfile(\"%1\")" ).arg( fi.absoluteFilePath() );
209 pyConsole->exec( command );
212 // import python module
213 QString command = QString( "import %1" ).arg( pyfiles[j] );
214 if ( extension == "py" )
215 command = QString( "import %1" ).arg( fi.completeBaseName() );
216 pyConsole->exec( command );
227 void SalomeApp_Application::createActions()
229 LightApp_Application::createActions();
231 SUIT_Desktop* desk = desktop();
234 // "Save GUI State" command is moved to VISU module
235 // createAction( SaveGUIStateId, tr( "TOT_DESK_FILE_SAVE_GUI_STATE" ), QIcon(),
236 // tr( "MEN_DESK_FILE_SAVE_GUI_STATE" ), tr( "PRP_DESK_FILE_SAVE_GUI_STATE" ),
237 // 0, desk, false, this, SLOT( onSaveGUIState() ) );
240 createAction( DumpStudyId, tr( "TOT_DESK_FILE_DUMP_STUDY" ), QIcon(),
241 tr( "MEN_DESK_FILE_DUMP_STUDY" ), tr( "PRP_DESK_FILE_DUMP_STUDY" ),
242 Qt::CTRL+Qt::Key_D, desk, false, this, SLOT( onDumpStudy() ) );
245 createAction(NoteBookId, tr( "TOT_DESK_FILE_NOTEBOOK" ), QIcon(),
246 tr( "MEN_DESK_FILE_NOTEBOOK" ), tr( "PRP_DESK_FILE_NOTEBOOK" ),
247 Qt::CTRL+Qt::Key_K, desk, false, this, SLOT(onNoteBook()));
250 createAction( LoadScriptId, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), QIcon(),
251 tr( "MEN_DESK_FILE_LOAD_SCRIPT" ), tr( "PRP_DESK_FILE_LOAD_SCRIPT" ),
252 Qt::CTRL+Qt::Key_T, desk, false, this, SLOT( onLoadScript() ) );
255 createAction( PropertiesId, tr( "TOT_DESK_PROPERTIES" ), QIcon(),
256 tr( "MEN_DESK_PROPERTIES" ), tr( "PRP_DESK_PROPERTIES" ),
257 Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onProperties() ) );
259 //! Catalog Generator
260 createAction( CatalogGenId, tr( "TOT_DESK_CATALOG_GENERATOR" ), QIcon(),
261 tr( "MEN_DESK_CATALOG_GENERATOR" ), tr( "PRP_DESK_CATALOG_GENERATOR" ),
262 Qt::SHIFT+Qt::Key_G, desk, false, this, SLOT( onCatalogGen() ) );
265 createAction( RegDisplayId, tr( "TOT_DESK_REGISTRY_DISPLAY" ), QIcon(),
266 tr( "MEN_DESK_REGISTRY_DISPLAY" ), tr( "PRP_DESK_REGISTRY_DISPLAY" ),
267 /*Qt::SHIFT+Qt::Key_D*/0, desk, false, this, SLOT( onRegDisplay() ) );
269 //SRN: BugID IPAL9021, add an action "Load"
270 createAction( FileLoadId, tr( "TOT_DESK_FILE_LOAD" ),
271 resourceMgr()->loadPixmap( "STD", tr( "ICON_FILE_OPEN" ) ),
272 tr( "MEN_DESK_FILE_LOAD" ), tr( "PRP_DESK_FILE_LOAD" ),
273 Qt::CTRL+Qt::Key_L, desk, false, this, SLOT( onLoadDoc() ) );
274 //SRN: BugID IPAL9021: End
277 int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
279 // "Save GUI State" command is renamed to "Save VISU State" and
280 // creation of menu item is moved to VISU
281 // createMenu( SaveGUIStateId, fileMenu, 10, -1 );
283 createMenu( FileLoadId, fileMenu, 0 ); //SRN: BugID IPAL9021, add a menu item "Load"
285 createMenu( DumpStudyId, fileMenu, 10, -1 );
286 createMenu( NoteBookId, fileMenu, 10, -1 );
287 createMenu( separator(), fileMenu, -1, 10, -1 );
288 createMenu( LoadScriptId, fileMenu, 10, -1 );
289 createMenu( separator(), fileMenu, -1, 10, -1 );
290 createMenu( PropertiesId, fileMenu, 10, -1 );
291 createMenu( separator(), fileMenu, -1, 10, -1 );
293 int toolsMenu = createMenu( tr( "MEN_DESK_TOOLS" ), -1, MenuToolsId, 50 );
294 createMenu( CatalogGenId, toolsMenu, 10, -1 );
295 createMenu( RegDisplayId, toolsMenu, 10, -1 );
296 createMenu( separator(), toolsMenu, -1, 15, -1 );
300 \brief Close application.
302 void SalomeApp_Application::onExit()
304 bool killServers = false;
307 if ( exitConfirmation() ) {
308 SalomeApp_ExitDlg dlg( desktop() );
309 result = dlg.exec() == QDialog::Accepted;
310 killServers = dlg.isServersShutdown();
314 SUIT_Session::session()->closeSession( SUIT_Session::ASK, killServers );
317 /*!SLOT. Load document.*/
318 void SalomeApp_Application::onLoadDoc()
322 std::vector<std::string> List = studyMgr()->GetOpenStudies();
324 SUIT_Session* aSession = SUIT_Session::session();
325 QList<SUIT_Application*> aAppList = aSession->applications();
327 QStringList unloadedStudies;
329 for ( unsigned int ind = 0; ind < List.size(); ind++ ) {
330 studyName = List[ind].c_str();
331 // Add to list only unloaded studies
332 bool isAlreadyOpen = false;
333 QListIterator<SUIT_Application*> it( aAppList );
334 while ( it.hasNext() && !isAlreadyOpen ) {
335 SUIT_Application* aApp = it.next();
336 if( !aApp || !aApp->activeStudy() )
338 if ( aApp->activeStudy()->studyName() == studyName )
339 isAlreadyOpen = true;
342 if ( !isAlreadyOpen )
343 unloadedStudies << studyName;
346 studyName = SalomeApp_LoadStudiesDlg::selectStudy( desktop(), unloadedStudies );
347 if ( studyName.isEmpty() )
351 // this code replaces marker of windows drive and path become invalid therefore
352 // defines placed there
353 studyName.replace( QRegExp(":"), "/" );
356 if ( onLoadDoc( studyName ) ) {
358 updateViewManagers();
359 updateObjectBrowser( true );
363 /*!SLOT. Load document with \a aName.*/
364 bool SalomeApp_Application::onLoadDoc( const QString& aName )
367 if ( !activeStudy() ) {
368 // if no study - load in current desktop
369 res = useStudy( aName );
372 // if study exists - load in new desktop. Check: is the same file is loaded?
373 SUIT_Session* aSession = SUIT_Session::session();
374 QList<SUIT_Application*> aAppList = aSession->applications();
375 bool isAlreadyOpen = false;
376 SalomeApp_Application* aApp = 0;
377 for ( QList<SUIT_Application*>::iterator it = aAppList.begin();
378 it != aAppList.end() && !isAlreadyOpen; ++it ) {
379 aApp = dynamic_cast<SalomeApp_Application*>( *it );
380 if ( aApp && aApp->activeStudy()->studyName() == aName )
381 isAlreadyOpen = true;
383 if ( !isAlreadyOpen ) {
384 aApp = dynamic_cast<SalomeApp_Application*>( startApplication( 0, 0 ) );
386 res = aApp->useStudy( aName );
389 aApp->desktop()->activateWindow();
396 /*!SLOT. Copy objects to study maneger from selection maneger..*/
397 void SalomeApp_Application::onCopy()
400 LightApp_SelectionMgr* mgr = selectionMgr();
401 mgr->selectedObjects(list);
403 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
404 if(study == NULL) return;
406 _PTR(Study) stdDS = study->studyDS();
409 SALOME_ListIteratorOfListIO it( list );
412 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
414 studyMgr()->Copy(so);
415 onSelectionChanged();
422 /*!SLOT. Paste objects to study maneger from selection manager.*/
423 void SalomeApp_Application::onPaste()
426 LightApp_SelectionMgr* mgr = selectionMgr();
427 mgr->selectedObjects(list);
429 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
430 if(study == NULL) return;
432 _PTR(Study) stdDS = study->studyDS();
435 if ( stdDS->GetProperties()->IsLocked() ) {
436 SUIT_MessageBox::warning( desktop(),
437 QObject::tr("WRN_WARNING"),
438 QObject::tr("WRN_STUDY_LOCKED") );
442 SALOME_ListIteratorOfListIO it( list );
445 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
447 studyMgr()->Paste(so);
448 updateObjectBrowser( true );
449 updateActions(); //SRN: BugID IPAL9377, case 3
456 /*!Check the application on closing.
457 * \retval true if possible, else false
459 bool SalomeApp_Application::isPossibleToClose( bool& closePermanently )
461 return LightApp_Application::isPossibleToClose( closePermanently );
464 /*! Check if the study is locked */
465 void SalomeApp_Application::onCloseDoc( bool ask )
467 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
470 _PTR(Study) stdDS = study->studyDS();
471 if(stdDS && stdDS->IsStudyLocked()) {
472 if ( SUIT_MessageBox::question( desktop(),
473 QObject::tr( "WRN_WARNING" ),
474 QObject::tr( "CLOSE_LOCKED_STUDY" ),
475 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
476 SUIT_MessageBox::No) == SUIT_MessageBox::No ) return;
481 LightApp_Application::onCloseDoc( ask );
482 if(myNoteBook && myNoteBook->isVisible())
486 /*!Sets enable or disable some actions on selection changed.*/
487 void SalomeApp_Application::onSelectionChanged()
490 LightApp_SelectionMgr* mgr = selectionMgr();
491 mgr->selectedObjects(list);
493 bool canCopy = false;
494 bool canPaste = false;
496 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
498 _PTR(Study) stdDS = study->studyDS();
501 SALOME_ListIteratorOfListIO it ( list );
503 if (it.More() && list.Extent() == 1) {
504 _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
507 canCopy = studyMgr()->CanCopy(so);
508 canPaste = studyMgr()->CanPaste(so);
514 action(EditCopyId)->setEnabled(canCopy);
515 action(EditPasteId)->setEnabled(canPaste);
518 /*!Delete references.*/
519 void SalomeApp_Application::onDeleteInvalidReferences()
522 LightApp_SelectionMgr* mgr = selectionMgr();
523 mgr->selectedObjects( aList, QString(), false );
525 if( aList.IsEmpty() )
528 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
529 _PTR(Study) aStudyDS = aStudy->studyDS();
530 _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder();
533 for( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() )
534 if ( it.Value()->hasEntry() )
536 _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
537 while( aRefObj && aRefObj->ReferencedObject( anObj ) )
540 if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
541 aStudyBuilder->RemoveReference( aSObject );
543 updateObjectBrowser();
547 void SalomeApp_Application::onOpenWith()
549 QApplication::setOverrideCursor( Qt::WaitCursor );
551 LightApp_SelectionMgr* mgr = selectionMgr();
552 mgr->selectedObjects(aList);
553 if (aList.Extent() != 1)
555 QApplication::restoreOverrideCursor();
558 Handle(SALOME_InteractiveObject) aIObj = aList.First();
559 QString aModuleName(aIObj->getComponentDataType());
560 QString aModuleTitle = moduleTitle(aModuleName);
561 activateModule(aModuleTitle);
562 QApplication::restoreOverrideCursor();
568 SUIT_Study* SalomeApp_Application::createNewStudy()
570 SalomeApp_Study* aStudy = new SalomeApp_Study( this );
572 // Set up processing of major study-related events
573 connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
574 connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
575 connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
576 connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
582 Enable/Disable menu items and toolbar buttons. Rebuild menu
584 void SalomeApp_Application::updateCommandsStatus()
586 LightApp_Application::updateCommandsStatus();
589 QAction* a = action( DumpStudyId );
591 a->setEnabled( activeStudy() );
594 a = action(NoteBookId);
596 a->setEnabled( activeStudy() );
599 a = action( LoadScriptId );
601 a->setEnabled( activeStudy() );
604 a = action( PropertiesId );
606 a->setEnabled( activeStudy() );
608 // Save GUI state menu
609 a = action( SaveGUIStateId );
611 a->setEnabled( activeStudy() );
613 // update state of Copy/Paste menu items
614 onSelectionChanged();
618 \class DumpStudyFileDlg
619 Private class used in Dump Study operation. Consists 2 check boxes:
620 "Publish in study" and "Save GUI parameters"
622 class DumpStudyFileDlg : public SUIT_FileDlg
625 DumpStudyFileDlg( QWidget* parent ) : SUIT_FileDlg( parent, false, true, true )
627 QGridLayout* grid = ::qobject_cast<QGridLayout*>( layout() );
630 QWidget *hB = new QWidget( this );
631 myPublishChk = new QCheckBox( tr("PUBLISH_IN_STUDY") );
632 mySaveGUIChk = new QCheckBox( tr("SAVE_GUI_STATE") );
634 QHBoxLayout *layout = new QHBoxLayout;
635 layout->addWidget(myPublishChk);
636 layout->addWidget(mySaveGUIChk);
637 hB->setLayout(layout);
639 QPushButton* pb = new QPushButton(this);
641 int row = grid->rowCount();
642 grid->addWidget( new QLabel("", this), row, 0 );
643 grid->addWidget( hB, row, 1, 1, 3 );
644 grid->addWidget( pb, row, 5 );
649 QCheckBox* myPublishChk;
650 QCheckBox* mySaveGUIChk;
653 class DumpStudyFileValidator : public SUIT_FileValidator
656 DumpStudyFileValidator( QWidget* parent) : SUIT_FileValidator ( parent ) {};
657 virtual ~DumpStudyFileValidator() {};
658 virtual bool canSave( const QString& file, bool permissions );
661 bool DumpStudyFileValidator::canSave(const QString& file, bool permissions)
663 QFileInfo fi( file );
664 QString name = fi.fileName();
666 if ( name.indexOf( QRegExp("[-!?#*&]") ) >= 0 ) {
667 SUIT_MessageBox::critical( parent(),
668 QObject::tr("WRN_WARNING"),
669 QObject::tr("WRN_FILE_NAME_BAD") );
672 return SUIT_FileValidator::canSave( file, permissions);
675 /*!Private SLOT. On dump study.*/
676 void SalomeApp_Application::onDumpStudy( )
678 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
679 if ( !appStudy ) return;
680 _PTR(Study) aStudy = appStudy->studyDS();
682 QStringList aFilters;
683 aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
685 DumpStudyFileDlg fd( desktop() );
686 fd.setValidator( new DumpStudyFileValidator( &fd ) );
687 fd.setWindowTitle( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
688 fd.setFilters( aFilters );
689 fd.myPublishChk->setChecked( true );
690 fd.mySaveGUIChk->setChecked( true );
691 if ( fd.exec() == QDialog::Accepted )
693 QString aFileName = fd.selectedFile();
695 bool toPublish = fd.myPublishChk->isChecked();
696 bool toSaveGUI = fd.mySaveGUIChk->isChecked();
698 if ( !aFileName.isEmpty() ) {
699 QFileInfo aFileInfo(aFileName);
700 if( aFileInfo.isDir() ) // IPAL19257
704 _PTR(AttributeParameter) ap;
705 _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
706 if(ip->isDumpPython(appStudy->studyDS())) ip->setDumpPython(appStudy->studyDS()); //Unset DumpPython flag.
707 if ( toSaveGUI ) { //SRN: Store a visual state of the study at the save point for DumpStudy method
708 ip->setDumpPython(appStudy->studyDS());
709 savePoint = SalomeApp_VisualState( this ).storeState(); //SRN: create a temporary save point
711 bool res = aStudy->DumpStudy( aFileInfo.absolutePath().toStdString(),
712 aFileInfo.baseName().toStdString(), toPublish);
714 appStudy->removeSavePoint(savePoint); //SRN: remove the created temporary save point.
716 SUIT_MessageBox::warning( desktop(),
717 QObject::tr("WRN_WARNING"),
718 tr("WRN_DUMP_STUDY_FAILED") );
723 /*!Private SLOT. On NoteBook*/
724 void SalomeApp_Application::onNoteBook()
726 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
728 _PTR(Study) aStudy = appStudy->studyDS();
730 myNoteBook = new SalomeApp_NoteBookDlg(desktop(),aStudy);
732 else if(!myNoteBook->isVisible()){
733 myNoteBook->Init(aStudy);
734 myNoteBook->adjustSize();
735 myNoteBook->move((int)(desktop()->x() + desktop()->width()/2 - myNoteBook->frameGeometry().width()/2),
736 (int)(desktop()->y() + desktop()->height()/2 - myNoteBook->frameGeometry().height()/2));
742 /*!Private SLOT. On load script.*/
743 void SalomeApp_Application::onLoadScript( )
745 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
746 if ( !appStudy ) return;
747 _PTR(Study) aStudy = appStudy->studyDS();
749 if ( aStudy->GetProperties()->IsLocked() ) {
750 SUIT_MessageBox::warning( desktop(),
751 QObject::tr("WRN_WARNING"),
752 QObject::tr("WRN_STUDY_LOCKED") );
756 QStringList filtersList;
757 filtersList.append(tr("PYTHON_FILES_FILTER"));
758 filtersList.append(tr("ALL_FILES_FILTER"));
760 QString anInitialPath = "";
761 if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
762 anInitialPath = QDir::currentPath();
764 QString aFile = SUIT_FileDlg::getFileName( desktop(), anInitialPath, filtersList, tr( "TOT_DESK_FILE_LOAD_SCRIPT" ), true, true );
766 if ( !aFile.isEmpty() )
768 QString command = QString("execfile(\"%1\")").arg(aFile);
770 PyConsole_Console* pyConsole = pythonConsole();
773 pyConsole->exec( command );
777 /*!Private SLOT. On save GUI state.*/
778 void SalomeApp_Application::onSaveGUIState()
780 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
782 SalomeApp_VisualState( this ).storeState();
783 updateSavePointDataObjects( study );
784 // temporary commented
785 //objectBrowser()->updateTree( study->root() );
791 *\retval QString "(*.hdf)"
793 QString SalomeApp_Application::getFileFilter() const
799 QWidget* SalomeApp_Application::createWindow( const int flag )
802 if ( flag != WT_PyConsole ) wid = LightApp_Application::createWindow(flag);
804 SUIT_ResourceMgr* resMgr = resourceMgr();
806 if ( flag == WT_ObjectBrowser )
808 SUIT_DataBrowser* ob = qobject_cast<SUIT_DataBrowser*>( wid );
810 // temporary commented
811 //ob->setUpdater( new SalomeApp_Updater() );
813 connect( ob, SIGNAL( doubleClicked( SUIT_DataObject* ) ), this, SLOT( onDblClick( SUIT_DataObject* ) ) );
816 ValueCol = QObject::tr( "VALUE_COLUMN" ),
817 IORCol = QObject::tr( "IOR_COLUMN" ),
818 RefCol = QObject::tr( "REFENTRY_COLUMN" ),
819 EntryCol = QObject::tr( "ENTRY_COLUMN" );
821 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
822 treeModel->registerColumn( 0, EntryCol, SalomeApp_DataObject::EntryId );
823 treeModel->registerColumn( 0, ValueCol, SalomeApp_DataObject::ValueId );
824 treeModel->registerColumn( 0, IORCol, SalomeApp_DataObject::IORId );
825 treeModel->registerColumn( 0, RefCol, SalomeApp_DataObject::RefEntryId );
826 treeModel->setAppropriate( EntryCol, Qtx::Toggled );
827 treeModel->setAppropriate( ValueCol, Qtx::Toggled );
828 treeModel->setAppropriate( IORCol, Qtx::Toggled );
829 treeModel->setAppropriate( RefCol, Qtx::Toggled );
831 bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
832 bool autoSizeFirst = resMgr->booleanValue( "ObjectBrowser", "auto_size_first", true );
833 bool resizeOnExpandItem = resMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", true );
835 ob->setAutoSizeFirstColumn(autoSizeFirst);
836 ob->setAutoSizeColumns(autoSize);
837 ob->setResizeOnExpandItem(resizeOnExpandItem);
839 // temporary commented
841 for ( int i = SalomeApp_DataObject::ValueIdx; i <= SalomeApp_DataObject::RefEntryIdx; i++ )
843 ob->addColumn( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i ) ), i );
844 ob->setColumnShown( i, resMgr->booleanValue( "ObjectBrowser",
845 QString().sprintf( "visibility_column_%d", i ), true ) );
849 // temporary commented
851 ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
852 ob->listView()->setColumnWidthMode( 0, autoSizeFirst ? QListView::Maximum : QListView::Manual );
853 ob->resize( desktop()->width()/3, ob->height() );
857 else if ( flag == WT_PyConsole )
859 PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new SalomeApp_PyInterp() );
860 pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) );
862 pyCons->resize( pyCons->width(), desktop()->height()/4 );
863 pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
868 /*!Create preferences.*/
869 void SalomeApp_Application::createPreferences( LightApp_Preferences* pref )
871 LightApp_Application::createPreferences(pref);
876 int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
877 int obTab = pref->addPreference( tr( "PREF_TAB_OBJBROWSER" ), salomeCat );
878 int defCols = pref->addPreference( tr( "PREF_GROUP_DEF_COLUMNS" ), obTab );
879 for ( int i = SalomeApp_DataObject::EntryId; i <= SalomeApp_DataObject::RefEntryId; i++ )
881 pref->addPreference( tr( QString().sprintf( "OBJ_BROWSER_COLUMN_%d", i-1 ).toLatin1() ), defCols,
882 LightApp_Preferences::Bool, "ObjectBrowser", QString().sprintf( "visibility_column_id_%d", i ) );
884 pref->setItemProperty( "orientation", Qt::Vertical, defCols );
886 // adding preference to LightApp_Application handled preferences.. a bit of hacking with resources..
887 int genTab = pref->addPreference( LightApp_Application::tr( "PREF_TAB_GENERAL" ), salomeCat );
888 int studyGroup = pref->addPreference( LightApp_Application::tr( "PREF_GROUP_STUDY" ), genTab );
889 pref->addPreference( tr( "PREF_STORE_VISUAL_STATE" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_visual_state" );
892 /*!Update desktop title.*/
893 void SalomeApp_Application::updateDesktopTitle() {
894 QString aTitle = applicationName();
895 QString aVer = applicationVersion();
896 if ( !aVer.isEmpty() )
897 aTitle += QString( " " ) + aVer;
901 QString sName = SUIT_Tools::file( activeStudy()->studyName().trimmed(), false );
902 if ( !sName.isEmpty() ) {
903 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
905 _PTR(Study) stdDS = study->studyDS();
907 if ( stdDS->GetProperties()->IsLocked() ) {
908 aTitle += QString( " - [%1 (%2)]").arg( sName ).arg( tr( "STUDY_LOCKED" ) );
910 aTitle += QString( " - [%1]" ).arg( sName );
917 desktop()->setWindowTitle( aTitle );
920 int SalomeApp_Application::closeChoice( const QString& docName )
922 int answer = SUIT_MessageBox::question( desktop(), tr( "APPCLOSE_CAPTION" ), tr( "APPCLOSE_DESCRIPTION" ).arg( docName ),
923 tr ("APPCLOSE_SAVE"), tr ("APPCLOSE_CLOSE"),
924 tr ("APPCLOSE_UNLOAD"), tr ("APPCLOSE_CANCEL"), 0 );
926 int res = CloseCancel;
929 else if ( answer == 1 )
931 else if ( answer == 2 )
937 bool SalomeApp_Application::closeAction( const int choice, bool& closePermanently )
943 if ( activeStudy()->isSaved() )
945 else if ( !onSaveAsDoc() )
951 closePermanently = false;
961 int SalomeApp_Application::openChoice( const QString& aName )
963 int choice = LightApp_Application::openChoice( aName );
965 if ( choice == OpenNew ) // The document isn't already open.
968 std::vector<std::string> lst = studyMgr()->GetOpenStudies();
969 for ( uint i = 0; i < lst.size() && !exist; i++ )
971 if ( aName == QString( lst[i].c_str() ) )
975 // The document already exists in the study manager.
976 // Do you want to reload it?
979 int answer = SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "QUE_DOC_ALREADYEXIST" ).arg( aName ),
980 SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No );
981 if ( answer == SUIT_MessageBox::Yes )
982 choice = OpenRefresh;
991 bool SalomeApp_Application::openAction( const int aChoice, const QString& aName )
994 int choice = aChoice;
999 _PTR(Study) aStudy = studyMgr()->GetStudyByName( aName.toStdString() );
1002 studyMgr()->Close( aStudy );
1007 res = LightApp_Application::openAction( choice, aName );
1015 \brief Get map of the operations which can be performed
1016 on the module activation.
1018 The method should return the map of the kind \c {<id>:<name>}
1019 where \c <id> is an integer identifier of the operation and
1020 \c <name> is a title for the button to be added to the
1021 dialog box. After user selects the required operation by the
1022 clicking the corresponding button in the dialog box, its identifier
1023 is passed to the moduleActionSelected() method to process
1026 \return map of the operations
1027 \sa moduleActionSelected()
1029 QMap<int, QString> SalomeApp_Application::activateModuleActions() const
1031 QMap<int, QString> opmap = LightApp_Application::activateModuleActions();
1032 opmap.insert( LoadStudyId, tr( "ACTIVATE_MODULE_OP_LOAD" ) );
1037 \brief Called when the used selectes required operation chosen
1038 from "Activate module" dialog box.
1040 Performs the required operation according to the user choice.
1042 \param id operation identifier
1043 \sa activateModuleActions()
1045 void SalomeApp_Application::moduleActionSelected( const int id )
1047 if ( id == LoadStudyId )
1050 LightApp_Application::moduleActionSelected( id );
1053 /*!Gets CORBA::ORB_var*/
1054 CORBA::ORB_var SalomeApp_Application::orb()
1056 ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
1057 static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
1061 /*!Create and return SALOMEDS_StudyManager.*/
1062 SALOMEDSClient_StudyManager* SalomeApp_Application::studyMgr()
1064 static _PTR(StudyManager) _sm;
1065 if(!_sm) _sm = ClientFactory::StudyManager();
1069 /*!Create and return SALOME_NamingService.*/
1070 SALOME_NamingService* SalomeApp_Application::namingService()
1072 static SALOME_NamingService* _ns = new SALOME_NamingService( orb() );
1076 /*!Create and return SALOME_LifeCycleCORBA.*/
1077 SALOME_LifeCycleCORBA* SalomeApp_Application::lcc()
1079 static SALOME_LifeCycleCORBA* _lcc = new SALOME_LifeCycleCORBA( namingService() );
1083 /*!Return default engine IOR for light modules*/
1084 QString SalomeApp_Application::defaultEngineIOR()
1086 /// Look for a default module engine (needed for CORBAless modules to use SALOMEDS persistence)
1087 QString anIOR( "" );
1088 CORBA::Object_ptr anEngine = namingService()->Resolve( "/SalomeAppEngine" );
1089 if ( !CORBA::is_nil( anEngine ) )
1091 CORBA::String_var objStr = orb()->object_to_string( anEngine );
1092 anIOR = QString( objStr.in() );
1097 /*!Private SLOT. On preferences.*/
1098 void SalomeApp_Application::onProperties()
1100 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1104 _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
1107 SalomeApp_StudyPropertiesDlg aDlg( desktop() );
1108 int res = aDlg.exec();
1109 if( res==QDialog::Accepted && aDlg.isChanged() )
1110 SB->CommitCommand();
1114 //study->updateCaptions();
1115 updateDesktopTitle();
1119 /*!Insert items in popup, which necessary for current application*/
1120 void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePopup, QString& title )
1122 LightApp_Application::contextMenuPopup( type, thePopup, title );
1124 // temporary commented
1125 /*OB_Browser* ob = objectBrowser();
1126 if ( !ob || type != ob->popupClientType() )
1129 // Get selected objects
1130 SALOME_ListIO aList;
1131 LightApp_SelectionMgr* mgr = selectionMgr();
1132 mgr->selectedObjects( aList, QString(), false );
1134 // add GUI state commands: restore, rename
1135 if ( aList.Extent() == 1 && aList.First()->hasEntry() &&
1136 QString( aList.First()->getEntry() ).startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) ) {
1137 thePopup->addSeparator();
1138 thePopup->addAction( tr( "MEN_RESTORE_VS" ), this, SLOT( onRestoreGUIState() ) );
1139 thePopup->addAction( tr( "MEN_RENAME_VS" ), this, SLOT( onRenameGUIState() ) );
1140 thePopup->addAction( tr( "MEN_DELETE_VS" ), this, SLOT( onDeleteGUIState() ) );
1143 // "Delete reference" item should appear only for invalid references
1145 // isInvalidRefs will be true, if at least one of selected objects is invalid reference
1146 bool isInvalidRefs = false;
1147 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
1148 _PTR(Study) aStudyDS = aStudy->studyDS();
1149 _PTR(SObject) anObj;
1151 for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() )
1152 if( it.Value()->hasEntry() )
1154 _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject;
1155 while( aRefObj && aRefObj->ReferencedObject( anObj ) )
1158 if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() )
1159 isInvalidRefs = true;
1162 // Add "Delete reference" item to popup
1163 if ( isInvalidRefs )
1165 thePopup->addSeparator();
1166 thePopup->addAction( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) );
1171 mgr->selectedObjects( aList );
1173 // "Activate module" item should appear only if it's necessary
1174 if (aList.Extent() != 1)
1176 Handle(SALOME_InteractiveObject) aIObj = aList.First();
1177 // check if item is a "GUI state" item (also a first level object)
1178 QString entry( aIObj->getEntry() );
1179 if ( entry.startsWith( tr( "SAVE_POINT_DEF_NAME" ) ) )
1181 QString aModuleName(aIObj->getComponentDataType());
1182 QString aModuleTitle = moduleTitle(aModuleName);
1183 CAM_Module* currentModule = activeModule();
1184 if (currentModule && currentModule->moduleName() == aModuleTitle)
1186 if ( !aModuleTitle.isEmpty() )
1187 thePopup->addAction( tr( "MEN_OPENWITH" ).arg( aModuleTitle ), this, SLOT( onOpenWith() ) );
1190 /*!Update obect browser:
1191 1.if 'updateModels' true, update existing data models;
1192 2. update "non-existing" (not loaded yet) data models;
1193 3. update object browser if it exists */
1194 void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
1196 // update "non-existing" (not loaded yet) data models
1197 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(activeStudy());
1200 _PTR(Study) stdDS = study->studyDS();
1203 for ( _PTR(SComponentIterator) it ( stdDS->NewComponentIterator() ); it->More(); it->Next() )
1205 _PTR(SComponent) aComponent ( it->Value() );
1207 if ( aComponent->ComponentDataType() == "Interface Applicative" )
1208 continue; // skip the magic "Interface Applicative" component
1210 getWindow( WT_ObjectBrowser );
1211 const bool isAutoUpdate = objectBrowser()->autoUpdate();
1212 objectBrowser()->setAutoUpdate( false );
1213 SalomeApp_DataModel::synchronize( aComponent, study );
1214 objectBrowser()->setAutoUpdate( isAutoUpdate );
1219 // create data objects that correspond to GUI state save points
1220 if ( study ) updateSavePointDataObjects( study );
1222 // update existing data models (already loaded SComponents)
1223 LightApp_Application::updateObjectBrowser( updateModels );
1226 /*!Display Catalog Genenerator dialog */
1227 void SalomeApp_Application::onCatalogGen()
1229 ToolsGUI_CatalogGeneratorDlg aDlg( desktop() );
1233 /*!Display Registry Display dialog */
1234 void SalomeApp_Application::onRegDisplay()
1236 CORBA::ORB_var anOrb = orb();
1237 ToolsGUI_RegWidget* regWnd = ToolsGUI_RegWidget::GetRegWidget( anOrb, desktop() );
1240 regWnd->activateWindow();
1243 /*!find original object by double click on item */
1244 void SalomeApp_Application::onDblClick( SUIT_DataObject* theObj )
1246 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( theObj );
1247 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1251 QString entry = obj->entry();
1252 _PTR(SObject) sobj = study->studyDS()->FindObjectID( entry.toStdString() ), ref;
1254 if( sobj && sobj->ReferencedObject( ref ) )
1256 entry = ref->GetID().c_str();
1258 SUIT_DataOwnerPtrList aList;
1259 aList.append( new LightApp_DataOwner( entry ) );
1260 selectionMgr()->setSelected( aList, false );
1262 SUIT_DataBrowser* ob = objectBrowser();
1264 QModelIndexList aSelectedIndexes = ob->selectedIndexes();
1265 if ( !aSelectedIndexes.isEmpty() )
1266 ob->treeView()->scrollTo( aSelectedIndexes.first() );
1272 Creates new view manager
1273 \param type - type of view manager
1275 SUIT_ViewManager* SalomeApp_Application::newViewManager(const QString& type)
1277 return createViewManager(type);
1281 /*!Global utility funciton, returns selected GUI Save point object's ID */
1282 int getSelectedSavePoint( const LightApp_SelectionMgr* selMgr )
1284 SALOME_ListIO aList;
1285 selMgr->selectedObjects( aList );
1286 Handle(SALOME_InteractiveObject) aIObj = aList.First();
1287 QString entry( aIObj->getEntry() );
1288 QString startStr = QObject::tr( "SAVE_POINT_DEF_NAME" );
1289 if ( !entry.startsWith( startStr ) ) // it's a "GUI state" object
1291 bool ok; // conversion to integer is ok?
1292 int savePoint = entry.right( entry.length() - startStr.length() ).toInt( &ok );
1293 return ok ? savePoint : -1;
1296 /*!Called on Restore GUI State popup command*/
1297 void SalomeApp_Application::onRestoreGUIState()
1299 int savePoint = ::getSelectedSavePoint( selectionMgr() );
1300 if ( savePoint == -1 )
1302 SalomeApp_VisualState( this ).restoreState( savePoint );
1305 /*!Called on Rename GUI State popup command*/
1306 void SalomeApp_Application::onRenameGUIState()
1308 int savePoint = ::getSelectedSavePoint( selectionMgr() );
1309 if ( savePoint == -1 )
1311 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1315 QString newName = LightApp_NameDlg::getName( desktop(), study->getNameOfSavePoint( savePoint ) );
1316 if ( !newName.isNull() && !newName.isEmpty() ) {
1317 study->setNameOfSavePoint( savePoint, newName );
1318 updateSavePointDataObjects( study );
1319 // temporary commented
1320 //objectBrowser()->updateTree( study->root() );
1325 /*!Called on Delete GUI State popup command*/
1326 void SalomeApp_Application::onDeleteGUIState()
1328 int savePoint = ::getSelectedSavePoint( selectionMgr() );
1329 if ( savePoint == -1 )
1331 SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1335 study->removeSavePoint( savePoint );
1336 updateSavePointDataObjects( study );
1339 /*!Called on New study operation*/
1340 void SalomeApp_Application::onStudyCreated( SUIT_Study* study )
1342 LightApp_Application::onStudyCreated( study );
1344 objectBrowserColumnsVisibility();
1347 /*!Called on Save study operation*/
1348 void SalomeApp_Application::onStudySaved( SUIT_Study* study )
1350 LightApp_Application::onStudySaved( study );
1352 // temporary commented
1353 /*if ( objectBrowser() ) {
1354 updateSavePointDataObjects( dynamic_cast<SalomeApp_Study*>( study ) );
1355 objectBrowser()->updateTree( study->root() );
1359 /*!Called on Open study operation*/
1360 void SalomeApp_Application::onStudyOpened( SUIT_Study* study )
1362 LightApp_Application::onStudyOpened( study );
1364 objectBrowserColumnsVisibility();
1366 // temporary commented
1367 /*if ( objectBrowser() ) {
1368 updateSavePointDataObjects( dynamic_cast<SalomeApp_Study*>( study ) );
1369 objectBrowser()->updateTree( study->root() );
1373 /*! updateSavePointDataObjects: syncronize data objects that correspond to save points (gui states)*/
1374 void SalomeApp_Application::updateSavePointDataObjects( SalomeApp_Study* study )
1376 // temporary commented
1377 //OB_Browser* ob = objectBrowser();
1379 if ( !study /*|| !ob */) // temporary commented
1382 // find GUI states root object
1383 SUIT_DataObject* guiRootObj = 0;
1385 study->root()->children( ch );
1386 DataObjectList::const_iterator it = ch.begin(), last = ch.end();
1387 for ( ; it != last ; ++it ) {
1388 if ( dynamic_cast<SalomeApp_SavePointRootObject*>( *it ) ) {
1393 std::vector<int> savePoints = study->getSavePoints();
1394 // case 1: no more save points but they existed in study's tree
1395 if ( savePoints.empty() && guiRootObj ) {
1399 // case 2: no more save points but root does not exist either
1400 if ( savePoints.empty() && !guiRootObj )
1402 // case 3: save points but no root for them - create it
1403 if ( !savePoints.empty() && !guiRootObj )
1404 guiRootObj = new SalomeApp_SavePointRootObject( study->root() );
1405 // case 4: everything already exists.. here may be a problem: we want "GUI states" root object
1406 // to be always the last one in the tree. Here we check - if it is not the last one - remove and
1408 if ( guiRootObj->nextBrother() ) {
1409 study->root()->removeChild(guiRootObj);
1410 study->root()->appendChild(guiRootObj);
1411 //study->root()->dump();
1414 // store data objects in a map id-to-DataObject
1415 QMap<int,SalomeApp_SavePointObject*> mapDO;
1417 guiRootObj->children( ch );
1418 for( it = ch.begin(), last = ch.end(); it != last ; ++it ) {
1419 SalomeApp_SavePointObject* dobj = dynamic_cast<SalomeApp_SavePointObject*>( *it );
1421 mapDO[dobj->getId()] = dobj;
1424 // iterate new save points. if DataObject with such ID not found in map - create DataObject
1425 // if in the map - remove it from map.
1426 for ( int i = 0; i < savePoints.size(); i++ )
1427 if ( !mapDO.contains( savePoints[i] ) )
1428 new SalomeApp_SavePointObject( guiRootObj, savePoints[i], study );
1430 mapDO.remove( savePoints[i] );
1432 // delete DataObjects that are still in the map -- their IDs were not found in data model
1433 for ( QMap<int,SalomeApp_SavePointObject*>::Iterator it = mapDO.begin(); it != mapDO.end(); ++it )
1437 /*! Check data object */
1438 bool SalomeApp_Application::checkDataObject(LightApp_DataObject* theObj)
1446 /*! Process standard messages from desktop */
1447 void SalomeApp_Application::onDesktopMessage( const QString& message )
1449 // update object browser
1450 if ( message.toLower() == "updateobjectbrowser" ||
1451 message.toLower() == "updateobjbrowser" )
1452 updateObjectBrowser();
1456 Opens other study into active Study. If Study is empty - creates it.
1457 \param theName - name of study
1459 bool SalomeApp_Application::useStudy( const QString& theName )
1462 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( activeStudy() );
1465 res = aStudy->loadDocument( theName );
1466 updateDesktopTitle();
1467 updateCommandsStatus();
1471 /*! Show/hide object browser colums according to preferences */
1472 void SalomeApp_Application::objectBrowserColumnsVisibility()
1474 if ( objectBrowser() )
1475 for ( int i = SalomeApp_DataObject::EntryId; i <= SalomeApp_DataObject::RefEntryId; i++ )
1477 bool shown = resourceMgr()->booleanValue( "ObjectBrowser", QString( "visibility_column_id_%1" ).arg( i ), true );
1478 objectBrowser()->treeView()->setColumnHidden( i, !shown );
1482 /*! Set SalomeApp_NoteBookDlg pointer */
1483 void SalomeApp_Application::setNoteBook(SalomeApp_NoteBookDlg* theNoteBook){
1484 myNoteBook = theNoteBook;
1487 /*! Return SalomeApp_NoteBookDlg pointer */
1488 SalomeApp_NoteBookDlg* SalomeApp_Application::getNoteBook() const