]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Cache properties dialog
authorouv <ouv@opencascade.com>
Thu, 23 Nov 2006 13:01:21 +0000 (13:01 +0000)
committerouv <ouv@opencascade.com>
Thu, 23 Nov 2006 13:01:21 +0000 (13:01 +0000)
idl/VISU_Gen.idl
resources/SalomeApp.xml
src/VISUGUI/Makefile.in
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI.h
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISUGUI/VisuGUI_CacheDlg.cxx [new file with mode: 0644]
src/VISUGUI/VisuGUI_CacheDlg.h [new file with mode: 0644]
src/VISU_I/VISU_ColoredPrs3dCache_i.cc
src/VISU_I/VISU_ColoredPrs3dCache_i.hh

index 310b95aff40e4c5a5970df9d7f0d37828dd75835..51da0b6ebace42c81ee8b71348205946edda592a 100644 (file)
@@ -627,6 +627,24 @@ module VISU {
    */
   interface ColoredPrs3dCache : PrsObject, SALOME::GenericObj
   {
+    /*!
+     * This enumeration contains the cache memory modes.
+     */
+    enum MemoryMode {
+      MINIMAL, /*!< Minimal memory mode (default behaviour). */
+      LIMITED  /*!< Limited memory mode (fixed memory size for presentations). */
+    };
+
+    /*!
+     * Sets a memory mode.
+     */
+    void SetMemoryMode(in MemoryMode theMode);
+
+    /*!
+     * Sets a memory size for limited mode.
+     */
+    void SetLimitedMemory(in long theMemorySize);
+
     /*!
      * Creates %ColoredPrs3dHolder.
      */
index 5488527cc80116efb353ae8fe1f2964896c0c2cb..d388080a0e38a7456764b5ba5a25674202917448 100644 (file)
     <parameter name="recorder_fps"         value="17.3" />
     <parameter name="recorder_quality"     value="100"  />
     <parameter name="recorder_progressive" value="true" />
+    <parameter name="cache_is_limited_memory" value="false" />
+    <parameter name="cache_limited_memory"    value="1" />
   </section>
   <section name="resources">
     <!-- Module resources -->
index 369dcaf9b14e801219daf4cf681f6a18c79e2b16..a6626b1adfcf7cfa4c69a7aceed705937214a8f8 100644 (file)
@@ -77,7 +77,8 @@ LIB_SRC =     VisuGUI.cxx \
                VisuGUI_TransparencyDlg.cxx \
                VisuGUI_Timer.cxx \
                VisuGUI_Slider.cxx \
-               VisuGUI_InputPane.cxx
+               VisuGUI_InputPane.cxx \
+               VisuGUI_CacheDlg.cxx
 
 LIB_MOC =      VisuGUI.h \
                VisuGUI_Module.h \
@@ -104,7 +105,8 @@ LIB_MOC =   VisuGUI.h \
                VisuGUI_BuildProgressDlg.h \
                VisuGUI_TransparencyDlg.h \
                VisuGUI_Slider.h \
-               VisuGUI_InputPane.h
+               VisuGUI_InputPane.h \
+               VisuGUI_CacheDlg.h
 
 LIB_CLIENT_IDL = SALOME_Exception.idl \
                 VISU_Gen.idl \
index 3dde5df081dca7866dcb070922283a282bbc9452..867b914a6c0534e7ab29b6f53ea22eb899f3991c 100644 (file)
@@ -401,6 +401,9 @@ msgstr "Arrange Actors"
 msgid "VisuGUI::MEN_PLOT3D_FROM_CUTPLANE"
 msgstr "Plot3d"
 
+msgid "VisuGUI::MEN_CACHE_PROPERTIES"
+msgstr "Properties"
+
 
 msgid "VisuGUI::ERR_ERROR_DURING_EXPORT"
 msgstr "Error has been occured during exporting to file"
@@ -1729,6 +1732,18 @@ msgstr "Opaque"
 msgid "VisuGUI_TransparencyDlg::BUT_CLOSE"
 msgstr "Close"
 
+msgid "VisuGUI_CacheDlg::CACHE_TITLE"
+msgstr "Cache properties"
+
+msgid "VisuGUI_CacheDlg::MEMORY_MODE"
+msgstr "Memory mode"
+
+msgid "VisuGUI_CacheDlg::MINIMAL_MEMORY"
+msgstr "Minimal memory"
+
+msgid "VisuGUI_CacheDlg::LIMITED_MEMORY"
+msgstr "Limited memory"
+
 msgid "VVTK_ViewManager::VTK_VIEW_TITLE"
 msgstr "Gauss scene:%1 - viewer:%2"
 
index 1082954768bdb2fa5128ed3183a21b7b2efb86f2..17d866219e65b4d443d11d43c5550e29a76d158d 100644 (file)
@@ -87,6 +87,8 @@
 #include "VISU_View_i.hh"
 #include "VISU_ViewManager_i.hh"
 #include "VISU_Plot3D_i.hh"
+#include "VISU_ColoredPrs3dCache_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
 
 #include "VISU_Actor.h"
 
 #include "VisuGUI_Displayer.h"
 #include "VisuGUI_BuildProgressDlg.h"
 #include "VisuGUI_TransparencyDlg.h"
+#include "VisuGUI_CacheDlg.h"
 
 #include "VISU_ScalarMap_i.hh"
 #include "VisuGUI_ScalarBarDlg.h"
 #include "VISU_Vectors_i.hh"
 #include "VisuGUI_VectorsDlg.h"
 
-#include "VISU_ColoredPrs3dHolder_i.hh"
-
 #include "VisuGUI_TableDlg.h"
 
 #include "SALOMEconfig.h"
@@ -2297,6 +2298,10 @@ createActions()
   createAction( VISU_PLOT3D_FROM_CUTPLANE, tr("MEN_PLOT3D_FROM_CUTPLANE"), QIconSet(aPixmap),
                 tr("MEN_PLOT3D_FROM_CUTPLANE"), "", 0, aParent, false,
                 this, SLOT(OnPlot3dFromCutPlane()));
+
+  createAction( VISU_CACHE_PROPERTIES, tr("MEN_CACHE_PROPERTIES"), QIconSet(),
+                tr("MEN_CACHE_PROPERTIES"), "", 0, aParent, false,
+                this, SLOT(OnCacheProperties()));
 }
 
 void
@@ -2742,6 +2747,16 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
   if (isOneCutPlane)
     action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu);
 
+  Handle(SALOME_InteractiveObject) anIO;
+  VISU::Storable::TRestoringMap aMap;
+  CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
+
+  if (!CORBA::is_nil(anObject)) {
+    VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
+    if (aBase && aBase->GetType() == VISU::TCOLOREDPRS3DCACHE)
+      action( VISU_CACHE_PROPERTIES )->addTo(theMenu);
+  }
+
   theMenu->insertSeparator();
 
   // Check if some (nb > 0) removable objects selected
@@ -2758,10 +2773,6 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q
   // Check single selection
   if (aListIO.Extent() != 1) return;
 
-  Handle(SALOME_InteractiveObject) anIO;
-  VISU::Storable::TRestoringMap aMap;
-  CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
-
   _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
   if ( !SO )
     return;
@@ -3350,3 +3361,30 @@ void VisuGUI::OnPlot3dFromCutPlane()
    application()->putInfo(QObject::tr("INF_DONE"));
  }
 }
+
+void VisuGUI::OnCacheProperties()
+{
+  CORBA::Object_var anObject = GetSelectedObj( this );
+  if( CORBA::is_nil( anObject ) )
+    return;
+
+  VISU::ColoredPrs3dCache_i* aCache = dynamic_cast<VISU::ColoredPrs3dCache_i*>(VISU::GetServant(anObject).in());
+  if( !aCache )
+    return;
+
+  VisuGUI_CacheDlg* aDlg = new VisuGUI_CacheDlg( this,
+                                                aCache->GetMemoryMode() == VISU::ColoredPrs3dCache::LIMITED,
+                                                aCache->GetLimitedMemory() );
+  if( !aDlg->exec() )
+    return;
+
+  if( aDlg->isLimitedMemory() )
+  {
+    aCache->SetMemoryMode( VISU::ColoredPrs3dCache::LIMITED );
+    aCache->SetLimitedMemory( aDlg->getLimitedMemory() );
+  }
+  else
+    aCache->SetMemoryMode( VISU::ColoredPrs3dCache::MINIMAL );
+
+  delete aDlg;
+}
index e486ca101f14c3eb328bc2afd8ecc5705d80b6fb..a22dc20054c3c2fae21ba02ad4e6f9b93591b268 100644 (file)
@@ -160,6 +160,8 @@ protected slots:
   void OnArrangeActors();
   void OnPlot3dFromCutPlane();
 
+  void OnCacheProperties();
+
 protected:
   virtual LightApp_Selection* createSelection() const;
 
index 0eaa8676cf8ef30994cac14f492ebf8a4cd6e5a6..ca4142999fc4814991ff1038fbafbfc1dc484553 100644 (file)
 
 #define VISU_PLOT3D_FROM_CUTPLANE   4085
 
+#define VISU_CACHE_PROPERTIES       4090
+
 #endif
diff --git a/src/VISUGUI/VisuGUI_CacheDlg.cxx b/src/VISUGUI/VisuGUI_CacheDlg.cxx
new file mode 100644 (file)
index 0000000..0e7e434
--- /dev/null
@@ -0,0 +1,139 @@
+//  VISU VISUGUI : GUI of VISU component
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : VisuGUI_CacheDlg.cxx
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#include "VisuGUI_CacheDlg.h"
+
+#include "VisuGUI_Tools.h"
+
+#include "VISU_ColoredPrs3dCache_i.hh"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_Session.h"
+
+#include "SalomeApp_Module.h"
+
+#include "LightApp_Application.h"
+
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qspinbox.h>
+
+VisuGUI_CacheDlg::VisuGUI_CacheDlg( SalomeApp_Module* theModule, bool theIsLimitedMemory, long theLimitedMemory )
+  : QDialog( VISU::GetDesktop( theModule ), "VisuGUI_CacheDlg", true,
+            WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+  setCaption( tr( "CACHE_TITLE" ) );
+
+  QVBoxLayout* aTopLayout = new QVBoxLayout( this );
+  aTopLayout->setSpacing( 6 );
+  aTopLayout->setMargin( 6 );
+  aTopLayout->setAutoAdd( true );
+
+  // Settings
+  QButtonGroup* aMemoryGroup = new QButtonGroup( 2, Qt::Vertical, tr( "MEMORY_MODE" ), this );
+  aMemoryGroup->setRadioButtonExclusive( true );
+
+  myLimitedMemoryButton = new QRadioButton( tr( "LIMITED_MEMORY" ), aMemoryGroup );
+  myLimitedMemoryButton->setChecked( theIsLimitedMemory );
+
+  myMimimalMemoryButton = new QRadioButton( tr( "MINIMAL_MEMORY" ), aMemoryGroup );
+  myMimimalMemoryButton->setChecked( !theIsLimitedMemory );
+
+  myLimitedMemory = new QSpinBox( 1, 5000, 1, aMemoryGroup );
+  myLimitedMemory->setSuffix( " Mb" );
+  myLimitedMemory->setValue( theLimitedMemory );
+  myLimitedMemory->setEnabled( theIsLimitedMemory );
+
+  connect( myLimitedMemoryButton, SIGNAL( toggled( bool ) ), myLimitedMemory, SLOT( setEnabled( bool ) ) );
+
+  // Ok / Cancel
+  QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+  GroupButtons->setColumnLayout(0, Qt::Vertical );
+  GroupButtons->layout()->setSpacing( 0 );
+  GroupButtons->layout()->setMargin( 0 );
+  QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+  GroupButtonsLayout->setAlignment( Qt::AlignTop );
+  GroupButtonsLayout->setSpacing( 6 );
+  GroupButtonsLayout->setMargin( 11 );
+
+  QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
+  buttonOk->setAutoDefault( TRUE );
+  buttonOk->setDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+  GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+  QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
+  buttonCancel->setAutoDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
+
+  QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
+  buttonHelp->setAutoDefault( TRUE );
+  GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
+
+  connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
+  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+  connect( buttonHelp,   SIGNAL( clicked() ), this, SLOT( onHelp() ) );
+}
+
+VisuGUI_CacheDlg::~VisuGUI_CacheDlg()
+{
+}
+
+bool VisuGUI_CacheDlg::isLimitedMemory()
+{
+  return myLimitedMemoryButton->isChecked();
+}
+
+int VisuGUI_CacheDlg::getLimitedMemory()
+{
+  return myLimitedMemory->value();
+}
+
+void VisuGUI_CacheDlg::accept()
+{
+  QDialog::accept();
+}
+
+void VisuGUI_CacheDlg::onHelp()
+{
+  QString aHelpFileName;// = "types_of_gauss_points_presentations.htm";
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app)
+    app->onHelpContextModule(app->activeModule() ?
+                            app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
+  else {
+    SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+                          QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                          arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
+                          QObject::tr("BUT_OK"));
+  }
+}
diff --git a/src/VISUGUI/VisuGUI_CacheDlg.h b/src/VISUGUI/VisuGUI_CacheDlg.h
new file mode 100644 (file)
index 0000000..aea2afe
--- /dev/null
@@ -0,0 +1,66 @@
+//  VISU VISUGUI : GUI of VISU component
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+//  File   : VisuGUI_CacheDlg.h
+//  Author : Oleg UVAROV
+//  Module : VISU
+
+#ifndef VISUGUI_CACHEDLG_H
+#define VISUGUI_CACHEDLG_H
+
+#include <qdialog.h>
+
+class QRadioButton;
+class QSpinBox;
+
+class SalomeApp_Module;
+
+namespace VISU
+{
+  class ColoredPrs3dCache_i;
+}
+
+class VisuGUI_CacheDlg : public QDialog
+{
+  Q_OBJECT
+
+public:
+  VisuGUI_CacheDlg( SalomeApp_Module* theModule, bool theIsLimitedMemory, long theLimitedMemory );
+  virtual ~VisuGUI_CacheDlg();
+
+public:
+  bool            isLimitedMemory();
+  int             getLimitedMemory();
+
+protected slots:
+  virtual void    accept();
+
+  void            onHelp();
+
+private:
+  QRadioButton*   myMimimalMemoryButton;
+  QRadioButton*   myLimitedMemoryButton;
+  QSpinBox*       myLimitedMemory;
+};
+
+#endif
index ad63258543254c18250019e3d911e3ee8dbf3ca0..52670247fc0f74538901174bda045cd4aaba1d11 100644 (file)
@@ -44,6 +44,8 @@
 #include "VISU_Vectors_i.hh"
 #include "VISU_StreamLines_i.hh"
 
+#include "SUIT_ResourceMgr.h"
+
 #include "VVTK_ViewWindow.h"
 
 using namespace VISU;
@@ -68,6 +70,15 @@ ColoredPrs3dCache_i(SALOMEDS::Study_ptr theStudy):
   SALOMEDS::SComponent_var aSComponent = VISU::FindOrCreateVisuComponent(theStudy);
   CORBA::String_var aFatherEntry = aSComponent->GetID();
   CreateAttributes(GetStudyDocument(), aFatherEntry.in(), "", anIOR.in(), myName, "", "", true);
+
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+  bool anIsLimitedMemory = aResourceMgr->booleanValue( "VISU", "cache_is_limited_memory", true );
+  SetMemoryMode( anIsLimitedMemory ? VISU::ColoredPrs3dCache::LIMITED : VISU::ColoredPrs3dCache::MINIMAL );
+
+  int aLimitedMemory = aResourceMgr->integerValue( "VISU", "cache_limited_memory", 10 );
+  SetLimitedMemory( aLimitedMemory );
+
 }
 
 
@@ -122,6 +133,26 @@ IsPossible(VISU::VISUType theType,
 }
 
 
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i::
+SetMemoryMode(VISU::ColoredPrs3dCache::MemoryMode theMode)
+{
+  myMemoryMode = theMode;
+  cout << theMode << endl;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU::ColoredPrs3dCache_i::
+SetLimitedMemory(CORBA::Long theMemorySize)
+{
+  myLimitedMemory = theMemorySize;
+  cout << theMemorySize << endl;
+}
+
+
 //----------------------------------------------------------------------------
 VISU::ColoredPrs3dHolder_ptr
 VISU::ColoredPrs3dCache_i::
index 0abd10bb488fd27b0b559b671aaee6dad47909f5..56a889a8f4d95f88fc5a914d34e465bff24f4459 100644 (file)
@@ -60,6 +60,18 @@ namespace VISU
     ~ColoredPrs3dCache_i();
 
     //----------------------------------------------------------------------------
+    /*!
+     * Sets a memory mode.
+     */
+    void
+    SetMemoryMode(VISU::ColoredPrs3dCache::MemoryMode theMode);
+
+    /*!
+     * Sets a memory size for limited mode.
+     */
+    void
+    SetLimitedMemory(CORBA::Long theMemorySize);
+
     /*!
      * Creates ColoredPrs3dHolder.
      */
@@ -68,6 +80,12 @@ namespace VISU
                 const VISU::ColoredPrs3dHolder::BasicInput& theInput);
 
     //----------------------------------------------------------------------------
+    VISU::ColoredPrs3dCache::MemoryMode
+    GetMemoryMode() const { return myMemoryMode; }
+
+    long
+    GetLimitedMemory() const { return myLimitedMemory; }
+
     virtual 
     VISU::VISUType 
     GetType() { return VISU::TCOLOREDPRS3DCACHE; }
@@ -115,7 +133,10 @@ namespace VISU
                   const VISU::ColoredPrs3dHolder::BasicInput& theInput);
 
   private:
-    TColoredPrs3dHolderMap   myHolderMap; 
+    VISU::ColoredPrs3dCache::MemoryMode myMemoryMode;
+    long                                myLimitedMemory;
+
+    TColoredPrs3dHolderMap              myHolderMap; 
   };
 }