]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Preferences
authorstv <stv@opencascade.com>
Wed, 22 Jun 2005 09:57:17 +0000 (09:57 +0000)
committerstv <stv@opencascade.com>
Wed, 22 Jun 2005 09:57:17 +0000 (09:57 +0000)
src/OCCViewer/OCCViewer_ViewModel.cxx
src/Qtx/QtxResourceEdit.cxx
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewModel.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/resources/SalomeApp_msg_en.po
src/VTKViewer/VTKViewer_ViewWindow.cxx

index a1fb001b36062ff1883e1cb55d3290dc199f6733..d8171544456f0452fd421dd1694e12ec168b1b21 100755 (executable)
@@ -416,7 +416,7 @@ int OCCViewer_Viewer::trihedronSize() const
 {
   int sz = 0;
   if ( !myTrihedron.IsNull() )
-    sz = myTrihedron->Size();
+    sz = (int)myTrihedron->Size();
   return sz;
 }
 
@@ -429,14 +429,14 @@ void OCCViewer_Viewer::setTrihedronSize( const int sz )
 void OCCViewer_Viewer::setIsos( const int u, const int v )
 {
   Handle(AIS_InteractiveContext) ic = getAISContext();
-  if ( !ic.IsNull() )
-  {
-    ic->SetIsoNumber( u, AIS_TOI_IsoU );
-    ic->SetIsoNumber( u, AIS_TOI_IsoV );
-  }
+  if ( ic.IsNull() )
+  return;
+
+  ic->SetIsoNumber( u, AIS_TOI_IsoU );
+  ic->SetIsoNumber( u, AIS_TOI_IsoV );
 }
 
-void OCCViewer_Viewer::isos( int& u, int& v ) const 
+void OCCViewer_Viewer::isos( int& u, int& v ) const
 {
   Handle(AIS_InteractiveContext) ic = getAISContext();
   if ( !ic.IsNull() )
index 1ee772a30edabdf16ca9b114eaff4b28cb34b77c..b368eb61a38b553e5818d7e0cc7b091861ba71b6 100644 (file)
@@ -95,7 +95,18 @@ void QtxResourceEdit::toBackup()
 
 void QtxResourceEdit::fromBackup()
 {
+  QMap<Item*, QString> before;
+  resourceValues( before );
+
   setResourceValues( myBackup );
+
+  QMap<Item*, QString> after;
+  resourceValues( after );
+
+  QMap<Item*, QString> changed;
+  differentValues( before, after, changed );
+
+  changedResources( changed );
 }
 
 void QtxResourceEdit::update()
index 5ff0869507f953700ef9fe215b312a1bd7c674a0..17f0ac85c997da479c1b5afc43f3a4cbffeafcd8 100644 (file)
@@ -51,6 +51,7 @@ static _PTR(Study) getStudyDS()
 //==========================================================
 SVTK_Viewer::SVTK_Viewer()
 {
+  myTrihedronSize = 100;
 }
 
 //==========================================================
@@ -74,15 +75,41 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop )
 {
   SVTK_ViewWindow* vw = new SVTK_ViewWindow( theDesktop, this );
   vw->setBackgroundColor( backgroundColor() );
+  vw->SetTrihedronSize( trihedronSize() );
   return vw;
 }
 
+int SVTK_Viewer::trihedronSize() const
+{
+  return myTrihedronSize;
+}
+
+void SVTK_Viewer::setTrihedronSize( const int sz )
+{
+  myTrihedronSize = sz;
+
+  SUIT_ViewManager* vm = getViewManager();
+  if ( !vm )
+    return;
+
+  QPtrVector<SUIT_ViewWindow> vec = vm->getViews();
+  for ( int i = 0; i < vec.count(); i++ )
+  {
+    SUIT_ViewWindow* win = vec.at( i );
+    if ( !win || !win->inherits( "SVTK_ViewWindow" ) )
+      continue;
+
+    SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win;
+    vw->SetTrihedronSize( sz );
+  }
+}
+
 //==========================================================
 void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
 {
   SUIT_ViewModel::setViewManager(theViewManager);
 
-  if(!theViewManager)
+  if ( !theViewManager )
     return;
 
   connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), 
index fbf1c14b3419841812385cf502638e0e077ee53f..912e31f3da37fbac05dfb81390aeb6688e68ab63 100644 (file)
@@ -28,6 +28,9 @@ public:
   QColor backgroundColor() const;
   void   setBackgroundColor( const QColor& );
 
+  int    trihedronSize() const;
+  void   setTrihedronSize( const int );
+
 public:
   void enableSelection(bool isEnabled);
   bool isSelectionEnabled() const { return mySelectionEnabled; }
@@ -68,6 +71,7 @@ protected slots:
 
 private:
   QColor myBgColor;
+  int    myTrihedronSize;
   bool   mySelectionEnabled;
   bool   myMultiSelectionEnabled;
 };
index cd140f5fa99436e555f1fafb216eae516eb52eac..db554906776f4ea941b3c8bd1f5ef188c6914257 100755 (executable)
@@ -37,7 +37,8 @@
 SVTK_ViewWindow
 ::SVTK_ViewWindow( SUIT_Desktop* theDesktop, 
                   SVTK_Viewer* theModel)
-  : SUIT_ViewWindow(theDesktop)
+  : SUIT_ViewWindow( theDesktop ),
+    myTrihedronSize( 100 )
 {
   myModel = theModel;
   mySelector = new SVTK_SelectorDef();
@@ -611,10 +612,7 @@ SVTK_ViewWindow
     aLength = max( ( aBndBox[ 5 ] - aBndBox[ 4 ] ),aLength );
   }
 
-  static float aSizeInPercents = 105;
-  //QString aSetting = QAD_CONFIG->getSetting( "Viewer:TrihedronSize" );
-  //if ( !aSetting.isEmpty() )
-  //  aSizeInPercents = aSetting.toFloat();
+  float aSizeInPercents = myTrihedronSize;
 
   static float EPS_SIZE = 5.0E-3;
   theSize = myTrihedron->GetSize();
@@ -626,14 +624,20 @@ SVTK_ViewWindow
 }
 
 //----------------------------------------------------------------------------
-double
-SVTK_ViewWindow
-::GetTrihedronSize() const
+int SVTK_ViewWindow::GetTrihedronSize() const
 {
-  return myTrihedron->GetSize();
+  return myTrihedronSize;
+}
+
+void SVTK_ViewWindow::SetTrihedronSize( const int sz )
+{
+  if ( myTrihedronSize == sz )
+    return;
+
+  myTrihedronSize = sz;
+  AdjustTrihedrons( true );
 }
 
-//----------------------------------------------------------------------------
 void
 SVTK_ViewWindow
 ::AdjustTrihedrons( const bool theIsForcedUpdate )
index a2f70efa4f815d37bb09a6671242af7cd1fd3e95..c2ebd3b23abe71bad2de1490e655b7961a0b891f 100755 (executable)
@@ -80,7 +80,9 @@ public:
   void AdjustTrihedrons( const bool forced );
   bool ComputeTrihedronSize( double& theNewSize,
                             double& theOldSize );
-  double GetTrihedronSize() const;
+
+  int  GetTrihedronSize() const;
+  void SetTrihedronSize( const int );
 
 public slots:
   void onSelectionChanged();
@@ -151,9 +153,10 @@ private:
 
   SVTK_RenderWindow* myRenderWindow;
   SVTK_RenderWindowInteractor* myRWInteractor;
-  
-  VTKViewer_Trihedron* myTrihedron;  
+
   VTKViewer_Transform* myTransform;
+  VTKViewer_Trihedron* myTrihedron;  
+  int                  myTrihedronSize;
   
   QToolBar* myToolBar;
   ActionsMap myActionsMap;  
index 317093a38c3c9b0f7ecb9eefe0b79c0c9f17dc05..a3eb99fea6c343d77f90bfde9f0bddafeadc8f77 100644 (file)
@@ -847,6 +847,11 @@ SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmTyp
     SOCC_Viewer* vm = new SOCC_Viewer();
     vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
     vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
+    int u( 1 ), v( 1 );
+    vm->isos( u, v );
+    u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
+    v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
+    //    vm->setIsos( u, v );
     viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
     new SalomeApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
   }
@@ -855,6 +860,7 @@ SUIT_ViewManager* SalomeApp_Application::createViewManager( const QString& vmTyp
     viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
     SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel();
     vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
+    vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
     new SalomeApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),mySelMgr);
   }
 
@@ -934,10 +940,10 @@ void SalomeApp_Application::onDumpStudy( )
   _PTR(Study) aStudy = appStudy->studyDS();
 
   QStringList aFilters;
-  aFilters.append(tr("PYTHON_FILES_FILTER"));
+  aFilters.append( tr( "PYTHON_FILES_FILTER" ) );
 
   SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg( desktop(), false, tr("PUBLISH_IN_STUDY"), true, true);
-  fd->setCaption(tr("TOT_DESK_FILE_DUMP_STUDY"));
+  fd->setCaption( tr( "TOT_DESK_FILE_DUMP_STUDY" ) );
   fd->setFilters( aFilters );  
   fd->SetChecked(true);
   fd->exec();
@@ -947,7 +953,7 @@ void SalomeApp_Application::onDumpStudy( )
 
   if(!aFileName.isEmpty()) {
     QFileInfo aFileInfo(aFileName);
-    aStudy->DumpStudy(aFileInfo.dirPath(true), aFileInfo.baseName(), toPublish);
+    aStudy->DumpStudy( aFileInfo.dirPath( true ).latin1(), aFileInfo.baseName().latin1(), toPublish );
   }
 }
 
@@ -1183,15 +1189,32 @@ void SalomeApp_Application::createPreferences( SalomeApp_Preferences* pref )
   pref->setProperty( occGroup, "columns", 1 );
   pref->setProperty( vtkGroup, "columns", 1 );
 
-  pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
-                      SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
+  int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
+                                  SalomeApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
                       SalomeApp_Preferences::Color, "OCCViewer", "background" );
 
-  pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
-                      SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
+  pref->setProperty( occTS, "min", 1 );
+  pref->setProperty( occTS, "max", 150 );
+
+  int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
+                                 SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
+  int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
+                                 SalomeApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
+
+  pref->setProperty( isoU, "min", 0 );
+  pref->setProperty( isoU, "max", 100000 );
+
+  pref->setProperty( isoV, "min", 0 );
+  pref->setProperty( isoV, "max", 100000 );
+
+  int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
+                                  SalomeApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
   pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
                       SalomeApp_Preferences::Color, "VTKViewer", "background" );
+
+  pref->setProperty( vtkTS, "min", 1 );
+  pref->setProperty( vtkTS, "max", 150 );
 }
 
 void SalomeApp_Application::preferencesChanged( const QString& sec, const QString& param )
@@ -1216,6 +1239,34 @@ void SalomeApp_Application::preferencesChanged( const QString& sec, const QStrin
       occVM->getAISContext()->UpdateCurrentViewer();
     }
   }
+
+  if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
+  {
+    int sz = resMgr->integerValue( sec, param, -1 );
+    QPtrList<SUIT_ViewManager> lst;
+    viewManagers( SVTK_Viewer::Type(), lst );
+    for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
+    {
+      SUIT_ViewModel* vm = it.current()->getViewModel();
+      if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
+       continue;
+
+      SVTK_Viewer* vtkVM = (SVTK_Viewer*)vm;
+      vtkVM->setTrihedronSize( sz );
+      vtkVM->Repaint();
+    }
+  }
+  /*
+  if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
+  {
+    QPtrList<SUIT_ViewManager> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    int u = resMgr->integerValue( sec, "iso_number_u" );
+    int v = resMgr->integerValue( sec, "iso_number_v" );
+    for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
+      ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
+  }
+  */
 }
 
 void SalomeApp_Application::afterCloseDoc()
index 43ed605f841c11b96d93997895a7a32dbd63a51c..aeabfcaa354dc4a3c703e92279bd65c1fffa3317 100644 (file)
@@ -168,6 +168,12 @@ msgstr "Background color"
 msgid "SalomeApp_Application::PREF_TRIHEDRON_SIZE"
 msgstr "Trihedron size"
 
+msgid "SalomeApp_Application::PREF_ISOS_U"
+msgstr "Number of isolines along U"
+
+msgid "SalomeApp_Application::PREF_ISOS_V"
+msgstr "Number of isolines along V"
+
 msgid "SalomeApp_Application::PREF_TRIHEDRON_SHOW"
 msgstr "Show trihedron"
 
index 78b400430e5b0d6b68d353fd89cb75b88f60fbf4..f179eb92b87e2714fd1cddcecfd8d714c99dd667 100755 (executable)
@@ -409,26 +409,22 @@ QColor VTKViewer_ViewWindow::backgroundColor() const
   return SUIT_ViewWindow::backgroundColor();
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::Repaint(bool theUpdateTrihedron)
 {
   if (theUpdateTrihedron) onAdjustTrihedron();
   myRenderWindow->update();
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::GetScale( double theScale[3] ) {
   myTransform->GetScale( theScale );
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::SetScale( double theScale[3] ) {
   myTransform->SetScale( theScale[0], theScale[1], theScale[2] );
   myRWInteractor->Render();
   Repaint();
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::onAdjustTrihedron(){   
   if( !isTrihedronDisplayed() ) 
     return;
@@ -466,37 +462,31 @@ void VTKViewer_ViewWindow::onAdjustTrihedron(){
   ::ResetCameraClippingRange(myRenderer);
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::onKeyPressed(QKeyEvent* event)
 {
   emit keyPressed( this, event );
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::onKeyReleased(QKeyEvent* event)
 {
   emit keyReleased( this, event );
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::onMousePressed(QMouseEvent* event)
 {
   emit mousePressed(this, event);
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::onMouseReleased(QMouseEvent* event)
 {
   emit mouseReleased( this, event );
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::onMouseMoving(QMouseEvent* event)
 {
   emit mouseMoving( this, event );
 }
 
-//****************************************************************
 void VTKViewer_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
 {
   emit mouseDoubleClicked( this, event );