Salome HOME
ENV: Windows porting
[modules/gui.git] / src / SalomeApp / SalomeApp_Application.cxx
index 5a47d786bca029cd8ecd677c0475de0dfb210422..742ecab766d682827e33d10b0f4be24d7fa3a1b1 100644 (file)
@@ -764,6 +764,33 @@ void SalomeApp_Application::onRefresh()
   updateObjectBrowser( true );
 }
 
+/*!Delete references.*/
+void SalomeApp_Application::onDeleteReferences()
+{
+  SALOME_ListIO aList;
+  SalomeApp_SelectionMgr* mgr = selectionMgr();
+  mgr->selectedObjects(aList);
+
+  if (aList.Extent() < 1) return;
+
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+  _PTR(Study) aStudyDS = aStudy->studyDS();
+  _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder();
+  _PTR(SObject) anObj;
+  
+  for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() )
+    {
+      if ( it.Value()->hasEntry() )
+       {
+         _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() );
+         if ( aSObject->ReferencedObject(anObj) )
+           aStudyBuilder->RemoveReference(aSObject);
+       }
+    }
+
+  updateObjectBrowser();
+}
+
 /*!Private SLOT. */
 void SalomeApp_Application::onOpenWith()
 {
@@ -1478,8 +1505,12 @@ void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
   int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
 
   int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
+
+  int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), viewTab );
+
   pref->setItemProperty( occGroup, "columns", 1 );
   pref->setItemProperty( vtkGroup, "columns", 1 );
+  pref->setItemProperty( plot2dGroup, "columns", 1 );
 
   int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
                                   SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
@@ -1507,7 +1538,71 @@ void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
 
   pref->setItemProperty( vtkTS, "min", 1 );
   pref->setItemProperty( vtkTS, "max", 150 );
-
+  
+  pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
+                      SalomeApp_Preferences::Bool, "Plot2d", "ShowLegend" );
+
+  int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
+                                           SalomeApp_Preferences::Selector, "Plot2d", "LegendPos" );
+  QStringList aLegendPosList;
+  aLegendPosList.append( tr("PREF_LEFT") );
+  aLegendPosList.append( tr("PREF_RIGHT") );
+  aLegendPosList.append( tr("PREF_TOP") );
+  aLegendPosList.append( tr("PREF_BOTTOM") );
+  
+  QValueList<QVariant> anIndexesList;
+  anIndexesList.append(0);
+  anIndexesList.append(1);
+  anIndexesList.append(2);
+  anIndexesList.append(3);
+  
+  pref->setItemProperty( legendPosition, "strings", aLegendPosList );
+  pref->setItemProperty( legendPosition, "indexes", anIndexesList );
+  
+  int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
+                                      SalomeApp_Preferences::Selector, "Plot2d", "CurveType" );
+  QStringList aCurveTypesList;
+  aCurveTypesList.append( tr("PREF_POINTS") );
+  aCurveTypesList.append( tr("PREF_LINES") );
+  aCurveTypesList.append( tr("PREF_SPLINE") );
+  
+  anIndexesList.clear();
+  anIndexesList.append(0);
+  anIndexesList.append(1);
+  anIndexesList.append(2);
+  
+  pref->setItemProperty( curveType, "strings", aCurveTypesList );
+  pref->setItemProperty( curveType, "indexes", anIndexesList );
+
+  int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
+                                       SalomeApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
+
+  pref->setItemProperty( markerSize, "min", 0 );
+  pref->setItemProperty( markerSize, "max", 100 );
+  
+  QStringList aScaleModesList;
+  aScaleModesList.append( tr("PREF_LINEAR") );
+  aScaleModesList.append( tr("PREF_LOGARITHMIC") );
+  
+  anIndexesList.clear();
+  anIndexesList.append(0);
+  anIndexesList.append(1);
+  
+  int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
+                                     SalomeApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
+
+  pref->setItemProperty( horScale, "strings", aScaleModesList );
+  pref->setItemProperty( horScale, "indexes", anIndexesList );
+
+  int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
+                                     SalomeApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
+  
+  pref->setItemProperty( verScale, "strings", aScaleModesList );
+  pref->setItemProperty( verScale, "indexes", anIndexesList );
+
+  pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup,
+                      SalomeApp_Preferences::Color, "Plot2d", "Background" );
+  
   int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
   int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
   pref->setItemProperty( dirGroup, "columns", 1 );
@@ -1874,10 +1969,45 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t
   thePopup->insertSeparator();
   thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
 
-  // "Activate module" item should appear only if it's necessary
+  // Get selected objects
   SALOME_ListIO aList;
   SalomeApp_SelectionMgr* mgr = selectionMgr();
   mgr->selectedObjects(aList);
+
+  // "Delete reference" item should appear only for invalid references
+  
+  // Check if selected objects is invalid references
+  bool isInvalidRefs = true;
+  
+  if ( aList.Extent() < 1 )
+    isInvalidRefs = false;
+  
+  if ( isInvalidRefs )
+    {
+      SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+      _PTR(Study) aStudyDS = aStudy->studyDS();
+      _PTR(SObject) anObj;
+      
+      for ( SALOME_ListIteratorOfListIO it( aList ); it.More() && isInvalidRefs; it.Next() )
+       {
+         if ( it.Value()->hasEntry() )
+           {
+             _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() );
+             if ( aSObject->ReferencedObject(anObj) == false || !QString(anObj->GetName().c_str()).isEmpty() )
+               isInvalidRefs = false;
+           }
+       }
+    }
+  
+  // Add "Delete refrence" item to popup
+  if ( isInvalidRefs )
+    {
+      thePopup->insertSeparator();
+      thePopup->insertItem( tr( "MEN_DELETE_REFERENCE" ), this, SLOT( onDeleteReferences() ) );
+      return;
+    }
+
+  // "Activate module" item should appear only if it's necessary
   if (aList.Extent() != 1)
     return;
   Handle(SALOME_InteractiveObject) aIObj = aList.First();
@@ -1887,6 +2017,7 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t
   if (currentModule && currentModule->moduleName() == aModuleTitle)
     return;
   thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
+  
 }
 
 /*!Update obect browser*/