Salome HOME
IPAL9182: linking to libSPlot2d.so added
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.cxx
index ffd325319d94928327607c654d29b20ef5045d08..6063e1fa77d2f7c799e7520a79d805eae69039c7 100644 (file)
@@ -18,6 +18,7 @@
 #include "SalomeApp_AboutDlg.h"
 #include "SalomeApp_ModuleDlg.h"
 #include "SalomeApp_PreferencesDlg.h"
+#include "SalomeApp_StudyPropertiesDlg.h"
 
 #include "SalomeApp_GLSelector.h"
 #include "SalomeApp_OBSelector.h"
@@ -263,6 +264,12 @@ void SalomeApp_Application::createActions()
                0, desk, false, this, SLOT( onLoadScript() ) );
   int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
   createMenu( LoadScriptId, fileMenu, 10, -1 );
+
+  createAction( PropertiesId, tr( "TOT_DESK_FILE_PROPERTIES" ), QIconSet(),
+               tr( "MEN_DESK_FILE_PROPERTIES" ), tr( "PRP_DESK_FILE_PROPERTIES" ),
+               0, desk, false, this, SLOT( onProperties() ) );
+  createMenu( PropertiesId, fileMenu, 10, -1 );
+
   
   // default icon for neutral point ('SALOME' module)
   QPixmap defIcon = resMgr->loadPixmap( "SalomeApp", tr( "APP_DEFAULT_ICO" ) );
@@ -476,16 +483,12 @@ void SalomeApp_Application::onSelectionChanged()
 
 void SalomeApp_Application::onAboutRefresh()
 {
-  SalomeApp_DataModel* dm = 0;
-  if ( activeModule() )
-  {
-    CAM_DataModel* camDM = activeModule()->dataModel();
+  for ( ModuleListIterator it = modules(); it.current(); ++it )
+  {    
+    CAM_DataModel* camDM = it.current()->dataModel();
     if ( camDM && camDM->inherits( "SalomeApp_DataModel" ) )
-      dm = (SalomeApp_DataModel*)camDM;
+      ((SalomeApp_DataModel*)camDM)->update();
   }
-
-  if ( dm )
-    dm->update();
 }
 
 void SalomeApp_Application::setActiveStudy( SUIT_Study* study )
@@ -531,6 +534,10 @@ void SalomeApp_Application::updateCommandsStatus()
   QAction* a = action( LoadScriptId );
   if ( a )
     a->setEnabled( activeStudy() );
+  
+  a = action( PropertiesId );
+  if( a )
+    a->setEnabled( activeStudy() );
 }
 
 //=======================================================================
@@ -703,15 +710,20 @@ SUIT_ViewManager* SalomeApp_Application::getViewManager( const QString& vmType,
 {
   SUIT_ViewManager* aVM = viewManager( vmType );
   SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
+
   if ( anActiveVM && anActiveVM->getType() == vmType )
     aVM = anActiveVM;
-  else if ( aVM )
+
+  if ( aVM && create )
   {
     if ( !aVM->getActiveView() )
       aVM->createView();
+    else
+      aVM->getActiveView()->setFocus();
   }
   else if ( create )
     aVM = createViewManager( vmType );
+
   return aVM;
 }
 
@@ -827,7 +839,7 @@ void SalomeApp_Application::onLoadScript( )
   filtersList.append(tr("PYTHON_FILES_FILTER"));
   filtersList.append(tr("ALL_FILES_FILTER"));
   
-  QString aFile = SUIT_FileDlg::getFileName(desktop(), "", filtersList, tr("TOT_DESK_FILE_LOAD_SCRIPT"), true, false);
+  QString aFile = SUIT_FileDlg::getFileName(desktop(), "", filtersList, tr("TOT_DESK_FILE_LOAD_SCRIPT"), true, true );
   if(!aFile.isEmpty()) {
     QString command = QString("execfile(\"%1\")").arg(aFile);
     
@@ -1092,3 +1104,30 @@ void SalomeApp_Application::activateWindows()
       itr.data()->activate( activeStudy()->id() );
   }
 }
+
+void SalomeApp_Application::onProperties()
+{
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+  if( !study )
+    return;
+
+  _PTR(StudyBuilder) SB = study->studyDS()->NewBuilder();
+  SB->NewCommand();
+
+  SalomeApp_StudyPropertiesDlg aDlg( desktop() );
+  int res = aDlg.exec();
+  if( res==QDialog::Accepted && aDlg.isChanged() )
+    SB->CommitCommand();
+  else
+    SB->AbortCommand();
+
+  //study->updateCaptions();
+}
+
+QString SalomeApp_Application::getFileName( bool open )
+{
+  QStringList filtersList;
+  filtersList.append( getFileFilter() );
+  QString initial = open ? QString( "" ) : ( activeStudy() ? activeStudy()->studyName() : QString( "" ) );
+  return SUIT_FileDlg::getFileName( desktop(), initial, filtersList, QString::null, open, true );
+}